I’ve put myself in a loop with this one. How do I avoid the automation is already running error when running this automation?
My triggers are for a switch that controls a ventilator for my HVAC
on, off and off from a 60 minute timer. The thing is, if it turns off from the timer, it also triggers the off trigger, so I get the error. Any ideas how I can avoid this?
thanks
alias: Turn on HRV Timer and Turn off HRV after 1 hr
description: >-
Turn on HRV timer for 1 hr based on trigger or activated remotely, and turn
off HRV when timer is done.
trigger:
- platform: state
entity_id:
- switch.shellyplus1_b8d61a87d8b8_switch_0
to: "on"
id: hrv_on
- platform: state
entity_id:
- switch.shellyplus1_b8d61a87d8b8_switch_0
to: "off"
id: hrv_off
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.hrv_60_min_timer
id: hrv_off_timer
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: hrv_on
sequence:
- service: timer.start
data: {}
target:
entity_id: timer.hrv_60_min_timer
- conditions:
- condition: trigger
id: hrv_off
sequence:
- service: timer.cancel
data: {}
target:
entity_id: timer.hrv_60_min_timer
- service: notify.mobile_app_sony_xperia_zx1
data:
message: >-
The HRV has turned off remotely, and the 60 minute timer has
been cancelled.
title: HRV Turned Off Remotely
- service: notify.mobile_app_iphone
data:
message: >-
The HRV has turned off remotely, and the 60 minute timer has
been cancelled.
title: HRV Turned Off Remotely
- conditions:
- condition: trigger
id: hrv_off_timer
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.shellyplus1_b8d61a87d8b8_switch_0
- service: timer.cancel
data: {}
target:
entity_id: timer.hrv_60_min_timer
- service: notify.mobile_app_sony_xperia_zx1
data:
message: >-
The HRV has turned off because the 60 minute timer has
completed.
title: HRV Turned Off Remotely
- service: notify.mobile_app_iphone
data:
message: >-
The HRV has turned off because the 60 minute timer has
completed.
title: HRV Turned Off Remotely
default:
- service: notify.mobile_app_sony_xperia_zx1
data:
message: The HRV has tried to turn on or off but no action has been taken.
title: HRV Triggered
mode: single
Is max_exceeded only available via YAML configuration? I set the following automation up via the Visual Editor and get warnings frequently so I’m going to add this to them manually, but just wanted to confirm that I didn’t mess something else up here.
Yes, you can add the max_exceeded option to your automation in the Visual Editor’s YAML mode. However, I suggest you do something different.
The reason for the warning message is because the moment the automation executes light.turn_off it causes the automation’s State Trigger to detect the light’s state-change to off … but the automation is still busy finishing up the light.turn_off command. This is a fairly common occurrence for automations designed to detect the very same state-changes that they produce. The optimal way of handling this situation is to set mode to queued as opposed to single.
BTW, if all you want to do is turn off the light after it’s been on for 15 minutes, you can do it like this (no timer entity required):
alias: Auto - Turn off Downstairs Light After 15 Minutes
description: ""
trigger:
- platform: state
entity_id: light.downstairs
to: 'on'
for:
minutes: 15
condition: []
action:
- service: light.turn_off
target:
entity_id: light.downstairs
mode: single
Thanks. I originally had the timers set like you shared, but that doesn’t persist across reboots, which is why I have a bunch of automations modeled like this one.