Mark entities as unavailable when bridge connection drops#145
Open
markusrauschergmxnet wants to merge 4 commits into
Open
Mark entities as unavailable when bridge connection drops#145markusrauschergmxnet wants to merge 4 commits into
markusrauschergmxnet wants to merge 4 commits into
Conversation
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>
|
works fine on my setup, just tested it now for 24h. I added a proposal to your branch for Would be happy to see the open PRs merged @michaelarnauts 😄 |
Added availability handling to the select entities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements bridge availability tracking for fan, sensor, and binary_sensor entities, replacing the two
# TODO: Mark sensors as available/unavailablecomments insend_keepalivewith a working dispatcher.When the periodic keepalive succeeds,
bridge.set_available(True)is called; when it fails withAioComfoConnectNotConnectedorAioComfoConnectTimeout,bridge.set_available(False)is called. A new dispatcher signalSIGNAL_COMFOCONNECT_AVAILABILITYis forwarded to all entity platforms, which update_attr_availableand 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
availabilityfiltering work correctly downstream.Scope
__init__.py— addsSIGNAL_COMFOCONNECT_AVAILABILITY,is_availablestate onComfoConnectBridge,set_available()callback that fires the signal on transition; wiresset_available(True/False)intosend_keepalive.sensor.py,fan.py,binary_sensor.py— register a listener for the availability signal inasync_added_to_hass, initialise_attr_availablefromccb.is_availablein__init__.No changes to
manifest.json,const.py,config_flow.py,select.py,button.py. No new dependencies. Backwards-compatible — entities default toavailable=Trueso 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:
unavailablewithin one keepalive interval (~30 s) and recover when the bridge comes back.availability:filtering on these entities now skip theunavailablestate cleanly instead of acting on stale values.