Hi there,
I would like to know what the easiest/nicest way to achieve this is.
I want a motion sensor trigger to turn a light on for 3 minutes, then turn it off.
If the time when the light is triggered is in range A, the light should be one colour, and if in range B, the light should be a different colour.
I think I can do it with two VERY similar scripts with sequences like:
turn_on, colour 1
delay
turn_off
and two similar automations (same trigger, different conditions and scripts).
So… is it possible to avoid using scripts? I.e. can you do sequences nicely in automation actions?
and if not, can I combine my scripts somehow so that I don’t have to have two near-identical scripts (maybe with a template)?
You can call scripts from within scripts. And you can pass variables / data to scripts. But the answer to your question is “no” simply because there is no “else” in sequences just “ifs”. If a condition is not met the script simply stops.
So you could have 3 scripts
Script 1:
check for condition for color 1
turn_on, colour 1
run script 3
Script 2:
check for condition for color 2
turn_on, colour 2
run script 3
Script 3:
delay
turn_off
In your automation you would then call script 1 AND 2 but you would also have to make sure that the conditions in script 1 and script 2 can never both be true at the same time, because that would f*ck up the whole thing XD