asyscom
(Davide)
March 10, 2019, 5:52pm
1
Hello,
i’ve this automation
- alias: Riscaldamento giorno weekand
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.only_time_weekand.state | int | timestamp_custom('%H:%M', False)) }}
- platform: homeassistant
event: start
condition:
condition: time
after: 08:00:00
before: '21:30:00'
weekday:
- sat
- sun
action:
- service: climate.set_temperature
data_template:
entity_id: clima.termostato
temperature: "{{states.input_number.pomeriggio_weekand.state | float }}"
id: a3ec9b56cf9e4db18a4a6b3d188a237e
and this as inputs
input_number:
mattino:
name: Temp mattino
initial: 21
min: 18
max: 25
step: 0.5
pomeriggio_weekand:
name: Temp pomerigio e weekand
initial: 20.5
min: 18
max: 25
step: 0.5
notte:
name: Temp notte
initial: 18
min: 16
max: 21
step: 0.5
input_datetime:
only_time_mattino:
name: Orario mattino
has_date: false
has_time: true
initial: "05:00"
only_time_sera:
name: Orario sera
has_date: false
has_time: true
initial: "21:30"
only_time_weekand:
name: Orario weekand
has_date: false
has_time: true
initial: "08:00"
The problem is that the trigger not work.
Any idea?
You don’t need “| int” and whatever comes after. Actualy by using int on time, it falls back to zero. That’s your error.
Tip: If you want to create templtes, use the “test-environment” for it. On the left side, where you have that icon that looks like a remote, one of these buttons is called “template”. The text-field is pre-filled with an example and next to it you see the output of that template(s). Delete this text (don’t worry, it will automaticly return) and insert your template. Then it will show you the result. If it is what you expect, use it. If it’s an error or something else, look for documentation or ask here.
asyscom
(Davide)
March 10, 2019, 6:53pm
3
Thank you very much sir! I’ll try and report feedback.
asyscom
(Davide)
March 10, 2019, 7:12pm
4
I’ve modified the automation
- alias: Riscaldamento giorno weekand
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.only_time_weekand.state) }}
- platform: homeassistant
event: start
condition:
condition: time
after: 08:00:00
before: '21:30:00'
weekday:
- sat
- sun
action:
- service: climate.set_temperature
data_template:
entity_id: clima.termostato
temperature: "{{states.input_number.pomeriggio_weekand.state | float }}"
id: a3ec9b56cf9e4db18a4a6b3d188a237e
still not working
If i try the template value into template editor (third icon from right in bottom menu) and set the current time into the slide the result is false
123
(Taras)
March 10, 2019, 8:27pm
5
This:
{{ states('sensor.time') }}
produces the current time as a string containing 5 characters. For example, 16:12
This:
{{ states('input_datetime.only_time_weekand') }}
produces the time as a string containing 8 characters. For example, 21:30:00
The two strings have different lengths and can never be equivalent. That’s why your equivalence test always results in False
.
This:
{{ states('input_datetime.only_time_weekend')[:5] }}
selects the first 5 characters of the 8-character string. For example, it will select 21:30
from 21:30:00
This is able to produce True
because it is comparing two 5-character strings:
{{ states('sensor.time') == (states('input_datetime.only_time_weekend')[:5]) }}
asyscom
(Davide)
March 10, 2019, 8:48pm
6
thank you for replay…i’ll try.
howevere i’ve discovered that also the temperature is not considere from automation.
I’ve tried to put the input only into target temp and leave the trigger with classic time template but not work…
is it ok this?
action:
- service: climate.set_temperature
data_template:
entity_id: clima.termostato
temperature: "{{states.input_number.pomeriggio_weekand.state | float }}"
asyscom
(Davide)
March 10, 2019, 8:49pm
7
may be that need a restart insted to the simply automation restart?