I’m now trying to solve this over the past 3 days and sadly failing. I’m trying to configure automation via the editor in the front end since for some reasons (might be a curse on me…) even editing in the code fails.
I have an input booleans that sets to Morning, Afternoon, etc based on time but also if it’s a workday or not.
I’m trying ot align my thermostats to this. The code below is build by the automation editor but it doesn’t fire on state change. What I am I doing wrong?
Thanks for the help everyone. I’m posting my final (Working) code here. A couple of interesting notes:
I have a custom component called “Climate.Groups”. In my house, there are 3 different radiators in one room so that was handy. This works with google assistant but… it never worked in this automation.
I also have evo home smart radiators everywhere and the recommended way is via evohome.set_zone_override. I did, it worked once, and never wanted to change again (not sure if there is a timeout on the API or something). So I reverted to climate service instead.
The working code:
I have an input select called
input_select.part_of_day
options:
- Midnight
- Morning
- Afternoon
- Evening
editable: true
friendly_name: Part of Day
I have the binary sensor “workday” - (out of the box - simply add this to configuration.yaml)
- platform: workday
country: NL
I have an automation to set the input select phases during the day (morning, afternoon, etc)
I also use this to set my lights during the day to different levels of intensity but that’ not in this code here
(I have a stupid cat that triggers lots of sensor lights during the night…)
- id: 'partofdaylloyd'
alias: Home Part of Day
description: ''
trigger:
- platform: time
at: '06:00:01'
- platform: time
at: '11:00:01'
- platform: time
at: '18:00:01'
- platform: time
at: '23:00:01'
- platform: time
at: '09:00:00'
condition: []
action:
- choose:
# IF Midnight
- conditions:
- condition: time
after: '23:00:00'
sequence:
- service: input_select.select_option
entity_id: input_select.part_of_day
data:
option: Midnight
# ELIF Evening
- conditions:
- condition: time
after: '18:00:00'
sequence:
- service: input_select.select_option
entity_id: input_select.part_of_day
data:
option: Evening
# ELIF Afternoon
- conditions:
- condition: time
after: '11:00:00'
sequence:
- service: input_select.select_option
entity_id: input_select.part_of_day
data:
option: Afternoon
# ELIF Morning workday on
- conditions:
- condition: time
after: '06:00:00'
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
sequence:
- service: input_select.select_option
entity_id: input_select.part_of_day
data:
option: Morning
# ELIF Morning workday off
- conditions:
- condition: time
after: '09:00:00'
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'off'
sequence:
- service: input_select.select_option
entity_id: input_select.part_of_day
data:
option: Morning
# ELSE Midnight
default:
- service: input_select.select_option
entity_id: input_select.part_of_day
data:
option: Midnight
And finally the automation discussed in this thread to setup my thermostats.
why dont you simply use a part_of_day sensor, instead of the first automation?
part_of_day:
friendly_name: Part of day
value_template: >
{% set trigger = states('sensor.time') %}
{% set hour = now().hour %}
{% if hour in range(0,6) %} Night
{% elif hour in range(6,12) %} Morning
{% elif hour in range(12,18) %} Afternoon
{% else %} Evening
{% endif %}
and use the states of that sensor in the conditions of the second automation?
btw, though I only have 1 climate entity, and can’t test it, I would think this:
Yes, indeed much more elegant - and it has to do that I’m not a very strong coder - I just try to adapt codes I find here and there until it works
(I had tried the template sensor already and gave up after many many tried where I coudn’t make it work… and lack understanding why - that’s why I went back to automation )
BTW, the system evohome.set_zone_override failed on me (it would only work ad hoc) but strangely the climate.set_temperature worked fine.