That’s why I have almost everything local based… The only stuff which is working via cloud is climate…
If somehow MELcloud could be managed localy directly via dNAT forwarding would be great…
MELcloud is back online… No official statement yet what was happening…
Just wanted to say big THANKS for this integration! Works like a charm.
Hi there, I have got some problems in setting HVAC mode via Alexa Integration (haaska).
For example when I try to switch to Dry mode, I got this:
2019-08-03 11:07:06 DEBUG (MainThread) [homeassistant.components.alexa.smart_home_http] Received Alexa Smart Home request: {'directive': {'header': {'namespace': 'Alexa.ThermostatController', 'name': 'SetThermostatMode', 'payloadVersion': '3', 'messageId': '5e67affd-747e-401a-b572-8a2563e5a185', 'correlationToken': 'AAAAAAAAAQC2msTtj2rk8StFKFdohi9MDAIAAAAAAADC9AFOiaKfH8YysVDtjKrmElauwiaG6yUitOVP96ZZWobOUB2LywjNkHSxsFxW16XDAe3rhU5n2RRfZjq9Q0bs5NMsSjAQUNFvBFnOoEgMn00quLkV8+Ut6cjuq1GlfWnpfU/O1RcaPvXRcUmc4oB8tF0lKoodiguFooaX/YsiUAxGxeq82BtRSWQY9mIaU+ZaVGsMR3m09SejuOETlslXiCjboKaXpDnCP7NG1cFObaOlW7d2smLbHaTzw7LYveAeLCQ2rPbMK+iYEkgGi7Hipb1lXpmTUT6TcQcSX3A4f9LcNCbuunmbEQbhWSn7zV3F86V2rc8rBTNd1z9MLX71W586rVVSKm9TVRo7Dfw14MrAQzoFj51ZVa+67YpyoiGDipTi82LQ52M8cNI60kYtGilN3tlrjcm/cUU3B3n12tisSKfUr808tsmn3luxRaRwiYf9r1aXvRxv/WPdF7FqY1hhWuB3jXUQWFTBcXyunefxdocQNe6JjNl005D+AmCCHieG0Mz2SGH2qSJpEj4MbCv/DGERnakIdgzJYP87OD2/wiUrBGMPmLv3tJnPVPXFwwh19v/lLpKC773iLiaikOapnTYHGX82lYKuBf/LRwZywzKui3XB2k/fj/5IyZA7awxQhcLULrAtGyxTLHigLoYmw4K61BqfLArduNP8izdnSl2zh3ZD3/puEQ=='}, 'endpoint': {'scope': {'type': 'BearerToken', 'token': 'Atza|IwEBIGNxYnQ_OgOnejk0_5vqixnLJbNfiYRxTfzUJ28DzG3XFKn4VyrP0R1UYvo3Kns4fOwhpChKbIN_skIDgZeuuAxaxERZLdvpN-s78GqDADaDPjJfaHImsf4awsjerozs7Egi1moeg4IaCAW8zxdr6flfjmIrqn77Hc-9V01OXyOtuORyMcwgYIhAnxJ_xi41eq1lMRHExszvPmAPUwyuepxFVALMCUvQghgfDCLyUS3cHdaQfprj6Fs2DYlobnGMjU11BY21rZNXoI0554fEHucgjzJ6EV4Ts5qtghQN1FaBXMCd9u3Ia-0DEFAfGXM_kIrUdMaHLzZaPdf-T3JZIQvkmyH0VcL7zDmL_D5JO22G_SkrXLouqEznVshHgKSXhX0uy_YkiMta_LqHDLryuKfR7FiQNrkWw43auD9LjLd5RFNBQNPvQRi7tFl5JUPpn3EuLOqSOOHC843rMBFscpZ6iXDu28xSl73N0js2e8OVqpwHOIhiBiiu6j-mG7EpWGXJl_q4jNF9nv1qNS7BrZJO'}, 'endpointId': 'climate#melcloud_sala_158966', 'cookie': {}}, 'payload': {'thermostatMode': {'value': 'CUSTOM', 'customName': 'DEHUMIDIFY'}}}}
2019-08-03 11:07:06 INFO (MainThread) [homeassistant.components.alexa.messages] Request Alexa.ThermostatController/SetThermostatMode error UNSUPPORTED_THERMOSTAT_MODE: The requested thermostat mode CUSTOM is not supported
2019-08-03 11:07:06 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event alexa_smart_home[L]: request=namespace=Alexa.ThermostatController, name=SetThermostatMode, entity_id=climate.melcloud_sala_158966, response=namespace=Alexa, name=ErrorResponse>
2019-08-03 11:07:06 DEBUG (MainThread) [homeassistant.components.alexa.smart_home_http] Sending Alexa Smart Home response: {'event': {'header': {'namespace': 'Alexa', 'name': 'ErrorResponse', 'messageId': 'c55caf1c-710d-4acf-ba4d-709131e0b7f8', 'payloadVersion': '3', 'correlationToken': 'AAAAAAAAAQC2msTtj2rk8StFKFdohi9MDAIAAAAAAADC9AFOiaKfH8YysVDtjKrmElauwiaG6yUitOVP96ZZWobOUB2LywjNkHSxsFxW16XDAe3rhU5n2RRfZjq9Q0bs5NMsSjAQUNFvBFnOoEgMn00quLkV8+Ut6cjuq1GlfWnpfU/O1RcaPvXRcUmc4oB8tF0lKoodiguFooaX/YsiUAxGxeq82BtRSWQY9mIaU+ZaVGsMR3m09SejuOETlslXiCjboKaXpDnCP7NG1cFObaOlW7d2smLbHaTzw7LYveAeLCQ2rPbMK+iYEkgGi7Hipb1lXpmTUT6TcQcSX3A4f9LcNCbuunmbEQbhWSn7zV3F86V2rc8rBTNd1z9MLX71W586rVVSKm9TVRo7Dfw14MrAQzoFj51ZVa+67YpyoiGDipTi82LQ52M8cNI60kYtGilN3tlrjcm/cUU3B3n12tisSKfUr808tsmn3luxRaRwiYf9r1aXvRxv/WPdF7FqY1hhWuB3jXUQWFTBcXyunefxdocQNe6JjNl005D+AmCCHieG0Mz2SGH2qSJpEj4MbCv/DGERnakIdgzJYP87OD2/wiUrBGMPmLv3tJnPVPXFwwh19v/lLpKC773iLiaikOapnTYHGX82lYKuBf/LRwZywzKui3XB2k/fj/5IyZA7awxQhcLULrAtGyxTLHigLoYmw4K61BqfLArduNP8izdnSl2zh3ZD3/puEQ=='}, 'payload': {'type': 'UNSUPPORTED_THERMOSTAT_MODE', 'message': 'The requested thermostat mode CUSTOM is not supported'}, 'endpoint': {'scope': {'type': 'BearerToken', 'token': 'Atza|IwEBIGNxYnQ_OgOnejk0_5vqixnLJbNfiYRxTfzUJ28DzG3XFKn4VyrP0R1UYvo3Kns4fOwhpChKbIN_skIDgZeuuAxaxERZLdvpN-s78GqDADaDPjJfaHImsf4awsjerozs7Egi1moeg4IaCAW8zxdr6flfjmIrqn77Hc-9V01OXyOtuORyMcwgYIhAnxJ_xi41eq1lMRHExszvPmAPUwyuepxFVALMCUvQghgfDCLyUS3cHdaQfprj6Fs2DYlobnGMjU11BY21rZNXoI0554fEHucgjzJ6EV4Ts5qtghQN1FaBXMCd9u3Ia-0DEFAfGXM_kIrUdMaHLzZaPdf-T3JZIQvkmyH0VcL7zDmL_D5JO22G_SkrXLouqEznVshHgKSXhX0uy_YkiMta_LqHDLryuKfR7FiQNrkWw43auD9LjLd5RFNBQNPvQRi7tFl5JUPpn3EuLOqSOOHC843rMBFscpZ6iXDu28xSl73N0js2e8OVqpwHOIhiBiiu6j-mG7EpWGXJl_q4jNF9nv1qNS7BrZJO'}, 'endpointId': 'climate#melcloud_sala_158966', 'cookie': {}}}}
Is there anything that I can do? Is it an Alexa integration problem?
Thank you.
Hi!
Many thanks for your hard work!
I’m pretty new to HA and my issue is that i ‘only’ see MelCloud target and current temperature as graphs in History.
I.e. lots of things are working correctly including MelCloud login.
But I cannot see any MelCloud instances in the HA Overview, setting target temp, operatione etc?
What could be the issue?
I’m running HA 0.96.5 in a RPI4, docker container.
Thanks!
For those of you with a Mitsubishi Ecodan Heater (for sanitary water and heating) you probably know it breaks this plug in when you add it to your MelCloud account. Somehow the plugin breaks when it gets water-related values that are not referenced in the component.
I created a MelCloud guest account to include only the devices that can be controlled by this component. But I found a way to at least monitor the Ecodan system. First get a contextKey by going to terminal (change email and password to your account login info):
curl --data "AppVersion=1.7.1.0&Language=7&CaptchaChallenge´=&CaptchaResponse=&Persist=true&[email protected]&Password=yourpassword" https://app.melcloud.com/Mitsubishi.Wifi.Client/Login/ClientLogin
Then copy and paste your context key here so you can get a list of buildings and devices on your MeLCloud account:
curl -v --header "X-MitsContextKey: contextkeynumbersgohere" https://app.melcloud.com/Mitsubishi.Wifi.Client/User/ListDevices
Building ID is the first ID number. Look closely to find your Ecodan Device ID, should be a 5-number string. Now you can get all available values by typing:
curl -v -H "X-MitsContextKey: contextkeynumbersgohere" "https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/Get?id=123456&buildingID=12345"
Now you can create a command_line sensor with any of those values as json_attributes, so you can have any number of extra sensors for whatever values you want to monitor. I just wanted to know if the system is on or off (Power), if the heat pump is running (OperationMode) and the water tank temperature (TankWaterTemperature):
- platform: command_line
json_attributes:
- TankWaterTemperature
- OperationMode
- Power
command: 'curl -v -H "X-MitsContextKey: contextkeynumbersgohere" "https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/Get?id=123456&buildingID=12345"'
name: Ecodan
unit_of_measurement: '°C'
value_template: '{{ value_json.TankWaterTemperature }}'
scan_interval: 90
command_timeout: 30
- platform: template
sensors:
ecodanoperationmode:
friendly_name: "Ecodan Heating"
value_template: >-
{% if is_state_attr('sensor.ecodan','OperationMode',0) %}
Off
{% elif is_state_attr('sensor.ecodan','OperationMode',1) %}
Heating ACS
{% elif is_state_attr('sensor.ecodan','OperationMode',2) %}
Heating Radiators
{% elif is_state_attr('sensor.ecodan','OperationMode',3) %}
Cooling
{% elif is_state_attr('sensor.ecodan','OperationMode',4) %}
Defrost
{% elif is_state_attr('sensor.ecodan','OperationMode',5) %}
Standby
{% elif is_state_attr('sensor.ecodan','OperationMode',6) %}
Legionella
{% else %}
Unknown
{% endif %}
ecodanpower:
friendly_name: "Ecodan Power"
device_class: power
value_template: >-
{% if is_state_attr('sensor.ecodan','Power',true) %}
ON
{% else %}
OFF
{% endif %}
That’s it. Now obviously this is read-only, and getting the Ecodan to work with the MelCloud component would be way more convenient. Just in case someone can take a look, here are the values to read/write:
{
"EffectiveFlags": 0,
"LocalIPAddress": null,
"SetTemperatureZone1": 30,
"SetTemperatureZone2": 20,
"RoomTemperatureZone1": 35.5,
"RoomTemperatureZone2": -39,
"OperationMode": 0,
"OperationModeZone1": 1,
"OperationModeZone2": 2,
"WeatherObservations": [
],
"ErrorMessage": null,
"ErrorCode": 8000,
"SetHeatFlowTemperatureZone1": 60,
"SetHeatFlowTemperatureZone2": 0,
"SetCoolFlowTemperatureZone1": 0,
"SetCoolFlowTemperatureZone2": 0,
"HCControlType": 1,
"TankWaterTemperature": 50.5,
"SetTankWaterTemperature": 50,
"ForcedHotWaterMode": false,
"UnitStatus": 0,
"OutdoorTemperature": 33,
"EcoHotWater": true,
"Zone1Name": "Heating",
"Zone2Name": null,
"HolidayMode": false,
"ProhibitZone1": false,
"ProhibitZone2": false,
"ProhibitHotWater": false,
"TemperatureIncrementOverride": 0,
"IdleZone1": true,
"IdleZone2": true,
"DeviceID": 123456,
"DeviceType": 1,
"LastCommunication": "2019-08-08T15:14:48.467",
"NextCommunication": "2019-08-08T15:15:48.467",
"Power": true,
"HasPendingCommand": false,
"Offline": false,
"Scene": null,
"SceneOwner": null
}
There might be some useful info here.
Greetings @o0Zz!
First of all, thanks for the great work!
I have a bit of an unusual setup - a ducted air con (one unit for the whole apartment with ducts to every room) and a Lossnay heat recovery ventilation unit.
Air Con is discovered fine, but has options for ‘Swing’ - is there a way to change the code for the situation when MELCloud does not provide swing values, so that the Swing menu is not displayed? Which lines I should look at?
Ventilation does not allow me to set an operating mode - the drop down menu has a line for ‘Auto’ and two blank (!) lines (I guess those are for EnergyRecovery = 0, ByPass = 1). Selecting a blank value from the drop down menu results in error “value is not allowed for dictionary value @ data[‘hvac_mode’]” Is there a way to fix this? How can I help?
Update: I guess the ventilation problem from above is common now (see below). Just an idea - we could classify ventilation as ‘fan’. This would also allow to expose it to Google Assistant.
Hi,
Do you have additional sensors (sensor.zunaj_t, sensor.kabinet_t) in use for the trigger? I was thinking of using the built-in current temperature data as it seems to update even if the AC is turned off. Just not quite sure yet on how to implement it. Tried via the automation UI but it’s not very clear and I think I might also have to go to automation.yaml to set it up correctly.
Something like this does not seem to work:
Best regards
Tuomas
I’m using external (Sonoff) sensors as triggering, yes… never used sensor of climate device…
Hello,
is there any project to try to run these devices offline instead of having to rely on the cloud? I’d much prefer to deny my wifi modules to access the internet.
Thanks
OK, got my set up working. So I didn’t yet figure out to way on how to access the attributes directly, but I created a custom sensor with the current temperature data from the AC and used that one instead. I think it makes the code also a bit more readable and probably also easier for me to switch to using another sensor in the future if I like.
Here’s the code for reference if anyone else is banging their head against the wall
One note in regards to testing the solution: the numeric_state trigger does NOT evaluate constantly if the condition is true, but only when the threshold is actually passed. I temporarily changed the trigger to a time pattern (to trigger every two mins) and added the numeric_state logic as a condition instead. Works like that as well, but I reverted to below model as it’s more simple and works fine in “production”.
- alias: "Turn on AC when it's too hot or cold"
trigger:
- platform: numeric_state
entity_id: sensor.current_temperature
below: 20
for: "00:15:00"
- platform: numeric_state
entity_id: sensor.current_temperature
above: 25
for: "00:15:00"
action:
- service: persistent_notification.create
data:
message: Current temperature is over 25 or below 20 degrees!
title: Turning Air Conditioner ON!
- service: climate.set_temperature
entity_id: climate.melcloud_XXXX
data:
temperature: '23'
- service: climate.set_fan_mode
entity_id: climate.melcloud_XXXX
data:
fan_mode: 'Speed Auto'
- service: climate.set_hvac_mode
data:
entity_id: climate.melcloud_XXXX
hvac_mode: 'auto'
- service: climate.set_swing_mode
entity_id: climate.melcloud_XXXX
data:
swing_mode: 'Auto'
- alias: "Turn off AC when target temperature is reached"
trigger:
platform: numeric_state
entity_id: sensor.current_temperature
below: 24
above: 22
for: "01:00:00"
condition:
condition: state
entity_id: climate.melcloud_XXXX
state: 'auto'
action:
- service: climate.set_hvac_mode
data:
entity_id: climate.melcloud_XXXX
hvac_mode: 'off'
- service: persistent_notification.create
data:
message: Current temperature has been between 22-24C for 1h!
title: Turning Air Conditioner OFF!
no offline support?
Haven’t seen a way to do this. Maybe if you could somehow hijack the traffic to/from the AC wifi unit, but might be a bit of an effort to do (should figure out how the device communicates and whatnot). I think this cloud approach was also reverse engineered though, so maybe it would be possible. Definitely would prefer offline as well, but glad to get it working some way at least. Just use a strong unique password for MELCloud and maybe it’s good enough regarding security?
I can definitely try that, I just asked to make sure that this was already tried without success.
You can have the password you want, if MELCloud gets compromised this will create a vetor of attack to your home network…
Hello,
I have an Ecodan and I stumbled into this thread. By copy/paste the code from Uspino I was able to make it work; now I would like to add some other info coming from the API to my HA, e.g. the FlowTemperature and the compressor frequency. I tried to modify the configuration but I can’t get it right, due to my very low knowledge… can you tell me how to add some of those temperatures to the configuration file? I tried to study a bit in the Hassio documentation, but probably I am getting old and cannot find the way myself.
I catch the opportunity to ask if any progress in making it work also to control the Ecodan operations. I am very frustrated by its short cycling in those mild days and could not find an embedded function in the Mitsubishi controller which is effective in reducing the problem… if I could program my own logic (isteresis or min off time) I am sure I can save a lot of energy and reduce stress on compressor and other components which are starting/stopping multiple times in one hour!
Thanks.
Guido
You can do it. It’s actually possible to control any parameter in the Ecodan by using command_line switches to write the corresponding value in the API. What I do is create a switch that writes the whole string changing only the one value for the switch. That way you can create switches for every value you want.
Writing the values requires sending multiple headers, so the curl command is pretty long. I guess not all headers are needed but once I made it work I never played with it. Here’s the command_line switch
to turn it on and off (don’t forget to change the Context key
and Device ID
with your data:
switch:
- platform: command_line
switches:
ecodan:
command_on: 'curl -v "https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAtw" -H "X-MitsContextKey: 111111111111111111111111111111" -H "Origin: https://app.melcloud.com" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: nl-NL,nl;q=0.9,en-NL;q=0.8,en;q=0.7,en-US;q=0.6,de;q=0.5" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" -H "Content-Type: application/json; charset=UTF-8" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Referer: https://app.melcloud.com/" -H "X-Requested-With: XMLHttpRequest" -H "Cookie: policyaccepted=true; gsScrollPos-2=0" -H "Connection: keep-alive" --data-binary "{"EffectiveFlags": 281483566710825,"SetTemperatureZone1":30,"OperationModeZone1":1,"SetHeatFlowTemperatureZone1":60,"SetCoolFlowTemperatureZone1":0,"HCControlType":1,"SetTankWaterTemperature":50,"ForcedHotWaterMode":false,"TemperatureIncrementOverride":0,"DeviceID":1111111,"DeviceType":1,"Power":true,"HasPendingCommand":true,"Offline":false,"Scene":null,"SceneOwner":null}" --compressed "https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAtw"'
command_off: 'curl -v "https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAtw" -H "X-MitsContextKey: 111111111111111111111111111111" -H "Origin: https://app.melcloud.com" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: nl-NL,nl;q=0.9,en-NL;q=0.8,en;q=0.7,en-US;q=0.6,de;q=0.5" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" -H "Content-Type: application/json; charset=UTF-8" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Referer: https://app.melcloud.com/" -H "X-Requested-With: XMLHttpRequest" -H "Cookie: policyaccepted=true; gsScrollPos-2=0" -H "Connection: keep-alive" --data-binary "{"EffectiveFlags": 281483566710825,"SetTemperatureZone1":30,"OperationModeZone1":1,"SetHeatFlowTemperatureZone1":60,"SetCoolFlowTemperatureZone1":0,"HCControlType":1,"SetTankWaterTemperature":50,"ForcedHotWaterMode":false,"TemperatureIncrementOverride":0,"DeviceID":1111111,"DeviceType":1,"Power":false,"HasPendingCommand":true,"Offline":false,"Scene":null,"SceneOwner":null}" --compressed "https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAtw"'
I could have used command_state
to read and sync the power state, but since we had already created a sensor for power state, I chose to hide this command_line switch and create another based on these two:
- platform: template
switches:
ecodantoggle:
value_template: >-
{% if is_state_attr('sensor.ecodan','Power',true) %}
on
{% else %}
off
{% endif %}
turn_on:
service: switch.turn_on
data:
entity_id: switch.ecodan
turn_off:
service: switch.turn_off
data:
entity_id: switch.ecodan
And that’s it. Now if you look at the curl command you can change any value: temperature, flow control, etc. Just make sure you don’t change any other value in the string.
Btw, I don’t know when and why context keys expire. Mine has been accepted for months now, but if it stops working you’ll have to generate another one.
All this can be done in a cleaner way with a simple python script, but my knowledge is also limited.
Good luck!
Hey! Thanks for this. I think I will buy a Mitsubishi AC machine for my home. It would be great it this component gets HA official!
Cheers!
Hi o0Zz,
Thank you so much for this, really appreated. A friend and I are installing in our homes a Mitsubishi AC just because this custom component exists.
Any news on having it integrated as an official component in HA?
Thank you in advance.
Best regards,
Marcos.
Probably for start it would be great if Melcloud would be integrated into HACS, so that future updating would be easier…
Thanks for this integration wounderful job !!! thank you to you you are a genius !!