Hello
I have a Script to cool the house down for 30 minutes then turn off the HVAC’s. I have been using a Delay to achieve this in my Script but would prefer the restore functionality of a timer. When I disabled the Delay and used a 30 minute timer it ran the script without waiting 30 minutes. Could someone provide some guidance on where I’m going wrong?
Thanks in advance
Here’s the yaml…
alias: AC Blast
sequence:
- if:
- condition: state
entity_id: binary_sensor.workday_sensor
state: "on"
then:
- service: climate.turn_on
data: {}
target:
entity_id:
- climate.device_0279b3
- climate.device_0276f8
- climate.device_02731d
- climate.device_02786c
- service: notify.notify
data:
message: A/C Blast commencing
enabled: true
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
enabled: false
- service: timer.start
metadata: {}
data:
duration: "00:30:00"
target:
entity_id: timer.a_c_blast_timer
enabled: true
- service: climate.turn_off
data: {}
target:
entity_id:
- climate.device_02731d
- climate.device_0276f8
- climate.device_02786c
- climate.device_0279b3
- service: notify.notify
data:
message: A/C Blast done!
enabled: true
else:
- service: climate.turn_on
data: {}
target:
entity_id:
- climate.device_0279b3
- climate.device_02731d
- service: notify.notify
data:
message: A/C Blast commencing
enabled: true
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
enabled: false
- service: timer.start
metadata: {}
data:
duration: "00:30:00"
target:
entity_id: timer.a_c_blast_timer
enabled: true
- service: climate.turn_off
data: {}
target:
entity_id:
- climate.device_02731d
- climate.device_0279b3
- service: notify.notify
data:
message: A/C Blast done!
enabled: true
mode: single
icon: mdi:air-conditioner
1 Like
You can post the source inline by surrounding it with three backticks (```).
Your code starts the timer and then turns off the switches. That’s not how timers work - you need another automation that responds to the timer.finished event, and turn them off in that.
Here is your code from google drive:
alias: AC Blast
sequence:
- if:
- condition: state
entity_id: binary_sensor.workday_sensor
state: "on"
then:
- service: climate.turn_on
data: {}
target:
entity_id:
- climate.device_0279b3
- climate.device_0276f8
- climate.device_02731d
- climate.device_02786c
- service: notify.notify
data:
message: A/C Blast commencing
enabled: true
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
enabled: false
- service: timer.start
metadata: {}
data:
duration: "00:30:00"
target:
entity_id: timer.a_c_blast_timer
enabled: true
- service: climate.turn_off
data: {}
target:
entity_id:
- climate.device_02731d
- climate.device_0276f8
- climate.device_02786c
- climate.device_0279b3
- service: notify.notify
data:
message: A/C Blast done!
enabled: true
else:
- service: climate.turn_on
data: {}
target:
entity_id:
- climate.device_0279b3
- climate.device_02731d
- service: notify.notify
data:
message: A/C Blast commencing
enabled: true
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
enabled: false
- service: timer.start
metadata: {}
data:
duration: "00:30:00"
target:
entity_id: timer.a_c_blast_timer
enabled: true
- service: climate.turn_off
data: {}
target:
entity_id:
- climate.device_02731d
- climate.device_0279b3
- service: notify.notify
data:
message: A/C Blast done!
enabled: true
mode: single
icon: mdi:air-conditioner
AC Blast.txt
Displaying AC Blast.txt.
1 Like
Ok, I’ve split them out as per your advice. What Trigger do I use to associate Timer to Automation to turn off?
Script to Turn HVAC on
alias: AC Blast (Duplicate)
sequence:
- if:
- condition: state
entity_id: binary_sensor.workday_sensor
state: "on"
then:
- service: climate.turn_on
data: {}
target:
entity_id:
- climate.device_0279b3
- climate.device_0276f8
- climate.device_02731d
- climate.device_02786c
- service: timer.start
metadata: {}
data: {}
target:
entity_id: timer.a_c_blast_timer
enabled: true
- service: notify.notify
data:
message: A/C Blast commencing
enabled: true
else:
- service: climate.turn_on
data: {}
target:
entity_id:
- climate.device_0279b3
- climate.device_02731d
- service: timer.start
metadata: {}
data: {}
target:
entity_id: timer.a_c_blast_timer
enabled: true
- service: notify.notify
data:
message: A/C Blast commencing
enabled: true
mode: single
icon: mdi:air-conditioner
Automation to Turn HVAC off
alias: A/C Blast Completed
description: ""
trigger: []
condition: []
action:
- if:
- condition: state
entity_id: binary_sensor.workday_sensor
state: "on"
then:
- service: climate.turn_off
data: {}
target:
entity_id:
- climate.device_02731d
- climate.device_0276f8
- climate.device_02786c
- climate.device_0279b3
- service: notify.notify
data:
message: A/C Blast done!
enabled: true
else:
- service: climate.turn_off
data: {}
target:
entity_id:
- climate.device_02731d
- climate.device_0279b3
- service: notify.notify
data:
message: A/C Blast done!
enabled: true
mode: single
Further down in the documentation they have some examples showing how to do it.
Thanks Michael, I’ll keep fiddling. Thanks for pointing me in the right direction.
Not sure I have this right, I’m very confused looking at the logic of the automation.
alias: A/C Blast Completed
description: ""
trigger:
- platform: state
entity_id:
- climate.device_0279b3
- climate.device_0276f8
- climate.device_02731d
- climate.device_02786c
to: "off"
condition: []
action:
- if:
- condition: state
entity_id: binary_sensor.workday_sensor
state: "on"
then:
- service: climate.turn_off
data: {}
target:
entity_id:
- climate.device_02731d
- climate.device_0276f8
- climate.device_02786c
- climate.device_0279b3
- service: timer.finish
metadata: {}
data: {}
target:
entity_id: timer.a_c_blast_timer
- service: notify.notify
data:
message: A/C Blast done!
enabled: true
else:
- service: climate.turn_off
data: {}
target:
entity_id:
- climate.device_02731d
- climate.device_0279b3
- service: timer.finish
metadata: {}
data: {}
target:
entity_id: timer.a_c_blast_timer
- service: notify.notify
data:
message: A/C Blast done!
enabled: true
mode: single