Skip to content

ConnectionStatus

Part of Diagnostics & preflight in the Python API reference.

Related guidance: getting-started/preflight, how-to/troubleshooting.

Runnable examples: preflight.py.

from picogrid_ecn_client import ConnectionStatus

Summarize the client’s lifecycle and MQTT connection state.

ConnectionStatus(
*,
state: ClientState,
ready: bool,
mqtt_connected: bool,
changed_at: datetime,
connection_generation: int = 0,
consecutive_attempt_count: int = 0,
last_connected_at: datetime | None = None,
last_disconnected_at: datetime | None = None,
next_retry_at: datetime | None = None,
last_failure_code: ConnectionFailureCode | None = None,
last_failure_operation: ConnectionFailureOperation | None = None,
retry_state: ConnectionRetryState = ConnectionRetryState.INACTIVE,
)

Source · models/diagnostics.py

NameTypeRequiredDefaultConstraintsDescription
stateClientStateyesCurrent client lifecycle state.
readyboolyesWhether the client is in READY state with MQTT connected.
mqtt_connectedboolyesWhether the client currently has an MQTT v5 connection.
changed_atdatetimeyesTimezone-aware UTC time when this status snapshot last changed.
connection_generationintno0ge=0Number of connections that reached strict readiness, starting at zero.
consecutive_attempt_countintno0ge=0Attempts in the current recovery episode; reset after stable readiness or a deliberate new episode.
last_connected_atdatetime | NonenoNoneUTC time when the most recent MQTT v5 CONNACK succeeded.
last_disconnected_atdatetime | NonenoNoneUTC time when the most recent MQTT transport connection ended.
next_retry_atdatetime | NonenoNoneUTC estimate for the next scheduled retry, when one is scheduled.
last_failure_codeConnectionFailureCode | NonenoNoneStable secret-safe classification of the latest recovery failure.
last_failure_operationConnectionFailureOperation | NonenoNoneStable connection phase associated with the latest recovery failure.
retry_stateConnectionRetryStatenoConnectionRetryState.INACTIVECurrent state of the sole reconnect supervisor.

Version 0.2.0 · branch main