Re-establish connection to Python server

Hello again,

I have a python server running for my alarmsystem.
Everytime the server loses connection it is reconnecting by the way this is setup, i have to restart home assistant everytime when the connection was lost before the alarm zones are found again.

Can i do something about this?

This is the server:

Gonna bump this one because it is annoying to restart home assistant every day.

The logs show me this

Logger: homeassistant.helpers.entity
Source: components/nx584/alarm_control_panel.py:135
First occurred: 03:02:30 (3 occurrences)
Last logged: 03:02:52

Update for alarm_control_panel.nx584 fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 744, in async_device_update
    await task
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/nx584/alarm_control_panel.py", line 135, in update
    if not part["armed"]:
UnboundLocalError: local variable 'part' referenced before assignment

I have the same issue. Only fix seems to be to restart HA. The ironic part is the NX584 server is still running and show that HA is still polling it, but somehow HA like gives up if connections are lost temporarily.

Logs and perhaps post to GitHub.