-
-
Notifications
You must be signed in to change notification settings - Fork 596
Description
I was able to get the data from an unsupported device (HeatCold Heating Floor Controller - cubee.airrtc.th123e) and to set the required parameters from a Terminal on Mac. Can someone help with converting this into a working plugin for Home Assistant and then HomeKit?
Here is my step-by-step guide for all newcomers who want to play with their devices:
-
Install python-miio on Mac. Enter this in Terminal app on Mac:
sudo pip3 install python-miio -
Get model name of your device ("cubee.airrtc.th123e" in my case), IP address (like "192.168.1.152") and Token (like "b110204d86732b019d3d6axxxxb9ad3a"). The easiest way for me was to use this integration for Home Assistant - https://github.com/AlexxIT/XiaomiGateway3
-
Check that your device is accessible by entering the following in a Terminal app on Mac:
miiocli -d device --ip 192.168.1.152 --token b110204d86732b019d3d6axxxxb9ad3a info
Note 1: You need to put your device's IP and Token here.
Note 2: "-d" is for Debug and can be excluded for a shorter output.
In my case I got something like this:
"Model: cubee.airrtc.th123e
Hardware version: esp32
Firmware version: 2.1.7"
Device is responding! Nice! Going to the next step. -
Find your device in the list of MIOT devices:
http://miot-spec.org/miot-spec-v2/instances?status=all
I searched for "cubee.airrtc.th123e" and found the following line:
{"status":"released","model":"cubee.airrtc.th123e","version":1,"type":**"urn:miot-spec-v2:device:thermostat:0000A031:cubee-th123e:1"**}, -
Copy the "urn" part after this url:
https://miot-spec.org/miot-spec-v2/instance?type=
in my case: https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:thermostat:0000A031:cubee-th123e:1
You will see an unformatted JSON text of the device's specs -
Put this JSON text to any JSON Formatter to make it more human readable. For example here: http://json.parser.online.fr/
-
You will see a hierarchy with a list of Services (later used as "siid"), each of which has a list of Properties ("piid"):
- You need to find some property in the list which you want to get from the device and which is readable
(in my case siid 1 didn't return the value, so you may want to check other services like "siid 2" and other properties)
I wanted to receive the current "Target Temperature". This is "siid":2 and "piid":5:
-
Try to get a response from your device by entering this in Terminal:
miiocli -d device --ip 192.168.1.152 --token b110204d86732b019d3d6axxxxb9ad3a raw_command get_properties "[{'did': 'MYDID', 'siid': 2, 'piid': 5 }]"
Note: replace IP, token, siid and piid with your values
I got a response the last line of which was:
"[{'did': 'MYDID', 'siid': 2, 'piid': 5, 'code': 0, 'value': 29}]"
This was an actual Target Temperature set on my device: 29 degrees celsius! It works! -
Now let's try to change some properties. Make sure it has a "write" access (look at the the field "access" for a particular piid in the JSON file mentioned above).
I want to set 28 degrees and here is the command for that:
miiocli -d device --ip 192.168.1.152 --token b110204d86732b019d3d6axxxxb9ad3a raw_command set_properties "[{'did': 'MYDID', 'siid': 2, 'piid': 5, 'value' : 28 }]"
The new temperature was set on my device and was also updated in MiHome app! -
Check that the value / setting was set on an actual device and redo step 9 to confirm that the new value is successfully returned by the device.
That's all! Now you can retrieve and set values from a Terminal.
This was my part. I would be glad if someone describes how to further make a Home Assistant plugin based on this knowledge :)
Originally posted by @SpeedFire0 in #543 (comment)

