-
-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A guide how to communicate with MIOT devices -> Plugin? #901
Comments
What is |
I'm not sure, to be honest. In my case the word "MYDID" did the job (so I haven't replaced it with any other word or number). |
The 'did' (device id, most likely) is something that gets returned back by the device for responses, but you can put any value to it. The current miot implementations are using that as a key to a user-friendly property name. Thanks for the guide, the current documentation on that front is definitely lacking. There is a tool under
And printing out the information:
|
I just modified the miottemplate to download the mapping file, if not available, to allow using |
If you don't mind, please check out the linked PR and try
|
@rytilahti
When I turn indicator light on using When I run
If I use Also there's number of "actions" in miot specs but I don't see how can I use them using |
I have found and modified an example of a simple switch for Home Assistant. |
Great! Yes, the siid1 (which is there for all miot devices,
Try I'll try add a way to call an action, thanks for noticing & testing! |
@SpeedFire0 I think xiaomi_raw from @syssi is the proper way for quick, stop-gap solutions. That is, as soon as it gets miot support. You can follow this issue for that: syssi/xiaomi_raw#6 The problem with custom components is that they deem to break when the official integration gets updated to use APIs that are not available for the python-miio versions pinned by custom integrations. In turn, the less custom components one has, the easier it is to do the manual adjustments to make it work again. |
Both didn't work |
Ah, indeed. |
@rytilahti there's method for that in distutils |
I tried to get commands from a Xiaomi camera and it returned the following error: |
which camera? most cams don't use miot, only a few latest models. |
|
these models talk miio only (unless something changed in latest fw). all devices have miot specs, but older devices never really deploy it in firmware and they still use human readable miio. |
I didn't find any way how to control them (even the simplest function like on/off). Is it possible? This is an example of "info" response: |
OK. But I feel myself as a complete idiot because I can't figure out how to use this in Home Assistant :( |
It's weird to add an import for this single function, but I have now fixed this by simply checking of the value is either 'true' or '1'. Feel free to test it again, the newest commit also adds the ability to call actions using |
@rytilahti it works now. As I mentioned earlier, I use "Indicator light" property to test and |
Thanks for testing @gudvinr! I'll write some tests for the new functionality when I'll find some free time again, and then it can be merged. |
@SpeedFire0 For the plugin you may try https://github.com/ha0y/xiaomi_miot_raw. The author of xiaomi_raw didn't implement it for so long time, so I did it myself. |
@ha0y You could help to improve |
i got this: |
@rytilahti I am trying to use |
@AlexKalopsia |
hi, I'm reading this thread, I can't do what needs to be done so that the thermostat starts displaying data, please tell me |
Can i ask a question?what's the action you want to do about the command?i have a smart socket,the mode is cuco.plug.v3,i want to turn on and turn off,do you have try on this action on you plug? |
I will lock this issue now as it's old and it contains a lot of outdated information, thanks to everyone who contributed and helped! The instructions on how to use To see the full list of available commands, use
|
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"):
(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)
The text was updated successfully, but these errors were encountered: