mirror of
https://github.com/cgiesche/streamdeck-homeassistant.git
synced 2026-04-22 03:00:19 -04:00
I just started seeing some issues where the Home Assistant connection dies and doesn't reconnect automatically when resuming from sleep until you do anything to cause the connection to attempt to communicate. At that point, it will discover that the connection is dead and automatically restart it. I think this issue might have started for me with the Windows 24H2 upgrade, as I did that a few days ago. With that said, this commit implements a couple of fixes for the issue. First, we implement the "onSystemDidWakeUp" callback to reconnect the Home Assistant connection when the system wakes up. This is the officially recommended way to handle this according to the SDK documentation. Unfortunately, from my testing, this callback doesn't actually seem to be called when my PC wakes up from sleep, so it didn't fix the issue. Maybe it's a bug in the SDK that will be fixed, so I'm going to leave the callback in there for the time being. The second fix in this commit is to add a heartbeat to the Home Assistant server, which calls the ping/pong websocket command. This will ping the server every 5 seconds after the last event was received. In the event that the connection drops, this should be enough to cause the internal reconnect logic to realize the connection is down and recreate it.