I don’t know if is it a bug or feature?!
I have a script, that send me the names of open windows per telegram.
That script is not the issue, that works well.
I want to start the script when its beginning to rain.
Also this works fine.
But i wont to start the script maximun only one time per hour. If in the meantime the rain stops and start agian.
I would like to use a template condition to calculete when the script was last triggered.
{{ (as_timestamp(now()) - as_timestamp(state_attr('script.regen_benachrichtigung','last_triggered'))) | default(0) | int > 3600}}
The Template Editor shows that the result ist false.
alias: Garten - Regen Benachrichtigung
description: ''
trigger:
- platform: state
entity_id: binary_sensor.regenmelder_regen
from: 'off'
to: 'on'
condition:
- condition: template
value_template: >-
{{ (as_timestamp(now()) -
as_timestamp(state_attr('script.regen_benachrichtigung','last_triggered')))
| default(0) | int > 3600}}
action:
- service: script.regen_benachrichtigung
data: {}
mode: single
But if I use the template in an Automation the condition doesn’t work anymore?!
It doesn’t matter if the condition is true or false. Always the Action will be executed.
It looks like that you can’t test a templete condition, beause the result is always this message?!
template value should be a string for dictionary value @ data[‘value_template’]. Got None
The trace looks also very strange?
Is my template not correct? Or it’s not possible to use such kind of template as a condition?
Thanks in advance.