<rant>
This issue has really bugged me and my family for a while as well. To the point where I even started testing proxies and emulated API’s between HA and the Hue bridge. The issue started immediately after HA migrated to aiohue while at the same time no Android app or other code talking directly to the bridge outside of HA was affected at all. The error message used to appear in the log intermittently with a few minutes up to a maximum of half an hour between them (most of the time around ten minutes). The issue was also triggered almost every time a bulb was manually switched via the HA frontend making all bulbs unavailable for a few seconds and the switched one didn’t turn on. Another attempt immediately after that worked most of the time. Bought several wall mounted switches to mitigate that annoyance but at least they work every time and are at least a fallback if the automations fail to trigger for whatever reason. When the setup can’t fulfill it’s primary purpose (which is home automation and not home control) it’s pretty useless though.
</rant>
While troubleshooting I figured it might help to increase some of the timeouts on the HA side and at least in my case it seems to have helped tremendously. After changing a timeout value in the Hue light component a few days can pass before even a single related error message appears. My assumption at this point is that a bridge needs more time to respond, the more populated it is. I don’t know what the optimal value of the timeout should be or if the changed value has any negative side effects but so far I haven’t noticed any on this setup.
Would be interesting to see stats from other people with this issue versus where it’s working as expected. This setup has 15 bulbs, 7 dimmers and at least a dozen groups but I don’t know if that should be considered many since the hub has support for up to 50 bulbs. Has anyone here tested a fully loaded hub with HA?
See the following patch (would be nice to see if it improves the situation for someone else as well):
--- hue.py.orig 2018-09-06 21:44:11.000000000 +0200
+++ hue.py 2018-09-19 11:59:25.053508771 +0200
@@ -164,7 +164,7 @@
api = bridge.api.lights
try:
- with async_timeout.timeout(4):
+ with async_timeout.timeout(30):
await api.update()
except (asyncio.TimeoutError, aiohue.AiohueException):
if not bridge.available: