I would like to control the heating of the house based on the time of day.
The base I started with is some automations that as trigger have time and in action set the temperature.
On top of that there are different actions on different days of the week, I would like to expand this so that it only works when I am home, so I added condition.
I would also like it to turn off when I leave the house, and turn on when I get home. And this is where it starts to get messy, because I added another automation with Zone as a trigger and Choose in action to determine which automation to run.
I found it easiest to create one or more template binary_sensors that combine the conditions and give a simple on/off for use in automations. For example, here’s my sensor that flags if I’m working from home on my own, which I use to turn off the heating as my study stays warm enough.
- name: wfh_solo
unique_id: f748f605-dac2-4743-a79f-c92bc82e3b46
state: >-
{{ is_state('zone.home', '1') and
is_state('person.troon', 'home') and
is_state('binary_sensor.workday_sensor', 'on') and
(states('sensor.time') < states('input_datetime.wfh_end')[0:5]) and
(states('sensor.time') >= states('input_datetime.wfh_start')[0:5]) }}
device_class: occupancy
I then use the state of that binary_sensor in an automation, keeping all of that lengthy logic out of the automation code.
I also tend to use several simple automations rather than one complex one. Currently, I have individual automations to:
Set away mode when all are away
Set comfort / sleep mode for day & night
Set sleep mode when working from home on my own
Set comfort mode when people return home or working from home conditions end.