fix(events): emit button_pressed/released from aiovantage StatusReceived stream#374
Open
sdhomecode wants to merge 1 commit into
Open
fix(events): emit button_pressed/released from aiovantage StatusReceived stream#374sdhomecode wants to merge 1 commit into
sdhomecode wants to merge 1 commit into
Conversation
Button presses in aiovantage 0.22.x arrive as StatusReceived(category="BTN") on the event stream rather than as ObjectUpdated on the buttons controller, so the existing handler was never invoked and vantage_button_pressed never fired on the Home Assistant event bus. Subscribe to the raw status stream for "BTN" and translate to the existing HA bus events; payload schema is unchanged.
Owner
|
Was this pull request created using AI? |
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.
PR: Fire
vantage_button_pressedfromStatusReceived("BTN")eventsTitle (suggested)
fix(events): emit button_pressed/released from aiovantage StatusReceived streamDescription
Problem
vantage_button_pressedandvantage_button_releasednever fire on the Home Assistant event bus, even when the controller is sending button status messages over the Host Command stream. Automations usingevent_type: vantage_button_pressedsilently never run.Tested on Home Assistant 2026.5.1,
home-assistant-vantage==0.14.7,aiovantage==0.22.8, against an InFusion controller.With
aiovantage: debug, the controller's messages are clearly arriving:…but
on_button_updatedinevents.pyis never invoked. I verified this by temporarily replacing the body ofon_button_updatedwith an unconditionallogging.warning(...)— zero calls during multiple button presses.Root cause
events.pysubscribes toObjectUpdated[Button]and guards withif "state" not in event.attrs_changed: return. Inaiovantage==0.22.x, button presses are emitted asStatusReceived(category="BTN", vid=…, args=["PRESS"|"RELEASE"])from theevent_stream, not asObjectUpdatedon the buttons controller. So the handler is never reached at all — the issue isn't thestatefilter, it's the wrong event class.Fix
Subscribe to the raw status stream for
"BTN"and translate it into the existing HA bus events. The button object is still looked up afterwards to enrich the payload with name/station/position, so the public event schema (button_id,button_name,button_text1/2,button_position,station_id,station_name) is unchanged.Two robustness improvements that come along for free:
event.args[0](the wire string), not from a Python attribute. The current code readsevent.obj.is_down, which has been an unstable target across aiovantage versions.attrs_changedcontaining any particular key.The Task
ObjectUpdatedpath is left untouched — task events come through the controller dispatcher correctly.Alternative: fix this upstream in
aiovantageYou maintain both libraries, so this could equally be fixed in
aiovantageby making the Button controller emitObjectUpdatedwhenever aBTNstatus changes the button's in-memory state, which would let the existingObjectUpdated[Button]subscription here keep working without changes. Happy to move the fix there if you'd prefer — let me know.I'd argue the
StatusReceivedpath is still slightly better for press events even in that world: presses are inherently transient signals (PRESS/RELEASE), not state transitions, and reading them from the wire stream avoids the "did this attribute actually change?" question entirely. But either fix resolves the user-visible bug.Verification
After the patch, on a real Vantage system:
A
wait_for_trigger-based double-click automation also works end-to-end:A second isolated press correctly times out without firing the script.
Reviewer checklist
custom_components/vantage/events.py), one commit, one logical change.manifest.json/ version / dependency bump included — happy to add one, or to leave that for your usualbumpverflow.pyproject.toml—D,E,F,UP,W,B007/B014,C,SIM*,T20,TRY004,RUF006,ICN001,PGH004,PLC0414— no expected violations. No lines exceed 88 cols, all functions/module have docstrings ending in a period, no unused imports.dict[str, Any]for the heterogeneous payload, no implicitAnys leaking through, no# type: ignorecomments — should be clean undertypeCheckingMode = "strict"pyright.uv run ruff check/uv run ruff format --check/uv run pyright— I patched the file in place on a running HA add-on and couldn't bring the dev container up here. If you spot a nit on first pass I'll happily fix it.button_id,button_name,button_text1/2,button_position,station_id,station_name) is preserved — existing user automations and blueprints continue to work unchanged.event_stream, etc.).Suggested commit message
Suggested branch name
fix/button-event-status-streamDiff