This is a package for interacting with MELCloud and Mitsubishi Electric devices. It's still a little rough around the edges and the documentation is non-existent.
The goals for this package are:
- To control and automate devices, not to configure them.
- Handle device capabilities behind the scenes.
- Make the different device types behave in predictable way.
There are built-in rate limits and debouncing for most of the methods
with the exception of the Device update method.
- Initialize devices for each account only once during application runtime.
- Make sure the
updatecalls for eachDeviceare rate limited. A 60 second update interval is a good starting point. Going much faster will exceed the expected load for MELCloud and can potentially cause availability issues. - Make absolutely sure the
updatecalls are rate limited.
- Air-to-air heat pumps (DeviceType=0)
- Air-to-water heat pumps (DeviceType=1)
- Energy Recovery Ventilators (DeviceType=3)
Reads access only locally cached state. Call device.update() to
fetch the latest state.
Available properties:
namemacserialunits- model info of related units.temp_unitlast_seenpowerdaily_energy_consumedwifi_signal
Other properties are available through _ prefixed state objects if
one has the time to go through the source.
room_temperaturetarget_temperaturetarget_temperature_steptarget_temperature_mintarget_temperature_maxoperation_mode- available
operation_modes fan_speed- available
fan_speeds vane_horizontal- available
vane_horizontal_positions vane_vertical- available
vane_vertical_positions total_energy_consumedin kWh. See notes below.
tank_temperaturetarget_tank_temperaturetank_temperature_mintank_temperature_maxoutside_temperaturezonesnamestatusroom_temperaturetarget_temperature
statusoperation_mode- available
operation_modes
room_temperatureoutdoor_temperature- available
fan_speeds fan_speedactual_supply_fan_speedactual_exhaust_fan_speed- available
ventilation_modes ventilation_modeactual_ventilation_modetotal_energy_consumedwifi_signalpresetserror_codecore_maintenance_requiredfilter_maintenance_requirednight_purge_moderoom_co2_level
The energy consumption reading is a little strange. The API returns a value of 1.8e6 for my unit. Judging by the scale the unit is either kJ or Wh. However, neither of them quite fits.
- Total reading in kJ matches better what I would expect based on the energy reports in MELCloud.
- In Wh the reading is 3-5 times greater than what I would expect, but the reading is increasing at a rate that seems to match energy reports in MELCloud.
Here are couple of readings with monthly reported usage as reference:
- 2020-01-04T23:42:00+02:00 - 1820400, 28.5 kWh
- 2020-01-05T09:44:00+02:00 - 1821300, 29.4 kWh
- 2020-01-05T10:49:00+02:00 - 1821500, 29.6 kWh
I'd say it's pretty clear that it is Wh and the total reading is not
reflective of unit lifetime energy consumption. total_energy_consumed
converts Wh to kWh.
Writes are applied after a debounce and update the local state once completed. The physical device does not register the changes immediately due to the 60 second polling interval.
Writable properties are:
power
target_temperatureoperation_modefan_speedvane_horizontalvane_vertical
There's weird behavior associated with the horizontal vane swing. Toggling it on will also toggle vertical swing on and the horizontal swing has to be disabled before vertical vanes can be adjusted to any other position. This behavior can be replicated using the MELCloud user inteface.
target_tank_temperatureoperation_modezone_1_target_temperaturezone_2_target_tempeature
Zone target temperatures can also be set via the Zone object
returned by zones property on AtwDevice.
ventilation_modefan_speed
import aiohttp
import asyncio
import pymelcloud
async def main():
async with aiohttp.ClientSession() as session:
# call the login method with the session
token = await pymelcloud.login("[email protected]", "mysecretpassword", session=session)
# lookup the device
devices = await pymelcloud.get_devices(token, session=session)
device = devices[pymelcloud.DEVICE_TYPE_ATW][0]
# perform logic on the device
await device.update()
print(device.name)
await session.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())