homematicip.connection.websocket_handler¶
homematicip.connection.websocket_handler
¶
WebsocketHandler
¶
Manages a WebSocket connection to Homematic IP and provides methods for starting, stopping, and processing messages. Supports automatic reconnect, adding handlers, and status queries.
add_on_connected_handler
¶
Adds a handler that is called when the connection is established.
add_on_disconnected_handler
¶
Adds a handler that is called when the connection is closed.
add_on_reconnect_handler
¶
Adds a handler that is called when the connection is re-established.
add_on_stale_handler
¶
Adds a handler called when the websocket reports connected but has gone silent past the configured thresholds.
Handler signature: handler(severity: str, seconds_since: float)
where severity is "warning" (>= STALE_WARNING_SECONDS) or
"error" (>= STALE_ERROR_SECONDS). Each severity fires at most
once per staleness episode and resets when a fresh message arrives.
last_disconnect_reason
¶
Returns the last recorded disconnect or reconnect reason.
last_message_time
¶
Returns the loop timestamp of the last received WebSocket message.
reconnect_attempt_count
¶
Returns the number of reconnect attempts in the current outage.
seconds_since_last_message
¶
Returns the seconds since the last WebSocket message was received.