home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.15k stars 30.19k forks source link

Xiaomi MIIO Integration - Air Purifier 3H detected but not working #86378

Open msavazzi opened 1 year ago

msavazzi commented 1 year ago

The problem

I've installed the Xiaomi MIIO integration (https://www.home-assistant.io/integrations/xiaomi_miio/) using the direct link from page. It asked me the credential and after detected correctly the Air Purifier but then:

image

and I get an infinite sequence of:


2023-01-22 14:47:16.134 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching Air 3H Studio data in 5.005 seconds (success: False)
2023-01-22 14:48:04.298 ERROR (MainThread) [homeassistant.components.homeassistant] The service homeassistant.turn_off cannot be called without a target
2023-01-22 14:48:36.197 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Initializing with host 192.168.1.132 (token cb988...)
2023-01-22 14:48:36.198 DEBUG (SyncWorker_39) [miio.click_common] Unknown model, trying autodetection. None None
2023-01-22 14:48:36.458 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Initializing with host 192.168.1.119 (token 95436...)
2023-01-22 14:48:36.459 DEBUG (SyncWorker_34) [miio.click_common] Unknown model, trying autodetection. None None
2023-01-22 14:48:41.203 DEBUG (SyncWorker_39) [miio.miioprotocol] Unable to discover a device at address 192.168.1.132
2023-01-22 14:48:41.204 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching Air 3H Studio data in 5.007 seconds (success: False)
2023-01-22 14:48:41.465 DEBUG (SyncWorker_34) [miio.miioprotocol] Unable to discover a device at address 192.168.1.119
2023-01-22 14:48:41.466 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching Air 3H Camera data in 5.008 seconds (success: False)
2023-01-22 14:50:01.449 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Initializing with host 192.168.1.132 (token cb988...)
2023-01-22 14:50:01.449 DEBUG (SyncWorker_46) [miio.click_common] Unknown model, trying autodetection. None None
2023-01-22 14:50:01.590 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Initializing with host 192.168.1.119 (token 95436...)
2023-01-22 14:50:01.591 DEBUG (SyncWorker_31) [miio.click_common] Unknown model, trying autodetection. None None
2023-01-22 14:50:06.455 DEBUG (SyncWorker_46) [miio.miioprotocol] Unable to discover a device at address 192.168.1.132
2023-01-22 14:50:06.456 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching Air 3H Studio data in 5.007 seconds (success: False)
2023-01-22 14:50:06.596 DEBUG (SyncWorker_31) [miio.miioprotocol] Unable to discover a device at address 192.168.1.119
2023-01-22 14:50:06.597 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching Air 3H Camera data in 5.007 seconds (success: False)

What version of Home Assistant Core has the issue?

