Skip to content

Conversation

P-R-O-C-H-Y
Copy link
Member

@P-R-O-C-H-Y P-R-O-C-H-Y commented Oct 7, 2025

Description of Change

This pull request introduces significant improvements to the Zigbee switch and color dimmer switch functionality, focusing on enhanced state polling, attribute readback, and callback handling for light state, level, and color changes. The changes improve how the switch tracks and reports the state of bound lights, and add flexible mechanisms for polling and responding to changes in light attributes.

Enhanced Zigbee Switch State Polling and Reporting:

  • Added a periodic task (periodicTask) in Zigbee_On_Off_Switch.ino to poll the light state every second and print bound devices every 10 seconds, improving real-time tracking of connected lights. [1] [2]
  • Introduced the onLightStateChange callback and light_state tracking to log state changes and ensure the application responds only to actual changes. [1] [2]

Expanded ZigbeeColorDimmerSwitch Attribute Handling and Callbacks:

  • Implemented multiple getLightState, getLightLevel, and getLightColor methods to support polling light state, level, and color for various addressing modes (group, endpoint, IEEE address), enabling more flexible device management. [1] [2]
  • Added callback setters (onLightStateChange, onLightLevelChange, onLightColorChange, etc.) to allow users to register handlers for state, level, and color changes, both with and without source information. [1] [2]
  • Enhanced the attribute readback logic in zbAttributeRead, including robust parsing and callback invocation for ON/OFF, level, and color attributes, with proper handling of XY and HS color updates and conversion to RGB.

These changes collectively make the Zigbee switch and color dimmer switch more responsive, extensible, and easier to integrate into applications requiring real-time light state monitoring and control.

Test Scenarios

Tested with Updated On/Off switch + Light example and Customized ColorDimmableSwitch + ColorDimmableLight examples.

Related links

Closes #11886

@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Oct 7, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y added the Area: Zigbee Issues and Feature Request about Zigbee label Oct 7, 2025
Copy link
Contributor

github-actions bot commented Oct 7, 2025

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello P-R-O-C-H-Y, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 1366fbf

Copy link
Contributor

github-actions bot commented Oct 7, 2025

Test Results

 76 files   76 suites   14m 19s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit 1366fbf.

♻️ This comment has been updated with latest results.

@P-R-O-C-H-Y P-R-O-C-H-Y force-pushed the feat/zigbee-switch-enhancement branch from 400c8e6 to 76b5a00 Compare October 8, 2025 07:52
Copy link
Contributor

github-actions bot commented Oct 8, 2025

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32C50‼️ +2K0.00⚠️ +0.270⚠️ +560.00⚠️ +0.15
ESP32S30‼️ +2K0.00⚠️ +0.330⚠️ +400.00⚠️ +0.11
ESP32S20‼️ +2K0.00⚠️ +0.370⚠️ +400.00⚠️ +0.13
ESP32C30‼️ +2K0.00⚠️ +0.300⚠️ +400.00⚠️ +0.14
ESP32C60‼️ +2K0.00⚠️ +0.290⚠️ +560.00⚠️ +0.17
ESP32H20‼️ +2K0.00⚠️ +0.290⚠️ +560.00⚠️ +0.18
ESP320‼️ +2K0.00⚠️ +0.330⚠️ +480.00⚠️ +0.13
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32C5ESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/Zigbee/examples/Zigbee_Analog_Input_Output00⚠️ +6160⚠️ +6160000000⚠️ +6160
libraries/Zigbee/examples/Zigbee_Binary_Input_Output00------0000--
libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light00------0000--
libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch‼️ +2K⚠️ +56‼️ +2K⚠️ +40‼️ +2K⚠️ +40‼️ +2K⚠️ +40‼️ +2K⚠️ +56‼️ +2K⚠️ +56‼️ +2K⚠️ +48
libraries/Zigbee/examples/Zigbee_Contact_Switch00------0000--
libraries/Zigbee/examples/Zigbee_Dimmable_Light00------0000--
libraries/Zigbee/examples/Zigbee_Electrical_AC_Sensor00⚠️ +6160⚠️ +6160000000⚠️ +6160
libraries/Zigbee/examples/Zigbee_Electrical_AC_Sensor_MultiPhase00⚠️ +6160⚠️ +6160000000⚠️ +6160
libraries/Zigbee/examples/Zigbee_Electrical_DC_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_Fan_Control00⚠️ +6160⚠️ +6160000000⚠️ +6160
libraries/Zigbee/examples/Zigbee_Gateway00⚠️ +6160⚠️ +616000----⚠️ +6160
libraries/Zigbee/examples/Zigbee_Illuminance_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_Multistate_Input_Output00⚠️ +6160⚠️ +6160000000⚠️ +6160
libraries/Zigbee/examples/Zigbee_OTA_Client⚠️ +180------⚠️ +180⚠️ +180--
libraries/Zigbee/examples/Zigbee_Occupancy_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_On_Off_Light00------0000--
libraries/Zigbee/examples/Zigbee_On_Off_MultiSwitch⚠️ +196⚠️ +16⚠️ +7160⚠️ +7200⚠️ +1960⚠️ +198⚠️ +16⚠️ +196⚠️ +16⚠️ +7320
libraries/Zigbee/examples/Zigbee_On_Off_Switch⚠️ +598⚠️ +24⚠️ +1044⚠️ +16⚠️ +1024⚠️ +16⚠️ +594⚠️ +24⚠️ +5880⚠️ +594⚠️ +24⚠️ +1064⚠️ +16
libraries/Zigbee/examples/Zigbee_PM25_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_Power_Outlet00⚠️ +6160⚠️ +6160000000⚠️ +6160
libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_Range_Extender00⚠️ +6160⚠️ +6160000000⚠️ +6160
libraries/Zigbee/examples/Zigbee_Scan_Networks00------0000--
libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy00------0000--
libraries/Zigbee/examples/Zigbee_Temperature_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_Thermostat00⚠️ +6160⚠️ +6160000000⚠️ +6200
libraries/Zigbee/examples/Zigbee_Vibration_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor00------0000--
libraries/Zigbee/examples/Zigbee_Window_Covering00------0000--

@P-R-O-C-H-Y P-R-O-C-H-Y added the Status: Review needed Issue or PR is awaiting review label Oct 8, 2025
@me-no-dev me-no-dev added Status: Pending Merge Pull Request is ready to be merged and removed Status: Review needed Issue or PR is awaiting review labels Oct 8, 2025
@me-no-dev me-no-dev merged commit 493c528 into master Oct 8, 2025
53 checks passed
@me-no-dev me-no-dev deleted the feat/zigbee-switch-enhancement branch October 8, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Zigbee Issues and Feature Request about Zigbee Status: Pending Merge Pull Request is ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to get the state of a ZIGBEE EP i.e. a lamp
2 participants