Page 1 of 1

[Solved] LUA script with beacon key + Security Panel

Posted: Wednesday 01 July 2020 13:32
by McJohn
We struggle with the script below. It won't "fire".
The script is working well without the text "and (otherdevices['Domoticz Security Panel'] == 'Disarmed')) then"
But what we want is that it only works when the Security Panel is "Disarmed" or when it is "Arm Away"

What have we done wrong?

Thanks in advance for the support.

Code: Select all

commandArray = {}
 if ((devicechanged['Beacon key'] == 'Off') and (otherdevices['Domoticz Security Panel'] == 'Disarm')) then
    commandArray['Domoticz Security Panel'] = 'Arm Away'
    commandArray['Variable:Security'] = 'On'
 else
 if ((devicechanged['Beacon key'] == 'On') and (otherdevices['Domoticz Security Panel'] == 'Arm Away')) then
    commandArray['Domoticz Security Panel'] = 'Disarm'
    commandArray['Variable:Security']= 'Off'
 end
 end
return commandArray

Re: LUA script with beacon key + Security Panel

Posted: Wednesday 01 July 2020 15:39
by jvdz
You are testing for the wrong value. They should be one of these:

Code: Select all

globalvariables['Security'] = 'Disarmed'    -- or  'Armed Home' or 'Armed Away'
So guess this should do it:

Code: Select all

commandArray = {}
 if ((devicechanged['Beacon key'] == 'Off') and (globalvariables['Security'] == 'Disarmed')) then
    commandArray['Domoticz Security Panel'] = 'Arm Away'
    commandArray['Variable:Security'] = 'On'
 else
 if ((devicechanged['Beacon key'] == 'On') and (globalvariables['Security'] == 'Armed Away')) then
    commandArray['Domoticz Security Panel'] = 'Disarm'
    commandArray['Variable:Security']= 'Off'
 end
 end
return commandArray
Jos :D

Re: LUA script with beacon key + Security Panel

Posted: Wednesday 01 July 2020 16:59
by McJohn
Jos! Friend!

Thank you so much for the quick reply.
It's working, fast and smooth!

(I saw you are the expert in this field, sorry for the simple question but sometimes the Domoticz Security Panel is a "device" and sometimes a variable).

All the best

John :)