kukulich / home-assistant-jablotron100

Home Assistant custom component for JABLOTRON 100+ alarm system
MIT License
65 stars 24 forks source link

Behaviour of the integration when a connection is lost #92

Closed Dehumanizer77 closed 2 months ago

Dehumanizer77 commented 3 months ago

Hi, I'm not sure what has changed, if it's caused by changes in HA or in the integration, but previously when a connection to the controller was lost (e.g. the usb cable was disconnected), all alarm sections immediately changed to "Unavailable". Now this does not happen anymore, I can only detect it using binary_sensor.jablotron_active, but that lags a log (like 30 seconds or so) and all other sensors look like everything is fine (alarm sections keep their previous state etc.). Is there any way how to bring back the previous behaviour?

Dehumanizer77 commented 3 months ago

To further explain, the problem is that if the connection is lost just for a few seconds (like accidentally disconnecting the usb cable and connecting it back immediately), I am unable to detect this and after reconnection the integration does not work anymore, everything looks normal but it does not communicate, until the integration is restarted. Previously I had an automation which would restart the integration when this happened (i.e. the alarm section became unavailable), but now I have no way of knowing that something happened and that the integration needs to be restarted, if the disconnection is shorther than the 30 or so seconds when the jablotron_active sensor catches it.

Dehumanizer77 commented 3 months ago

I have checked logs and I might have an idea what is a problem (or how can it be fixed/changed) I see this: OSError: [Errno 30] Read-only file system: '/dev/jablotron' 2024-05-08 11:07:02.905 ERROR (ThreadPoolExecutor-110_1) [custom_components.jablotron100] Write error: [Errno 30] Read-only file system: '/dev/jablotron' Traceback (most recent call last): File "/config/custom_components/jablotron100/jablotron.py", line 1069, in _keepalive self._send_packet(self.create_packet_command(COMMAND_HEARTBEAT)) File "/config/custom_components/jablotron100/jablotron.py", line 1097, in _send_packet self._send_packet_by_stream(packet) File "/config/custom_components/jablotron100/jablotron.py", line 1100, in _send_packet_by_stream stream = self._open_write_stream() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/jablotron100/jablotron.py", line 1114, in _open_write_stream return open(self._serial_port, "wb", buffering=0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ which means the integration is trying to write to the device while it's not available (resulting in the "read-only filesystem" error, since it can't create anything in /dev of course) Maybe it would be to sufficient to catch this exception and set the whole alarm to unavailable if this happens.

Dehumanizer77 commented 3 months ago

Actually, the binary_sensor.jablotron_active is my own sensor, which I was trying to mitigate this issue with, so please disregard that. But everything else is still valid.

cris1410 commented 3 months ago

Ive got very similar problems since HA 2024.5

Dehumanizer77 commented 2 months ago

Can this be fixed somehow?

kukulich commented 2 months ago

The log mentioned in https://github.com/kukulich/home-assistant-jablotron100/issues/92#issuecomment-2100147908 is the only log when this happens?

Dehumanizer77 commented 2 months ago

I think there wasn't anything more, but I can test again tomorrow (as there were few new HA versions since I created the issue). I'll post my findings here.

Dehumanizer77 commented 2 months ago

Ok I have checked and that is the only error I see. Here is the full log, after this, there is the same error twice per second until the connection is reestablished. err.txt

kukulich commented 2 months ago

Please try latest dev version.

Dehumanizer77 commented 2 months ago

I am quite busy right now, but I'll try to test it until the end of week if noone else willl.

Dehumanizer77 commented 2 months ago

OK I had some time to test it now, but still the same error. I have selected to install the "master" version of the integration in HACS, is that correct?

kukulich commented 2 months ago

@Dehumanizer77 yes, master version should be the latest. You can check the latest commit if you have the changes in your HA.

what means “the same error”? Logs should be same, only entities should be unavailable.

Dehumanizer77 commented 2 months ago

Ok sorry for the confusion. I have removed the USB cable, but the entities were still unchanged and available in the last state.

kukulich commented 2 months ago

@Dehumanizer77 Please try the "new" latest version again.

Dehumanizer77 commented 2 months ago

Works perfectly! Thanks!

kukulich commented 2 months ago

https://github.com/kukulich/home-assistant-jablotron100/releases/tag/3.24.1