esphome-docs icon indicating copy to clipboard operation
esphome-docs copied to clipboard

Add factory reset after 5 reboots example to cookbook

Open nagyrobi opened this issue 1 year ago • 6 comments

taken from https://github.com/esphome/esphome/pull/5887#issue-2022819069 thanks @fornellas

Description:

Related issue (if applicable): fixes

Pull request in esphome with YAML changes (if applicable): esphome/esphome#<esphome PR number goes here>

Checklist:

  • [ ] I am merging into next because this is new documentation that has a matching pull-request in esphome as linked above.
    or

  • [ ] I am merging into current because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.

  • [ ] Link added in /index.rst when creating new documents for new components or cookbook.

nagyrobi avatar Dec 05 '23 08:12 nagyrobi

Deploy Preview for esphome ready!

Name Link
Latest commit f5c799e3c6e31b692f9b8e048cf28403bb521506
Latest deploy log https://app.netlify.com/sites/esphome/deploys/668cf68ea4c8ed0008603c2d
Deploy Preview https://deploy-preview-3433--esphome.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Dec 05 '23 08:12 netlify[bot]

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

github-actions[bot] avatar Feb 19 '24 01:02 github-actions[bot]

Ping @jesserockz for review.

fornellas avatar Feb 23 '24 15:02 fornellas

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

esphome[bot] avatar Feb 25 '24 20:02 esphome[bot]

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

github-actions[bot] avatar Apr 30 '24 01:04 github-actions[bot]

Walkthrough

A new section was added to the cookbook/lambda_magic.rst file. It demonstrates how to trigger a factory reset after detecting five quick reboots using lambdas. This feature includes YAML configuration examples and lambda functions to manage the factory reset process based on the reboot count. Additionally, new script, global variable, and button platform declarations were added to support this functionality.

Changes

Files Change Summaries
cookbook/lambda_magic.rst Added section on triggering factory reset after 5 quick reboots
...
script/fast_boot_factory_reset_script Added new script for factory reset handling
globals/fast_boot Added new global variable for counting reboots
button/factory_reset_button Added new button platform for triggering factory reset

Sequence Diagram(s)

sequenceDiagram
    participant Device
    participant LambdaFunction
    participant GlobalVariable
    participant FactoryResetFunction

    Device->>LambdaFunction: On Reboot
    LambdaFunction->>GlobalVariable: Increment fast_boot
    GlobalVariable-->>LambdaFunction: Get fast_boot value
    LambdaFunction->>FactoryResetFunction: If fast_boot >= 5, trigger factory reset
    FactoryResetFunction->>Device: Perform factory reset
    FactoryResetFunction->>GlobalVariable: Reset fast_boot to 0

Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL

Commits

Files that changed from the base of the PR and between 74c578bb8ebf4616de62975f4016381f98ff99a8 and f5c799e3c6e31b692f9b8e048cf28403bb521506.

Files selected for processing (1)
  • cookbook/lambda_magic.rst (1 hunks)
Additional context used
Path-based instructions (1)
cookbook/lambda_magic.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

Additional comments not posted (6)
cookbook/lambda_magic.rst (6)

413-419: Ensure correct YAML indentation and formatting.

The YAML code looks correct but ensure proper indentation and formatting for readability.


423-425: Use substitutions for better maintainability.

Using substitutions improves maintainability and readability of the configuration.


426-430: Ensure global variables are necessary.

The global variable fast_boot is necessary for this example and uses best practices by setting restore_value to yes.


433-456: Correct minor typographical errors and ensure logic clarity.

There are minor typographical errors and potential improvements in the logic clarity.

-                    ESP_LOGD("Fast Boot Factory Reset", "Performing factotry reset");
+                    ESP_LOGD("Fast Boot Factory Reset", "Performing factory reset");

Additionally, ensure the use of fast_boot->loop() and global_preferences->sync() is correct and necessary in this context.


457-462: Ensure Wi-Fi configuration is correct.

The Wi-Fi configuration looks correct, but make sure it aligns with the overall project requirements.


463-469: Ensure button configuration is correct.

The button configuration for factory reset looks correct and follows best practices.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jul 09 '24 08:07 coderabbitai[bot]