kvj / hass_nuki_ng

Better support for Nuki devices in the Home Assistant
MIT License
185 stars 36 forks source link

High number of HA errors due to 503 Service Unavailable #122

Closed anthonws closed 1 year ago

anthonws commented 1 year ago

Is this due to poor design of the bridge? Is there something I can do on my end to improve this? Maybe ditch the bridge and go for a custom bridge on Pi?

Home Assistant 2022.11.4 Nuki Bridge FW 1.23.0

Thanks!

2022-11-29 18:38:22.751 ERROR (MainThread) [homeassistant.components.webhook] Error processing webhook nuki_ng_bridge_hook_7d07fd866f13463a97b7839d1202d693 Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 129, in async_handle_webhook response = await webhook["handler"](hass, webhook_id, request) File "/config/custom_components/nuki_ng/nuki.py", line 449, in _hook_handler self._add_update(body.get("nukiId"), body) File "/config/custom_components/nuki_ng/nuki.py", line 368, in _add_update self.async_set_updated_data(data) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, in async_set_updated_data self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 348, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state if (state := self.state) is None: File "/config/custom_components/nuki_ng/sensor.py", line 98, in state return self.native_value File "/config/custom_components/nuki_ng/sensor.py", line 94, in native_value return self.data.get("bridge_info", {}).get("rssi") AttributeError: 'NoneType' object has no attribute 'get' 2022-11-29 18:38:39.869 ERROR (MainThread) [homeassistant.components.webhook] Error processing webhook nuki_ng_bridge_hook_7d07fd866f13463a97b7839d1202d693 Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 129, in async_handle_webhook response = await webhook["handler"](hass, webhook_id, request) File "/config/custom_components/nuki_ng/nuki.py", line 449, in _hook_handler self._add_update(body.get("nukiId"), body) File "/config/custom_components/nuki_ng/nuki.py", line 368, in _add_update self.async_set_updated_data(data) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, in async_set_updated_data self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 348, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state if (state := self.state) is None: File "/config/custom_components/nuki_ng/sensor.py", line 98, in state return self.native_value File "/config/custom_components/nuki_ng/sensor.py", line 94, in native_value return self.data.get("bridge_info", {}).get("rssi") AttributeError: 'NoneType' object has no attribute 'get' 2022-11-29 23:42:52.341 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to get latest data: Http response for http://192.168.25.130:8080/list?token=9jquj0: 503 Service Unavailable Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 400, in _update device_list = await self.api.bridge_list() File "/config/custom_components/nuki_ng/nuki.py", line 71, in bridge_list data = await self.async_json(lambda r: r.get(self.bridge_url("/list"), timeout=BRIDGE_TIMEOUT)) File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}") ConnectionError: Http response for http://192.168.25.130:8080/list?token=9jquj0: 503 Service Unavailable 2022-11-29 23:42:52.343 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error fetching nuki_ng data: 2022-11-30 02:30:25.252 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to get latest data: Http response for http://192.168.25.130:8080/info?token=9jquj0: 503 Service Unavailable Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 396, in _update bridge_info = await self.api.bridge_info() File "/config/custom_components/nuki_ng/nuki.py", line 78, in bridge_info return await self.async_json(lambda r: r.get(self.bridge_url("/info"), timeout=BRIDGE_TIMEOUT)) File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}") ConnectionError: Http response for http://192.168.25.130:8080/info?token=9jquj0: 503 Service Unavailable 2022-11-30 02:30:25.253 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error fetching nuki_ng data: 2022-11-30 03:27:51.337 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 348, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state if (state := self.state) is None: File "/config/custom_components/nuki_ng/sensor.py", line 98, in state return self.native_value File "/config/custom_components/nuki_ng/sensor.py", line 94, in native_value return self.data.get("bridge_info", {}).get("rssi") AttributeError: 'NoneType' object has no attribute 'get' 2022-11-30 04:20:05.333 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to get latest data: Http response for http://192.168.25.130:8080/list?token=9jquj0: 503 Service Unavailable Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 400, in _update device_list = await self.api.bridge_list() File "/config/custom_components/nuki_ng/nuki.py", line 71, in bridge_list data = await self.async_json(lambda r: r.get(self.bridge_url("/list"), timeout=BRIDGE_TIMEOUT)) File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}") ConnectionError: Http response for http://192.168.25.130:8080/list?token=9jquj0: 503 Service Unavailable 2022-11-30 04:20:05.335 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error fetching nuki_ng data: 2022-11-30 05:45:01.251 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to get latest data: Http response for http://192.168.25.130:8080/info?token=9jquj0: 503 Service Unavailable Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 396, in _update bridge_info = await self.api.bridge_info() File "/config/custom_components/nuki_ng/nuki.py", line 78, in bridge_info return await self.async_json(lambda r: r.get(self.bridge_url("/info"), timeout=BRIDGE_TIMEOUT)) File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}") ConnectionError: Http response for http://192.168.25.130:8080/info?token=9jquj0: 503 Service Unavailable 2022-11-30 05:45:01.253 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error fetching nuki_ng data: 2022-11-30 09:41:52.402 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to update callback http://192.168.25.9:8123/api/webhook/nuki_ng_bridge_hook_7d07fd866f13463a97b7839d1202d693 Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 391, in _update callbacks_list = await self.api.bridge_check_callback( File "/config/custom_components/nuki_ng/nuki.py", line 154, in bridge_check_callback callbacks = await self.async_json( File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}") ConnectionError: Http response for http://192.168.25.130:8080/callback/list?token=9jquj0: 503 Service Unavailable 2022-11-30 09:41:52.611 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to get latest data: Http response for http://192.168.25.130:8080/info?token=9jquj0: 503 Service Unavailable Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 396, in _update bridge_info = await self.api.bridge_info() File "/config/custom_components/nuki_ng/nuki.py", line 78, in bridge_info return await self.async_json(lambda r: r.get(self.bridge_url("/info"), timeout=BRIDGE_TIMEOUT)) File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}") ConnectionError: Http response for http://192.168.25.130:8080/info?token=9jquj0: 503 Service Unavailable 2022-11-30 09:41:52.612 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error fetching nuki_ng data: 2022-11-30 10:13:58.259 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to get latest data: Http response for http://192.168.25.130:8080/info?token=9jquj0: 503 Service Unavailable Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 396, in _update bridge_info = await self.api.bridge_info() File "/config/custom_components/nuki_ng/nuki.py", line 78, in bridge_info return await self.async_json(lambda r: r.get(self.bridge_url("/info"), timeout=BRIDGE_TIMEOUT)) File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}") ConnectionError: Http response for http://192.168.25.130:8080/info?token=9jquj0: 503 Service Unavailable 2022-11-30 10:13:58.261 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error fetching nuki_ng data:

