-
-
Notifications
You must be signed in to change notification settings - Fork 566
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
miio local api soon deprecated? / add support for miot api #543
Comments
Wow. Terrible news. |
it possible to use miot api on external software, like domoticz or Home Assistant? i know it is cloud based, but possible to make api call across the cloud? Like this not help? Or it only work with Yeelight lamp? |
If that's true then i have bought my last Xiaomi product. |
It's true. I have an Air Purifier 3. If someone knows how to get a console (or something like this) on this "thing", it would be great! (ESP32 inside!) |
can you check |
Sent: {"id": 2, "method": "get_properties", "params": ["prop.3.6"]} Sent: {"id": 1, "method": "get_properties", "params": [{"siid": 3, "piid": 6}]} |
Xiaomi Fan seems to work atleast so far. |
"method":"set_properties","params":[{"piid":2,"siid":2,"value":true}] |
{'code': -9999, 'message': 'user ack timeout'} |
strange, this is exact command sent to device from automation to power on purifier. {"sa_id":2866,"model":"zhimi.airpurifier.ma4","name":"Turn on","keyName":"Turn on","type":0,"groupInfo":[],"tr_id":201,"payload":{"did":"","command":"zhimi.airpurifier.ma4.set_properties","value":[{"siid":2,"piid":2,"value":true}]}} i even put such automation (manual trigger) on device where i can log device <> cloud traffic and got this from miio.log {"from":"6,X,Y,.click","id":Z,"method":"set_properties","params":[{"piid":2,"siid":2,"value":true}]} |
Got it working with the DID! "method":"set_properties","params":[{"did":"MYDID","siid":2,"piid":2,"value":true}] "method":"set_properties","params":[{"did":"MYDID","siid":2,"piid":2,"value":true}] "method":"get_properties","params":[{"did":"MYDID","siid": 3, "piid": 6}] How do you get the mapping (siid,piid) <-> function / property ? |
i found out that they use did with siid/piid from some RN plugin and sent you some json for test to your github mail yesterday. did you get it? anyway i'm glad it works, because it proves devices that deploy new miot-spec scheme can still be used with local api :) do you have chinese version (ma4)? here is full json spec for it https://ufile.io/53ribhi8 |
I got it (but prefer to write as much information in public ;) ) |
so it looks like miot-spec is based on 3 method "get_properties", "set_properties" and "action" invoked with params according to device specs. can you check last method (action)? 1st get some info about filter usage with get_properties siid:4/piid:3 (filter life) and siid:4/piid:5 (filter usage time). next send (with aiid, not piid) "method":"action","params":[{"did":"MYDID","siid":4,"aiid":1}] if executed correctly it should reset your filter life. hope it won't be big issue because you don't have it to long ;) resend get_properties to confirm. |
It does nothing. No reply and no change on filter-life-level. I tried with {"did":"MYDID","siid":4,"aiid":1, "in": [ true ]}] also, without luck. |
try this way (i found it on some blanket) "method":"action","params":[{"did":"MYDID","siid":4,"aiid":1,"in":[{"piid":1,"value":true}]}] if it does not work maybe they just didn't implement it in firmware. i guess it's not so important for purifier while get/set works. |
No luck... |
miot-spec is what they manually setup with xiaomi iot developer platform so it does not have to fully cover firmware features. i guess we will test it with some other devices, because more and more will come which deploy this scheme. |
My Air purifier 3 is on the way. It possible that is supported? |
A minimal implementation using Python and MQTT is here: https://github.com/roth-m/mqttmiot-airpurifier3 |
great news!!! Thanks! You will plan to expand the features list? (if possible, of course) |
@roth-m can you please share props value for 13/4 (aqi-zone) and 10/1-6? i would like to compare with older models. aqi-zone defines aqi value ranges for auto mode (each range has associated fan speed with 10/1-6). for my 2s it was factory "35,75,115,150,250", but i played with firmware ;) |
So, for the record... aqi zones 13 4: 35,75,115,150,250 |
Just send 70 to /fanspeed and it should set the fan speed to 70%. At this time, the fanspeed/state will not be exactly the same as there are only 14 levels of speed and thus the code will update fanspeed/state to /14*100. |
The "On/Off" and "Mode" params working with your device? I try this to turn on the device:
other question, the fanspeed state is RPM value? |
Yes they work. Are you trying to issue a command using nodejs miio package?! Using my implementation, the reported fanspeed is a percentage (among the 14 levels). This might change in a later version. |
How to send ON or OFF (ar any control ) command with your implementation via MQTT? |
Send ON or OFF to the PREFIX/power topic. |
Ehh oh my god. I'm stupid, i send the command before the "state" subtopic.... sorry for that.... Working well, thanks! |
Hi all I don't understand if xiaomi replace old miio protocol by miot based on cloud ? Can you confirm these informations |
How can somebody help on this issue / protocol? Could we get up a TODO list? |
@rezmus Based on my testing, it looks like this parameter needs to be set every minute to 60 to get AQI updates from purifier. If you don't set it, once it zeroes out, the purifier stops giving frequent updates (AQI doesn't seem to change as much - almost like its being smoothened). It's like a keep-alive heartbeat that tells the purifier to update AQI real-time. |
yeah from my understanding and when i checked plugin code when it's set it sends data to cloud every 5s. that's why plugin set it to 60 every 50s so it keeps data feed frequent when you are in the app. my idea for regular users with mi home app was to set it twice a day to 43200 (12x3600s) via schedule to keep constant feed (you can't open plugin meanwhile). i'm just not sure if it won't make too much traffic to cloud ;) |
So if we want to use only locally only (no cloud), we can set the value to maximum possible and since plugin is where cloud update happens, there will be no cloud traffic hitting their servers hard. Why don't you give it a try and tell us how it goes? I don't use mi home for automations, I use home-assistant. |
i don't have 3/3h. for non mi home users you just don't set it because there is no point. 0 counter = no cloud updates. |
I think the parameter affects real-time reporting of AQI versus smoothened AQI in the purifier firmware. I'm sure what you say about plugin reporting to xiaomi server is correct but I'm talking about the firmware on the purifier itself. Seems to be that when this heartbeat is set to zero (not alive), there is a smoothened AQI number reported by purifier (if within +/- 10 AQI of previous reading, don't report a new value). When it is positive (get alive!), it picks up the actual AQI (within +/- 1 AQI). This is probably coded in the firmware itself and not the app plugin. In a way, the user needs to be looking for real-time update via the app to receive actual number. If the plugin isn't opened, say you look at the shortcut card - it will not set this parameter. Once you open the plugin, it sets it for 60 seconds (probably average user interaction time with the plugin) so that user sees live values. |
are you saying that when the app is off (counter = 0) you don't get real time readings on oled or via get_properties 3/6? that would be really strange. like i said i don't have 3/3h, but with older purifiers i never seen such thing. |
OLED shows real-time but get_prop doesn't. And yeah I have older air purifiers which don't do this but then their AQI readings change a lot over a few minutes (+/- 2 of a mean value) especially in lower AQI number range. People have reported this in the re-opened air purifier 3 pull request #585 as the 20 AQI issue (eg #585 (comment)) where oled shows a lower number than get_properties. @pawelkw @cisco-devnet please set 13:9 to 600 and test by blowing smoke or vapor at your purifiers. Expected result should be real-time AQI values for 10 minutes. And while you're at it, could you also check if you get temperature readings in 0.1 C increments or 0.5 C increments. |
Update regarding how my purifiers (I have 3 new ones) are all acting up - they report AQI/Temperature as a float with 10 decimal places and then go unavailable/offline. This happens throughout the day but a lot more when the purifier is on. I'm hoping it's a fixable firmware issue. Worst case it's a miot issue that can not be fixed. Anyone else seen this behaviour in the purifier 3 or other devices? @rezmus what's the prop name for 13:9 so i can send a raw command? |
with miot spec there are not prop names. you just send {"method":"set_properties","params":[{"did":"yourdid","siid":13,"piid":9,"value":x}]} |
Thanks for that. Setting this prop did enable real-time reporting of PM25. |
Do you have some news about this request ? |
@CLARENNE-Q could you be more specific? The current state of affairs is that we have now basic miot implementation and support for one device using this protocol. |
The next homeassistant release (0.109) will include support for that device, as how to use this before that you need to consult hassio documentation (or support forums) to find out how you can install the dev branch of homeassistant on it. Anyway, as we now have basic miot support merged, I will close this issue now. Special thanks to @rezmus, @petrkotek and @foxel for their work on this! 🥇 |
so do zhimi.fan.fa1 |
Based on the information above 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. Now is the hard part - how to convert this in the 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:
That's all! Now you can retrieve and set values from a Terminal. |
just to let you know. this is part of mail sent to xiaomi iot platform devs today (translated):
The Xiaomi IoT platform is fully implementing the MioT-Spec access work. The Xiaomi IoT Device Protocol Specification (MIoT Specification) will replace the original miio profile protocol specification.
i've checked some plugins of new devices and many of them use miot api (cloud only) rather than miio. for example air purifier 3. i can't say for sure because i don't have device, but from what i saw it's stripped from local miio api.
The text was updated successfully, but these errors were encountered: