Check if script is already running with specific variables

Hi,

I’m looking for a way to check if a generic script is currently running with specific provided variables.

The background:
I have a few automation to switch on/off/dim lights. (It makes a selection on what to do based on which button is pressed or held). The lights are dimmed based on a number of external variables (based on the current time and the current position of the sun).

For example:
Button 1: if pressed the lightbulb 1 switches on on, and if the button is held lightbulb 1 goes brighter until released
Button 2: if held down and the lightbulb 1 is on, lightbulb 1 is will be dimmed until released
Button 3 and four do the same for lightbulb 2

The idea is that after one hour of the ‘manual override’ (holding the buttons) that the light will go back to the default setting. I currently have a sequence in the dim/bright function that waits for 3600 seconds and then runs another automation that sets the light back. This works fine as long as the other light managed by the switch isn’t also executed.
So it fails when:

  • Light one is switched on
  • Light one is set brighter
  • Light two is switched on

I of course could create a ‘reset to default’ script for each of the light bulbs (which I currently have in automations)

I however would prefer to have a generic script for all of my lights. So the script accepts variables (the light and when it should return), and the timer should be reset for the specific lightbulb when it is dimmed again and of course it shouldn’t switch the light back on if it the lightbulb was turned off before the timer runs out and switched is back on again.

My idea was to somehow check if a script is already running with specific variables/fields and go from there. I however can’t find a way to do that. If someone else has another idea to achieve the above, any suggestions are welcome :slight_smile: