Hii,
Can someone help me to configure a sensor that will give me the last time that door was open?
I have a binary sensor that connect to the raspberry and i want to add sensor for the last time the door was open,
I have tried to add sensor with “last_change” but it is giving me a wrong time (he is taking every change, even unknown status)
hi friend.
Try this:
- platform: template
sensors:
door_last_opened:
friendly_name: 'Front door last opened'
icon_template: mdi:glassdoor
value_template: '{{ as_timestamp(states.sensor.front_door_opened.last_updated) | timestamp_custom("%a %H:%M", True) }}'
Thank you, it was very helpful
i have a binary sensor : “binary_sensor.0x00158d0001f3e7eb” Friendly name “Correio”
have this in Sensor.yaml
- platform: template
sensors:
last_mail:
friendly_name: 'mail door last opened'
value_template: '{{ as_timestamp(states.sensor. binary_sensor.0x00158d0001f3e7eb.last_updated) | timestamp_custom("%a %H:%M", True) }}'
but gives error
can you help
Try:
- platform: template
sensors:
last_mail:
friendly_name: 'mail door last opened'
value_template: '{{ as_timestamp(states.binary_sensor["0x00158d0001f3e7eb"].last_updated) | timestamp_custom("%a %H:%M", True) }}'
many many thanks
I’m sorry to pick this thread up, but how do I show the value on a card in LoveLace?
Which card should I use?
That’s kind of off topic, but it’s just an entity, so any card you like that can show an entity.
All I get is “Off” and not a timestamp, like this:
(“Av” is norwegian for “Off”).
Please share your sensor config.
EDIT: My guess is you’ve defined it as a binary_sensor
instead of a sensor
.
Yes, you’re absolutely spot on
sensor:
- platform: template
sensors:
sistaapnet_altandor:
friendly_name: 'Altandør sist åpnet'
value_template: '{{ as_timestamp(states.binary_sensor["Altandør"].last_updated) | timestamp_custom("%a %H:%M", True) }}'
My card now shows:
(“Utilgjengelig” = norwegian for unavailable).
If I click the card, the popup shows what I’m looking for (“Opened 3 minutes ago”) - is it possible to get that text on the “main” card?
I’m guessing the state of this template sensor is unavailable
because the value_template
is not correct. Specifically, I’m guessing that’s not the Object ID of the binary_sensor
you’re trying to retrieve the last_update
value from.
Please go to the STATES tab of the Developer Tools page and look for that binary sensor in the list. What is its name in the Entity column? I’m guessing it isn’t binary_sensor.Altandør
.