Hello,
I want to change the globalvariable security to "Arm away" in a lua script. But it seems not to work. Perhaps it is impossible, or I don't know the correct syntax. Can anybody help me?
commandArray['Security']='Arm Away'
commandArray['globalvariables:Security']='Arm Away'
What is correct? Thanks
changing security via LUA
Moderator: leecollings
-
- Posts: 184
- Joined: Sunday 13 November 2016 10:43
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Germany
- Contact:
- jvdz
- Posts: 2332
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: changing security via LUA
This should work fine:
Jos
Code: Select all
commandArray['SecPanel']='Arm Home'
commandArray['SecPanel']='Arm Away'
commandArray['SecPanel']='Disarm'
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 184
- Joined: Sunday 13 November 2016 10:43
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Germany
- Contact:
Re: changing security via LUA
Hello Jos,
thanks for the reply. I include it in my script (it is a device-based-lua script) but it seems not to work.
if (devicechanged['Sicherheit'] == 'On') then
print ( globalvariables['Security'] )
commandArray['SecPanel']='Arm Away'
print ( globalvariables['Security'] )
end
For the print statmements I see the following in the log:
2017-01-28 13:29:48.042 User: Admin initiated a switch command (94/Sicherheit/On)
2017-01-28 13:29:48.050 LUA: Disarmed
2017-01-28 13:29:48.050 LUA: Disarmed
So security hasn't changed. I also see it, because I have a security script which doesn't start. When I change security status via the security panel the script starts.
thanks for the reply. I include it in my script (it is a device-based-lua script) but it seems not to work.
if (devicechanged['Sicherheit'] == 'On') then
print ( globalvariables['Security'] )
commandArray['SecPanel']='Arm Away'
print ( globalvariables['Security'] )
end
For the print statmements I see the following in the log:
2017-01-28 13:29:48.042 User: Admin initiated a switch command (94/Sicherheit/On)
2017-01-28 13:29:48.050 LUA: Disarmed
2017-01-28 13:29:48.050 LUA: Disarmed
So security hasn't changed. I also see it, because I have a security script which doesn't start. When I change security status via the security panel the script starts.
-
- Posts: 184
- Joined: Sunday 13 November 2016 10:43
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Germany
- Contact:
Re: changing security via LUA
I could fix it myself. I had to set a password for the security panel, arm it and then I saw it as a switch. Then it worked.
- jvdz
- Posts: 2332
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: changing security via LUA
That is because it isn't change at the time you fill the TAble, but rather processed after the LUA script ends.
Look at the domoticz.log to see if the security setting changed after the script completed.
You could also create a LUA script called: script_security_panel-changes.lua and add this into it:
Jos
Look at the domoticz.log to see if the security setting changed after the script completed.
You could also create a LUA script called: script_security_panel-changes.lua and add this into it:
Code: Select all
commandArray = {}
printlog('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
return commandArray
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
- jvdz
- Posts: 2332
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: changing security via LUA
I see I was answering while you posted this.harrykausl wrote:I could fix it myself. I had to set a password for the security panel, arm it and then I saw it as a switch. Then it worked.
Good to hear it worked now!
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 184
- Joined: Sunday 13 November 2016 10:43
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Germany
- Contact:
Re: changing security via LUA
@Jos: Thanks!
Who is online
Users browsing this forum: No registered users and 1 guest