Mitsubishi MELCLOUD integration with Home Assistant

@alex5 . Thank. you for posting this.
I’m trying to use your code, but I’m getting an error when getting the device data.
I’m able to use this to get my Context Key:

curl --data "AppVersion=1.7.1.0&Language=7&CaptchaChallenge´=&CaptchaResponse=&Persist=true&Email=useremail&Password=password" https://app.melcloud.com/Mitsubishi.Wifi.Client/Login/ClientLogin

and then

curl -v --header "X-MitsContextKey: ContextKey" https://app.melcloud.com/Mitsubishi.Wifi.Client/User/ListDevices

to get the DeviceId and buildingID.
But when I’m testing this

curl -v --header "X-MitsContextKey: ContextKey" https://app.melcloud.com/Mitsubishi.Wifi.Client/User/ListDevices?id=id&buildingID=buildingID

I’m getting

zsh: no matches found: https://app.melcloud.com/Mitsubishi.Wifi.Client/User/ListDevices?id=61484                                                                                                                 
[1]  + exit 1     curl -v --header "X-MitsContextKey: my_context_key" 

Can you help me?
Thanks
R

@alex5 Your script is working correctly, so I don’t know what’s wrong with the last curl , but I don’t care.
Did you manage to get those sensors in the energy dashboard?

@vilppuvuorinen I’m integrating those values in the pymelcloud repo, and I will submit the PR

1 Like

I’m using:

curl -v -H "X-MitsContextKey: ContextKey" "https://app.melcloud.com/Mitsubishi.Wifi.Client/user/ListDevices?id=id&buildingID=buildingID"| jq ".[].Structure.Devices[].Device"

for my Mitsubishi heatpump. Maybe that works for you as well?

Do you see consumption sensors in Energy Dashboard?

@gn3sh I’ve added the utily meters to get the values in Energy Dashboard. I’ve renamed the rest sensor to be consistent with the daily utility meter sensors.

sensor:
  - platform: rest
    name: heat_pump_api
    resource: https://app.melcloud.com/Mitsubishi.Wifi.Client/user/ListDevices?id=61484&buildingID=20719
    method: GET
    headers:
      X-MitsContextKey: "CONTEXTKEY"
    value_template: "OK"
    scan_interval: 60
    json_attributes_path: "$..Devices[?(@.DeviceID==DEVICEID)].Device"
    json_attributes:
      - CurrentEnergyConsumed
      - DailyHeatingEnergyConsumed
      - DailyCoolingEnergyConsumed
      - DailyHotWaterEnergyConsumed
      - DailyEnergyConsumedDate

  - platform: template
    sensors:
      heat_pump_power:
        friendly_name: "Heat Pump Power"
        # availability_template: "{{ is_state('sensor.heat_pump_api', 'OK') }}"
        availability_template: >-
          {{ (states("sensor.heat_pump_api") not in ["unknown", "unavailable"]) and (state_attr('sensor.heat_pump_api', 'CurrentEnergyConsumed') != None) }}
        value_template: "{{ state_attr('sensor.heat_pump_api', 'CurrentEnergyConsumed') }}"
        device_class: power
        unit_of_measurement: "kW"
      heat_pump_heating_energy_consumed:
        friendly_name: "Heat Pump Heating Energy"
        # availability_template: "{{ is_state('sensor.heat_pump_api', 'OK') }}"
        availability_template: >-
          {{ (states("sensor.heat_pump_api") not in ["unknown", "unavailable"]) and (state_attr('sensor.heat_pump_api', 'DailyHeatingEnergyConsumed') != None) }}
        value_template: "{{ state_attr('sensor.heat_pump_api', 'DailyHeatingEnergyConsumed') }}"
        device_class: energy
        unit_of_measurement: "kWh"
      heat_pump_cooling_energy_consumed:
        friendly_name: "Heat Pump Cooling Energy"
        # availability_template: "{{ is_state('sensor.heat_pump_api', 'OK') }}"
        availability_template: >-
          {{ (states("sensor.heat_pump_api") not in ["unknown", "unavailable"]) and (state_attr('sensor.heat_pump_api', 'DailyCoolingEnergyConsumed') != None) }}
        value_template: "{{ state_attr('sensor.heat_pump_api', 'DailyCoolingEnergyConsumed') }}"
        device_class: energy
        unit_of_measurement: "kWh"
      heat_pump_hot_water_energy_consumed:
        friendly_name: "Heat Pump Hot Water Energy"
        # availability_template: "{{ is_state('sensor.heat_pump_api', 'OK') }}"
        availability_template: >-
          {{ (states("sensor.heat_pump_api") not in ["unknown", "unavailable"]) and (state_attr('sensor.heat_pump_api', 'DailyHotWaterEnergyConsumed') != None) }}
        value_template: "{{ state_attr('sensor.heat_pump_api', 'DailyHotWaterEnergyConsumed') }}"
        device_class: energy
        unit_of_measurement: "kWh"
      heat_pump_energy_consumed:
        friendly_name: "Heat Pump Total Energy"
        availability_template: >-
          {{ (states("sensor.heat_pump_api") not in ["unknown", "unavailable"]) and
           ((state_attr('sensor.heat_pump_api', 'DailyHotWaterEnergyConsumed') != None) or
            (state_attr('sensor.heat_pump_api', 'DailyHeatingEnergyConsumed') != None) or 
            (state_attr('sensor.heat_pump_api', 'DailyCoolingEnergyConsumed') != None) )}}
        value_template: "{{ state_attr('sensor.heat_pump_api', 'DailyHeatingEnergyConsumed') + state_attr('sensor.heat_pump_api', 'DailyCoolingEnergyConsumed') + state_attr('sensor.heat_pump_api', 'DailyHotWaterEnergyConsumed') }}"
        device_class: energy
        unit_of_measurement: "kWh"

