Unable to discover Xiaomi Miio device
The problem
manny error at log: Unable to discover the device 12h - about 1k error lines
What version of Home Assistant Core has the issue?
2023.5.2
What was the last working version of Home Assistant Core?
dont know
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?
Logger: homeassistant.components.xiaomi_miio
Source: helpers/update_coordinator.py:204
Integration: Xiaomi Miio (documentation, issues)
First occurred: 7 maja 2023 21:16:13 (989 occurrences)
Last logged: 09:56:23
Error fetching zhimi.airpurifier.mb3 data: Unable to discover the device DEVIPADDR
Timeout fetching zhimi.airpurifier.mb3 data
Error fetching zhimi.fan.za5 data: Unable to discover the device DEVIPADDR
Error fetching zhimi.airpurifier.mb3_2 data: Unable to discover the device DEVIPADDR
Error fetching zhimi.fan.za5_2 data: Unable to discover the device DEVIPADDR
Additional information
No response
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 closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign xiaomi_miioRemoves 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)
Same issue here. Probably the api changed?
I have exactly the same issue:
Logger: homeassistant.components.xiaomi_miio Source: helpers/update_coordinator.py:204 Integration: Xiaomi Miio (documentation, issues) First occurred: 11:51:29 (15 occurrences) Last logged: 12:21:19
Error fetching Oczyszczacz-Smartmi data: Unable to discover the device 192.168.0.59
the same problem:
Logger: homeassistant.components.xiaomi_miio Source: helpers/update_coordinator.py:204 Integration: Xiaomi Miio (documentation, issues) First occurred: 16:39:59 (1 occurrences) Last logged: 16:39:59
Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 10.10.10.93
Just to add more information, I'm facing the same problem, where a device (Xiaomi Air Purifier 4 Pro) became unavailable after few hours. But I noticed the IP that Home Assistant is trying to reach is wrong. Based on the Xiaomi Home app, my device IP is of a different value.
the same problem:
` Logger: homeassistant.components.xiaomi_miio Source: helpers/update_coordinator.py:204 Integration: Xiaomi Miio (documentation, issues) First occurred: 10:34:13 (72 occurrences) Last logged: 12:55:38
Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 192.168.0.90 `
same here: 023-05-28 18:00:20.651 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Initializing with host 111.222.333.444 (token abcde...) 2023-05-28 18:00:25.657 DEBUG (SyncWorker_8) [homeassistant.components.xiaomi_miio] Unable to fetch timers, this may happen on some devices: Unable to discover the device 111.222.333.444 2023-05-28 18:00:30.652 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching Roborock S6 data in 10.001 seconds (success: False)
I also have an issue discovering my Fan:
2023-06-16 00:01:08.160 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching dmaker.fan.1c data in 5.008 seconds (success: False) 2023-06-16 00:01:08.161 WARNING (MainThread) [homeassistant.config_entries] Config entry 'dmaker.fan.1c' for xiaomi_miio integration not ready yet: Unable to discover the device 10.10.7.8; Retrying in background 2023-06-16 00:01:13.437 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Initializing with host 10.10.7.8 (token 2e438...) 2023-06-16 00:01:18.440 DEBUG (SyncWorker_7) [miio.miioprotocol] Unable to discover a device at address 10.10.7.8
I am using Home Assistant OS, the Fan is in a seperate VLAN.
same here...
Logger: homeassistant.components.xiaomi_miio Source: helpers/update_coordinator.py:229 Integration: Xiaomi Miio (documentation, issues) First occurred: 19:41:55 (2 occurrences) Last logged: 20:00:10
Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 192.168.188.58
Same, also the Xiaomi Air purifier 3H
Logger: homeassistant.components.xiaomi_miio Source: helpers/update_coordinator.py:229 Integration: Xiaomi Miio (documentation, issues) First occurred: 18:03:09 (88 occurrences) Last logged: 22:09:55
Error fetching Xiaomi Air Purifier data: Unable to discover the device 192.168.1.233 Timeout fetching Xiaomi Air Purifier data
Same here with Smart Standing Fan 2 (2 pieces both same problem)
Same Problem here :
Config entry 'Xiaomi Smart Air Purifier 4 Pro' for xiaomi_miio integration not ready yet: Unable to discover the device 10.5.6.2; Retrying in background
I'm having a similar issue, the issues started around 2023.5ish, I anecdotally believe this behaviour starting around about the time this PR was merged https://github.com/home-assistant/core/pull/82601
Basically the fan will be added fine via the integration. But every few minutes it will go unavailable, and you can see the following in the logs:
2023-08-05 23:43:37.511 DEBUG (SyncWorker_0) [miio.miioprotocol] 192.168.4.39:54321 >>: {'id': 52, 'method': 'get_properties', 'params': [{'did': 'power', 'siid': 2, 'piid': 1}, {'did': 'fan_level', 'siid': 2, 'piid': 2}, {'did': 'swing_mode', 'siid': 2, 'piid': 3}, {'did': 'swing_mode_angle', 'siid': 2, 'piid': 5}, {'did': 'mode', 'siid': 2, 'piid': 7}, {'did': 'power_off_time', 'siid': 2, 'piid': 10}, {'did': 'anion', 'siid': 2, 'piid': 11}, {'did': 'child_lock', 'siid': 3, 'piid': 1}, {'did': 'light', 'siid': 4, 'piid': 3}, {'did': 'buzzer', 'siid': 5, 'piid': 1}, {'did': 'buttons_pressed', 'siid': 6, 'piid': 1}, {'did': 'battery_supported', 'siid': 6, 'piid': 2}, {'did': 'set_move', 'siid': 6, 'piid': 3}, {'did': 'speed_rpm', 'siid': 6, 'piid': 4}, {'did': 'powersupply_attached', 'siid': 6, 'piid': 5}]}
2023-08-05 23:43:37.840 DEBUG (SyncWorker_0) [miio.miioprotocol] 192.168.4.39:54321 (ts: 1970-01-24 00:10:26, id: 52) << {'id': 52, 'result': [{'did': 'power', 'siid': 2, 'piid': 1, 'code': 0, 'value': False}, {'did': 'fan_level', 'siid': 2, 'piid': 2, 'code': 0, 'value': 1}, {'did': 'swing_mode', 'siid': 2, 'piid': 3, 'code': 0, 'value': True}, {'did': 'swing_mode_angle', 'siid': 2, 'piid': 5, 'code': 0, 'value': 90}, {'did': 'mode', 'siid': 2, 'piid': 7, 'code': 0, 'value': 1}, {'did': 'power_off_time', 'siid': 2, 'piid': 10, 'code': 0, 'value': 0}, {'did': 'anion', 'siid': 2, 'piid': 11, 'code': 0, 'value': True}, {'did': 'child_lock', 'siid': 3, 'piid': 1, 'code': 0, 'value': False}, {'did': 'light', 'siid': 4, 'piid': 3, 'code': 0, 'value': 100}, {'did': 'buzzer', 'siid': 5, 'piid': 1, 'code': 0, 'value': False}, {'did': 'buttons_pressed', 'siid': 6, 'piid': 1, 'code': 0, 'value': 0}, {'did': 'battery_supported', 'siid': 6, 'piid': 2, 'code': 0, 'value': False}, {'did': 'set_move', 'siid': 6, 'piid': 3, 'code': -4005}, {'did': 'speed_rpm', 'siid': 6, 'piid': 4, 'code': 0, 'value': 0}, {'did': 'powersupply_attached', 'siid': 6, 'piid': 5, 'code': 0, 'value': True}], 'exe_time': 120}
2023-08-05 23:43:42.846 DEBUG (SyncWorker_0) [miio.miioprotocol] Unable to discover a device at address 192.168.4.39
2023-08-05 23:43:42.847 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Error fetching zhimi.fan.za5 data: Unable to discover the device 192.168.4.39
2023-08-05 23:43:42.848 DEBUG (MainThread) [homeassistant.components.xiaomi_miio] Finished fetching zhimi.fan.za5 data in 5.467 seconds (success: False)
After a minute or two discovery will work again any the device will come online again.
If there is some way to revert and disable "lazy discover" again I could test that to pinpoint whether this is really the issue
The same issue for zhimi.airpurifier.za1
2023-09-09 07:15:12.001 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Error fetching Smartmi Air Purifier data: Unable to discover the device 192.168.2.53
2023-09-09 07:24:41.203 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Error fetching Smartmi Air Purifier data: Unable to discover the device 192.168.2.53
2023-09-09 07:28:16.264 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Error fetching Smartmi Air Purifier data: Unable to discover the device 192.168.2.53
2023-09-09 07:30:47.182 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Error fetching Smartmi Air Purifier data: Unable to discover the device 192.168.2.53
@pedrams1 Very good spot. It seems that it works. With flag set to false I have unavailable state at least few times per hour. With flag set to true this behaviour gone.
@pedrams1 You can test this by downloading the component code (from branch matching your HA version) and placing it in config/custom_components. This will override the internal one. You just need to add the version tag to manifest.json and set that lazy_discover flag to true in init.py
@pedrams1 Very good spot. It seems that it works. With flag set to false I have unavailable state at least few times per hour. With flag set to true this behaviour gone.
@pedrams1 You can test this by downloading the component code (from branch matching your HA version) and placing it in config/custom_components. This will override the internal one. You just need to add the version tag to manifest.json and set that lazy_discover flag to true in init.py
![]()
![]()
@dameq1 Can you describe step by step how to achive this?
I'm not sure what are the next steps to revert this bug, but can finally @syssi @rytilahti @starkillerOG look on this issue? It was opened in may what are your comment/action on this?
@relektronik
- clone the HA Core repo from the branch tagged to your current version to your PC
- copy the folder of
xiaomi_miiointegrationhomeassistant/components/xiaomi_miiointo yourconfig/custom_componentsfolder - add to the manifest.json file:
"version": "0.0.1"(do not forget about,in the line above) - edit the
__init__.pyline (in my version it was 299)lazy_discover = Truechanging that to True
Done.
Remember that this component can fail after a core update if something changes.
I can confirm reverting lazy discover to 'true' fixes this behaviour with these devices. Looking through the PR that changed the setting to default to 'false' - https://github.com/home-assistant/core/pull/82601 - it seems it was done for the same reason, that some devices have the same issue with the opposite setting - lazy discover set to 'true'.
The conclusion is some devices need it 'true' to function correctly, and some need it set to 'false' so a PR to revert the change above would recreate the issue somewhere else.
Is it possible to override the default setting for certain devices that need lazy discover to be set to 'true'? It probably makes sense to leave the default remaining as-is? From reading this thread, those devices would be at least (only quoting those that have provided the device code itself to avoid mistakes):
- zhimi.fan.za5
- zhimi.airpurifier.za1
My Python skills aren't where they need to be to make the contribution myself, but I'll happily buy a coffee for the developer that raises the PR! :) fyi @mrwogu who raised the original PR.
We should probably keep the current default as-is, and just start collecting a list of models that require a specific setting. I created a draft PR (#100490) to get us started.
Feel free to add a comment there if your device is not already listed and switching the lazy_discover to True helps with it!
I can't seem to get mine working again with the "lazy_discover = True" fix. I'm seeing following in logs:
2023-11-02 19:07:53.588 DEBUG (SyncWorker_0) [custom_components.xiaomi_miio] Unable to fetch timers, this may happen on some devices: Unable to discover the device 192.168.3.106 2023-11-02 19:07:53.588 DEBUG (SyncWorker_0) [miio.click_common] Unknown model, trying autodetection. None None 2023-11-02 19:07:58.555 DEBUG (MainThread) [custom_components.xiaomi_miio] Finished fetching Robo data in 10.003 seconds (success: False) 2023-11-02 19:07:58.604 DEBUG (SyncWorker_0) [miio.miioprotocol] Unable to discover a device at address 192.168.3.106
I can't seem to get mine working again with the "lazy_discover = True" fix. I'm seeing following in logs:
2023-11-02 19:07:53.588 DEBUG (SyncWorker_0) [custom_components.xiaomi_miio] Unable to fetch timers, this may happen on some devices: Unable to discover the device 192.168.3.106 2023-11-02 19:07:53.588 DEBUG (SyncWorker_0) [miio.click_common] Unknown model, trying autodetection. None None 2023-11-02 19:07:58.555 DEBUG (MainThread) [custom_components.xiaomi_miio] Finished fetching Robo data in 10.003 seconds (success: False) 2023-11-02 19:07:58.604 DEBUG (SyncWorker_0) [miio.miioprotocol] Unable to discover a device at address 192.168.3.106
Looks that you have 2 components trying to access 1 device: miio.miioprotocol and custom_components.xiaomi_miio
I have upgraded to 2023.11.2 but the issue still persists. My affected models are zhimi.fan.sa1 and zhimi.fan.za4.
I have upgraded to 2023.11.2 but the issue still persists. My affected models are zhimi.fan.sa1 and zhimi.fan.za4.
Because your devices are not on the list: Change was applied only for:
zhimi.fan.za5 zhimi.airpurifier.za1
Raised in the discussion.
Hello, HA Core version: 2023.12.4
Problem: Tons of logs:
2023-12-29 11:00:09.285 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Error fetching purifier_room1 data: Unable to discover the device 172.16.16.100 2023-12-29 11:03:15.605 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Error fetching purifier_room2 data: Unable to discover the device 172.16.16.101
For my 2 zhimi.airpurifier.mb3 instances.
Could You please take a look?
Have this still a long time. Could be from the 2023.5.x version. Now on Core version 2023.12.3 Latest OS on a RPI4 and there is no solution?
Logger: homeassistant.components.xiaomi_miio Source: helpers/update_coordinator.py:306 Integration: Xiaomi Miio (documentation, issues) First occurred: 29 december 2023 om 18:09:23 (50 occurrences) Last logged: 04:24:46
Timeout fetching Lucy data - { Vacuum S50 from Xiaomi } Timeout fetching Air Purifier data - { zhimi.airpurifier.mb3 }
till now - no solutiion. Only one is change this intergation to Xiaomi Miot Auto from HASC, and all working i think better that with this official intergation. This integration working very good with no errors till 2023.5 after that many many errors at log check this hacs integration and You will see that errors happen occasionally
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.
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.
Issue still persist in 2024.3.3 version of Home Assistant
Integration: homeassistant.components.xiaomi_miio Device: zhimi.airpurifier.mb3
Error fetching Purifier1 data: Unable to discover the device xxx.xx.xx.xx
Source: helpers/update_coordinator.py:350
Unexpected error fetching Purifier1 data: byte indices must be integers or slices, not str
Source: helpers/update_coordinator.py:318
2 errors above are the most common one
We should probably keep the current default as-is, and just start collecting a list of models that require a specific setting. I created a draft PR (#100490) to get us started.
Feel free to add a comment there if your device is not already listed and switching the
lazy_discovertoTruehelps with it!
@rytilahti I recently installed xiaomi_miio on my HA and immediately faced this problem for my zhimi.airpurifier.m1
Being super happy seeing the solution I applied it locally and also create PR immediately, but now I am a bit lost. I applied the mentioned here workaround as setting up the lazy discovery flag to False, but logs are still flooded with different message.
lazy_discover set to True (original)
2024-04-05 14:37:52.200 ERROR (MainThread) [homeassistant.components.xiaomi_miio] Error fetching Air purifier data: Unable to discover the device XXX.XXX.XXX.XXX
vs
lazy_discover set to False (custom)
2024-04-05 14:32:57.362 ERROR (MainThread) [custom_components.xiaomi_miio] Timeout fetching Air purifier data
so with this workaround I am back to original issue for which this flag was actually introduced. So both ways my logs are flooded anyway.
Any update on this issue? Come on, this is so frustrating...
