Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cascading errors from update failure #37

Open
ibatten opened this issue Sep 23, 2024 · 0 comments
Open

Cascading errors from update failure #37

ibatten opened this issue Sep 23, 2024 · 0 comments

Comments

@ibatten
Copy link

ibatten commented Sep 23, 2024

From what I can deduce from the logs, my monitoring service hit a problem at 23:32:30 on 22 Sep. nginx in front of the tycomonitor service return 502 server error: bad gateway (usually that means an origin server has gone away). self.alarm.update_status() failed but didn't throw enough of an error, and eventually at line 358, in update_status, an attempt was made to unpack partitions that didn't exist (because the update_status had failed).

Subsequently, the code didn't notice that -- I am guessing -- the session id had got messed up, and every subsequent access failed. I didn't notice until 1900 on the 23rd, when I put the visonicalarm2 library onto another machine and checked that it all still worked with a simple access example (ie, that Tyco hadn't broken things at their end). After staring at the code for a bit, I came to the conclusion that the internal state of the alarm object was messed up, restarted Home Assistant and all was well.

Obviously, I'd like to help fix the code so that it can receover from this. My guess, and it really is only a guess, is that at a minimum line 153 in VisonicAlarm2/visonic/alarm.py the call to self.update_status() should be wrapped in a try/except block to make sure that if the hub.update() fails then the status is set to unknown or unavailable. And then "somewhere" if the hub is in state unavailable, a fresh attempt to get a session token should be made.

Happy to help, but don't want to make a mess of the code before I talk to others.

2024-09-22 23:32:30.563 ERROR (SyncWorker_26) [root] 502 Server Error: Bad Gateway for url: https://visonic.tycomonitor.com/rest_api/10.0/status
2024-09-22 23:32:30.564 ERROR (SyncWorker_26) [root]

<title>502 Bad Gateway</title>

502 Bad Gateway


nginx

2024-09-22 23:32:30.564 ERROR (SyncWorker_26) [root]

<title>502 Bad Gateway</title>

502 Bad Gateway


nginx

2024-09-22 23:32:30.564 ERROR (SyncWorker_26) [custom_components.visonicalarm] Update failed: 'NoneType' object is not subscriptable
2024-09-22 23:32:30.577 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.visonic_alarm fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/visonicalarm/alarm_control_panel.py", line 153, in update
hub.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 184, in wrapper
result = method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/visonicalarm/init.py", line 119, in update
self.alarm.update_status()
File "/usr/local/lib/python3.12/site-packages/visonic/alarm.py", line 358, in update_status
partition = status['partitions'][0]
~~~~~~^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
2024-09-22 23:32:40.837 ERROR (SyncWorker_3) [root] 403 Client Error: Forbidden for url: https://visonic.tycomonitor.com/rest_api/10.0/status
2024-09-22 23:32:40.838 ERROR (SyncWorker_3) [root]

<title>403 Forbidden</title>

403 Forbidden


nginx

2024-09-22 23:32:40.838 ERROR (SyncWorker_3) [root]

<title>403 Forbidden</title>

403 Forbidden


nginx

2024-09-22 23:32:40.838 ERROR (SyncWorker_3) [custom_components.visonicalarm] Update failed: 'NoneType' object is not subscriptable
2024-09-22 23:32:40.841 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.visonic_alarm fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/visonicalarm/alarm_control_panel.py", line 153, in update
hub.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 184, in wrapper
result = method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/visonicalarm/init.py", line 119, in update
self.alarm.update_status()
File "/usr/local/lib/python3.12/site-packages/visonic/alarm.py", line 358, in update_status
partition = status['partitions'][0]
~~~~~~^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant