home-assistant-glow icon indicating copy to clipboard operation
home-assistant-glow copied to clipboard

Persistent values after reboot for sensor_total_energy and sensor_total_daily_energy

Open ojwc opened this issue 7 months ago • 5 comments

Changes to pulse_meter, sensor_total_energy, and sensor_total_daily_energy to restore their previous values after a reboot

Also adds on_boot flag to esphome which calls pulse_meter.set_total_pulses to manually restore the value as pulse_meter total doesn't have a restore 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

    • Added configuration for resetting pulse meter total pulses on boot.
    • Introduced settings for flash write interval to optimize web server performance.
    • Added a global variable to persist total energy readings across reboots.
  • Improvements

    • Enhanced sensor reading filters for more accurate pulse rate calculations.
    • Implemented a restore property for the sensor to maintain state across reboots.

ojwc avatar Jul 06 '24 09:07 ojwc