Hello all! Long time lurker, first time poster.
I’m working on an automation for my mother-in-law, basically setting up some panic buttons to flash a number of lights in case she’s in trouble. For completeness: My system is Insteon with an ISY acting as the gateway to HA, and I’ve got three RemoteLinc 2 mini-remotes set up into a group for the panic switch. I’m running hass.io on an RPi 3 with HA 0.72.1, supervisor v110 and ResinOS 2.3.0+rev1.
I’ve followed the example for flashing lights on the HA page, specifically creating a pair of scripts that turn on each other to create the loop to blink. The problem I’m running into is turning off this pair of scripts.
All of these examples have the following common groups:
panic_switches:
entities:
- light.panic_button_1
- light.panic_button_2
- light.panic_button_3
panic_lights:
entities:
- light.upper_master_hallway_switch
I started with the example here, but stripped down the system to the following automations and scripts:
automation:
- alias: 'Panic_Start'
trigger:
platform: state
entity_id: group.panic_switches
to: 'on'
action:
# flash lights if panic button is pressed
service: script.turn_on
entity_id: script.panic_flash
- alias: 'Panic_Stop'
trigger:
platform: state
entity_id: group.panic_switches
to: 'off'
action:
- service: script.turn_off
data:
entity_id: script.panic_flash
- service: homeassistant.turn_off
data:
entity_id: group.panic_lights
script:
panic_flash:
alias: 'Flash Lights for Panic'
sequence:
- alias: 'Panic Lights on'
service: homeassistant.turn_on
data:
entity_id: group.panic_lights
- delay:
# time for flash light on
seconds: 0.5
- alias: 'Panic Lights Off'
service: homeassistant.turn_off
data:
entity_id: group.panic_lights
- alias: 'Trigger Flash Loop'
service: script.turn_on
data:
entity_id: script.flash_loop
flash_loop:
alias: 'Flash loop'
sequence:
- delay:
# time for flash light off
seconds: 0.5
- alias: 'Panic Loop Return'
service: script.turn_on
data:
entity_id: script.panic_flash
The Panic_Start
automation triggers fine, and the light starts flashing, but when I trigger Panic_Stop
it would not shut down the script loop. My assumption was that it only tried to turn off the panic_flash
script, so I amended the Panic_Stop
automation to be this:
- alias: 'Panic_Stop'
trigger:
platform: state
entity_id: group.panic_switches
to: 'off'
action:
- service: script.turn_off
data:
entity_id:
- script.panic_flash
- script.flash_loop
- service: homeassistant.turn_off
data:
entity_id: group.panic_lights
This is where things get strange (to me). When the Panic_Stop
automation is triggered from turning the remote switch off, the scripts will still be executing. However, when I trigger Panic_Stop
from within the HA GUI, the scripts will stop.
At this point, my mind started going down the rabbit hole of possible synchronization delays between the ISY and the way HA queues up events and scripts, but I tend to over-complicate the solution of problems like this, and hope there’s an easier way to reliably turn off both flash scripts from the automation. What am I doing wrong?