hass_nuki_ng icon indicating copy to clipboard operation
hass_nuki_ng copied to clipboard

ConnectionError: Http response: 503 in Automation

Open CAVACO-PT opened this issue 3 years ago • 5 comments

Hi There anyone know why my automation , that is really simple , just to close the lock , fails sometimes with 503 ??

Error executing script. Unexpected error for call_service at pos 8: Http response: 503 While executing automation automation.abrir_portas Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 372, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 575, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 668, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 927, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 705, in _handle_entity_call await result File "/config/custom_components/nuki_ng/lock.py", line 57, in async_unlock await self.coordinator.action(self.device_id, "unlock") File "/config/custom_components/nuki_ng/nuki.py", line 326, in action result = await self.api.bridge_lock_action(dev_id, action, device_type) File "/config/custom_components/nuki_ng/nuki.py", line 87, in bridge_lock_action return await self.async_json( File "/config/custom_components/nuki_ng/nuki.py", line 41, in async_json raise ConnectionError(f"Http response: {response.status_code}") ConnectionError: Http response: 503

CAVACO-PT avatar Feb 11 '22 08:02 CAVACO-PT

have the same or similar issue:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 372, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 588, in _async_device_step
    await platform.async_call_action_from_config(
  File "/usr/src/homeassistant/homeassistant/components/lock/device_action.py", line 76, in async_call_action_from_config
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 668, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 705, in _handle_entity_call
    await result
  File "/config/custom_components/nuki_ng/lock.py", line 54, in async_lock
    await self.coordinator.action(self.device_id, "lock")
  File "/config/custom_components/nuki_ng/nuki.py", line 326, in action
    result = await self.api.bridge_lock_action(dev_id, action, device_type)
  File "/config/custom_components/nuki_ng/nuki.py", line 87, in bridge_lock_action
    return await self.async_json(
  File "/config/custom_components/nuki_ng/nuki.py", line 41, in async_json
    raise ConnectionError(f"Http response: {response.status_code}")
ConnectionError: Http response: 503

KitHubek avatar Feb 20 '22 07:02 KitHubek

The Nuki Bridge hardware isn't great. 503s happen from time to time

kvj avatar Feb 20 '22 17:02 kvj

If you have a lot of 503 errors, it's because the bridge is limited to processing one request at a time. If it receives requests from the component AND from the mobile app or some other sw, it will process the first and send 503 to the other requests.

Make sure only the component communicates constantly with the bridge, uninstall other integrations (the official one, many leave it running). If you use the mobile app a lot, it can happen that it sends a command while the component does too...and that leads to 503. Unfortunately the bridge is a bad piece of hw and fw, no queue mechanism, very limited cpu, etc.

alexdelprete avatar Feb 20 '22 17:02 alexdelprete

As a workaround, would it be feasable to retry a few times on 503?

Opening the door might take 2 secs longer, but it will not discard an "open door" command from home assistant.

chiefdeputy avatar Sep 22 '22 18:09 chiefdeputy

As a workaround, would it be feasable to retry a few times on 503?

Opening the door might take 2 secs longer, but it will not discard an "open door" command from home assistant.

I have the same problem and looking for a solution

leranp avatar Oct 04 '22 08:10 leranp