How to retain HA value after power failure

Some how I need to ensure the cat_feeder works when HA is out and do not come back from a power failure.

I have a setup where I pass the start_time to Esphome, but its not persistant.

  - platform: homeassistant
    id: start_time_hour
    entity_id: input_datetime.cat_feeder
    attribute: hour
  
  - platform: homeassistant
    id: start_time_minute
    entity_id: input_datetime.cat_feeder
    attribute: minute

Could you just move those inputs into an ESPHOME template number or similar?

but how can I program so when there is no connection with HA and the esp restart the old HA value persist on the esp?

If you use an ESPHOME number template the number lives on the ESP, not HA. It is sent to HA. It can be restored across esp reboots. This number will also appear in the HA frontend and you can set it from there.

Maybe have a quick test and see if it’s what you need.

You might also want to add a RTC to your esp so it doesn’t depend on HA or other remote time sources :alarm_clock:

https://esphome.io/components/time/ds1307.html

https://beta.esphome.io/components/time/pcf85063.html

1 Like