- platform: template
sensors:
bathroom_motion_last10:
value_template: >-
{{ (as_timestamp(now())- as_timestamp(states.binary_sensor.bathroom_motion.last_changed)) < 600 }}
friendly_name: Motion in Last 10min
device_class: motion
This template seems to alway report true/detected even though I have verified thru dev-template that {{ (as_timestamp(now())- as_timestamp(states.binary_sensor.bathroom_motion.last_changed)) < 600 }} is false.
you need to have the template update peroidically. add the sensor.time component and then add that to your template. It will update on the minute at that point.
I think we may be trying to do the same thing (see when a motion sensor was activated then create a binary switch to be on for x minutes), so I’d love to see your finished code for this.
Care to share?
Thanks.
P.s. Whenever you find an answer to a question it’s always really helpful to post your solution since people may end up coming here from a search, even years later.