You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of problem: In case of network is unreachable Xiaomi Gateway discovery throws an exception (OSError: [Errno 101] Network is unreachable) and stops discovering devices. This happens at me in case of a power outage and after power comes back HASS is booting up faster than my router is able to finish setting up the local network.
Expected: I expect this component to better handle any exception and keep continuing device discovery.
Traceback (if applicable):
Error during setup of component xiaomi_aqara
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py", line 193, in _async_setup_component
component.setup, hass, processed_config)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/xiaomi_aqara.py", line 115, in setup
xiaomi.discover_gateways()
File "/srv/homeassistant/lib/python3.4/site-packages/PyXiaomiGateway/__init__.py", line 70, in discover_gateways
(self.MULTICAST_ADDRESS, self.GATEWAY_DISCOVERY_PORT))
Additional info:
I managed to fix this issue in home-assistant/homeassistant/components/xiaomi_aqara.py around line 113 where the discovery happens in a for loop. What I did is to encapsulate the xiaomi.discover_gateways() call in a try..except block as follows:
for k in range(discovery_retry):
_LOGGER.info('Discovering Xiaomi Gateways (Try %s)', k + 1)
try:
xiaomi.discover_gateways()
if len(xiaomi.gateways) >= len(gateways):
break
except Exception as e:
_LOGGER.error('Unexpected error occured while discovering Xiaomi Gateways: ' + str(e))
time.sleep(5)
I believe the sleep() call is necessary because this exception occurs immediately and the loop would finish instantly. Maybe the number of seconds to sleep could be extracted as a config option.
For my case I had to set discovery_retry: 50 so this component has enough time until the network is reachable again.
But IMHO the best would be to wait/sleep until the network is reachable again and not incrementing the retry counter. Without network HASS is useless anyways.
I'm happy to create a pull request with this fix if you accept it.
The text was updated successfully, but these errors were encountered:
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 will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍
Home Assistant release (
hass --version
): 0.60.0Python release (
python3 --version
): 3.4.2Component/platform: xiaomi_aqara
Description of problem: In case of network is unreachable Xiaomi Gateway discovery throws an exception (
OSError: [Errno 101] Network is unreachable
) and stops discovering devices. This happens at me in case of a power outage and after power comes back HASS is booting up faster than my router is able to finish setting up the local network.Expected: I expect this component to better handle any exception and keep continuing device discovery.
Traceback (if applicable):
Additional info:
I managed to fix this issue in
home-assistant/homeassistant/components/xiaomi_aqara.py
around line 113 where the discovery happens in a for loop. What I did is to encapsulate thexiaomi.discover_gateways()
call in atry..except
block as follows:I believe the
sleep()
call is necessary because this exception occurs immediately and the loop would finish instantly. Maybe the number of seconds to sleep could be extracted as a config option.For my case I had to set
discovery_retry: 50
so this component has enough time until the network is reachable again.But IMHO the best would be to wait/sleep until the network is reachable again and not incrementing the retry counter. Without network HASS is useless anyways.
I'm happy to create a pull request with this fix if you accept it.
The text was updated successfully, but these errors were encountered: