Feat/port profile switch entities - #100
Merged
Merged
Conversation
…d filtering - Updated the UnifiRuleUpdateCoordinator to derive VPN clients and servers from existing network data, improving efficiency and accuracy. - Introduced a new helper function to filter out VPN networks, ensuring only suitable networks are exposed as switch entities. - Added methods for updating and toggling network configurations in the API, enhancing network management capabilities. - Improved error handling and logging for network operations.
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for managing UniFi networks and port profiles as switch entities in Home Assistant, expanding the integration beyond just traditional firewall rules. The key enhancement is the ability to toggle network and port profile states directly from the Home Assistant UI.
- Added NetworkConf and PortProfile typed models with computed enabled states
- Extended the coordinator to fetch and manage networks and port profiles alongside existing entities
- Created new switch entity classes for networks and port profiles with proper toggle functionality
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
udm/profiles.py |
Added toggle_port_profile method to enable/disable port profiles by managing native network assignment |
udm/network.py |
Added network management methods including get_networks, update_network, and toggle_network |
switch.py |
Added UnifiPortProfileSwitch and UnifiNetworkSwitch entity classes with toggle logic and state attributes |
models/port_profile.py |
New typed model for port profiles with computed enabled state based on native network configuration |
models/network.py |
New typed model for network configurations with purpose and enabled state accessors |
helpers/rule.py |
Extended helper functions to support NetworkConf and PortProfile types, added VPN network filtering |
coordinator.py |
Added port profile and network data management, improved VPN derivation from network data |
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.
New feature adding switch support for all networks, including WAN, LAN, and new UniFi WAN magic, along with Port Profile switches. Based on the requested features #87 and #99
This pull request adds support for managing UniFi network and port profile entities within the coordinator, improves VPN client/server derivation by using network data, and enhances helper functions to better handle these new types. The changes increase feature coverage and robustness for entity management and naming.
Entity management and feature expansion:
port_profilesandnetworksin the coordinator, including new async update methods (_update_port_profiles_in_dict,_update_networks_in_dict) and updates to the coordinator's state and refresh logic. [1] [2] [3] [4] [5] [6] [7]Helper and utility enhancements:
helpers/rule.pyto handleNetworkConfandPortProfiletypes for enabled state, ID generation, descriptive naming, and rule type prefixing. Also added logic to filter out VPN networks for switch entities. [1] [2] [3] [4] [5] [6] [7]Code robustness and cleanup:
These changes collectively improve the coordinator's ability to track and manage new types of UniFi entities, provide better naming and identification, and ensure robust operation during API or conversion errors.