Skip to content

Mark entities as unavailable when bridge connection drops#145

Open
markusrauschergmxnet wants to merge 4 commits into
michaelarnauts:masterfrom
markusrauschergmxnet:availability-dispatcher
Open

Mark entities as unavailable when bridge connection drops#145
markusrauschergmxnet wants to merge 4 commits into
michaelarnauts:masterfrom
markusrauschergmxnet:availability-dispatcher

Conversation

@markusrauschergmxnet

Copy link
Copy Markdown

Summary

Implements bridge availability tracking for fan, sensor, and binary_sensor entities, replacing the two # TODO: Mark sensors as available/unavailable comments in send_keepalive with a working dispatcher.

When the periodic keepalive succeeds, bridge.set_available(True) is called; when it fails with AioComfoConnectNotConnected or AioComfoConnectTimeout, bridge.set_available(False) is called. A new dispatcher signal SIGNAL_COMFOCONNECT_AVAILABILITY is forwarded to all entity platforms, which update _attr_available and trigger a state update.

Why

While running this integration on a flaky bridge connection, sensors held their last numeric value indefinitely after the bridge dropped, and the library callback occasionally fed through 0-valued spikes that visibly flapped automations relying on those entities. Marking the entities as unavailable on bridge disconnect makes their state honest and lets HA's own availability filtering work correctly downstream.

Scope

  • __init__.py — adds SIGNAL_COMFOCONNECT_AVAILABILITY, is_available state on ComfoConnectBridge, set_available() callback that fires the signal on transition; wires set_available(True/False) into send_keepalive.
  • sensor.py, fan.py, binary_sensor.py — register a listener for the availability signal in async_added_to_hass, initialise _attr_available from ccb.is_available in __init__.

No changes to manifest.json, const.py, config_flow.py, select.py, button.py. No new dependencies. Backwards-compatible — entities default to available=True so existing installations behave identically until the bridge actually drops.

Related

Possibly addresses #87 and #107 (entity flapping / stale values during bridge issues), although I haven't reproduced those tickets exactly.

Test plan

Running this on a single ComfoAirQ unit with a ComfoConnect LAN C bridge since 2026-05-07. Verified:

  • Bridge power-cycle → all comfoconnect entities flip to unavailable within one keepalive interval (~30 s) and recover when the bridge comes back.
  • Steady-state operation: no spurious availability flips, no log spam.
  • Existing automations using availability: filtering on these entities now skip the unavailable state cleanly instead of acting on stale values.

Implements the two TODOs in send_keepalive that previously left sensors,
fans, and binary sensors with stale values whenever the ComfoConnect
bridge stopped responding.

A new dispatcher signal SIGNAL_COMFOCONNECT_AVAILABILITY is emitted by
ComfoConnectBridge.set_available() on transitions between connected and
disconnected. The fan, sensor, and binary_sensor platforms subscribe to
the signal in async_added_to_hass and update _attr_available accordingly,
so HA's normal availability filtering takes effect downstream.

Backwards-compatible: entities default to available=True, matching prior
behaviour until the bridge actually drops.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@N3rdix

N3rdix commented May 15, 2026

Copy link
Copy Markdown

works fine on my setup, just tested it now for 24h. I added a proposal to your branch for select.py, this has also been tested.

Would be happy to see the open PRs merged @michaelarnauts 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants