Mitsubishi Kumo Cloud Integration

This is awesome, I’ll try to find some time to get it up and running in the coming weeks.

Ugh. I was going to get started on testing your integration @parkercat … but I got stuck on build issues with KumoJS which is necessary to generate the config. So first thing is first - NPM does not come with the libraries needed to run KumoJS. I don’t remember what they are, but you have to install two more packages to get the compile to go beyond library problems.

I’m currently stuck on build issues - these look code based to me. Other people seem to have gotten it work though… so I’m wondering if someone more familiar with NPM can work it out for/with me.

Appreciate any help I can get. Thanks.

src/kumojs.ts:60:25 - error TS2345: Argument of type 'unknown[]' is not assignable to parameter of type 'number[]'.
  Type 'unknown' is not assignable to type 'number'.

60                         Array.prototype.map.call(p+dt, function (m2:any) {
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61                             return m2.charCodeAt(0)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62                         })
   ~~~~~~~~~~~~~~~~~~~~~~~~~~

src/kumojs.ts:75:43 - error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...any[]]'.
  Type 'number[]' is missing the following properties from type '[number, number, ...any[]]': 0, 1

75         Array.prototype.splice.apply(dt3, [32, 32].concat(dt1_l));
                                             ~~~~~~~~~~~~~~~~~~~~~~

src/kumojs.ts:87:43 - error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...any[]]'.

87         Array.prototype.splice.apply(dt3, [0, 32].concat(W))
                                             ~~~~~~~~~~~~~~~~~

src/kumojs.ts:124:57 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(callback: (...args: any[]) => void, ms: number, ...args: any[]): Timeout', gave the following error.
    Argument of type 'Number' is not assignable to parameter of type 'number'.
      'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible.
  Overload 2 of 2, '(handler: TimerHandler, timeout?: number | undefined, ...arguments: any[]): number', gave the following error.
    Argument of type 'Number' is not assignable to parameter of type 'number'.
      'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible.

124       return new Promise(resolve => setTimeout(resolve, ms));
                                                            ~~



