Let me first describe my problem to make things clear: I have a script that controls different light scenes different rooms. Which scene should be activated is currently defined in a String Item, as I didn’t find a better way to pass a parameter to the script. This Item is controlled by different rules which are triggered by events (e.g. motion, time, …). So the rules set the Item and then use the action
Most of the time this works fine, but sometimes some scenes in a sequence (e.g. switch on light in living-room, switch off light in corridor when tv is switched on) are not, in the example the corridor scene is not executed. When looking in my log i see instead that the living-room scene is executed twice. So I assume that the script is activated before the Item got the new value.
So my question is, is there a way to synchronize these 2 actions (postupdate and callscript) to make sure that the Item is updated first. An additonal rule for this doesn’t work as it didn’t solve the problem. It will make sure that the Item is updated first, but as it also works asynchonous it may well lead to the problem that the corridor rule is executed twice as the sequence is too fast (the reason why I used a script and not a rule for the control). The only idea I have is to wait after setting the item and before calling the script. I currently do this but don’t really like it as it either waits to long for most cases or too short for some cases.
Has anyone an idea how to solve the problem?