Lua code for Alarm Remote
Moderators: leecollings, remb0
-
- Posts: 10
- Joined: Saturday 16 December 2017 12:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Lua code for Alarm Remote
I have a Marmitek SH600 remote to operate the Domoticz Security Panel. In DOmoticz the remote is called 'Afstandsbediening' and the security panel is called 'Inbraak Alarm'. I have the code below to operate the security panel from the remote and the other way around but it does not seem to work. What is it I am doing wrong?
script_device_alarmremote.lua
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Arm Home') then
commandArray['Inbraak Alarm'] = 'Arm Home'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
elseif (devicechanged['Afstandbediening'] == 'Arm Away') then
commandArray['Inbraak Alarm'] = 'Arm Away'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
elseif (devicechanged['Afstandbediening'] == 'Disarm') then
commandArray['Inbraak Alarm'] = 'Disarm'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
end
if (devicechanged['Inbraak Alarm'] == 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
elseif (devicechanged['Inbraak Alarm'] == 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
elseif (devicechanged['Inbraak Alarm'] == 'Disarm') then
commandArray['Afstandsbediening'] = 'Disarm'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
end
return commandArray
script_device_alarmremote.lua
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Arm Home') then
commandArray['Inbraak Alarm'] = 'Arm Home'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
elseif (devicechanged['Afstandbediening'] == 'Arm Away') then
commandArray['Inbraak Alarm'] = 'Arm Away'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
elseif (devicechanged['Afstandbediening'] == 'Disarm') then
commandArray['Inbraak Alarm'] = 'Disarm'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
end
if (devicechanged['Inbraak Alarm'] == 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
elseif (devicechanged['Inbraak Alarm'] == 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
elseif (devicechanged['Inbraak Alarm'] == 'Disarm') then
commandArray['Afstandsbediening'] = 'Disarm'
print('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
end
return commandArray
- jvdz
- Posts: 2328
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Lua code for Alarm Remote
"but doesn't work" doesn't tell us much. 
What do you actually see in the domoticz log?
One thing I could imagine that you have created an enless loop since you set 'Inbraak Alarm' which sets 'Afstandsbediening' which sets 'Inbraak Alarm' etc... but this should also be reflected in the domoticz log by the print('###'...) statement.
Jos

What do you actually see in the domoticz log?
One thing I could imagine that you have created an enless loop since you set 'Inbraak Alarm' which sets 'Afstandsbediening' which sets 'Inbraak Alarm' etc... but this should also be reflected in the domoticz log by the print('###'...) statement.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 10
- Joined: Saturday 16 December 2017 12:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua code for Alarm Remote
Here are the 4 situations, switching on and off the alarm through both the domo security panel and the remote. Only when the domo secpanel is put on ARM AWAY, the status of the remote changes as well, in all other cases, the remote or secpanel does not change along.
On the remote when I push ARM AWAY, I get this on the dashboard and log:
'Inbraak Alarm.: Normaal
'Afstandbediening': Beveiligd (Afwezig)
2017-12-17 14:28:12.260 (rfxtrx433e) Security (Afstandsbediening)
On the remote when I push DISARM, I get this on the dashboard and log:
'Inbraak Alarm.: Normaal
'Afstandbediening': Alarm uit
2017-12-17 14:29:00.667 (rfxtrx433e) Security (Afstandsbediening)
On the Domoticz Security Panel when I enter ARM AWAY, I get this on the dashboard and log:
'Inbraak Alarm.: Beveiligd (Afwezig)
'Afstandbediening': Beveiligd (Afwezig)
2017-12-17 14:30:57.064 LUA: ###
2017-12-17 14:30:57.067 LUA: SecPanel: status changed to Armed Away
2017-12-17 14:30:57.069 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 14:30:57.073 (Domoticz Internal) Security (Inbraak Alarm)
2017-12-17 14:30:57.087 (rfxtrx433e) Security (Afstandsbediening)
On the Domoticz Security Panel when I enter DISARMED, I get this on the dashboard and log:
'Inbraak Alarm.: Normaal
'Afstandbediening': Beveiligd (Afwezig)
2017-12-17 14:32:13.618 (Domoticz Internal) Security (Inbraak Alarm)
Many thanks
Jeroen
On the remote when I push ARM AWAY, I get this on the dashboard and log:
'Inbraak Alarm.: Normaal
'Afstandbediening': Beveiligd (Afwezig)
2017-12-17 14:28:12.260 (rfxtrx433e) Security (Afstandsbediening)
On the remote when I push DISARM, I get this on the dashboard and log:
'Inbraak Alarm.: Normaal
'Afstandbediening': Alarm uit
2017-12-17 14:29:00.667 (rfxtrx433e) Security (Afstandsbediening)
On the Domoticz Security Panel when I enter ARM AWAY, I get this on the dashboard and log:
'Inbraak Alarm.: Beveiligd (Afwezig)
'Afstandbediening': Beveiligd (Afwezig)
2017-12-17 14:30:57.064 LUA: ###
2017-12-17 14:30:57.067 LUA: SecPanel: status changed to Armed Away
2017-12-17 14:30:57.069 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 14:30:57.073 (Domoticz Internal) Security (Inbraak Alarm)
2017-12-17 14:30:57.087 (rfxtrx433e) Security (Afstandsbediening)
On the Domoticz Security Panel when I enter DISARMED, I get this on the dashboard and log:
'Inbraak Alarm.: Normaal
'Afstandbediening': Beveiligd (Afwezig)
2017-12-17 14:32:13.618 (Domoticz Internal) Security (Inbraak Alarm)
Many thanks
Jeroen
- jvdz
- Posts: 2328
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Lua code for Alarm Remote
So you are not getting any output from the print() statements in the script as they start with "###"?
This would indicate the if conditions are never met.
Maybe add this to at the top of the script to get some better informatio about the status change:
Jos
This would indicate the if conditions are never met.
Maybe add this to at the top of the script to get some better informatio about the status change:
Code: Select all
commandArray = {}
if devicechanged['Afstandsbediening'] then
print('###', 'Debug - Afstandsbediening changed to:' .. devicechanged['Afstandsbediening'])
print('###', 'Debug - Inbraak Alarm current status:' .. devicechanged['Inbraak Alarm'])
end
if devicechanged['Inbraak Alarm'] then
print('###', 'Debug - Inbraak Alarm changed to:' .. devicechanged['Inbraak Alarm'])
print('###', 'Debug - Afstandsbediening current status:' .. devicechanged['Afstandsbediening'])
end
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 10
- Joined: Saturday 16 December 2017 12:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua code for Alarm Remote
This is the final version I came up with, but there is a catch. Below is the log when I switch on and off the alarm through the remote and through the secpanel. On the 4th action, when I switch off the alarm through the secpanel, the remote remains in "arm away" state and will not return to "disarm" state. I think it has to do with the fact that when disarming through the inbraakalarm/security panel, its state is changed to "normal" and not "disarmed".
ARM AWAY THROUGH AFSTANDSBEDIENING
2017-12-17 22:19:29.457 LUA: ###
2017-12-17 22:19:29.458 LUA: Afstandsbediening status changed to Arm Away
2017-12-17 22:19:29.458 LUA: Security Panel current status is Disarmed
2017-12-17 22:19:29.458 LUA: ###
2017-12-17 22:19:29.458 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:19:29.468 (rfxtrx433e) Security (Afstandsbediening)
2017-12-17 22:20:30.947 LUA: ###
DISARM THROUGH AFSTANDSBEDIENING
2017-12-17 22:20:30.948 LUA: Inbraakalarm status changed to Arm Away
2017-12-17 22:20:30.948 LUA: Security Panel current status is Armed Away
2017-12-17 22:20:30.948 LUA: ###
2017-12-17 22:20:30.948 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:20:30.957 (Domoticz Internal) Security (Inbraakalarm)
2017-12-17 22:20:30.999 LUA: ###
2017-12-17 22:20:30.999 LUA: Afstandsbediening status changed to Arm Away
2017-12-17 22:20:31.000 LUA: Security Panel current status is Armed Away
2017-12-17 22:20:31.000 LUA: ###
2017-12-17 22:20:31.000 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:20:31.010 (rfxtrx433e) Security (Afstandsbediening)
2017-12-17 22:20:50.267 LUA: ###
2017-12-17 22:20:50.268 LUA: Afstandsbediening status changed to Disarm
2017-12-17 22:20:50.268 LUA: Security Panel current status is Armed Away
2017-12-17 22:20:50.268 LUA: ###
2017-12-17 22:20:50.268 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:20:50.279 (rfxtrx433e) Security (Afstandsbediening)
2017-12-17 22:20:50.319 LUA: ###
2017-12-17 22:20:50.319 LUA: Inbraakalarm status changed to Normal
2017-12-17 22:20:50.319 LUA: Security Panel current status is Disarmed
2017-12-17 22:20:50.319 LUA: ###
2017-12-17 22:20:50.329 (Domoticz Internal) Security (Inbraakalarm)
ARM AWAY THROUGH INBRAAKALARM
2017-12-17 22:23:27.011 LUA: ###
2017-12-17 22:23:27.013 LUA: Inbraakalarm status changed to Arm Away
2017-12-17 22:23:27.015 LUA: Security Panel current status is Armed Away
2017-12-17 22:23:27.016 LUA: ###
2017-12-17 22:23:27.018 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:23:27.028 (Domoticz Internal) Security (Inbraakalarm)
2017-12-17 22:23:27.050 LUA: ###
2017-12-17 22:23:27.050 LUA: Afstandsbediening status changed to Arm Away
2017-12-17 22:23:27.050 LUA: Security Panel current status is Armed Away
2017-12-17 22:23:27.050 LUA: ###
2017-12-17 22:23:27.051 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:23:27.060 (rfxtrx433e) Security (Afstandsbediening)
DISARM THROUGH INBRAAKALARM
2017-12-17 22:23:36.881 LUA: ###
2017-12-17 22:23:36.881 LUA: Inbraakalarm status changed to Normal
2017-12-17 22:23:36.881 LUA: Security Panel current status is Disarmed
2017-12-17 22:23:36.881 LUA: ###
2017-12-17 22:23:36.890 (Domoticz Internal) Security (Inbraakalarm)
-- filename: script_device_alarmremote.lua
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Arm Home') then
commandArray['Inbraakalarm'] = 'Arm Home'
elseif (devicechanged['Afstandsbediening'] == 'Arm Away') then
commandArray['Inbraakalarm'] = 'Arm Away'
elseif (devicechanged['Afstandsbediening'] == 'Disarm') then
commandArray['Inbraakalarm'] = 'Disarm'
elseif (devicechanged['Afstandsbediening'] == 'Panic') then
goto endoffile
end
if (devicechanged['Inbraakalarm'] == 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
elseif (devicechanged['Inbraakalarm'] == 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
elseif (devicechanged['Inbraakalarm'] == 'Disarm') then
commandArray['Afstandsbediening'] = 'Disarm'
end
if (devicechanged['Afstandsbediening'] or devicechanged['Inbraakalarm']) then
if devicechanged['Afstandsbediening'] then
print('###', 'Afstandsbediening status changed to ' .. devicechanged['Afstandsbediening'])
elseif devicechanged['Inbraakalarm'] then
print('###', 'Inbraakalarm status changed to ' .. devicechanged['Inbraakalarm'])
end
print('Security Panel current status is ' .. globalvariables['Security'], '###')
end
::endoffile::
return commandArray
ARM AWAY THROUGH AFSTANDSBEDIENING
2017-12-17 22:19:29.457 LUA: ###
2017-12-17 22:19:29.458 LUA: Afstandsbediening status changed to Arm Away
2017-12-17 22:19:29.458 LUA: Security Panel current status is Disarmed
2017-12-17 22:19:29.458 LUA: ###
2017-12-17 22:19:29.458 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:19:29.468 (rfxtrx433e) Security (Afstandsbediening)
2017-12-17 22:20:30.947 LUA: ###
DISARM THROUGH AFSTANDSBEDIENING
2017-12-17 22:20:30.948 LUA: Inbraakalarm status changed to Arm Away
2017-12-17 22:20:30.948 LUA: Security Panel current status is Armed Away
2017-12-17 22:20:30.948 LUA: ###
2017-12-17 22:20:30.948 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:20:30.957 (Domoticz Internal) Security (Inbraakalarm)
2017-12-17 22:20:30.999 LUA: ###
2017-12-17 22:20:30.999 LUA: Afstandsbediening status changed to Arm Away
2017-12-17 22:20:31.000 LUA: Security Panel current status is Armed Away
2017-12-17 22:20:31.000 LUA: ###
2017-12-17 22:20:31.000 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:20:31.010 (rfxtrx433e) Security (Afstandsbediening)
2017-12-17 22:20:50.267 LUA: ###
2017-12-17 22:20:50.268 LUA: Afstandsbediening status changed to Disarm
2017-12-17 22:20:50.268 LUA: Security Panel current status is Armed Away
2017-12-17 22:20:50.268 LUA: ###
2017-12-17 22:20:50.268 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:20:50.279 (rfxtrx433e) Security (Afstandsbediening)
2017-12-17 22:20:50.319 LUA: ###
2017-12-17 22:20:50.319 LUA: Inbraakalarm status changed to Normal
2017-12-17 22:20:50.319 LUA: Security Panel current status is Disarmed
2017-12-17 22:20:50.319 LUA: ###
2017-12-17 22:20:50.329 (Domoticz Internal) Security (Inbraakalarm)
ARM AWAY THROUGH INBRAAKALARM
2017-12-17 22:23:27.011 LUA: ###
2017-12-17 22:23:27.013 LUA: Inbraakalarm status changed to Arm Away
2017-12-17 22:23:27.015 LUA: Security Panel current status is Armed Away
2017-12-17 22:23:27.016 LUA: ###
2017-12-17 22:23:27.018 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:23:27.028 (Domoticz Internal) Security (Inbraakalarm)
2017-12-17 22:23:27.050 LUA: ###
2017-12-17 22:23:27.050 LUA: Afstandsbediening status changed to Arm Away
2017-12-17 22:23:27.050 LUA: Security Panel current status is Armed Away
2017-12-17 22:23:27.050 LUA: ###
2017-12-17 22:23:27.051 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-17 22:23:27.060 (rfxtrx433e) Security (Afstandsbediening)
DISARM THROUGH INBRAAKALARM
2017-12-17 22:23:36.881 LUA: ###
2017-12-17 22:23:36.881 LUA: Inbraakalarm status changed to Normal
2017-12-17 22:23:36.881 LUA: Security Panel current status is Disarmed
2017-12-17 22:23:36.881 LUA: ###
2017-12-17 22:23:36.890 (Domoticz Internal) Security (Inbraakalarm)
-- filename: script_device_alarmremote.lua
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Arm Home') then
commandArray['Inbraakalarm'] = 'Arm Home'
elseif (devicechanged['Afstandsbediening'] == 'Arm Away') then
commandArray['Inbraakalarm'] = 'Arm Away'
elseif (devicechanged['Afstandsbediening'] == 'Disarm') then
commandArray['Inbraakalarm'] = 'Disarm'
elseif (devicechanged['Afstandsbediening'] == 'Panic') then
goto endoffile
end
if (devicechanged['Inbraakalarm'] == 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
elseif (devicechanged['Inbraakalarm'] == 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
elseif (devicechanged['Inbraakalarm'] == 'Disarm') then
commandArray['Afstandsbediening'] = 'Disarm'
end
if (devicechanged['Afstandsbediening'] or devicechanged['Inbraakalarm']) then
if devicechanged['Afstandsbediening'] then
print('###', 'Afstandsbediening status changed to ' .. devicechanged['Afstandsbediening'])
elseif devicechanged['Inbraakalarm'] then
print('###', 'Inbraakalarm status changed to ' .. devicechanged['Inbraakalarm'])
end
print('Security Panel current status is ' .. globalvariables['Security'], '###')
end
::endoffile::
return commandArray
- jvdz
- Posts: 2328
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Lua code for Alarm Remote
That is why I suggested to add those debug statements so you can actually see what i happening. So did you try changing it to "Normal"?counterstrike wrote: ↑Sunday 17 December 2017 22:32 On the 4th action, when I switch off the alarm through the secpanel, the remote remains in "arm away" state and will not return to "disarm" state. I think it has to do with the fact that when disarming through the inbraakalarm/security panel, its state is changed to "normal" and not "disarmed".
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 10
- Joined: Saturday 16 December 2017 12:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua code for Alarm Remote
This is what I have now to address that issue, but it is going now through an infinite loop, it keeps throwing out messages on the log every second.
-- filename: script_device_alarmremote.lua
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Panic') then
goto endoffile
elseif (devicechanged['Afstandsbediening'] == 'Arm Home') then
commandArray['Inbraakalarm'] = 'Arm Home'
elseif (devicechanged['Afstandsbediening'] == 'Arm Away') then
commandArray['Inbraakalarm'] = 'Arm Away'
elseif (devicechanged['Afstandsbediening'] == 'Disarm') then
commandArray['Inbraakalarm'] = 'Disarm'
end
if (devicechanged['Inbraakalarm'] == 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
elseif (devicechanged['Inbraakalarm'] == 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
elseif (devicechanged['Inbraakalarm'] == 'Normal') then
commandArray['Afstandsbediening'] = 'Disarm'
end
if (devicechanged['Afstandsbediening'] or devicechanged['Inbraakalarm']) then
if devicechanged['Afstandsbediening'] then
print('###', 'Afstandsbediening status changed to: ' .. devicechanged['Afstandsbediening'])
elseif devicechanged['Inbraakalarm'] then
print('###', 'Inbraakalarm status changed to: ' .. devicechanged['Inbraakalarm'])
end
print('Security Panel current status is: ' .. globalvariables['Security'], '###')
end
::endoffile::
return commandArray
2017-12-18 00:21:18.516 LUA: ###
2017-12-18 00:21:18.516 LUA: Inbraakalarm status changed to: Normal
2017-12-18 00:21:18.516 LUA: Security Panel current status is: Disarmed
2017-12-18 00:21:18.516 LUA: ###
2017-12-18 00:21:18.516 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-18 00:21:18.524 (Domoticz Internal) Security (Inbraakalarm)
2017-12-18 00:21:18.575 LUA: ###
2017-12-18 00:21:18.575 LUA: Afstandsbediening status changed to: Disarm
2017-12-18 00:21:18.575 LUA: Security Panel current status is: Disarmed
2017-12-18 00:21:18.575 LUA: ###
2017-12-18 00:21:18.576 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-18 00:21:18.584 (rfxtrx433e) Security (Afstandsbediening)
2017-12-18 00:17:31.084 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
-- filename: script_device_alarmremote.lua
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Panic') then
goto endoffile
elseif (devicechanged['Afstandsbediening'] == 'Arm Home') then
commandArray['Inbraakalarm'] = 'Arm Home'
elseif (devicechanged['Afstandsbediening'] == 'Arm Away') then
commandArray['Inbraakalarm'] = 'Arm Away'
elseif (devicechanged['Afstandsbediening'] == 'Disarm') then
commandArray['Inbraakalarm'] = 'Disarm'
end
if (devicechanged['Inbraakalarm'] == 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
elseif (devicechanged['Inbraakalarm'] == 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
elseif (devicechanged['Inbraakalarm'] == 'Normal') then
commandArray['Afstandsbediening'] = 'Disarm'
end
if (devicechanged['Afstandsbediening'] or devicechanged['Inbraakalarm']) then
if devicechanged['Afstandsbediening'] then
print('###', 'Afstandsbediening status changed to: ' .. devicechanged['Afstandsbediening'])
elseif devicechanged['Inbraakalarm'] then
print('###', 'Inbraakalarm status changed to: ' .. devicechanged['Inbraakalarm'])
end
print('Security Panel current status is: ' .. globalvariables['Security'], '###')
end
::endoffile::
return commandArray
2017-12-18 00:21:18.516 LUA: ###
2017-12-18 00:21:18.516 LUA: Inbraakalarm status changed to: Normal
2017-12-18 00:21:18.516 LUA: Security Panel current status is: Disarmed
2017-12-18 00:21:18.516 LUA: ###
2017-12-18 00:21:18.516 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-18 00:21:18.524 (Domoticz Internal) Security (Inbraakalarm)
2017-12-18 00:21:18.575 LUA: ###
2017-12-18 00:21:18.575 LUA: Afstandsbediening status changed to: Disarm
2017-12-18 00:21:18.575 LUA: Security Panel current status is: Disarmed
2017-12-18 00:21:18.575 LUA: ###
2017-12-18 00:21:18.576 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
2017-12-18 00:21:18.584 (rfxtrx433e) Security (Afstandsbediening)
2017-12-18 00:17:31.084 EventSystem: Script event triggered: /usr/src/domoticz/scripts/lua/script_device_alarmremote.lua
- jvdz
- Posts: 2328
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Lua code for Alarm Remote
That is what I already promised you in the first reply!counterstrike wrote: ↑Monday 18 December 2017 0:21 This is what I have now to address that issue, but it is going now through an infinite loop, it keeps throwing out messages on the log every second.

try something like this to fix that:
Code: Select all
-- filename: script_device_alarmremote.lua
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Panic') then
goto endoffile
elseif (devicechanged['Afstandsbediening'] == 'Arm Home' and globalvariables['Security'] ~= 'Armed Home') then
commandArray['Inbraakalarm'] = 'Arm Home'
elseif (devicechanged['Afstandsbediening'] == 'Arm Away' and globalvariables['Security'] ~= 'Armed Away') then
commandArray['Inbraakalarm'] = 'Arm Away'
elseif (devicechanged['Afstandsbediening'] == 'Disarm' and globalvariables['Security'] ~= 'Disarmed') then
commandArray['Inbraakalarm'] = 'Disarm'
end
if (devicechanged['Inbraakalarm'] == 'Arm Home' and otherdevices['Afstandsbediening'] ~= 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
elseif (devicechanged['Inbraakalarm'] == 'Arm Away' and otherdevices['Afstandsbediening'] ~= 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
elseif (devicechanged['Inbraakalarm'] == 'Normal' and otherdevices['Afstandsbediening'] ~= 'Disarm') then
commandArray['Afstandsbediening'] = 'Disarm'
end
if (devicechanged['Afstandsbediening'] or devicechanged['Inbraakalarm']) then
if devicechanged['Afstandsbediening'] then
print('###', 'Afstandsbediening status changed to: ' .. devicechanged['Afstandsbediening'])
elseif devicechanged['Inbraakalarm'] then
print('###', 'Inbraakalarm status changed to: ' .. devicechanged['Inbraakalarm'])
end
print('Security Panel current status is: ' .. globalvariables['Security'], '###')
end
::endoffile::
return commandArray
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 10
- Joined: Saturday 16 December 2017 12:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua code for Alarm Remote
This seems to work a lot better. I have added the Panic option as well. The only part that isnt working yet is when both the Afstandsbediening and Inbraakalarm are at status "Arm Away", switching to "disarm" with the Afstandsbediening does not change the Inbraakalarm status to "disarm", it just remains "Arm Away".
-- filename: script_device_alarmremote.lua
-- content: lua script for marmitek sh600 remote control interaction with Domoticz security panel
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Panic' and globalvariables['Security'] ~= 'Panic') then
globalvariables['Security'] = 'Panic'
elseif (devicechanged['Afstandsbediening'] == 'No Panic' and globalvariables['Security'] == 'Panic') then
globalvariables['Security'] = 'No Panic'
commandArray['Alarm Sirene'] = 'Off'
end
if (devicechanged['Afstandsbediening'] == 'Arm Home' and globalvariables['Security'] ~= 'Armed Home') then
commandArray['Inbraakalarm'] = 'Arm Home'
elseif (devicechanged['Afstandsbediening'] == 'Arm Away' and globalvariables['Security'] ~= 'Armed Away') then
commandArray['Inbraakalarm'] = 'Arm Away'
elseif (devicechanged['Afstandsbediening'] == 'Disarmed') then
commandArray['Inbraakalarm'] = 'Disarm'
commandArray['Alarm Sirene'] = 'Off'
end
if (devicechanged['Inbraakalarm'] == 'Arm Home' and otherdevices['Afstandsbediening'] ~= 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
elseif (devicechanged['Inbraakalarm'] == 'Arm Away' and otherdevices['Afstandsbediening'] ~= 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
elseif (devicechanged['Inbraakalarm'] == 'Normal' and otherdevices['Afstandsbediening'] ~= 'Disarm') then
commandArray['Afstandsbediening'] = 'Disarm'
commandArray['Alarm Sirene'] = 'Off'
end
if (devicechanged['Afstandsbediening'] or devicechanged['Inbraakalarm']) then
elseif devicechanged['Afstandsbediening'] then
print('###', 'Afstandsbediening status changed to: ' .. devicechanged['Afstandsbediening'])
print('Inbraakalarm status remains: ' .. otherdevices['Inbraakalarm'])
if devicechanged['Inbraakalarm'] then
print('###', 'Inbraakalarm status changed to: ' .. devicechanged['Inbraakalarm'])
print('Afstandsbediening status remains: ' .. globalvariables['Afstandsbediening'])
end
print('Security Panel current status is: ' .. globalvariables['Security'], '###')
end
return commandArray
-- filename: script_device_alarmremote.lua
-- content: lua script for marmitek sh600 remote control interaction with Domoticz security panel
commandArray = {}
if (devicechanged['Afstandsbediening'] == 'Panic' and globalvariables['Security'] ~= 'Panic') then
globalvariables['Security'] = 'Panic'
elseif (devicechanged['Afstandsbediening'] == 'No Panic' and globalvariables['Security'] == 'Panic') then
globalvariables['Security'] = 'No Panic'
commandArray['Alarm Sirene'] = 'Off'
end
if (devicechanged['Afstandsbediening'] == 'Arm Home' and globalvariables['Security'] ~= 'Armed Home') then
commandArray['Inbraakalarm'] = 'Arm Home'
elseif (devicechanged['Afstandsbediening'] == 'Arm Away' and globalvariables['Security'] ~= 'Armed Away') then
commandArray['Inbraakalarm'] = 'Arm Away'
elseif (devicechanged['Afstandsbediening'] == 'Disarmed') then
commandArray['Inbraakalarm'] = 'Disarm'
commandArray['Alarm Sirene'] = 'Off'
end
if (devicechanged['Inbraakalarm'] == 'Arm Home' and otherdevices['Afstandsbediening'] ~= 'Arm Home') then
commandArray['Afstandsbediening'] = 'Arm Home'
elseif (devicechanged['Inbraakalarm'] == 'Arm Away' and otherdevices['Afstandsbediening'] ~= 'Arm Away') then
commandArray['Afstandsbediening'] = 'Arm Away'
elseif (devicechanged['Inbraakalarm'] == 'Normal' and otherdevices['Afstandsbediening'] ~= 'Disarm') then
commandArray['Afstandsbediening'] = 'Disarm'
commandArray['Alarm Sirene'] = 'Off'
end
if (devicechanged['Afstandsbediening'] or devicechanged['Inbraakalarm']) then
elseif devicechanged['Afstandsbediening'] then
print('###', 'Afstandsbediening status changed to: ' .. devicechanged['Afstandsbediening'])
print('Inbraakalarm status remains: ' .. otherdevices['Inbraakalarm'])
if devicechanged['Inbraakalarm'] then
print('###', 'Inbraakalarm status changed to: ' .. devicechanged['Inbraakalarm'])
print('Afstandsbediening status remains: ' .. globalvariables['Afstandsbediening'])
end
print('Security Panel current status is: ' .. globalvariables['Security'], '###')
end
return commandArray
- jvdz
- Posts: 2328
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Lua code for Alarm Remote
So what does the debug statements tell you when this happens so we can verify the Logic in the script?counterstrike wrote: ↑Tuesday 19 December 2017 11:20 This seems to work a lot better. I have added the Panic option as well. The only part that isnt working yet is when both the Afstandsbediening and Inbraakalarm are at status "Arm Away", switching to "disarm" with the Afstandsbediening does not change the Inbraakalarm status to "disarm", it just remains "Arm Away".
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Who is online
Users browsing this forum: Google [Bot] and 1 guest