Bondo2
(Bondo2)
February 5, 2022, 3:38am
1
I have the following automation which turns down heat to 14C in weekdays at 10PM and is supposed to wait untill midnight on weekends (for me that means Friday and Saturday nights). I can’t get it to work on Fridays because I use the workday sensor and Friday is a work day. Any help ?
alias: Heating nights
description: ''
trigger:
- platform: time
at: '22:00:00'
condition:
- condition: template
value_template: ' {{ is_state(''input_boolean.vacation_mode'', ''off'') }}'
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'off'
- condition: or
conditions:
- condition: time
weekday:
- fri
sequence:
- wait_for_trigger:
- platform: time
at: '23:59:00'
default: []
- service: climate.turn_on
target:
entity_id: climate.t6_pro_z_wave_programmable_thermostat
- service: climate.set_temperature
data:
temperature: 14
hvac_mode: heat
target:
entity_id: climate.t6_pro_z_wave_programmable_thermostat
mode: single
Bondo2
(Bondo2)
February 5, 2022, 5:52pm
5
Can you explain more, maybe with code?
Bondo2
(Bondo2)
February 5, 2022, 5:56pm
6
The condition will be true if both vacation mode and weekday are off or its a Friday. This is not what what am looking for
The whole automation should not run off vacation mode is on. If it is off then run the action if it is any weekday except on Fridays
Bondo2
(Bondo2)
February 5, 2022, 5:57pm
7
Am intentionally not using weekday because I want the weekends and holidays. This is why am using workday sensor
Bondo2
(Bondo2)
February 6, 2022, 4:00am
10
## Comment: 0=Monday, 7=Sunday
- >-
{{ now().strftime('%H:%M') == '22:00' and ( now().weekday() == 7 or
now().weekday() == 0 or now().weekday() == 1 or now().weekday() == 2
or now().weekday() == 3 or now().weekday() == 4) }}
- >-
{{ now().strftime(''%H:%M'') == '00:00' and ( now().weekday() == 6) or
now().weekday() == 7 }}
This will work as I don’t want to set the temperature to 14 if vacation mode is ON, like this
IF Input Boolean Vacation Mode is OFF (is NOT vacation)
Switch Heater to ON and set temperature to 14°C
From Sunday to Thursday Nights at 10 PM ( what if Monday is a holiday ?)
Friday and Saturday Nights at 00 AM
but EITHER days/times ONLY IF
Binary Workday Sensor is in state OFF (is NOT public holidays)
ELSE
Do Nothing
Can this code be changed to (even though it won’t fight my use case)
## Comment: 0=Monday, 7=Sunday
- >-
{{ now().strftime('%H:%M') == '22:00' and ( now().weekday() == 7 or
now().weekday() == 0 or now().weekday() > 0 or now().weekday() < 5
}}
- >-
{{ now().strftime(''%H:%M'') == '00:00' and ( now().weekday() == 6) or
now().weekday() == 7 }}
koying
(Chris B)
February 6, 2022, 8:39am
12
Note that you can use an offset in workday
, e.g.
- platform: workday
name: Workday_Today
country: US
province: PA
add_holidays:
- "2021-11-25"
- "2021-11-26"
- "2021-12-23"
- "2021-12-24"
- "2021-12-25"
- "2021-12-31"
- platform: workday
name: Workday_Tomorrow
days_offset: 1
country: US
province: PA
add_holidays:
- "2021-11-25"
- "2021-11-26"
- "2021-12-23"
- "2021-12-24"
- "2021-12-25"
- "2021-12-31"
So you could also do
alias: Heating nights
description: ''
trigger:
- platform: time
at: '22:00:00'
id: "trig_22"
- platform: time
at: '00:00:00'
id: "trig_midnight"
condition:
condition: or
conditions:
- condition: and
conditions:
- condition: trigger
id: trig_22
- condition: state
entity_id: binary_sensor.workday_tomorrow
state: "on"
- condition: and
conditions:
- condition: trigger
id: trig_midnight
- condition: state
entity_id: binary_sensor.workday_today # midnight is already "today"
state: "off"
action:
- service: climate.turn_on
target:
entity_id: climate.t6_pro_z_wave_programmable_thermostat
- service: climate.set_temperature
data:
temperature: 14
hvac_mode: heat
target:
entity_id: climate.t6_pro_z_wave_programmable_thermostat
mode: single
1 Like
Bondo2
(Bondo2)
February 7, 2022, 1:15am
13
I don’t see vacation_mode used
Bondo2
(Bondo2)
February 7, 2022, 1:23am
14
This is what I get when I try to paste that code
Message malformed: Expected a dictionary @ data[‘condition’][0][‘conditions’][2][‘conditions’][1]
Bondo2
(Bondo2)
February 7, 2022, 2:04am
16
alias: Heating nights
description: ''
trigger:
- platform: time
at: '22:00:00'
- platform: time
at: '00:00:00'
condition:
condition: and
conditions:
- condition: template
value_template: ' {{ is_state(''input_boolean.vacation_mode'', ''off'') }}'
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'off'
- condition: or
conditions:
## Comment: 0=Monday, 7=Sunday
- >-
{{ now().strftime('%H:%M') == '22:00' and ( now().weekday() == 6 or
now().weekday() == 0 or now().weekday() == 1 or now().weekday() == 2
or now().weekday() == 3) }}
- >-
{{ now().strftime(''%H:%M'') == '00:00' and ( now().weekday() == 4) or
now().weekday() == 5 }}
action:
- service: climate.turn_on
target:
entity_id: climate.t6_pro_z_wave_programmable_thermostat
- service: climate.set_temperature
data:
temperature: 14
hvac_mode: heat
target:
entity_id: climate.t6_pro_z_wave_programmable_thermostat
mode: single
Bondo2
(Bondo2)
February 7, 2022, 2:24am
18
Received another error saving it. Fixed it to this
alias: Heating nights
description: ''
trigger:
- platform: time
at: '22:00:00'
- platform: time
at: '00:00:00'
condition:
condition: and
conditions:
- condition: template
value_template: "{{ is_state('input_boolean.vacation_mode', 'off') }}"
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'off'
- condition: or
conditions:
## Comment: 0=Monday, 6=Sunday
- >-
{{ now().strftime('%H:%M') == '22:00' and ( now().weekday() == 6 or
now().weekday() == 0 or now().weekday() == 1 or now().weekday() == 2
or now().weekday() == 3) }}
- >-
{{ now().strftime('%H:%M') == '00:00' and ( now().weekday() == 4) or
now().weekday() == 5 }}
action:
- service: climate.turn_on
target:
entity_id: climate.t6_pro_z_wave_programmable_thermostat
- service: climate.set_temperature
data:
temperature: 14
hvac_mode: heat
target:
entity_id: climate.t6_pro_z_wave_programmable_thermostat
mode: single
Will report later
koying
(Chris B)
February 7, 2022, 8:13am
21
Well, add it if you need.
You can add holidays to the workday integration, as you know, so you shouldn’t need it unless you have “impromptu” vacations…
Bondo2
(Bondo2)
February 8, 2022, 3:09am
22
This worked on Sunday night but failed on Monday night
Bondo2
(Bondo2)
February 8, 2022, 4:55am
24
This screenshot is the trace from the automation, there is nothing below that part and I am not sure I understand it.
Workday is on as today is a workday and according to the logic I put in thy OP, the heating should be set to 14C.
Bondo2
(Bondo2)
February 8, 2022, 5:04am
26
Only for Friday and Saturday
Friday and Saturday Nights at 00 AM
but EITHER days/times ONLY IF
Binary Workday Sensor is in state OFF (is NOT public holidays)
ELSE
Do Nothing