-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Add basic support for Xiaomi Mi Air Purifier 3/3H #585
Conversation
@rytilahti I'm thinking about extracting the send() functionality to extra class and then using composition rather than inheritance. This would make testing easier. We could trial this for this device and potentially then adopt for other new miot devices. What do you think? |
@petrkotek I agree that it makes sense to separate the protocol handling out from the device class, so feel free to experiment :-) The pieces are quite convoluted, see also #437 which is somewhat related. |
…t that, also implement MiotDevice class with basic support for MIoT protocol.
…eparate util class
…ng to an actual device
aefdd96
to
9507181
Compare
eba6a54
to
09f27a5
Compare
Gentlemen, I see this is not yet merged in - can I help somehow? I just got the hardware and I can't wait to get it into my Home Assistant. |
Hi there, I just git cloned this and checked out PR585 to try things locally with my Air Purifier 3, and despite seeing the miot related files, when I run cli.py, airpurifiermiot is not listed, nor it is accepted as a command. Anything wrong with this version cli.py? |
Same with me - I have Air Purifier 3 (CN)
|
I was on holidays; I'll have a look into this tonight tonight as well as will try to progress with #592 (1st step for getting this merged). Thanks for understanding! |
Are you sure you're on the right branch?
On a separate note, i did notice there was an issue in |
… out if no button was pressed since purifier started up
I think so...
...but running miio/cli-py:
...airpurifiermiot still missing... maybe something is not commited to the repo? |
@ivanxx, @bluemanos Thank you both! I'm able to replicate it now on freshly cloned directory. Doesn't seem to be due to uncommitted files - most importantly, the (Sorry, I'm somewhat a Python newbie, so might be related to that :) ) |
@ivanxx, @bluemanos Looks like it might be because previously executed This sequence works fine for me:
|
That's working for me too. I just had to change |
Hello, First - grats that you did so much in this area and many thanks. I had the same issue with missing airpurifiermiot option. It was on container with python 3.7.6 (I'm not sure if this is important - but may be). Container was based on Debian GNU/Linux 9 (stretch), but python 3.7 was from testing installed. After this I installed second container based on ubuntu (Ubuntu 18.04.3 LTS), on which I installed python3 (version 3.6.9) - and here I have this airpurifiermiot option. I'm new here, and I don't have any mi home app installed. I have couple of 2s purifier working like a charm on stub network (they even don't have any DNS and any Gateway - they only take an ip/subnet from dhcp). I used node js with miio for them to obtain token, update wifi network ssid/psk and after this I was able to manage them using node miio or python-miio using the token they sent on first step on their open wifi network. /python-miio# python3 miio/cli.py -d airpurifiermiot --ip 192.168.4.1 --token d426829f54159729f891faeb6048684e status After this I used node js milo to send information about WiFi network which purifier should be connected to. It connects properly, takes an IP address properly, and probably it changes the token. I can ping it, but I cannot discover it using node js milo nor send direct command using python-miio. I'm wondering about this message of token set to ffffffffffffffffffffffffffffffff :/ is /python-miio# python3 miio/cli.py -d airpurifiermiot --ip 192.168.144.24 --token d426829f54159729f891faeb6048684e status During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): The above exception was the direct cause of the following exception: Traceback (most recent call last): Model info taken from node js milo command run when container was connected to purifiers open WiFi network (after reset of purifier) shown such name of my device: Model info: zhimi.airpurifier.mb3 Device id is changing (didn't noticed yet if every reset of device or in other way. tokens are changing every reset of device for sure. What I observed also. When I'm pinging devices - I have responses from 2s or pro in around 1-2ms. : devices 20,21,22,23 are 2s and pro, while 24 is 3h. isn't it wired? |
@cisco-devnet - sorry not related to your original issue, but you should probably redact your token from your message above. |
Hi @curtis86 what do you mean by redact? Before pasting here outputs I changed device ID, token and ip addresses just in case, although I noticed, that tokens are different for sure every reset of purifier (as I checked on console logs it looks like the same is with device id). |
@petrkotek @bluemanos @curtis86 if I go through the setup.py install I get a miioclient executable installed in /usr/local/bin that actually works!! (but I'm still unable to use the python3 miio/cli.py directly, it's still missing the airpurifiermiot command when I run it). All in all, it's good to see it finally working. Readings are consistent with the on-screen data (temp is rounded on the screen) and on/off, set_mode, set_led_brightness, set buzzer... all working. Great job!! Many many thanks @petrkotek |
Does it work with no internet connection? Seems like some Xiaomi devices work locally only if they able to connect to Chinese servers. They become uncontrollable without the internet. |
For sure purifiers 2s and pro can be managed without Internet connection (never connected to Internet). |
@petrkotek just want to confirm that the |
I don't have any purifier but I am able to get "airpurifiermiot" after executing "python3 setup.py install". @petrkotek I am interested in adding basic support for new mijia vacuum 1c STYTJ01ZHM (dreame.vacuum.mc1808), can you help me somehow understanding how to do it? |
Can confirm that I also see the 20 AQI issue. Couldn't pinpoint when it happens but it does happen. The value on the 3h screen is different. |
I noticed that this aqi value 20 (returner via local API) changed after some time (didn't check yet if the same period or random time), but this delay in changing is around 10 maybe even more minutes. I have many purifiers (s2/pro/3h) and only 3h has such delay in changing aqi value returned via this API. In my case all purifiers are cut from the internet at all. @pawelkw is your device connected to Internet? are you using in parallel mi home app? |
Yes and yes. |
Hi. |
@petrkotek Hello! from miio import AirPurifierMiot
air_purifier_device = AirPurifierMiot(ip, token)
for prop in air_purifier_device.get_properties():
print(prop) ...and got:
As you can see, I've got an error on parsing this list in the method below: def status(self) -> AirPurifierMiotStatus:
"""Retrieve properties."""
return AirPurifierMiotStatus(
{prop["did"]: prop["value"] for prop in self.miot_client.get_properties()}
) But API (http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-va1:2) says that EDIT: So I figure out, how make it work. You can get level of alarm volume (from 0 to 100) with the next command: air_purifier_device.send(
"get_properties",[{"did": 'buzzer', 'siid': 5, 'piid': 2}]
) Also you can set level of it (even app can't): air_purifier_device.send(
"set_properties",[{"did": 'buzzer', 'siid': 5, 'piid': 2, "value": 10}]
) Notification sound toggle in the app becomes selected when you set values >=50. But I still don't know why other command doesn't work. Maybe something with the bool type? |
@petrkotek Could you need any assistance in getting this branch in a mergeable state? I would like to help :) |
Hi all! Sorry, I've been a bit busy 😞 I can see that @foxel opened a new (draft) PR - home-assistant/core#31729, so I think it's better if he takes over. |
Hi @petrkotek – we are all volunteers here, so no worries! To my understanding that PR is just about integrating this PR, so I think we should re-open this and figure out what changes are still necessary prior to merging (if any). Do you mind taking a look what you think is still missing, and rebasing this to the current master? We (@tuxuser and @foxel are seemingly volunteering to help) can help you out from there :-) |
Closing in favor of now-merged #634. Thanks @petrkotek for making this happen :-) |
Add support for basic operations for new Xiaomi Air Purifier 3/3H (
zhimi-airpurifier-mb3
andzhimi-airpurifier-ma4
(#577)).In order to support that, also implement
MiotDevice
class with basic support for MIoT protocol which theAirPurifierMiot
extends to retrieve & set properties.Mapping is based on #543 (comment) - thanks, it helped a lot!
Note
Disclaimer: this is my first contribution to this project & I don't have Python experience.
ToDo:
Manually tested operations:
info
(see output below)status
(see output below)off
on
set_buzzer <true|false>
set_child_lock <true|false>
set_fan_level <1-3>
set_favorite_level <0-14>
set_led <true|false>
set_led_brightness <off|dim|bright>
set_mode <auto|fan|favorite|silent>
Example output of
info
:Example output of
status
:Closes #577