Page 1 of 1

Alarm Trigger Event via LUA (solved)

Posted: Saturday 18 March 2017 1:29
by roy1982hd
Hi everybody,

My LUA-intruder-alarm-event seems to contain a small mistake.

Protocol says:
Error: EventSystem: in Alarmfall Einbruch: [string "commandArray = {} ..."]:4: ')' expected near '='
Here's the event-code:

Code: Select all

commandArray = {}
 if (devicechanged['FensterOderTuerOffen']) then
        if (otherdevices['FensterOderTuerOffen'] == 'On') then
                if (otherdevices['Domoticz Security Panel'] = 'Arm Away') then
                    commandArray['Group:Alarmmelder']='On FOR 60'
                    print('Einbruch! Alarmmelder angeschaltet für 60 Minuten!')
                elseif (otherdevices['Domoticz Security Panel'] = 'Disarm') then
                    print('Tür oder Fenster wurde geöffnet')
                end
        else
                print('Alle Türen und Fenster geschlossen')
        end
end
return commandArray
Can anyone help me to find the mistake? Where is the bracket missing?

Thanks in advance!

Re: Alarm Trigger Event via LUA / Can't find the mistake

Posted: Saturday 18 March 2017 1:42
by jvdz
if (otherdevices['Domoticz Security Panel'] = 'Arm Away') then
should be
if (otherdevices['Domoticz Security Panel'] == 'Arm Away') then

and
elseif (otherdevices['Domoticz Security Panel'] = 'Disarm') then
should be
elseif (otherdevices['Domoticz Security Panel'] == 'Disarm') then
Jos

Re: Alarm Trigger Event via LUA / Can't find the mistake

Posted: Saturday 18 March 2017 2:16
by roy1982hd
Thank you very much, Jos!

Just tested it and the alarm-event works now!



I) ALARM TRIGGER EVENT
1) FensterOderTuerOffen' = is a virtual device that is a parent switch of all door and window-sensors
2) 'Alarmmelder' = is a group that controls all sirens/smoke detectors

Code:

Code: Select all

commandArray = {}
 if (devicechanged['FensterOderTuerOffen']) then
        if (otherdevices['FensterOderTuerOffen'] == 'On') then
                if (otherdevices['Domoticz Security Panel'] == 'Arm Away') then
                    commandArray['Group:Alarmmelder']='On FOR 60'
                    print('Einbruch! Alarmmelder angeschaltet für 60 Minuten!')
                elseif (otherdevices['Domoticz Security Panel'] == 'Disarm') then
                    print('Tür oder Fenster wurde geöffnet')
                end
        else
                print('Alle Türen und Fenster geschlossen')
        end
end
return commandArray

----------------------------------

II) Zipato RFID Keypad EVENT

With a second event I control the actions of a Zipato RFID Keypad.
If the Zipato is switched to "Away", the Security Panel is switched to "Arm Away" and two Zipato RGBW bulbs (one inside and one outside of the front door of our house) give an orange light ... like a security status LED.
If the Zipato is switched to "Home", the Security Panel is switched to "Disarm" and the bulbs light in green colour and then switch off after some seconds.

Code:

Code: Select all

commandArray = {}
 if (devicechanged['Keypad']) then
        if (otherdevices['Keypad'] == 'On') then
                print('AlarmPanel Arm Away')
                commandArray['Domoticz Security Panel'] = 'Arm Away'
                commandArray['Group:Alarmstatuslampen orange']='On'
        else
                print('AlarmPanel Disarm')
                commandArray['Domoticz Security Panel'] = 'Disarm'
                commandArray['Group:Alarmmelder']='Off'
                commandArray['Group:Alarmstatuslampen grün']='On'
                commandArray['Alarmstatuslampe innen']='Off AFTER 10'
                commandArray['Alarmstatuslampe außen']='Off AFTER 10'
        end
end
return commandArray