I want to create a card that shows me the last time my door sensor changed its state.
Everything I tried so far gave me only the state of the contact sensor (Closed \ Open).
I want to see the hour when it’s closed or opened, like in HA Demo:
Changing the XXX part to marry your entity
states.binary_sensor.XXX_XXX_XXX.last_changed
However note that this method (and I dont know of any other, but there might be) will show the last changed OR the last time HA was started so wont always be an accurate representation.
To use this on the frontend you could either use the above template in a card that supports templates like markdown card for example or you could create a template sensor in your yaml files something like this maybe:
template:
- sensor:
- name: front door last changed time
state: >-
{{ as_timestamp(states.binary_sensor.front_door_last_ding.last_changed) |
timestamp_custom ('%H:%M' ) }}