Doorbell button Date/Time may not change after reboot HA

I have made a doorbell in HA with 10 sound banks which can be triggered on different dates via my agenda. The sounds in these sound banks played randomly. Everything works fine.

On my dashboard the doorbell button is visible so I can see when someone has pressed the button.

To get this button on my dashboard I made a sensor in the configuration.yaml file.

# Deurbel Drukknop tijd datum
sensor belknoptijddatum:
  - platform: template
        friendly_name: "Deurbel tijd datum"
        value_template: "{{as_timestamp(states.binary_sensor.lumi_lumi_sensor_magnet_aq2_7d73e707_on_off.last_changed) |timestamp_custom ('%d %B %X')}}"

The only thing I have to solve is that the date and time may not be updated when I reboot HA.
Is there any possibility that I can make the date/time independent of a reboot?

One option would be to add a trigger to your existing sensor, which will solve the false values, but your dashboard card will show “unavailable” after restart until someone presses the button.

Instead of using a template sensor, use an entity that doesn’t reset on restart. Use an automation to save the timestamp to a helper.

Thanks for the tip. I will give it a try. :blush: