unfoldedcircle / integration-home-assistant

Home-Assistant Integration for Remote Two
Mozilla Public License 2.0
28 stars 5 forks source link

Option to disconnect from HA when device enters standby #50

Closed zehnm closed 9 months ago

zehnm commented 9 months ago

When running on the Remote Two device, the WebSocket connection to the HA server is currently kept open when the device enters suspend mode.

The Remote Two sends the enter_standby and exit_standby events, but they aren't being used yet in the integration besides setting a flag: https://github.com/unfoldedcircle/integration-home-assistant/blob/6cbc80eb01708e5f4ab96bca643b01c77b64c8d0/src/controller/handler/r2_event.rs#L36-L42

In certain environments this works quite well and the HA connection is immediately available after WiFi is connected. However, this can also cause connectivity issues after the device wakes up and take longer to detect a no longer working WebSocket connection.

With the upcoming, renewed connection logic in the core (https://github.com/unfoldedcircle/feature-and-bug-tracker/issues/320) the integration should disconnect from HA when entering standby, and immediatly reconnect when receiving the exit_standby event.

This might also help with the following HA server log entries: Client unable to keep up with pending messages (https://github.com/unfoldedcircle/feature-and-bug-tracker/issues/301). Assumption: remote is in standby and HA tries to send entity change events over the still open WebSocket connection.