Global variable and competing scripts
Posted: Monday 11 November 2019 14:27
Hi all,
I'm quite new to dzVents and Domoticz and I just read about global persistent variables and I thought of a use case where I might use such variables. It's for my alarm system where I want to have motion detected by two different motion sensors within a given time range to trigger the alarm. The reason I don't trigger the alarm right away is to cut down on the number of false alarms.
Anyway, I thought that I would set the current time in a global variable when a motion is detected and the name of the detecting device in another variable. Then when the next sensor detects a motion, it can compare time and name to see if the alarm should be triggered or if it should just update the variables with a new time and device name.
It's important that this pattern is very stable and I wonder if there is any risk of exceptions or other behavior I forgot to think of due to perhaps competing scripts trying to change the same global variables at the same time?
Or perhaps there is a much better way to achieve this?
I'm quite new to dzVents and Domoticz and I just read about global persistent variables and I thought of a use case where I might use such variables. It's for my alarm system where I want to have motion detected by two different motion sensors within a given time range to trigger the alarm. The reason I don't trigger the alarm right away is to cut down on the number of false alarms.
Anyway, I thought that I would set the current time in a global variable when a motion is detected and the name of the detecting device in another variable. Then when the next sensor detects a motion, it can compare time and name to see if the alarm should be triggered or if it should just update the variables with a new time and device name.
It's important that this pattern is very stable and I wonder if there is any risk of exceptions or other behavior I forgot to think of due to perhaps competing scripts trying to change the same global variables at the same time?
Or perhaps there is a much better way to achieve this?