Skip to main content

pykumo

Python library to interact with Mitsubishi Kumo Cloud devices via their local API.

The hard work of generating the security token was done by https://github.com/sushilks/kumojs, and that part of pykumo is based heavily on sushilks's code, translated to Python by me. pykumo has no dependency on kumojs.

Current Status

Mitsubishi has once again made changes that prevent us from retrieving local-control credentials from the cloud service (Comfort) in the US (see #78 and #233 / #230). The Canadian market seems to be still using Kumo Cloud (see #62 and #232) and so it may be possible for Canadian users to retrieve the required information.

What does this mean for you?

  • If it's working for you, don't change anything (especially not network-related) and safeguard your kumo_cache.py file
  • If you're a new user or add new indoor units to your system, you're out of luck. I recommend the esp32 route if you have the technical skills.
  • The official Mitsubishi Comfort Home Assistant integration (heavily leveraged my own work without my knowledge) seems to be leaning toward cloud control, and so may be a (less performant) alternative.

Kumo System Components

Outdoor Unit

The outdoor unit houses the compressor and the outdoor coil. Each indoor unit connects to its outdoor unit via a pair of refrigerant lines and an electric power supply and communication cable. (Collectively this connection is called a lineset.) Kumo Cloud does not appear to be able to communicate directly with an outdoor unit.

Indoor Unit

Indoor units, also called air handlers, are in the conditioned space, and contain the indoor fan and heat exchanger coil, providing either cooling or heating. An indoor unit can be connected to some or all of the following:

  • WiFi adapter (e.g. PAC-USWHS002-WF-2) (via CN105 connector)
  • Wall-mounted controller MHK2 (via CN105 connector)
  • Wireless remote sensor (via Bluetooth to the WiFi adapter)

An indoor unit with a WiFi adapter has its own IP address on your local network.

Pykumo communicates with an indoor unit via its WiFi adapter, using an API exposed by the adapter.

MHK2

The MHK2 wall-mounted controller, if present, acts like a traditional thermostat for a single indoor unit, while also providing other controls. It also contains its own temperature and humidity sensors.

Kumo Station

Kumo Station allows controlling traditional HVAC equipment via the Kumo Cloud app, managing switchover between Kumo and external equipment. It also provides an outdoor temperature sensor. A Kumo Station has its own IP address.

Troubleshooting

WiFi

The most common cause of flaky behavior is weak WiFi signal at the indoor unit. Try measuring WiFi strength (2.4 GHz only) with a phone app. Also try repositioning the Mitsubishi WiFi adapter within the unit, positioning it close to the plastic exterior rather than metal interior components. Users have also reported that isolating the indoor units to their own subnet and WiFi SSID can improve behavior.

API errors

In early 2023 Mitsubishi appears to have made some change that makes the WiFi adapter less reliable. My educated guess is that it has a memory leak. See Issue 105 in the hass-kumo repository for discussion.

As of mid 2024, pykumo will issue a reboot command to the indoor unit's WiFi adapter (at most once every 30 minutes) if serializer_error or __no_memory errors occur when performing operations.

Interactive Use

It's possible to use pykumo in an interactive shell to do debugging, investigation of possible new features, and so on.

I recommend doing this work in a virtualenv. If you're not familiar with these, search the web for "python virtualenv" for details specific to your preferred operating system.

Start an Interactive Python Shell

pip3 install pykumo
python3

Set Up KumoCloudAccount

Inside the Python shell:

import pykumo
account = pykumo.KumoCloudAccount.Factory(username="your@email.com", password="your-password")

Alternatively, you can call it without arguments to be prompted:

account = pykumo.KumoCloudAccount.Factory()

If you have a cached configuration, you can provide it directly:

account = pykumo.KumoCloudAccount.Factory(kumo_dict=my_cached_dict)

This will set up the account using the KumoCloud V3 API for credential retrieval and local IP discovery.

account.get_indoor_units()

If successful, get_indoor_units prints a list of your indoor units' serial numbers.

Get Indoor Units

kumos = account.make_pykumos()
unit = kumos['<indoor unit name>']
unit.update_status()

The indoor unit name is the human-readable name. If successful, update_status prints True. You can then make various API calls on the unit object.

Get Raw Information from Indoor Unit

You can print the internal state of the indoor unit object, which includes the JSON information fetched from the unit itself. This is a good place to look when requesting support for additional pykumo features.

import pprint
pp = pprint.PrettyPrinter()
pp.pprint(unit.__dict__)

Reboot a unit's WiFi adapter

If an indoor unit is reachable but returns error responses to legitimate commands, a reboot may help.

unit.do_reboot()

Use an external temperature sensor

The WiFi adapter can source its room temperature reading from the API instead of a physical thermistor. This lets you use an external sensor of your choice as the unit's temperature input.

unit.set_temp_source('api')
unit.set_injected_room_temp(18.5)

To restore the unit's own return-air sensor:

unit.set_temp_source('returnair')

Writes are applied asynchronously, so the response may have a stale value if queried immediately. Re-send the temperature periodically (roughly every 20 seconds) to keep it fresh. activeThermistor reports which temp source is currently in effect. If an updated temperature is not supplied for a while, the device automatically falls back to using the internal thermistor.

Note that the temperature source setting persists across adapter reboots, so be sure to restore it when you're done.

Query or Command an Indoor Unit Directly

Indoor units speak a simple protocol of nested JSON. I'm not documenting the protocol here (though documentation patches would be welcome!), but if you look through the pykumo.py code for calls to self._request you can see the queries and commands that are already enabled. For example:

query = '{"c":{"indoorUnit":{"status":{}}}}'.encode('utf-8')
unit._request(query)

This prints the primary record, the status object. Most of the valid queries and commands were discovered by snooping the traffic between the Kumo Cloud app and the indoor unit. A few were determined by experimentation. It's possible that additional values and controls are available beyond those already discovered, especially on indoor units newer than those owned by this author. I welcome details on these via pull requests or issues on this repo.

Development

Pull requests are welcome for new features or bug fixes. The primary maintainer's day job may make response times somewhat slow.

Pre-commit is configured on this repo. To make development easier, run pre-commit install. Pre-commit and unit tests will run on pull requests. For PRs from forked repos, this will happen after maintainer approval.

Metadata

Release files for pykumo 0.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pykumo 0.5.4
File Size Uploaded Provenance Actions
pykumo-0.5.4.tar.gz 38.3 kB Without provenance Details for pykumo-0.5.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pykumo 0.5.4
File Interpreter ABI Platform Actions
pykumo-0.5.4-py3-none-any.whl Python 3 none any Details for pykumo-0.5.4-py3-none-any.whl

Total release size: 78.3 kB

Release files / pykumo-0.5.4.tar.gz

Download URL pykumo-0.5.4.tar.gz
Size 38.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d6d81cc207937865599c9d846dad5ca8bdd12fd696cc6736e7dff5c71e4d252e
BLAKE2b-256 checksum
How to use checksums
0943064b45847add97a2f886c33d16bd5adf20216ff6c762320ccaed61298552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / pykumo-0.5.4-py3-none-any.whl

Download URL pykumo-0.5.4-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c57bafd834d0046c01a6560786713d9e1d703a857dbf3b824c0067575df5b9b
BLAKE2b-256 checksum
How to use checksums
0cd2e80533c19a999bad249d9af4b1bd9d6594e0901126b45afe384f0ae13170
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for pykumo 0.5.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page