Mitsubishi MELCLOUD integration with Home Assistant

On my Ecodan system I can only get an estimate in Melcloud, as the HP is not fitted with energy meters. In case electrical meters are fitted, their values are passed through the API.
As I am more than a newbie, it took me literally weeks to figure out the right syntax to get all the parameters out of the JSON… :smiley:

What I do:

  - platform: rest
    name: Ecodan_FlowTemperature
#    friendly_name: "Flow Temp"
    unit_of_measurement: '°C'
    resource: https://app.melcloud.com/Mitsubishi.Wifi.Client/user/ListDevices?id=**yourdeviceID**&buildingID=**yourbuildingID**
    method: GET
    headers: 
        X-MitsContextKey: '**yourcontextkeyhere**'
    value_template: '{{ value_json[0].Structure.Devices[0]["Device"]["FlowTemperature"]}}' 
    scan_interval: 30          

By replacing “FlowTemperature” by “CurrentEnergyConsumed” you would get the energy consumption.

My problem is that I can’t get the template properly working so I am using a list of rest sensors and I call the API every time… Some help would be appreciated! :slight_smile:

Did you try my approach in post #194? I can get any value from the Ecodan json with just one call to the API…

Hi - yes, initially I copied your post #194 but then I found out that I could get more data by making another call (https://app.melcloud.com/Mitsubishi.Wifi.Client/user/ListDevices). For example I can get the compressor speed! The response though is much more complicated and I am not able to write myself a better code than calling the API several times. If I try something similar to your code, I get either “unknown” or other error codes for the sensors I defined through templating… probably due to the length of the API answer and my inability to use the right syntax to parse the json.

Yes, it’s all on the parsing of the json. With the right syntax you can extract any data you want with just one call. You can maybe try and post the json in the general help forum, see if someone there can help you point at the values you need.

Finally I could make it work: I used “jq” to eliminate the brackets from the json coming out from the API and now I can use attributes and through templating it’s quite straightforward to extract all values I want from a single call.
Reference here: RESTful Sensor with json result as array values?

My call is now looking like:
command: ‘curl -v -H “X-MitsContextKey: yourkeyhere” “https://app.melcloud.com/Mitsubishi.Wifi.Client/user/ListDevices?id=yourID&buildingID=buildingID”| jq “.[].Structure.Devices[].Device”’

1 Like

Hello everybody,

This is an amazing job @o0Zz!
I have some questions though.
Through MEL I can see the below screenshot for my unit.

On my HA, after inserting your code, I can see this.

My questions are:

  • Swing mode refers (I guess) to vane vertical positions. Is there any possibility to add another option for vane horizontal positions?
  • Is it possible to add the presets as well? It is really handy to adjust the whole unit with one click.

bonjour,
je suis nouveau dans cet univers, je possède depuis peu 1 PAC Mitsubishi ECODAN et j’utilise MELCLOUD depuis que j’ai installé le MAC-5671F-E (très rapidement après la pose de ma PAC début octobre 2019).
J’utilise aussi Hassio après m’être équipé d’un Raspberry et je cherche à intégrer MELCloud. Je commençais à désespérer et j’ai découvert votre communauté et les gens formidables qui sont à l’oeuvre…
Par contre je ne parviens pas à réaliserc ce que vous décrivez.
Mes connaissances en informatique sont très limitées et en général j’arrive à faire les choses en regardant et en copiant ce qui fonctionne mais cette fois la barre est un peu haute, ce qui me manque c’est le démarrage. Pourriez vous m’indiquer comment utiliser le code que vous donnez dans le post #194? Je n’ai pas compris non plus comment faire un compte invité… je n’ai donc pas obtenu la clé de contexte, la liste des bâtiments ni les périphériques liés à mon compte.
Un grand merci d’avance
franciscodaspis

I’ve got the same, but at this point it’s only the vertical you can control.

Regarding presets, there I would suggest that you either look for automations or scripts. I myself is using of course automations based on criterias, but I’ve also assigned a few scripts to buttons in Lovelace so that I can have some presets (run cool or heat for a few hours with highest fan speed).

Anglais s’I’ll vous plait.

Hello,
I’m new to this world, I recently Cap 1 Mitsubishi ECODAN and I use MELCLOUD since I installed the MAC-5671F-E (very soon after the installation of the CAP in early October 2019).
I also use Hassio after having equipped myself with a raspberry and I try to integrate it with MELCloud. I was beginning to despair and I discovered your community and the great people who are at work …
By cons I can not achieve what you describe.
My computer skills are very limited and in general I can do things by looking and copying what works but this time the bar is a little high, what I miss is the start. Could you tell me how to use the code you give in post # 194? I also did not understand how to make a guest account … so I did not get the context key, the list of buildings or devices related to my account.
A big thank you in advance
franciscodaspis

