-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
Persistent values after reboot for sensor_total_energy and sensor_total_daily_energy #527
base: develop
Are you sure you want to change the base?
Conversation
create global variable persist_sensor_total_energy, supports making sensor_total_energy persistent after reboot
restricts flash write intervals to 5 minutes, ensures no unnecessary wear on flash memory
change pulse_meter_on_raw_value filter so it writes sensor_total_energy to global persist_sensor_total_energy
adding on_boot flag to restore sensor_total_energy from flash after a reboot.
adding restore: True to sensor_total_daily_energy so previous value is restored from flash after boot
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughWalkthroughThe recent updates enhance the configuration of the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
PS: apologies for the excessive number of commits, I haven't done this before. |
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- components/pulse_meter.yaml (2 hunks)
- home-assistant-glow/esp32.yaml (2 hunks)
Additional context used
yamllint
home-assistant-glow/esp32.yaml
[error] 28-28: trailing spaces
(trailing-spaces)
[error] 30-30: trailing spaces
(trailing-spaces)
Additional comments not posted (4)
home-assistant-glow/esp32.yaml (2)
68-72
: LGTM!Setting
flash_write_interval
to 5 minutes to reduce flash wear is a good practice.
73-76
: LGTM!Adding a global variable
persist_sensor_total_energy
withrestore_value
set to true is appropriate for persisting the sensor value across reboots.components/pulse_meter.yaml (2)
64-68
: LGTM!The lambda function appropriately updates the value of
persist_sensor_total_energy
and computes the pulse rate.
94-97
: LGTM!Setting the
restore
property to true for thesensor_total_daily_energy
is appropriate for enabling state restoration across reboots.
good bot Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- home-assistant-glow/esp32.yaml (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- home-assistant-glow/esp32.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we adjust things in pulse_meter, adjustments are also needed in the ESP8266 code, otherwise it will break.
fixed formatting + added explanatory comment
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- components/pulse_meter.yaml (2 hunks)
Additional context used
yamllint
components/pulse_meter.yaml
[error] 68-68: syntax error: expected , but found ''
(syntax)
Additional comments not posted (1)
components/pulse_meter.yaml (1)
93-93
: The addition of therestore
property is approved.Adding
restore: True
ensures the sensor's state is retained across reboots, enhancing reliability.
I don't have any ESP8266 devices available for testing - are you able to make the necessary adjustments? |
formatting :( Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- components/pulse_meter.yaml (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- components/pulse_meter.yaml
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. |
Changes to
pulse_meter
,sensor_total_energy
, andsensor_total_daily_energy
to restore their previous values after a rebootAlso adds
on_boot
flag toesphome
which callspulse_meter.set_total_pulses
to manually restore the value aspulse_meter
total
doesn't have arestore
flag.Finally, added
preferences
to restrict flash writes to once every 5 minutes, to reduce wear on flash memory.Tested on ESP32 nodemcu-32s only.
Summary by CodeRabbit
New Features
Improvements