feat: connection-state callbacks for availability tracking#18
Draft
bluetoothbot wants to merge 2 commits into
Draft
feat: connection-state callbacks for availability tracking#18bluetoothbot wants to merge 2 commits into
bluetoothbot wants to merge 2 commits into
Conversation
The auto-reconnect loop silently handled drops and restorations, leaving consumers (e.g. a Home Assistant integration) with no way to observe device availability. Add add_connection_callback(fn) and an available property: fires True after login (including auto-reconnect), False on connection loss, deduped to transitions only.
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.
What
Add connection-state (availability) callbacks to
ThermostatConnection.Why
The auto-reconnect loop handled connection drops and restorations silently. Consumers — notably a Home Assistant integration — had no way to know when the thermostat went offline or came back, so entities couldn't reflect availability. Event callbacks only fire on incoming messages, never on lifecycle transitions.
How
add_connection_callback(fn)registersfn(available: bool), returning an unregister callable (mirrorsadd_event_callback).availableproperty: True when connected and authenticated.Trueafterlogin()succeeds (including post-reconnect logins),Falseon connection loss and explicitdisconnect().Testing
Quality Report
Changes: 3 files changed, 145 insertions(+)
Code scan: 1 issue(s) found
README.md:141— debug print statementTests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan