In case someone is also struggling with the MelCloud, here is something with pictures to follow.
Who wants can paste this code into the cnfiguration.yaml or into the sensors.yaml.
Short explanation:
id = id of the device; in my case marked by XXXXX
buildingID = BuildingID; in my case marked by YYYYY
X-MitsContextKey = X-MitsContextKey; in my case marked by TTTTTTTTTTTTTTT
These three codes must be replaced by your own.
You can find them as follows:
Open Firefox => go to the Melcloud page => enter your credentials, before logging in press the F12 key on your keyboard => in the opened command line click on networkanalys see attached pictures.
sensor:
- platform: rest
name: heat_pump_api
resource: https://app.melcloud.com/Mitsubishi.Wifi.Client/user/ListDevices?id=XXXXX&buildingID=YYYYY
method: GET
headers:
X-MitsContextKey: 'TTTTTTTTTTTTTTTTTTTTT'
value_template: "OK"
scan_interval: 60
json_attributes_path: "$..Devices[?(@.DeviceID==XXXXX)].Device"
json_attributes:
- CurrentEnergyConsumed
- DailyHeatingEnergyConsumed
- DailyHotWaterEnergyConsumed
- DailyEnergyConsumedDate
- HeatPumpFrequency
- DefrostMode
- 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"
unique_id: 010320231
heat_pump_daily_heating_energy_consumed:
friendly_name: "Daily 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"
unique_id: 010320232
heat_pump_daily_hot_water_energy_consumed:
friendly_name: "Daily 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"
unique_id: 010320233
heat_pump_daily_energy_consumed:
friendly_name: "Daily Heat Pump Energy"
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', 'DailyHeatingEnergyConsumed') + state_attr('sensor.heat_pump_api', 'DailyCoolingEnergyConsumed') + state_attr('sensor.heat_pump_api', 'DailyHotWaterEnergyConsumed') }}"
device_class: energy
unit_of_measurement: "kWh"
unique_id: 010320234
heat_pump_frequency:
friendly_name: "Heat Pump Frequency"
# 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', 'HeatPumpFrequency') != None) }}
value_template: "{{ state_attr('sensor.heat_pump_api', 'HeatPumpFrequency') }}"
device_class: frequency
unit_of_measurement: "Hz"
unique_id: 010320235
heat_pump_defrost_mode:
friendly_name: "Heat Pump Defrost"
# 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', 'DefrostMode') != None) }}
value_template: "{{ state_attr('sensor.heat_pump_api', 'DefrostMode') }}"
device_class: aqi
unit_of_measurement: ""
unique_id: 010320236