core-2023.1.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Xiaomi MIIO

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xiaomi_miio/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @rytilahti, @syssi, @starkillerog, mind taking a look at this issue as it has been labeled with an integration (xiaomi_miio) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `xiaomi_miio` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign xiaomi_miio` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


xiaomi_miio documentation xiaomi_miio source (message by IssueLinks)

mmika85 commented 1 year ago

stesso mio problema con Xiaomi Smart Air Purifier 4 installato con l'integrazione xiaomi miio sia automatico che con l'inserimento del token.

Immagine 2023-02-04 180745

2023-02-04 17:49:58.387 WARNING (MainThread) [homeassistant.config_entries] Config entry 'zhimi.airp.mb5' for xiaomi_miio integration not ready yet: Unable to discover the device 192.168.1.76; Retrying in background 2023-02-04 17:49:58.406 WARNING (MainThread) [homeassistant.config_entries] Config entry 'zhimi.airp.mb5' for xiaomi_miio integration not ready yet: Unable to discover the device 192.168.1.76; Retrying in background 2023-02-04 17:49:58.411 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Xiaomi Smart Air Purifier 4' for xiaomi_miio integration not ready yet: Unable to discover the device 192.168.1.76; Retrying in background

uamarchuan commented 1 year ago

I have the same issue with my Mi Air Purifier 3H. Any progress?

I have tried a custom xiaomi_airpurifier one and no problem with connection... I ma waiting on a fix, but meantime using this workaround.

cydia2020 commented 1 year ago

Original comment

Having the same issue with my Zhimi Air Purifier 3 (ma4) after it was disconnected from Wi-Fi (edit: this was incorrect), interestingly, my Roborock S6 MaxV behaves just fine. The air purifier was purchased from AliExpress so it's linked to a cn Xiaomi account.

image

2023-04-04 12:56:29.180 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching zhimi.airpurifier.ma4 data in 5.044 seconds (success: False)
2023-04-04 12:56:29.181 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'zhimi.airpurifier.ma4' for xiaomi_miio integration not ready yet: Unable to discover the device 192.168.2.23; Retrying in 10 seconds
2023-04-04 12:56:29.181 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139964701399488] Sending {"id":181,"type":"event","event":[{"type":"updated","entry":{"entry_id":"c7a63a5a69be1b3cf988c46c48c9fbf1","domain":"xiaomi_miio","title":"zhimi.airpurifier.ma4","source":"user","state":"setup_retry","supports_options":true,"supports_remove_device":false,"supports_unload":true,"pref_disable_new_entities":false,"pref_disable_polling":false,"disabled_by":null,"reason":"Unable to discover the device 192.168.2.23"}}]}
2023-04-04 12:56:44.519 DEBUG (SyncWorker_5) [miio.miioprotocol] Unable to discover a device at address 192.168.2.23
2023-04-04 12:56:44.522 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching zhimi.airpurifier.ma4 data in 5.010 seconds (success: False)
2023-04-04 12:56:44.522 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'zhimi.airpurifier.ma4' for xiaomi_miio integration not ready yet: Unable to discover the device 192.168.2.23; Retrying in 20 seconds
2023-04-04 12:56:39.511 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Initializing with host 192.168.2.23 (token 8dd27...)
2023-04-04 12:56:39.513 DEBUG (SyncWorker_5) [miio.click_common] Unknown model, trying autodetection. None None

Edit

OK I think I've found the problem specific to my setup - I have two separate networks, one for most of my devices (this includes the NAS that my home assistant instance is running on) and another one for IoT devices. If the Xiaomi device isn't on the same subnet as the Home Assistant instance, it will fault, otherwise it works fine.

Edit 2

For those of you who don't want to deal with Xiaomi's platform, some air purifiers use an ESP32 to communicate over Wi-Fi. A custom ESPHome component that talks to the air purifier's onboard STM32 to enable controls of its various features is available here - https://github.com/jaromeyer/mipurifier-esphome

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

cydia2020 commented 1 year ago

Not stale

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

drpsyko101 commented 1 year ago

I'm having the exact same issue as @cydia2020 for having a different subnet for the host and the discovered device. Will try with the same subnet later.

fmunozs commented 11 months ago

I am using the last version of HA, got the same error with the xiaomi air purifier on a different vlan, there are no firewall blocking rules between them so all the traffic should be allowed. Is it confirmed that moving it to the same vlan should fix it?

2023-10-19 14:02:21.517 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Mi Air Purifier 3/3H' for xiaomi_miio integration not ready yet: Unable to discover the device 192.168.x.x; Retrying in background
cydia2020 commented 11 months ago

I am using the last version of HA, got the same error with the xiaomi air purifier on a different vlan, there are no firewall blocking rules between them so all the traffic should be allowed. Is it confirmed that moving it to the same vlan should fix it?

2023-10-19 14:02:21.517 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Mi Air Purifier 3/3H' for xiaomi_miio integration not ready yet: Unable to discover the device 192.168.x.x; Retrying in background

Correct, moving the device to the same VLAN as HA should fix it.

spiderman07 commented 10 months ago

my mi purifier is on same vlan, don't have multiple ones and yet I get same error.

deleting and adding integration again fixed it. but I don't think it's a permanent fix.

luixal commented 9 months ago

Same problem here, just noticed (xD).

Is there any work in progress for this?

Thanks!

serlinGi commented 8 months ago

same issue: "Error fetching Mi Air Purifier Pro H data: Unable to discover the device 192.168.13.121"

I've only 1 VLAN with 3 AP in mesh.

with app is OK and in the LAN I didn't register any disconnection

ha-reporting2023 commented 7 months ago

My HA is in one VLAN, the IOT devices like the Air Purifier 3H are in another VLAN, with a firewall/router in between. It used to work, about 2 years ago, then not so much somewhere around the summer of 2022 for me. A lot of changes happened in these 2 years. Fresh HA hardware, new HA versions, new firewall code, fresh Xiaomi firmware...

But today I could confirm that the problem is really my network setup and the seperate VLANS. To confirm this, I had to setup a spare Raspberry PI with HA, put it on the same wireless VLAN & SSID as the IOT Xiaomi devices and the Xiaomi Miio integration works perfectly.

I will still have a look if a Avahi service that services mDNS can help as that helped me with the Ikea Dirigera hub that could not be found with the Ikea Smart Home App until Avahi was configured on the router.

iliyankxyz commented 7 months ago

The same issue here. I have 3 MI devices in the same network as the HA server. After pairing to HA the integration works for a while and devices are lost....

ha-reporting2023 commented 7 months ago

It's fixable. I spend some time on it, and the root cause of much of the issues is that those Purifier 3H devices ONLY respond to packets coming from either "the Xiaomi Cloud servers" or from an device with an IP address on the same subnet. Having your HA in another subnet, even without any firewall rules blocking anything is not allowed by the firmware of the Purifiers. So you can either move your HA or Purifiers around, or you can do some IP masquerading so that packets coming from a HA in another subnet or VLAN, seems to be coming from a device on the subnet/vlan of the Purifiers.

If you happen to use Pfsense as a firewall then this will fix it: image

serlinGi commented 7 months ago

It's fixable. I spend some time on it, and the root cause of much of the issues is that those Purifier 3H devices ONLY respond to packets coming from either "the Xiaomi Cloud servers" or from an device with an IP address on the same subnet. Having your HA in another subnet, even without any firewall rules blocking anything is not allowed by the firmware of the Purifiers. So you can either move your HA or Purifiers around, or you can do some IP masquerading so that packets coming from a HA in another subnet or VLAN, seems to be coming from a device on the subnet/vlan of the Purifiers.

If you happen to use Pfsense as a firewall then this will fix it: image

I don't think I understood correctly; I have a single Vlan, all devices, including my HA server, are on the same network. I don't think this is the problem

drpsyko101 commented 7 months ago

Thanks @ha-reporting2023, I was able to masquerade the packet by setting NAT:Outbound as follows:

Interface Source Source Port Destination Destination Port NAT Address NAT Port Static Port
IOT_VLAN <HA IP address> * <Air Purifier IP address> * IOT_VLAN address * NO
ChristBKK commented 5 months ago

Same Problem. My solution will be to get rid of these Xiaomi Purifiers :D I was already not so happy to have to use something different than ZHA.

The Levoit Purifiers seem to be best integrated into HA at the moment.

ha-reporting2023 commented 5 months ago

I'm not sure that the Levoit integration is all that great looking at https://www.home-assistant.io/integrations/vesync/

But the 99 euro price for a Core 200S is inline with the Xiaomi pricing.

ChristBKK commented 5 months ago

I'm not sure that the Levoit integration is all that great looking at https://www.home-assistant.io/integrations/vesync/

  • you are still very cloud dependent,
  • you are still very dependent on the app to make network changes
  • the integration breaks from time to time
  • EU models may not always be supported

But the 99 euro price for a Core 200S is inline with the Xiaomi pricing.

Any better alternatives? Philips is also cloud based.

The vital 200s looks great will wait till it's better HA integrated maybe. But I really want to go far away from Xiaomi.

issue-triage-workflows[bot] commented 2 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

cydia2020 commented 2 months ago

Not stale

luixal commented 1 month ago

Hey @ChristBKK I own an smaller Levoit purifier too and I would throw it out the window every time I have to deal with it.

I have everything integrated into HA, some custom parts indeed, but I just gave up with the Levoit purifer and just use its own app. Why?

Hope my next purifier will be matter compliant xD