[Solved] LUA script with beacon key + Security Panel

Moderator: leecollings

Post Reply
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

[Solved] LUA script with beacon key + Security Panel

Post 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
Last edited by McJohn on Wednesday 01 July 2020 17:29, edited 1 time in total.
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: LUA script with beacon key + Security Panel

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: LUA script with beacon key + Security Panel

Post 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 :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest