How do I monitor and do something (in lua) if the security status (globalvariables['Security'] i assume) changes?
I am trying to run some os commands when I use the domoticz security panel.
here is what I have so far but this just runs in an endless loop. I assume I need to an "if changed" check around this all.
Code: Select all
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
commandArray = {}
if globalvariables['Security'] == 'Disarmed' then
print('Security Panel - Disarmed')
commandArray['SendNotification']='System Disarmed#System has been disarmed'
os.execute('echo "rfsec 0x11 disarm" | nc -w 2 localhost 1099')
elseif globalvariables['Security'] == 'Armed Home' then
print('Security Panel - Armed Home')
commandArray['SendNotification']='System Armed (Home)#System has been armed'
os.execute('echo "rfsec 0x11 arm_home_min" | nc -w 2 localhost 1099')
elseif globalvariables['Security'] == 'Armed Away' then
print('Security Panel - Armed Away')
commandArray['SendNotification']='System Armed (Away)#System has been armed'
os.execute('echo "rfsec 0x11 arm_away_max" | nc -w 2 localhost 1099')
end
return commandArray