Check variable value (if changed)
Posted: Tuesday 28 January 2020 13:11
Hi, i want to do some actions when the content of a variable is changed.
Currently i have this script (the script is more articulated but i put the essential part) that do some actions according the value of two variable (Tag_Andrea - Tag_Ilaria) which is controlled by BLE presence script. These variable could have two string content: Out when someone is away from the house, Home when someone is back:
Now the problem is that often BLE plugin retest the value and write again the variables with the same content, but updating the 'last update' value.
How can i edit this script to be triggered only on variable content changed?
Thanks since now for your help!
Currently i have this script (the script is more articulated but i put the essential part) that do some actions according the value of two variable (Tag_Andrea - Tag_Ilaria) which is controlled by BLE presence script. These variable could have two string content: Out when someone is away from the house, Home when someone is back:
Code: Select all
on = {
variables = {
'Tag_Andrea',
'Tag_Ilaria'
},
},
execute = function(domoticz, Tag)
if domoticz.variables('Tag_Andrea').value == 'Out' and domoticz.variables('Tag_Ilaria').value == 'Out' then
-------------- TURN ON THE ALARM AND DO MUCH MORE
elseif domoticz.variables('Tag_Andrea').value == 'Home' or domoticz.variables('Tag_Ilaria').value == 'Home' then
-------------- TURN OFF THE ALARM AND DO MUCH MORE
How can i edit this script to be triggered only on variable content changed?
Thanks since now for your help!