MELCLOUD REST integration example

Hello everyone,
I would like to share my Melcloud sensor integration, which could read more parameters than the Melcloud default integration out of my specific installation (multiple zones, Mixing tank etc…)
It makes use of the REST interface and the Melcloud app (credentials)
See also the post, how to get the credentials out of your Melcloud App:

Attention: It is important to include the force_update: true flag, as without it, you will not get the polling running.

Melcloud.yaml

Walter

5 Likes

Hi, thanks! As a little bit of a ‘starting n00b’ question, where do i implement your yaml code? Do I create a melcloud.yaml file and refer to it from the config yaml? Or do I add in in the template.yaml file?

Edit: I have uploaded your integration in sensor.yaml but the sensors are not showing up in HA.

Edit2: Nevermind, got it working now :slight_smile:

Hi Walter,

still another question for, hope you don’t mind. I’m trying to get my COP in HA (which works for now) and I’m using the following code:

#COP berekening
- platform: template
  sensors:
    heating_cop_current:
     friendly_name: 'Current Heating COP'
     value_template: >
       {% set q = states('sensor.shelly_pro3em_total_active_energy') | float %}
       {% set w = states('sensor.heat_pump_currentenergyproduced') | float %}
       {% if q >= 0 and w > 0 %}
       {{ (q / w) | round(2) }}
       {% else %}
         0
       {% endif %}

This actually works, and I’m using an external Shelly PRO 3EM to check the actual powerconsumption.

Do I need to use sensor.heat_pump_currentenergyproduced or the dailyheatingenergyproduced?

I would like to make a distinction between the SWW and the Heating COP if possible.

Hi, how do you get it to work ?
I added his code in sensors.yaml too and rebooted HA, but nothing appears, no sensors.

Hi, did you add

sensor: !include sensors.yaml

in your configuration.yaml file?

By the way, I am running into 2 issues:

  • I accidentally switched q and w which resulted in a wrong calculation
  • The data from the sensor currentenergyproduced is not realtime and is calculated the next day. This results in a weird COP.

Any ideas maybe how to calculate it better?

yes, here is the beginning of my configuration.yaml:


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate
homeassistant:
  customize: !include customize.yaml

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
command_line: !include command_line.yaml
sensor: !include sensors.yaml

Strange, everything looks good imho.

Hello Roy,
sorry for the late response, I am not a frequent user and not so active on these goups.
You have to use the daily values as the current values are only reporting the integral part.
I did some “precdiction calculations” of power use (have no real power meter in between) using a formula based on the heatpump frequency * 46/watt. This can give u an instant power consume value withaut a meter. But it is not accurate.
PS: I updated te melcloud.yaml file with an integration that automatically extracts the X-MitsContextKey, as Melcloud seems to change this frequently now.
Still testing if a polling frequency every 20000sec is ok, to not lose too much data.
Maybe i will rethink is using a service and automation trigger, when the sonsors aren’t getting any data anymore.
Sorry for the late response.

Hi,
I am very new on Home Assistant and definitely I do something wrong but I don’t know what!! Can you please help me?
I try to add melcoud.yaml on the configuration.yaml, but is not working and the sensors are not populated? If I try sensor : !include melcloud.yaml is not working… I also try with sensors but same… how can I do a debug? Or some hint? Thanks

Hello,
I did change the melcloud.yaml file in a way that one senor polls for the API key and will be updated every 20000 sec.
It happens somethimes that the communication does not work.
A way to check that is looking Development Tools/States to the sensor heat_pump_API, it should give you the last poll time.
If it is unavailable, try to restart the REST entities and notification service in Development tools/Yaml.
This should give you a new poll of the heat_pump_API sensor (look in small I to find the time it was last polled).
A second source of information can be: Terminal Home-asssitant.log found in the subfolder /config. But for this you need to know some linux commands:
cd config
cat home-assistant.log
should give you a full printout.
Hopefully this works.
As of 1 jan, I see a lot of drops on the communication with melcloud, but it recovers.
Now, I refresh the API key every 20000 sec, but I think I have to change that, based on the sensor comming unavailable or so.

I hope this info is helpfull.
Walter

Hello,
I do not find heat_pump_api …
Is my declaration wrong? or I need to install a REST module?
See how is included in my config file
image

Hello,
if you used my provided melcloud.yaml, the variables like heat_pump_api are included in that as a rest sensor.
You should reboot HA to get the sensors active and you will find them in your Developer Tools/States.
PS: Dont forget to include your login/password and Device/buidling ID’s in your own melcloud.yaml file.

Sometimes I see that the connection is not working properly after a reboot.
You can try to manually restart the REST ENTITIES AND NOTIFY SENORS and afetr 10 sec the TEMPLATE SENSORS.

After that, the heat_pump_api should appear and you should see a time stamp updating every 2 minutes.

PS: I am making a web site with all kinds of information about my installation, including the Melcloud integration. It is in Dutch, but Google can translate it.
See: limburg.myuba.be/…/Homeassistant/Melcloud
I hope this helps you.
Walter

Hey AWM,

I have used the info on your page and managed to get all that info in Home Assistant. Thanks for that.
Any idea on how could I automatically STOP/START the heat pump after an ERROR?

Hi Alex,

I’ve noticed that sometimes the Mitsubishi MELCloud API doesn’t provide complete update information in Home Assistant. Even though some values update properly, others seem to get stuck.

A full reboot of Home Assistant appears to fix the issue most of the time. However, restarting individual components or using other methods haven’t been successful. I’m not sure why a full reboot works best.

Thanks,
Walter