Cancel script on light change

Hi there!

Didn’t find it in the forum:
Is it possible to stop a script (for example welcome home) when I change the light settings by an external hue switch?

I want to cancel the normal ‘give a warm welcome for 10 minutes’ if I change the lightning in a specific room to whatever.

Many thanks in advanced :slight_smile:

Hi Hensing!

I have a heap of scripts set up for my lighting that get started & stopped/cancelled as required.

The script for turning off my bedroom light for instance is:

  alias: "Turn off the bedroom light"
# if the bedroom light is on
    - condition: state
      entity_id: light.bedroom
      state: "on"
# wait 15 seconds
    - delay: 00:00:15
# turn off the bedroom light
    - service: light.turn_off
      entity_id: light.bedroom

And when I want to turn the bedroom light on:

  alias: "Turn on the bedroom light"
# cancel any timer due to turn off the bedroom light
    - service: script.turn_off
        entity_id: script.turn_off_bedroom_light
# turn on the bedroom light
    - service: light.turn_on
      entity_id: light.bedroom
        brightness: 255
        rgb_color: [255, 255, 255]

It cancels any currently running script that is going to turn it off in 15 seconds.

I don’t have Philips Hue & so can’t help you on that front. Hopefully these examples might give you some ideas to move forward with. Does the external hue switch update Home Assistant in some way that it could trigger an automation that would stop the running script?


A script can be canceled as :

    - service: script.turn_off
         entity_id: script.welcome_home
1 Like

Thank you for you help so far!

The problem in my current setup is, that I want to switch a scene not via home assistant but with an hardware zigbee switch from the hue system.

Therefor I’m looking for something like this pseudo code:

- alias: cancel automatic switch off by welcome_home
    - platform: light
      entity_id: light.livingroom
      to: 'change'
   -  service: script.turn_off
      entity_id: script.welcome_home

As far as I know there is not a trigger for that :frowning:
Maybe I could use a template and compare with the welcome-home-scene …
Any better ideas?

Ok, do you have the zigbee switch directly connected to the hue hub or is it connected to hass somehow?
So can you do something like:

    - platform: state
      entity_id: switch.zigbee
      to: 'on'

Sadly it is connected to the hue hub only. Maybe I should buy a zigbee adapter to catch the message.

Does the trigger work on push buttons as well?

or you make 2 automations.

1 with state from on to off and 1 with state from off to on.
both canceling the script.