I have some issues with lost connection/reconnect, which causes state change. It would be nice if the code could do at least 1 retry before changing state to unavailable.
I am using an ESP32 with the Wemos sample code. I have a PowerMax Pro. HomeESP log further down. Looks like both ends blame the other.
One more comment, HomeESP shows it occasionally going offline/online as well. But log channel is not interrupted (or reconnect happens hehind the scenes)
2023-01-03 19:21:23.295 DEBUG (MainThread) [custom_components.visonic.client] Visonic update event panel=4 event=1 {'Zone': 1, 'Event': 5, 'Description': 'Violated (Motion)', 'condition': 1}
2023-01-03 19:27:17.005 ERROR (MainThread) [custom_components.visonic.pyvisonic] ERROR Connection Lost : disconnected because the Ethernet/USB connection was externally terminated.
2023-01-03 19:27:17.009 ERROR (MainThread) [custom_components.visonic.pyvisonic] ERROR Connection Lost : disconnected due to exception [Errno 104] Connection reset by peer
2023-01-03 19:27:17.014 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for visonic doing blocking calls at custom_components/visonic/pyvisonic.py, line 1512: sleep(5.0) # a bit of time for the watchdog timers and keep alive loops to self terminate
2023-01-03 19:27:22.021 ERROR (MainThread) [custom_components.visonic.pyvisonic] Calling Exception handler.
2023-01-03 19:27:22.025 DEBUG (MainThread) [custom_components.visonic.client] PyVisonic has caused an exception [Errno 104] Connection reset by peer
2023-01-03 19:27:22.031 DEBUG (MainThread) [custom_components.visonic.client] ........... terminating connection and setting up reconnection
2023-01-03 19:27:23.630 DEBUG (MainThread) [custom_components.visonic.client] ........... Closing down Current Task
2023-01-03 19:27:25.632 DEBUG (MainThread) [custom_components.visonic.client] ........... Current Task Done
2023-01-03 19:27:28.634 DEBUG (MainThread) [custom_components.visonic.client] ........... attempting reconnection
2023-01-03 19:27:28.634 DEBUG (MainThread) [custom_components.visonic.client] ........... attempting connection
2023-01-03 19:27:28.635 DEBUG (MainThread) [custom_components.visonic.client] Visonic Connection Device Type is ethernet {<PyConfiguration.DownloadCode: 0>: '9999', <PyConfiguration.ForceStandard: 9>: False, <PyConfiguration.ForceAutoEnroll: 1>: False, <PyConfiguration.AutoSyncTime: 2>: True, <PyConfiguration.PluginLanguage: 3>: 'EN', <PyConfiguration.MotionOffDelay: 4>: 120.0, <PyConfiguration.SirenTriggerList: 5>: ['intruder'], <PyConfiguration.B0_Enable: 6>: False, <PyConfiguration.B0_Min_Interval_Time: 7>: 5, <PyConfiguration.B0_Max_Wait_Time: 8>: 30}
2023-01-03 19:27:30.679 DEBUG (MainThread) [custom_components.visonic.client] ........... connection made
2023-01-03 19:27:40.928 DEBUG (SyncWorker_26) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
2023-01-03 19:27:41.055 DEBUG (MainThread) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
2023-01-03 19:27:41.319 DEBUG (MainThread) [custom_components.visonic.client] Visonic update event panel=4 event=2 {'Zone': 0, 'Entity': None, 'Tamper': False, 'Siren': False, 'Reset': False, 'Time': datetime.datetime(2023, 1, 3, 19, 27, 41, 318722), 'Count': 1, 'Type': [97], 'Event': [0], 'Mode': ['Installer Programming'], 'Name': ['System'], 'condition': 2}
2023-01-03 19:27:41.376 DEBUG (SyncWorker_23) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
2023-01-03 19:27:41.379 DEBUG (MainThread) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
2023-01-03 19:27:41.381 DEBUG (MainThread) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
HomeESP log
[19:26:53][D][sensor:127]: 'visonicinterface WiFi Signal': Sending state -57.00000 dBm with 0 decimals of accuracy
INFO alarm.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO alarm.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for alarm.local
WARNING Disconnected from API
INFO Successfully connected to alarm.local
[19:27:28][D][streamserver:106]: New client connected from 192.168.1.203
[19:27:57][D][sensor:127]: 'visonicinterface WiFi Signal': Sending state -53.00000 dBm with 0 decimals of accuracy