Hello,
I’m trying to configure an automation with a template condition but I’m not getting why it does not works. I tried my template with the dev tool and it seems to work there.
The automation:
alias: Time tests
description: ''
trigger:
- platform: time
at: '22:00'
condition:
- condition: template
value_template: >
{% set fifteenMinutesInSeconds = 15 * 60 %}
{% set date = states('sensor.date') %}
{% set nowTime = states('sensor.time') %}
{% set nowTimestamp = strptime(date + ' ' + nowTime, '%y-%m-%d %H:%M:%S')
| as_timestamp %}
{% set startTime = states('input_datetime.cb_extra_heater_start_time') %}
{% set startTimestamp = strptime(date + ' ' + startTime, '%y-%m-%d
%H:%M:%S') | as_timestamp %}
{% set endTime = states('input_datetime.cb_extra_heater_end_time') %}
{% set endTimestamp = strptime(date + ' ' + endTime, '%y-%m-%d %H:%M:%S')
| as_timestamp %}
{{ (startTimestamp <= nowTimestamp) and (nowTimestamp <= (endTimestamp -
fifteenMinutesInSeconds)) }}
action:
- service: notify.notify
data:
message: test3
mode: single
Any idea what I’m doing wrong ? Is it because it is multiline ?
Also another small question related to the condition, is there an eaesier way to compare time (without checking date)?