kvj / hass_nuki_ng

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

change the exception name to HomeAssistantError #124

Closed leranp closed 1 year ago

leranp commented 1 year ago

this will allow HA to use the continue on error in the automation and scripts, now we can not use the "continue on error" and when the the bridge is busy and return 503 code.

ConnectionError: Http response for http://xx.xxx.xx.xx:8080/lockAction?token=HXXXXXXXX&action=3&nukiId=XXXXXXX&deviceType=4: 503 Service Unavailable

in HA there is a "if" function that only allow HomeAssistant Error to continue on error

        # Only Home Assistant errors and can be ignored.
        if not isinstance(exception, exceptions.HomeAssistantError):
            raise exception
kvj commented 1 year ago

That's a pretty cool improvement, thanks!

alexdelprete commented 1 year ago

in HA there is a "if" function that only allow HomeAssistant Error to continue on error

this is excellent to better manage the limitations of the bridge. has this been introduced recently in HA? I'm thinking about the minimum version requirement for HA...

leranp commented 1 year ago

Please check if this change is working. I think there's an error when the log function is triggered. I am not a developer :-)

alexdelprete commented 1 year ago

The only real developer here is @kvj :D

enkama commented 1 year ago
2023-01-05 21:46:07.421 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to get latest data: name 'HomeAssistantError' is not defined
Traceback (most recent call last):
  File "/config/custom_components/nuki_ng/nuki.py", line 423, in _update
    item["last_log"] = await self.api.web_get_last_unlock_log(web_id)
  File "/config/custom_components/nuki_ng/nuki.py", line 200, in web_get_last_unlock_log
    response = await self.web_async_json(
  File "/config/custom_components/nuki_ng/nuki.py", line 184, in web_async_json
    return await self.async_json(
  File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json
    raise HomeAssistantError(f"Http response for {response.request.url}: {response.status_code} {response.reason}")
NameError: name 'HomeAssistantError' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/config/custom_components/nuki_ng/nuki.py", line 424, in _update
    except HomeAssistantError:
NameError: name 'HomeAssistantError' is not defined
enkama commented 1 year ago

Makes an error @alexdelprete @leranp @kvj

leranp commented 1 year ago

Makes an error @alexdelprete @leranp @kvj @kvj @alexdelprete @Wibias

130

please report back if it working now I have check with my HA and it looks fine

kvj commented 1 year ago

merged

leranp commented 1 year ago

merged

Did you check if it was working?

enkama commented 1 year ago

Yup thats working. Just throwing the old homeassistant.exceptions.HomeAssistantError: Http response for https://api.nuki.io/smartlock/*****/log: 500 Server and Despite being configured, Web API request has failed error now.

Getting spammed a bit to much tbh so its a must for me to add custom_components.nuki_ng.nuki: critical

leranp commented 1 year ago

Yup thats working. Just throwing the old homeassistant.exceptions.HomeAssistantError: Http response for https://api.nuki.io/smartlock/*****/log: 500 Server and Despite being configured, Web API request has failed error now.

Getting spammed a bit to much tbh so its a must for me to add custom_components.nuki_ng.nuki: critical

Tomorrow i will take a look and see if there's an option to make it look better ☺️