Hi
I’m trying to setup template sensors based on my motion sensors. I’m planning on using them as input for Bayesian sensors.
platform: template
sensors:
template_sov_now_vs_motion_3min:
friendly_name: 'Sov - Now vs Motion'
value_template: "{{ (as_timestamp(now()) - as_timestamp(states.binary_sensor.sov_sen_motion.last_changed)) | int < 180 }}"
# value_template: "{% if (as_timestamp(now()) - as_timestamp(states.binary_sensor.sov_sen_motion.last_changed)) | int < 180 %} true {% else %} false {%endif%}"
But the problem is that the sensor template_sov_now_vs_motion_3min don’t update. I tried both variants as shown above. If I test the value_template in the template editor, then it works fine.
This is the editor output. The result is False as it should be, be the template sensor is still true/on.
If I changed to > instead of <, its just off all the time. I tried using float instead of int, but no luck.
That didn’t make any difference, it still don’t update.I thought the template sensor refreshed every x seconds, but do it need an entity state change to “refresh on”.?
I tried creating a second template sensor with a Hue motion sensor binary_sensor.stue_sen_motion, but with same result.
Can i use a different entity to force the update?
templates only update when a entity inside the template updates. If you want it to update every xx seconds, you need to find an entity in your sytem that updates every xx seconds and use that in the entity_id field. Otherwise you can get minutely updates by integrating the time integration and using sensor.time.