[Solved] LUA script (to the security panel) -> dzVents script is working well
Posted: Sunday 14 October 2018 21:47
Hello,
We have a Blockly script for a one button Neo keyfob (it sends only an “On” command.)
The script is: If Keyfob=On and Var Alarm=Off
Set Var Alarm=On
That script is working perfect and every time when we push the button at the key fob it toggles the Variable Alarm from On to Off and Vice versa. (And a Virtual Device is also listening working well with that Variable, it goes on and off with a Blockly script.)
BUT:
Than we made the Lua script below to change the Domoticz Security Panel.
Unfortunately then the Variable “Alarm” (of the Blockly script above) comes in a loop and several times in a row the Domticz security panel displays Armed and Disarmed (see log below).
How is it possible that the Lua script which has only to READ the Variable “Alarm” also changes the Variable? (we saw it automatically changing serval times in the Variable window)
(The only script that may change this Variable “Alarm” is the Blockly script above with the keyfob!
What’s going wrong here?
Thanks for there help and kind regards,
John
commandArray = {}
if (uservariables["Alarm"] == 'On') then
commandArray['Domoticz Security Panel'] = 'Arm Away'
print('### SecPanel: status changed to ' .. globalvariables['Security'])
end
if (uservariables["Alarm"] == 'Off') then
commandArray['Domoticz Security Panel'] = 'Disarm'
print('### SecPanel: status changed to ' .. globalvariables['Security'])
end
return commandArray
2018-10-14 21:08:48.005 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.008 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.014 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.015 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.055 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.058 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.064 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.064 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.104 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.107 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.113 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.114 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.153 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.156 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.162 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.163 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.202 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.205 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.212 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.212 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.251 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.254 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.261 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.261 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.301 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.304 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.310 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.311 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.350 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.353 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.359 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.360 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.399 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.402 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.408 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.409 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.449 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.451 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.458 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.458 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.498 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.501 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.507 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.508 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.547 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.550 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.556 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.557 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.596 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.599 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.605 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.606 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.645 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.648 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.655 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.655 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.695 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.698 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.704 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.704 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.744 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.746 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.753 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.753 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.793 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.796 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.802 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.803 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.843 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.845 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.852 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.852 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.892 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.895 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.901 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.902 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.941 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.944 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.950 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.951 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.990 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.993 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.999 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:49.041 (Domoticz Internal) Security (Domoticz Security Panel)
2018-10-14 21:08:49.000 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:49.007 Status: EventSystem: reset all events...
We have a Blockly script for a one button Neo keyfob (it sends only an “On” command.)
The script is: If Keyfob=On and Var Alarm=Off
Set Var Alarm=On
That script is working perfect and every time when we push the button at the key fob it toggles the Variable Alarm from On to Off and Vice versa. (And a Virtual Device is also listening working well with that Variable, it goes on and off with a Blockly script.)
BUT:
Than we made the Lua script below to change the Domoticz Security Panel.
Unfortunately then the Variable “Alarm” (of the Blockly script above) comes in a loop and several times in a row the Domticz security panel displays Armed and Disarmed (see log below).
How is it possible that the Lua script which has only to READ the Variable “Alarm” also changes the Variable? (we saw it automatically changing serval times in the Variable window)
(The only script that may change this Variable “Alarm” is the Blockly script above with the keyfob!
What’s going wrong here?
Thanks for there help and kind regards,
John
commandArray = {}
if (uservariables["Alarm"] == 'On') then
commandArray['Domoticz Security Panel'] = 'Arm Away'
print('### SecPanel: status changed to ' .. globalvariables['Security'])
end
if (uservariables["Alarm"] == 'Off') then
commandArray['Domoticz Security Panel'] = 'Disarm'
print('### SecPanel: status changed to ' .. globalvariables['Security'])
end
return commandArray
2018-10-14 21:08:48.005 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.008 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.014 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.015 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.055 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.058 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.064 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.064 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.104 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.107 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.113 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.114 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.153 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.156 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.162 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.163 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.202 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.205 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.212 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.212 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.251 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.254 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.261 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.261 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.301 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.304 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.310 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.311 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.350 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.353 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.359 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.360 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.399 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.402 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.408 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.409 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.449 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.451 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.458 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.458 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.498 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.501 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.507 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.508 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.547 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.550 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.556 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.557 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.596 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.599 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.605 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.606 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.645 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.648 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.655 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.655 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.695 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.698 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.704 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.704 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.744 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.746 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.753 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.753 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.793 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.796 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.802 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.803 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.843 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.845 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.852 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.852 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.892 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.895 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.901 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.902 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.941 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.944 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.950 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.951 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.990 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:48.993 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:48.999 Status: LUA: ### SecPanel: status changed to Disarmed
2018-10-14 21:08:49.041 (Domoticz Internal) Security (Domoticz Security Panel)
2018-10-14 21:08:49.000 Status: EventSystem: Script event triggered: AlarmPaneel
2018-10-14 21:08:49.007 Status: EventSystem: reset all events...