Hi, I’m looking for help with creating a template for entity picture in a template sensor. What I want is a sensor for an alarm. Which can show three stages. 1. Motion. 2 Post motion, which is between the motion and smaller then 10s from last changed. And 3. no motion when the time is bigger then 10s since last_changed. I made this template:
platform: template
sensors:
pir_woonkamer:
friendly_name: "Woonkamer"
value_template: >-
{% if is_state('binary_sensor.pir_woonkamer', 'on') %}
beweging
{% else %}
geen
{% endif %}
entity_picture_template: >-
{% if is_state('binary_sensor.pir_woonkamer', 'on') %}
/local/icons/motion.png
{% elif as_timestamp(now()) - as_timestamp(states.binary_sensor.pir_woonkamer.last_changed) < 10 %}
/local/icons/post-motion.png
{% else %}
/local/icons/no-motion.png
{% endif %}
The value part works and I do not have questions about that. The entity_picture template works partly and I could use some help to get it 100% working.
- When there is motion the picture motion.png is shown. So far so good!
- When the now()-last_changed from the sensor < 10 seconds it shows post-motion. This also works.
- But the else statement with the picture no-motion never shows. When the time after the last_changed is bigger the 10s, the picture post-motion stays.
If someone could help, that would be great!