Skip to content

Add a controller connectivity binary sensor#378

Open
ptr727 wants to merge 3 commits into
loopj:mainfrom
ptr727:feat/controller-connectivity-binary-sensor
Open

Add a controller connectivity binary sensor#378
ptr727 wants to merge 3 commits into
loopj:mainfrom
ptr727:feat/controller-connectivity-binary-sensor

Conversation

@ptr727

@ptr727 ptr727 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Why

The integration has no entity that reflects whether the Vantage controller (the InFusion master) is reachable. Existing entities only drop to unavailable as their individual object polls fail, staggered, so there is no single prompt signal that the controller itself is offline (powered off, crashed, or network-isolated). That makes it hard to alert on or automate around a controller outage.

How it is implemented

Adds a binary_sensor per master (vantage.masters), VantageControllerConnectivityEntity:

  • device_class: connectivity, entity_category: diagnostic, attached to the controller device.
  • Reflects the aiovantage event-stream connection: subscribes to Connected / Reconnected (on) and Disconnected (off) in async_added_to_hass.
  • Does not poll, so it stays available and reports off while disconnected, giving one clear signal independent of per-object availability.
  • unique_id is {vid}:connectivity, consistent with the existing "object id plus optional suffix" convention.

Also adds Python 3.14 to the lint matrix (current Home Assistant supports 3.14).

Note on detection latency: the events already exist in the pinned aiovantage, so this entity works as-is, but prompt detection depends on aiovantage surfacing Disconnected quickly. A companion aiovantage change (loopj/aiovantage#373, a read timeout on the event stream) brings a hard power-off down from about 15 minutes to about 2 minutes.

How it was tested

Validated against a real InFusion controller (with the companion aiovantage read-timeout fix applied), correlating the entity against ground-truth ICMP reachability across several power-off / power-on cycles:

  • Goes off about 2 minutes after the controller becomes unreachable, and stays available (not unavailable).
  • Returns to on within seconds of the controller returning.
  • Tracks reachability with no flapping.

Lint (ruff check, ruff format, pyright strict on 3.13 and 3.14) and hassfest run on this PR.

ptr727 and others added 2 commits June 1, 2026 08:44
Why: the integration exposed no reliable signal for whether the InFusion
controller is reachable. The hub-level switch/update entities never go
unavailable, and the per-object entities only drop one by one as their polls
fail, staggered over ~15 min, so offline-detection automations had to watch a
single module's power going unavailable as a fragile proxy.

How: add VantageControllerConnectivityEntity, a per-master binary_sensor with
device_class connectivity (diagnostic), registered via
add_entities_from_controller over vantage.masters. It tracks the aiovantage
event_stream Connected/Reconnected/Disconnected events and defaults to on after
a successful initialize(). It does not poll and never marks itself unavailable,
so it stays available and reports off during an outage, unlike the per-object
entities.

Tested: ruff check, ruff format --check, and pyright (strict) all pass.
Real-hardware outage test on a live controller still pending.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Run the lint/type-check job on Python 3.13 and 3.14 (current Home Assistant
supports 3.14).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 1, 2026 18:27

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a per-controller connectivity binary sensor backed by aiovantage connection events, and extends the lint workflow to run on multiple Python versions.

Changes:

  • New VantageControllerConnectivityEntity exposing controller online/offline state via BinarySensorDeviceClass.CONNECTIVITY.
  • Subscribes to Connected/Reconnected/Disconnected events to update state.
  • Lint workflow now runs against Python 3.13 and 3.14 via a matrix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
custom_components/vantage/binary_sensor.py Adds connectivity binary sensor entity per Vantage Master controller.
.github/workflows/lint.yml Runs pre-commit lint job across Python 3.13 and 3.14.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread custom_components/vantage/binary_sensor.py Outdated
Comment thread .github/workflows/lint.yml
BinarySensorEntity.is_on already returns _attr_is_on, so the override added
nothing. State is held in _attr_is_on (set in the connection event handlers)
and read through the inherited property.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ptr727 ptr727 requested a review from Copilot June 1, 2026 18:33

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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