One button, two actions with script running check

I have an Amazon Dash button in my bedroom and I use it to trigger ON/OFF the alarm on the stairs in the evening.
I wake up with some yeelights with a long script.

I would like to use the button

  1. In the evening, arm/disarm the trigger
  2. In the morning, if the light script is running: stop the script and turn the lights off.

Is it possibile?
How can I test if the script is running?

Assuming you mean a YAML script, its state shows if it’s running: on means it’s running, off means it’s not. So you can do:

condition: state
entity_id: script.whatever
state: 'on'

to test if it’s running. Or, you can just stop it with the following, whether it’s running or not:

service: script.turn_off
entity_id: script.whatever
1 Like