Hi everyone,
I’ve been trying to make an automation and after several trials I’ve come to the result that I need help to get this done.
What the automation should do: 10 minutes before my smartphone alarm starts and if the temperature in my bathroom is under 20°C the thermostate will be enabled.
My code so far:
- id: '1581871043818'
alias: Bathroom Warmup
description: ''
trigger:
- minutes: /1
platform: time_pattern
seconds: '0'
condition:
- condition: template
value_template: '{{ (((as_timestamp(now()) | int) + 10*60) | timestamp_custom("%Y-%m-%d
%H:%M:00")) == states.sensor.next_alarm.state }}'
- condition: template
data_template: "{{ state_attr('climate.heizungsthermostat_climate', 'current_temperature') | float < 20 }}"
action:
- entity_id: script.1581870339430
service: script.turn_on
By the way: The part to start 10 minutes before the alarm goes off works already properly on other automations.
Thanks for your help in advance.
AhmadK
(akasma74)
March 3, 2020, 10:57pm
2
What help do you need?
you need quotes around value
should be value_template
. and why 2 template conditions?
Thanks for your help! So it has to be like this?
condition:
- condition: template
value_template:
{{ (((as_timestamp(now()) | int) + 10*60) | timestamp_custom("%Y-%m-%d%H:%M:00")) == states.sensor.next_alarm.state }}
{{ state_attr('climate.heizungsthermostat_climate', 'current_temperature') | float < 20 }}
Edit: No, this can’t be. I’m getting errors in the configurator.
AhmadK
(akasma74)
March 4, 2020, 11:23pm
4
I still don’t know what is the problem
your value_template
isn’t right at least because it should return either True of anything else.
Something like this
condition:
- condition: template
value_template: >
{% set ctime = states.sensor.time %}
{{
(((as_timestamp(now()) | int) + 10*60) | timestamp_custom("%Y-%m-%d%H:%M:00")) == states('sensor.next_alarm') and
state_attr('climate.heizungsthermostat_climate', 'current_temperature') | float < 20
}}
The problem is that I don’t get the code working and always getting errors
With your code I still get this error:
missed comma between flow collection entries at line 162, column 8:
{% set ctime = states.sensor.time %}
^
AhmadK
(akasma74)
March 7, 2020, 10:36pm
6
that’s easy - I forgot >
after value_template
- updated my previous post, try it out.