Just wanted to say a big thank you for this plugin. My installer recommended us to run the fan of our air heater at max speed during the cold winters in Sweden to get the most value out of our investment. It works really well, but it sounds like a… Big fan…

But using this plugin can adjust the speed of the fan during our TV sessions.

  - alias: "Shield off climate on"
    trigger:
      - platform: state
        entity_id: media_player.shieldtv
        to: 'off'
    action:
      - service: climate.set_fan_mode
        data:
          entity_id: climate.melcloud_kallaren_181404
          fan_mode: 'Speed 5 (Max)'
          
  - alias: "Shield on climate off"
    trigger:
      - platform: state
        entity_id: media_player.shieldtv
        from: 'off'
    action:
      - service: climate.set_fan_mode
        data:
          entity_id: climate.melcloud_kallaren_181404
          fan_mode: 'Speed 4'

It works really well and the wife is really pleased. Happy wife, happy life…

Thanks again.

2 Likes

Did you ever move forward with this idea? I want to do the same

It’s a shameless plug but here’s my take on integrating MELCloud and Home Assistant: https://github.com/vilppuvuorinen/hass-melcloud

It’s basically a copy of the Daikin integration without the switch platform. It’s 100% async and configured using Config Flow. Only the ContextKey token from MELCloud is stored to the Config Entry. Once I’ve solved the authentication, the it should be possible to PR the whole thing to Home Assistant.

I haven’t yet implemented vane control or swing modes and there’s only support for DeviceType 0 devices.

2 Likes

Not all heroes wear capes… Thanks!

1 Like

I did some further digging into the MELCloud API and it looks like they have an Oauth provider and some sort of a grant management scheme integrated to the service.

I tried to email the MELCloud support to check if it is possible to provision some sort of developer client ids. It would be pretty neat to get the integration working with the OAuth2 Control Flow. Let’s see whether it will be a friendly reply or a cease and desist letter.

3 Likes

Simple thermostat option:
image

Code:

cards:
  - control:
      _names: false
    entity: climate.melcloud_kabinet_XXXXXX
    hide:
      state: false
      temperature: true
    name: Klima
    sensors:
      - entity: sensor.kabinet_klima_temperatura
        name: Klima
      - entity: sensor.kabinet_t
        name: Kabinet
    step_size: 1
    type: 'custom:simple-thermostat'
type: vertical-stack

On name click you still get “old” and more detailed options menu…

BR,
Simon

To add component to HA I simply install via Community plugin (HACS) or manually:

After HA restart just add this code and restart HA again:

climate:
  - platform: melcloud
    email: [email protected]
    password: PASSWORD

(mail and password need to be the same as used for Melcloud login under website or via phone app)

After restart you will get new climate ID device, then you can use it as I use in previous post.

PS.
So, is that the same repository (@vilppuvuorinen) and copy as from @o0Zz?

Didn’t know that @vilppuvuorinen you have copyright of Melcloud component for HA?? :thinking:
image
Wouldn’t be fair to make merit also to other people before you make copy/paste of the code?

Dunno man. My integration is registering the entities etc the similar way as the Daikin integration. Maybe that deserves some sort of attribution or not. Otherwise it’s not related to o0Zz’s Melcloud integration. I didn’t like it and wrote my own. Usually writing something gets you the copyright. Is there something I’m missing here?

Sorry… if you wrote code completly from the strach then OK. But if you use some code from other source then you should mention this in license… But it’s your call…

Ao how is your integration different then Daikin or o0Zz integration?

I’m not sure if following best practices using a reference implementation warrants attribution or not. I’m trying to get this thing into a shape that could be PRd to HA so it’s not a high prio thing to sort out from that perspective either.

I used Daikin as a reference on how to do multiple platforms for domain and register things in async way. So it’s just similar async_setup, async_setup_entry, async_unload_entry and config_flow approach. Just the parts that do setup against HA. The Daikin integration interacts with Daikin products so there’s nothing else of interest for doing integration with Melcloud.

The integration in my repo tries to be more closely compliant with HA integration guidelines. Config flow, asyncio, external pypi package for melcloud client, unloading, etc. It has also multiple platforms. I didn’t see it productive to try to PR these changes to something existing.

2 Likes