I have wrote a trigger that should get fired when nobody has been seen in kitchen for 20 seconds: {% if as_timestamp(now())-as_timestamp(states.switch.kok_rorelse.last_changed) > 20 %}true{% else -%}false{%endif %}
But it never got fired. In the Developer Toolbox for template i got “true”.
When I for a test change to if as_timestamp(now()) > 20
it is working.
Thank you! I was needed to add “from” and t"o" also, not only for seconds. but now it works
In the documentation “from” and “to” is optional, but got error 2017-08-06 09:41:49 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: dependency violation - key "for" requires key "to" to exist @ data['trigger'][0]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 94). Please check the docs at https://home-assistant.io/components/automation/
platform: state
entity_id: switch.kok_rorelse
from: 'on'
to: 'off'
for:
seconds: 20
But the {{ as_timestamp(now())-as_timestamp(states.switch.kok_rorelse.last_changed) > 20 }} dosent work, strange?