Add WAN status sensors to UniFi integration#166918
Open
cln-io wants to merge 1 commit intohome-assistant:devfrom
Open
Add WAN status sensors to UniFi integration#166918cln-io wants to merge 1 commit intohome-assistant:devfrom
cln-io wants to merge 1 commit intohome-assistant:devfrom
Conversation
Bump aiounifi from 88 to 90, which exposes WAN TypedDicts, device properties needed for WAN sensor data, and SSO 2FA support. Add per-interface WAN Status enum sensors (online/offline) for up to 6 WAN interfaces, disabled by default. Non-existent WANs are filtered out per-device via supported_fn.
|
Hey there @Kane610, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new diagnostic WAN status enum sensors to the UniFi integration (for gateway devices), enabled via an aiounifi dependency bump that exposes the required WAN fields.
Changes:
- Bump
aiounififrom 88 → 90 across integration manifest and pinned requirements. - Add factory-generated WAN status (
online/offline) enum sensors for WAN1–WAN6, disabled by default and filtered per-device. - Add
wan_statusenum state translations and a new unit test covering online→offline transitions.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/unifi/sensor.py |
Adds supported/value helpers plus a factory to create up to 6 WAN status enum sensors and registers them with existing entity descriptions. |
homeassistant/components/unifi/strings.json |
Adds translations for wan_status enum states (online/offline). |
homeassistant/components/unifi/manifest.json |
Pins UniFi integration dependency to aiounifi==90. |
requirements_all.txt |
Updates global pinned aiounifi version to 90. |
requirements_test_all.txt |
Updates test pinned aiounifi version to 90. |
tests/components/unifi/test_sensor.py |
Adds a WAN-status sensor test using a gateway device payload and websocket updates. |
|
|
||
| # WAN3-6 sensors should not exist (no data) | ||
| assert entity_registry.async_get("sensor.gateway_wan3_status") is None | ||
| assert entity_registry.async_get("sensor.gateway_wan4_status") is None |
There was a problem hiding this comment.
Align the test with the comment by either asserting WAN5/WAN6 are also absent or updating the comment to match the actual assertions.
Suggested change
| assert entity_registry.async_get("sensor.gateway_wan4_status") is None | |
| assert entity_registry.async_get("sensor.gateway_wan4_status") is None | |
| assert entity_registry.async_get("sensor.gateway_wan5_status") is None | |
| assert entity_registry.async_get("sensor.gateway_wan6_status") is None |
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.
Bump aiounifi from 88 to 90, which exposes WAN TypedDicts, device properties needed for WAN sensor data, and SSO 2FA support.
Add per-interface WAN Status enum sensors (online/offline) for up to 6 WAN interfaces, disabled by default. Non-existent WANs are filtered out per-device via supported_fn.
Breaking change
N/A — this PR only adds new sensors, no existing functionality is changed.
Proposed change
Add WAN Status enum sensors to the UniFi integration for gateway devices (UDM, UCG, EFG, etc.).
For each WAN interface (up to 6, matching the UXG Fiber's max port count):
All sensors are disabled by default and classified as
EntityCategory.DIAGNOSTIC. Thesupported_fncheck ensures sensors only appear for WANs that actually exist on each device.This is PR 1 of 5, split from #164818 per reviewer request. The full series:
Dependency
Bumps
aiounififrom 88 to 90, which includes:wan1–wan6,last_wan_status,last_wan_ip)Changes
sensor.py:async_device_wan_status_supported_fn— checks specific WAN interface presence indevice.rawasync_device_wan_status_value_fn— reads fromdevice.last_wan_statusmake_wan_status_sensors()factory generating status sensors for WAN1–WAN6strings.json:wan_statustranslation key withonline/offlinestatesmanifest.json/requirements_all.txt/requirements_test_all.txt:aiounifi88 → 90Testing
Verified against a live UCG Ultra (UDRULT) with dual-WAN:
onlinefor both WANsofflinewhen a WAN is disconnectedType of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: