Skip to content

Add a trigger log subscription to the event stream - #407

Open
ptr727 wants to merge 2 commits into
loopj:mainfrom
ptr727:trigger-log
Open

ptr727 wants to merge 2 commits into
loopj:mainfrom
ptr727:trigger-log

Conversation

@ptr727

@ptr727 ptr727 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Stacked on #406. This branch carries that PR's commit too, for its log type enums. Only the last commit, "Add a trigger log subscription to the event stream", is new here.

Why

InFusion Diagnostics' History view shows which object started which task, eg. which button press ran a scene. The IDiagnostic PR adds reading that history. This adds the live version, from the Host Command EVENT enhanced log, so an integration can react to a trigger as it happens rather than polling the history.

This is the second of three PRs split from #404, as asked.

How it is implemented

  • EventStream.subscribe_triggers subscribes to the EVENT enhanced log and passes each trigger line to the callback as a TriggerReceived, with its source, destination, event code and parameters. trigger_type names the code with TriggerType. It is built on subscribe_enhanced_log, so peers, reference counting and resubscribing after a reconnect work as they already do.
  • Enhanced log lines carry no type tag, so every log type a client has enabled arrives on the same stream. A trigger is five integers, and an object status line is a VID followed by Interface.Method, so each parser matches only its own shape.
  • The controllers' enhanced log handler now skips lines that aren't object status. Without that, a trigger line can match a managed object's VID, and a short line like 100 raises during unpacking and stops the event stream.
  • Example: examples/command_client/monitor_triggers.py.

Protocol notes

Verified against an IC-II controller on 4.11 firmware:

  • EVENT lines are <source> <destination> <event> <param1> <param2>. A press, a double press (param1 = 2) and a hold were captured live and matched the trigger history one to one.
  • A module losing a line feed raises trigger code 0xA004 from the module, with what looks like the feed number in param1.
  • Subscribing turns on ELENABLE EVENT ON, which stays on after the client disconnects, the same as the existing enhanced log subscriptions.

How it was tested

  • New tests:
    • trigger parsing, including lines of the other shapes and codes outside the known types;
    • subscribing and unsubscribing with reference counting;
    • the status handler skipping non-status lines.
  • pytest, ruff check, ruff format --check and pyright pass.
  • Run against a live controller: button presses, a double press, a hold, and a deliberate breaker trip on one module, which showed up as a 0xA004 trigger.

Home Assistant

A companion change to home-assistant-vantage fires a vantage_trigger event from this subscription. It will follow once an aiovantage release carrying these changes is available to pin.

🤖 Generated with Claude Code

ptr727 and others added 2 commits October 22, 2026 12:26
Add DiagnosticInterface for the read-only IDiagnostic methods InFusion
Diagnostics uses for its History and Log views: the trigger history, the
system log, and the modules answering on an enclosure's bus. TriggerType
and SysLogType name the trigger and log type codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add EventStream.subscribe_triggers for the live EVENT enhanced log, which
names the object that started each task, and have the controllers'
enhanced log handler skip lines that are not object status.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The reviewed changes have no unresolved blocking issues, and all approval assessments indicate readiness.

No open issues 🎉

What changed in this PR

Adds live trigger notifications from the controller’s EVENT enhanced log, alongside diagnostic history APIs and safeguards for unrelated enhanced-log messages.

Changes:

  • Adds TriggerReceived parsing and EventStream.subscribe_triggers with reference counting and reconnect support.
  • Adds diagnostic models, interfaces, enums, tests, and examples.
  • Filters non-object-status enhanced-log lines before controller status handling.
File Description
tests/​controllers/​test_base.py Tests filtering non-status enhanced-log messages.
tests/​config_client/​test_diagnostic.py Tests diagnostic RPC parsing and edge cases.
tests/​command_client/​test_events.py Tests trigger parsing, subscription, and reference counting.
src/​aiovantage/​events.py Defines the TriggerReceived event model and parser.
src/​aiovantage/​config_client.py Exports diagnostic interfaces, models, and log enums.
src/​aiovantage/​_log_types.py Defines trigger and system log type enums.
src/​aiovantage/​_controllers/​base.py Ignores enhanced-log lines that are not object status messages.
src/​aiovantage/​_config_client/​interfaces/​diagnostic.py Implements diagnostic models and RPC wrappers.
src/​aiovantage/​_command_client/​events.py Adds the trigger log subscription API.
examples/​config_client/​dump_diagnostics.py Demonstrates reading diagnostic information.
examples/​command_client/​monitor_triggers.py Demonstrates live trigger monitoring.

Review effort: Lite

This branch has not been deployed

No deployments
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