Found 4 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jhuan\AppData\Roaming\npm-cache\_logs\2019-09-06T04_45_34_776Z-debug.log
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\jhuan\Downloads\node-v10.16.3-win-x64\package.json'
npm WARN node-v10.16.3-win-x64 No description
npm WARN node-v10.16.3-win-x64 No repository field.
npm WARN node-v10.16.3-win-x64 No README data
npm WARN node-v10.16.3-win-x64 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] postinstall: `npm run build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jhuan\AppData\Roaming\npm-cache\_logs\2019-09-06T04_45_35_259Z-debug.log

Also - one more side question… is KumoJS an attempt to replace KumoCloud servers?.. or does it simply facilitate communications to/from KumoCloud? Ultimately, it would be ideal if I were able to communicate to my Kumo devices on the intranet without having to involve the KumoCloud at all. That thing is a dog at times and takes forever to communicate down.

You can get the info you need by downloading a file from KumoCloud using your credentials.
I don’t have a lot of time this morning so this reply will be pretty skeletal.

Use:
curl -d '{"username":"<kumocloud-username>","password":"<kumocloud-password>","appVersion":"2.2.0"}' -H "Accept: application/json, text/plain, */*" -H "Accept-Encoding: gzip, deflate, br" -H "Content-Type: application/json" https://geo-c.kumocloud.com/login > kumocloud.json

Substitute in your own kumocloud username and password. In the resulting kumocloud.json file, search for params as follows for each indoor unit:

  • search for "address" for the IP address of the indoor unit(s)
  • search for "password" for the password param
  • search for "cryptoSerial" for the crypto_serial param

w_param and s_param are constants, always "w_param": "44c73283b498d432ff25f5c8e06a016aef931e68f0a00ea710e36e6338fb22db", "s_param": 0,
I’ll pull those into the pykumo library next time I’m making changes.

Clearly, gathering this info via code is pretty straightforward and that’s a next step. In fact, this file has all we need to do autodiscovery & auto-creation of the climate entities (and also some sensor entities; more on that later). Doing re-discovery on HA restart would help out people whose indoor units get a different DHCP lease (IP address), too.

Also: yes, you’re correct. This code (as well as kumojs) are communicating with your indoor units over your local LAN, no need to involve the KumoCloud service (though they are phoning home to keep the app up to date). The only time we need to talk to KumoCloud is to retrieve the above configuration file.

Thanks for that. I’m stuck now on trying to get HASS.IO to recognize and use the python scripts. I tried dropping it in the /configuration folder without luck. Is this supposed to go into the master python install? I haven’t found any documentation on where that even is in the HASS.IO install. Any help/thoughts would be appreciated. Thanks.

A little bit more research and I’m going to take myself out of this test. Apparently the only way to get the .py scripts installed is to write it write into my HASS.IO docker image. I’m not really sure I’m comfortable doing that at this point. Installing custom python packages edits

Anyhow, @parkercat - would appreciate an update in this thread when you are able to submit the library to PyPI and this automagically resolves itself. Thanks.

I’ve made a couple minor improvements:

  • w_param and s_param are no longer configuration params since they’re constants
  • A new script to fetch the required configuration from your KumoCloud account. It spits out the required configuration.yaml lines. No need to install KumoJS at all anymore!

Be sure to fetch the latest from both repos to try it out.

@James_Huang I’ve never used HASS.IO myself so I have no advice for you. I suspect we’re quite a ways from pykumo being ready to be an actual PyPI module – principally because I’ve never done it before, but also because it’s still in flux.

@Sean_Hollister KumoJS is no longer needed, if you’re still interested in giving this a try.

@parkercat Bless you, going to see if I can get it running this week.

@James_Huang @parkercat

So last night I spent some time playing around with this and discovered a very easy way to include the python module without having to fight docker or wait for it to get added to python. Within the customer_component/kumo folder, I created a new folder called pykumo and dropped the pykumo.py and the __init__.py file into it. I then change line #16 in the climate.py file to

from .pykumo import pykumo

After I made that change and restarted everything, my Kumo controlled items appeared. I did test completely restarting the server which would destroy and rebuild the docker instance and it carries over because the module is part of the component.

Hope that helps!

Awesome! I’ve updated the install instructions on GitHub. Thanks!

I need a little bit more help… I’m getting a “Platform error climate.kumo - Integration kumo not found.”

My Configuration.yaml reads as:

climate:

  • platform: kumo
    name: “Therm5”
    host: 192.168.1.###
    config: "{‘w_param’: 'xxxxxxxxxxx

I’ve created a custom_components\kumo\pykumo folder.

What isn’t clear to me is where to pull what from. I’ve tried different permutations, but the one that made the most sense to me (without looking at the code too much) was pulling in the files as such:

pykumo-master\pykumo.py --> \custom_components\kumo\pykumo
pykumo-master\pykumo_init_.py --> \custom_components\kumo\pykumo
hass-kumo-native\kumo\* --> \config\custom_components\kumo

Can you see where I went wrong?..

I’ve pushed new versions of the components this evening.

NOTE: This is a BREAKING CHANGE:

The Kumo component now fetches setup information directly from the KumoCloud servers. So instead of listing your indoor units with address, config params, etc., you now simply set up the kumo platform and provide it with your KumoCloud username and password. The climate entities will be auto-created.

The syntax to pull the pykumo library from a local directory (as suggested by @landrysplace above) is now the default, as well. This will change, of course, when pykumo is submitted to PyPI, but we’re a ways away from that still.

I’ll update the documentation on the hass-kumo GitHub shortly.

Tried the new build @parkercat . Got the following error message when starting up:

2019-09-22 20:55:41 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform kumo
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 442, in wait_for
return fut.result()
File “/config/custom_components/kumo/climate.py”, line 50, in async_setup_platform
names = data.get_account().get_indoor_units()
File “/config/custom_components/kumo/pykumo/pykumo.py”, line 272, in get_indoor_units
for child in self._kumo_dict[2][‘children’]:
TypeError: ‘NoneType’ object is not subscriptable

One last thing - it might be obvious to more seasoned vets, but the instructions should say to restart HASS.IO after copying the components into the proper directories. Without the restart, adding the configuration.yaml yields an error indicating that the component cannot be found.

Thanks @parkercat cat - I know this is hard work and it’s very much appreciated.

@parkercat It’s working!!! Tried your new instructions on Hassio (thanks @landrysplace as well), restarted the server, and it auto-detected and created entities for all five of my units. They respond way faster than the official Mitsubishi app, too.

Will start testing and reporting back. Two notes so far after a quick test of one of my FH-series units: there doesn’t seem to be an option for “fan mode”, and the “vertical” vane setting isn’t working there. Other vane settings all seem to be working.

Please tell me where you accept donations. :slight_smile:

… and I’m an idiot. Mistyped my username in the config file. Thanks @parkercat - it’s working!

2 Likes

I need to add some better error checking in this section of code, because if anything goes wrong (like wrong username, or a problem with the KumoCloud server) it’ll hit here first. But I’m glad it’s working for you!

I suspect there may be some differences in the commands supported by the different model units. The most straightforward way to figure this out would be with some packet captures. If you have a Linux laptop you could follow instructions here: https://www.cellstream.com/reference-reading/tipsandtricks/335-capturing-wi-fi-wlan-packets-in-wireshark-on-linux , or alternatively install a packet capture app on your phone – I have used one on Android. Then use the KumoCloud app to control the aspects that aren’t working, and share the captured communications – probably on GitHub would be easier than here.

I used a quick & dirty Python program to test out different commands – that’s how I discovered how to retrieve the humidity (and battery level) from a remote sensor. I should clean that up and add it to the pykumo repo.

The amount of work I’ve done here is not worthy of donations. If anything, send some bucks or recognition to Sushil Singh, who did the original hard reverse-engineering work for kumojs.

I don’t have the vertical vane issue, but I am missing fan functionality. I’ve created a GitHub issue for it and have a link to the packet sniffing output for it. Please let me know if it’s missing what you need and I’ll take a harder look at getting the data you need.