alexdelprete commented 1 year ago

Either wait for the new fw for the Nuki Bridge, that will support MQTT so these problems will be finally solved, or switch to Nuki Hub, a bridge replacement: https://github.com/technyon/nuki_hub.

I switched 1 month ago, the firmware has some small bugs, but it's working much better than the Nuki Bridge.

anthonws commented 1 year ago

MQTT is going to be available?!!? WOW! Great news!

Yes, that was the project I was referring too. I might try it in the meantime.

Thanks! I'll close this then.

neuhausf commented 1 year ago

@anthonws what new firmware are you referring to? I have 1.23.0. Is there a beta you are testing?

anthonws commented 1 year ago

@anthonws what new firmware are you referring to? I have 1.23.0. Is there a beta you are testing?

Alex was most probably talking about the MQTT support for Nuki Bridge 3 Pro. More info here: https://developer.nuki.io/t/nuki-bridge-mqtt-support/2498

neuhausf commented 1 year ago

Sorry, I used the wrong mention. So I guess I have to buy the version 3 bridge to profit from MQTT.

For the meantime: Does it help to reduce 503 errors, if we use cloud-API only?

alexdelprete commented 1 year ago

Sorry, I used the wrong mention. So I guess I have to buy the version 3 bridge to profit from MQTT.

For the meantime: Does it help to reduce 503 errors, if we use cloud-API only?

The fw that will support MQTT should be available on all bridges. I didn't hear any news about a new platform for the bridge, it is the usual very limited hw which doesn't handle more than 1 connection. Very bad design. That's why I switched to Nuki Hub. And that is why they finally decided to implement MQTT support: too many issues with the bridge, and MQTT support should resolve almost all of them.

If you want to minimise 503 errors you need to ensure that only nuki_ng accesses the bridge, if you use nuki_ng, use the mobile app a lot, etc. you will see a lot of 503 errors because there will be more connections to the bad bridge.

You can use cloud-only and disable the bridge when configuring nuki_ng. This way you avoid all 503 errors but you will have high latency and you will depend on the cloud, while that is the reason why a user buys the bridge, to not depend on the cloud.

neuhausf commented 1 year ago

@alexdelprete Hm, I see. I also saw your posts in the Nuki developer community. So if I get this right: There is a V2 Bridge (with different firmware), but there is no real HW change? It has the same issues as V1? Lets see if MQTT solves all our problems 😉 In the meantime I give the Nuki hub a try. Thx!

alexdelprete commented 1 year ago

Hm, I see. I also saw your posts in the Nuki developer community.

There's a closed section of the forum only for some users, discussing about the MQTT implementation: right now there's a beta fw ONLY for SL3 Pro. After the beta phase, it will be available also in the Bridge firmware.

I asked for MQTT support 2y ago, and also pointed to the very bad limitations of the bridge, despite the €99 cost. A device that should cost €20, sold at €99, and with a very very bad design. The new version of the bridge is the same stuff.

I also had a virtual meeting with the product manager 1y ago, I gave him a pretty long list of things to be improved, one of them was MQTT (or zigbee support). MQTT didn't require hw changes. Finally they decided to go that way, I think because there were way too many complaints and 503 errors from home automation users.

I also asked for HA autodiscovery, and they should implement it.