Simplying LED api integration and state managmenet - #86
Merged
Conversation
… integration and state mangement - Updated the device state change detection method in `coordinator.py` to specifically monitor LED state changes for managed devices. - Improved logging to clarify the nature of state changes being detected and dispatched. - Refactored the immediate trigger firing in `switch.py` to utilize full device objects for consistency with rule triggers. - Adjusted the API call in `network.py` to return properly typed Device objects for LED-capable devices, enhancing integration reliability. - Updated trigger descriptions in `trigger.py` to reflect the focus on LED state changes.
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors the UniFi Network Rules integration to focus exclusively on LED state management for access points, removing connection state monitoring and improving data handling consistency. The changes streamline the codebase by using typed Device objects throughout and enhance trigger mechanisms for LED state changes.
Key changes include:
- Refactored device state monitoring to focus only on LED state changes, removing connection state handling
- Enhanced data handling by returning typed Device objects instead of raw dictionaries from the API
- Improved trigger mechanisms with optimistic state updates and better logging for LED operations
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| coordinator.py | Refactored device state monitoring to focus on LED changes only, improved logging and trigger handling |
| udm/network.py | Changed get_device_led_states to return typed Device objects instead of dictionaries |
| switch.py | Enhanced LED toggle function with optimistic state updates for immediate triggers |
| trigger.py | Updated trigger descriptions to clarify LED-focused scope |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
This pull request refines the UniFi Network Rules integration to focus exclusively on managing LED-capable devices, improving clarity, consistency, and functionality. Key changes include narrowing the scope of device state monitoring to LED-specific states, enhancing data handling by using typed
Deviceobjects, and improving logging and trigger mechanisms for LED state changes.Refactoring for LED State Monitoring:
_check_for_device_state_changesto monitor only LED state changes, removing connection state handling. Added device lookups for fullDeviceobjects to ensure consistent trigger payloads. [1] [2] [3] [4]_async_update_datato reflect the narrowed scope by renaming checks to "LED State Changes."Enhanced Data Handling:
Deviceobjects inget_device_led_states, simplifying device creation and ensuring consistency with other components. [1] [2]_update_devices_in_dictby directly usingDeviceobjects from the API, removing redundant manual object creation.Improved Trigger Mechanisms:
trigger.py. [1] [2]_async_toggle_ruleto include optimistic state updates for immediate triggers, ensuring consistency with rule-based triggers.Logging and Documentation: