Hi, I can’t figure out how to setup an automation (not multiple) to fire at 5:30 on MTWTF and 7:00 on SS. Is it possible on a single automation? The automation is to set temperature at those specific time if someone is present (I know how to do the present thing, not just the time thing for multiple days).
Yes, it can be done, but honestly, it would be much easier to move the actions into a script, then have two automations, one for 5:30 on MTWTF and one for 7:00 on SS, and have both call the script. You can even put the “if someone is present” thing as a condition at the start of the script so you don’t have to duplicate that in each automation.
Here’s one for my coffee maker that does this and a few other triggers. hope it helpd.
Also has a presence sensor and other conditions. It’s the conditions you are mainly interested in.
- id: '1507434167220'
alias: Coffee Maker On
trigger:
- platform: time
at: '07:00:00'
- platform: time
at: '07:15:00'
- platform: time
at: '08:00:00'
- platform: time
at: '12:00:00'
- platform: time
at: '19:00:00'
- platform: time
at: '20:00:00'
- entity_id: person.liz
from: 'not_home'
platform: state
to: 'home'
condition:
condition: and
conditions:
- condition: state
entity_id: 'input_boolean.homeandawayauto'
state: 'on'
- condition: or
conditions:
- condition: template
value_template: "{{ now().strftime('%H:%M') == '07:00' and now().weekday()
< 5 and (states('input_boolean.holiday') == 'off') }}"
- condition: template
value_template: "{{ now().strftime('%H:%M') == '07:15' and ((as_timestamp(now())
- as_timestamp('2017-09-24 00:00:00')) / 86400)|int % 28 == 0 }}"
- condition: template
value_template: "{{ now().strftime('%H:%M') == '08:00' }}"
- condition: template
value_template: "{{ now().strftime('%H:%M') == '12:00' and ((as_timestamp(now())
- as_timestamp('2017-09-24 00:00:00')) / 86400)|int % 28 == 0 }}"
- condition: template
value_template: "{{ now().strftime('%H:%M') == '19:00' and (states('input_boolean.overtime') == 'off') }}"
- condition: template
value_template: "{{ now().strftime('%H:%M') == '19:00' and now().weekday() > 4 }}"
- condition: template
value_template: "{{ now().strftime('%H:%M') == '20:00' and (states('input_boolean.overtime') == 'on') and now().weekday() < 5 }}"
- condition: and
conditions:
- condition: template
value_template: "{{ now().weekday() < 5 }}"
- condition: time
after: '18:00:00'
before: '19:00:00'
- condition: state
entity_id: person.liz
state: 'home'
action:
- service: switch.turn_on
data:
entity_id: switch.sonoff12914
- condition: and
conditions:
- condition: template
value_template: "{{ now().weekday() < 5 }}"
- condition: time
after: '18:00:00'
before: '19:00:00'
- condition: state
entity_id: person.liz
state: 'home'
- service: notify.david_ios_notify
data:
message: 'Coffee Maker On'
title: 'Liz is home'
Thank you both. I went with the binary_sensor weekday and a combination of ands and ors as follow:
Edit: Previous version didn’t correctly work on weekends. Was missing a nested And. Now fixed.
- id: '1578617316410'
alias: Présence - Martin le matin
description: ''
trigger:
- at: '5:30:00'
platform: time
- at: '7:00:00'
platform: time
condition:
- condition: state
entity_id: person.martin
state: home
- condition: or
conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- after: '5:00:00'
before: '6:00:00'
condition: time
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'off'
- after: '6:30:00'
before: '7:00:00'
condition: time
action:
- data:
temperature: 22
entity_id: climate.neviweb130_climate_martin
service: climate.set_temperature
This I hope will work and if it does, will set the temperature at 22C at 5:30 on a weekday (unless it’s a holiday, as defined in Québec, Canada) and at 7:00 on a weekend (including if it’s a holiday, as defined in Québec, Canada). In both cases, it will only happen for that thermostat if ‘Martin’ is home.