Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zigbee): Save network channel after 1st joining for faster rejoin #11123

Merged

Conversation

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

Description of Change

This PR improves Zigbee rejoining process, as the network channel is saved to zb NVRAM, so after device reset the scanning will occur only on the saved channel saving time and energy.

Tests scenarios

Tested using sleepy example and HA. (did not test the actual power consumption, but the reconnection is a lot faster)

Related links

Closes #10746

@P-R-O-C-H-Y P-R-O-C-H-Y added Status: Review needed Issue or PR is awaiting review Area: Zigbee Issues and Feature Request about Zigbee labels Mar 14, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Mar 14, 2025
Copy link
Contributor

github-actions bot commented Mar 14, 2025

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "feaz(zigbee): Move function to private and add set method":
    • type/action should be one of [change, ci, docs, feat, fix, refactor, remove, revert, test]

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 10 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

👋 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.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- 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 677a984

Copy link
Contributor

github-actions bot commented Mar 14, 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
ESP32S30⚠️ +2200.00⚠️ +0.03000.000.00
ESP32S20⚠️ +2240.00⚠️ +0.03000.000.00
ESP32C30⚠️ +1800.00⚠️ +0.03000.000.00
ESP32C60⚠️ +2040.00⚠️ +0.040⚠️ +160.00⚠️ +0.06
ESP32H20⚠️ +2020.00⚠️ +0.040⚠️ +160.00⚠️ +0.06
ESP320⚠️ +2240.00⚠️ +0.03000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
Zigbee/examples/Zigbee_Color_Dimmer_Switch⚠️ +1960⚠️ +2040⚠️ +1800⚠️ +178⚠️ +16⚠️ +1820⚠️ +2200
Zigbee/examples/Zigbee_Gateway⚠️ +2160⚠️ +2240⚠️ +1780----⚠️ +2240
Zigbee/examples/Zigbee_On_Off_Switch⚠️ +2160⚠️ +2120⚠️ +1780⚠️ +1780⚠️ +1800⚠️ +2120
Zigbee/examples/Zigbee_Range_Extender⚠️ +1960⚠️ +2000⚠️ +1760⚠️ +174⚠️ +16⚠️ +1760⚠️ +2120
Zigbee/examples/Zigbee_Thermostat⚠️ +2200⚠️ +2120⚠️ +1760⚠️ +178⚠️ +16⚠️ +1800⚠️ +2080
Zigbee/examples/Zigbee_Analog_Input_Output------⚠️ +1960⚠️ +198⚠️ +16--
Zigbee/examples/Zigbee_CarbonDioxide_Sensor------⚠️ +198⚠️ +16⚠️ +2000--
Zigbee/examples/Zigbee_Color_Dimmable_Light------⚠️ +202⚠️ +16⚠️ +2020--
Zigbee/examples/Zigbee_Contact_Switch------⚠️ +1980⚠️ +1960--
Zigbee/examples/Zigbee_Dimmable_Light------⚠️ +2000⚠️ +1980--
Zigbee/examples/Zigbee_OTA_Client------⚠️ +2020⚠️ +1980--
Zigbee/examples/Zigbee_Occupancy_Sensor------⚠️ +200⚠️ +16⚠️ +1960--
Zigbee/examples/Zigbee_On_Off_Light------⚠️ +1980⚠️ +1980--
Zigbee/examples/Zigbee_Pressure_Flow_Sensor------⚠️ +1960⚠️ +2020--
Zigbee/examples/Zigbee_Scan_Networks------⚠️ +1960⚠️ +1960--
Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy------⚠️ +204⚠️ +16⚠️ +1940--
Zigbee/examples/Zigbee_Temperature_Sensor------⚠️ +1980⚠️ +198⚠️ +16--
Zigbee/examples/Zigbee_Vibration_Sensor------⚠️ +2000⚠️ +1960--
Zigbee/examples/Zigbee_Wind_Speed_Sensor------⚠️ +198⚠️ +16⚠️ +2000--
Zigbee/examples/Zigbee_Window_Covering------⚠️ +2040⚠️ +2000--

Copy link
Contributor

github-actions bot commented Mar 14, 2025

Test Results

 76 files   76 suites   13m 48s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit 677a984.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@lucasssvaz lucasssvaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@P-R-O-C-H-Y P-R-O-C-H-Y added Status: In Progress ⚠️ Issue is in progress and removed Status: Review needed Issue or PR is awaiting review labels Mar 14, 2025
Copy link
Collaborator

@SuGlider SuGlider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SuGlider SuGlider added Status: Pending Merge Pull Request is ready to be merged and removed Status: In Progress ⚠️ Issue is in progress labels Mar 14, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: In Progress ⚠️ Issue is in progress and removed Status: Pending Merge Pull Request is ready to be merged labels Mar 14, 2025
@P-R-O-C-H-Y
Copy link
Member Author

Still in progress. Please don't change the labels :) Need a small update

@SuGlider
Copy link
Collaborator

Still in progress. Please don't change the labels :) Need a small update

Sorry. I've read "review pending, instead..."

@P-R-O-C-H-Y P-R-O-C-H-Y force-pushed the feat/zigbee-rejoin-scan-enhancement branch from 225ad7e to 1ff918b Compare March 18, 2025 10:18
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: Review needed Issue or PR is awaiting review and removed Status: In Progress ⚠️ Issue is in progress labels Mar 18, 2025
@SuGlider SuGlider self-requested a review March 18, 2025 18:07
Copy link
Collaborator

@SuGlider SuGlider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@P-R-O-C-H-Y P-R-O-C-H-Y removed the Status: Review needed Issue or PR is awaiting review label Mar 18, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y added the Status: Pending Merge Pull Request is ready to be merged label Mar 18, 2025
@P-R-O-C-H-Y
Copy link
Member Author

Marking as Pending merge, tested also by community.

@me-no-dev me-no-dev merged commit e2915c4 into espressif:master Mar 19, 2025
56 checks passed
@def1149
Copy link

def1149 commented Mar 20, 2025

@P-R-O-C-H-Y

After more testing .... this change has problems.

Using the updated sleepy temperature example:

  1. If remove the EP in ZHA Home it will automatically re-adds, without me activating Add Device, the next time it tries to connect.
    This occurs even if Zigbee.factoryReset() is called.

  2. I can't add the EP to a different controller after it has been added to a different controller then removed

It appears that the information about the first controller is saved in NVM and not cleared by a Zigbee.factoryReset() so it reconnects to the first controller unless I reflash the device and erase nvm

As an aside, to cause Zigbee.factoryReset() in the sleepy temperature example the BOOT button must be held for 60+ seconds to be down the next time the EP wakes from sleep. I added a wake on external I/O to force an immediate wakeup. The BOOT button I/O is not an available external wake-up pin so I jumped IO9 to IO2 so IO2 goes low when the BOOT button is pressed and wakes up the ESP32 It's a hack but it works 😁

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

P-R-O-C-H-Y commented Mar 21, 2025

@def1149 To have the answer also here, I am able to reproduce this behavior also with other manufacturer devices.
It looks like ZHA is not closing the network when you leave the "add device" screen and keeping it open for some more time.

about the factoryReset() in sleepy sensor, I have also a reset button on my ESP devkit, so I just hold the BOOT button and click the RESET button to wake up the esp.

@def1149
Copy link

def1149 commented Mar 21, 2025

@P-R-O-C-H-Y I'm going to remove a device that's been running overnight

Of course you're right about restarting and holding the boot button and pressing the reset to force a factoryReset()

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.

Zigbee: Improve the sleep sketch with regard to energy requirements
5 participants