Expose UniFi Policy Engine rules as switches#169675
Draft
ryanr14 wants to merge 2 commits intohome-assistant:devfrom
Draft
Expose UniFi Policy Engine rules as switches#169675ryanr14 wants to merge 2 commits intohome-assistant:devfrom
ryanr14 wants to merge 2 commits intohome-assistant:devfrom
Conversation
Contributor
|
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 UniFi Policy Engine (object-oriented network config) rules as controllable switch entities in the UniFi integration, enabling Home Assistant to toggle “simple rules” (e.g., “turn off internet”) that are not represented by the existing firewall-policy switch support.
Changes:
- Add a new switch entity description backed by
api.object_oriented_network_configsto expose Policy Engine rules as switches. - Add polling coordination for
object_oriented_network_configsto keep state updated after toggles. - Bump
aiounifidependency to==91and add/extend tests and fixtures for the new endpoint.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/unifi/switch.py |
Introduces a new switch description and control function for Policy Engine rules via object_oriented_network_configs. |
homeassistant/components/unifi/hub/entity_loader.py |
Adds a polling UnifiDataUpdateCoordinator for object-oriented network configs to refresh state. |
homeassistant/components/unifi/manifest.json |
Updates integration requirement to aiounifi==91. |
requirements_all.txt |
Updates global dependency pin to aiounifi==91. |
requirements_test_all.txt |
Updates test dependency pin to aiounifi==91. |
tests/components/unifi/conftest.py |
Adds fixture payload + GET mocking for /object-oriented-network-configs. |
tests/components/unifi/test_switch.py |
Adds coverage for listing/toggling Policy Engine rule switches and expected API calls. |
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.
Proposed change
Expose supported UniFi Policy Engine / Object-Oriented Network rules as switch entities.
The UniFi Network application creates simple Policy Engine rules, such as "turn off internet" rules, as object-oriented network configs at
/object-oriented-network-configs. Those configs then generate predefined firewall policy rows, but the predefined firewall policy rows are not controllable directly and are filtered out by the existing firewall-policy switch support.This adds a new switch description backed by
api.object_oriented_network_configsso Home Assistant can list and toggle the underlying Policy Engine rule itself. The switch description is intentionally constrained to secure internet rules withmode: TURN_OFF_INTERNETso route/QoS-style object-oriented configs are not duplicated with the existing traffic route support.Depends on
aiounifi==91from:Type of change
Additional information
Related background:
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..coveragerc.To help with the load of incoming pull requests: