Skip to content

Refactor LED toggle functionality in network.py to use DeviceSetLedStatus with fallback - #82

Merged
sirkirby merged 1 commit into
devfrom
led-switch-compatibility
Jul 15, 2025
Merged

Refactor LED toggle functionality in network.py to use DeviceSetLedStatus with fallback#82
sirkirby merged 1 commit into
devfrom
led-switch-compatibility

Conversation

@sirkirby

Copy link
Copy Markdown
Owner

This pull request refines the set_device_led method in custom_components/unifi_network_rules/udm/network.py to improve its robustness and flexibility. It introduces a two-step approach for toggling the LED status of a device, prioritizing a new method (DeviceSetLedStatus) with a fallback to the original minimal payload approach.

fixes #80

Enhancements to LED toggle functionality:

  • Primary Approach: Added support for toggling LED status using DeviceSetLedStatus from aiounifi. This method provides a more structured and modern way to interact with the UniFi API.
  • Fallback Approach: Retained the original minimal payload method as a fallback, ensuring compatibility with older UniFi Network versions. This approach uses the legacy API endpoint for device updates.

Logging improvements:

  • Enhanced logging to provide detailed debug information for both the primary and fallback methods, including success and failure cases. This aids in troubleshooting and monitoring.

Error handling improvements:

  • Improved exception handling for both approaches, ensuring that failures are logged clearly and the method gracefully handles errors without crashing.

…ity with older UniFi Network versions. Implemented a dual approach using DeviceSetLedStatus with a fallback to a minimal payload, enhancing error handling and logging for better debugging.
@sirkirby sirkirby self-assigned this Jul 15, 2025
@sirkirby
sirkirby merged commit 5a2c9d4 into dev Jul 15, 2025
9 checks passed
@sirkirby
sirkirby deleted the led-switch-compatibility branch July 15, 2025 17:38
sirkirby added a commit that referenced this pull request Jul 28, 2025
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.

1 participant