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:
turn_off_bedroom_light:
alias: "Turn off the bedroom light"
sequence:
# 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:
turn_on_bedroom_light:
alias: "Turn on the bedroom light"
sequence:
# cancel any timer due to turn off the bedroom light
- service: script.turn_off
data:
entity_id: script.turn_off_bedroom_light
# turn on the bedroom light
- service: light.turn_on
entity_id: light.bedroom
data:
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?