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

Restore light state on boot #61

Merged
merged 3 commits into from
Dec 23, 2024
Merged

Restore light state on boot #61

merged 3 commits into from
Dec 23, 2024

Conversation

edwardtfn
Copy link
Owner

@edwardtfn edwardtfn commented Dec 23, 2024

Trying to solve #47

Summary by CodeRabbit

  • New Features
    • Introduced new restore_mode options for light entities, ensuring they default to an off state upon system restart.
    • Added a RELAY_RESTORE_MODE for relay entities, enhancing their initialization behavior.
    • Standardized power state behavior for individual LEDs and relay lights on startup.

Copy link
Contributor

coderabbitai bot commented Dec 23, 2024

Walkthrough

The pull request introduces new configuration options for light and relay entities in two ESPHome configuration files. Specifically, it adds restore_mode settings with a default value of RESTORE_DEFAULT_OFF for various light entities and relays, ensuring they default to an off state upon system restart or reset. This change standardizes the initialization behavior across both files, preventing inadvertent activation of lights and relays during system startup.

Changes

File Changes
ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml - Added LIGHT_FULL_RESTORE_MODE, LIGHT_SIDES_RESTORE_MODE, LIGHT_INDIVIDUAL_RESTORE_MODE, LIGHT_RELAYS_RESTORE_MODE
- Updated restore_mode for light entities: light_full, light_eu, light_00, light_eu_rl_1_1_bottom
- Incorporated restore_mode into templates: light_partition_individual_led, light_partition_relays
ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml - Added RELAY_RESTORE_MODE: RESTORE_DEFAULT_OFF
- Updated restore_mode for entities: light_output_1, sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4 to reference RELAY_RESTORE_MODE

Possibly related PRs


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 248f7e9 and 6230e31.

📒 Files selected for processing (1)
  • ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@edwardtfn edwardtfn linked an issue Dec 23, 2024 that may be closed by this pull request
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml (1)

47-47: Well-structured implementation of boot state restoration.

The implementation follows a systematic approach by:

  1. Applying the restore mode to the main light strip
  2. Cascading it through model-specific partitions
  3. Ensuring individual LEDs and relay indicators maintain the same behavior
  4. Maintaining consistency between EU and US models

This comprehensive implementation ensures predictable behavior across all light components on boot.

Also applies to: 56-56, 189-190, 424-424

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 226d5db and 6343e6e.

📒 Files selected for processing (2)
  • ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml (4 hunks)
  • ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml (1 hunks)
🔇 Additional comments (4)
ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml (2)

32-32: LGTM: Consistent state restoration behavior for light outputs.

The addition of restore_mode: RESTORE_DEFAULT_OFF ensures the light output defaults to off state on boot, which aligns with the PR objective.


Line range hint 424-424: LGTM: Consistent implementation across all relay lights.

The restore_mode: RESTORE_DEFAULT_OFF configuration is correctly applied to the relay light template, ensuring all relay lights consistently default to off state on boot.

ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml (2)

47-47: LGTM: Proper state restoration for main light control.

The addition of restore_mode: RESTORE_DEFAULT_OFF to light_full ensures the main NeoPixelBus light strip defaults to off state on boot.


56-56: LGTM: Consistent state restoration across all light partitions.

The restore_mode: RESTORE_DEFAULT_OFF configuration is correctly applied to both model-specific lights and individual LED templates, ensuring consistent behavior across all light segments.

Also applies to: 189-190

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml (1)

28-31: Well-structured implementation of light state restoration.

The implementation provides a comprehensive solution for managing light states on boot:

  1. Separate restore mode configurations for different light categories
  2. Safe default-off behavior prevents unexpected light activation
  3. Consistent application across both EU and US models
  4. Integration with the existing boot initialization process

The architecture allows for future customization of restore behavior per light category if needed.

Also applies to: 52-52, 61-61, 194-194, 428-428

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6343e6e and 248f7e9.

📒 Files selected for processing (2)
  • ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml (5 hunks)
  • ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml
🔇 Additional comments (4)
ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml (4)

28-31: LGTM! Well-structured restore mode configuration.

The separation into distinct restore mode variables for different light categories (full, sides, individual, relays) with RESTORE_DEFAULT_OFF provides a safe default state on boot while maintaining flexibility for future customization.


52-52: LGTM! Appropriate restore mode for the main light controller.

Setting RESTORE_DEFAULT_OFF for the primary NeoPixelBus controller ensures a predictable and safe initial state for all LEDs on boot.


61-61: LGTM! Consistent restore mode for model-specific light partitions.

The LIGHT_SIDES_RESTORE_MODE is appropriately applied to the partition template used by both EU and US models, maintaining consistency in boot behavior.


428-428: LGTM! Appropriate restore mode for relay indicator lights.

The LIGHT_RELAYS_RESTORE_MODE is correctly applied to the relay lights template, ensuring consistent boot behavior for all relay status indicators.

ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml Outdated Show resolved Hide resolved
As suggested by CodeRabbitAI
@edwardtfn edwardtfn merged commit 085250c into main Dec 23, 2024
14 checks passed
@edwardtfn edwardtfn deleted the light-restore-state-on-boot branch December 23, 2024 17:39
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.

The LEDs reset back to white on boot if you power cycle it.
1 participant