utility_meter:
  heat_pump_daily_energy_consumed:
    source: sensor.heat_pump_energy_consumed
    name: Heat Pump Daily Energy Consumed
    cycle: daily
  heat_pump_daily_heating_energy_consumed:
    source: sensor.heat_pump_heating_energy_consumed
    name: Heat Pump Daily Heating Energy Consumed
    cycle: daily
  heat_pump_daily_cooling_energy_consumed:
    source: sensor.heat_pump_cooling_energy_consumed
    name: Heat Pump Daily Cooling Energy Consumed
    cycle: daily
  heat_pump_daily_hot_water_energy_consumed:
    source: sensor.heat_pump_hot_water_energy_consumed
    name: Heat Pump Daily HotWater Energy Consumed
    cycle: daily
1 Like

@rzulian Thank you! I will try.

Hi,
I see Energy recovery ventilators are not supported yet, will they be supported in the future? I want to install the mitsubishi air-water heatpump and maybe the Lossnay ventilation system.

With this code I get very big consumption numbers - 16000kwh per day. It seems that DailyEnergyConsumedDate parameter is read regularly and constantly added throughout the day, but it should be added once a day. Do you have any ideas how to fix it?

Now I changed scan_interval to 86400, maybe it will fix the issue.

This is what I get in the states

I have this. Can’t figure out why the numbers are so big.

and this?

This one is the same - OK.
I changed the names of variables and now the states of this variables are looking normal. But in Energy Dashboard no data for now. I believe that it will appear in 24 h. Thank you for trying to help!

But sometimes API gets all zero values. Do you have the same?

I own an ATW, I would like to have cool mode enabled so I’m glad to help and test some out.

A question about the heat pump.
By entity water_heater.heatpump
I have a switch to power down the heat pump.
I made an automation to power down the heat pump when reached the 50 degrees Celsius.

I want to make an automation to power down when reached the attribute “temperature”
I’m a Newbie. How to do this?
Thanks

i have the same unortunately, sometimes zero and whatever i do it keeps messing with the utility meter. annoying that it updates once per day, 2 minutes after midnight for me as well :expressionless:

Hello everyone,

Could someone tell me if the energy consumption readings are fixed now? I have air-to-air option with updated firmware but when I compare the consumption between the MELCloud app and HA I see 1.2kWh from the app and 0.2kWh from HA. Do you know about an alternative or the fix to that? What should I do?

Thanks, Piotr.

Hi Team,

I am having challenges with the heater operation mode.
I can see the current mode from MELCloud, but i cannot change it in HA.
cool, heat, off, curve, flow are all not selectable.

Please help

@ptaqp A fix for the energy meter issue is in the works. It has been a nightmare to get the new home-assistant dev container setup working and it has delayed the fix quite a bit.

@MMouse There has been a feature branch open for a year (or two?) that would split the air-to-water device into mode specific thermostats to align things with the way the device is modeled ln MELCloud. It’s just a pain the get it working without having access to a device.