Cannot change Alarm state in LUA script
Moderator: leecollings
-
- Posts: 10
- Joined: Friday 17 July 2015 10:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Cannot change Alarm state in LUA script
Hi All,
I made a dummy switch(name: SetSecurity) to toggle the alarm status. It triggers the LUA script, but it doesn't really work. It seems tot change the "otherdevices['Domoticz Security Panel'" to normal state, but will not set the status. It seems not to remember....
What am i doing wrong?
Tnx
commandArray = {}
print("______________________________________________________________")
print(otherdevices["Domoticz Security Panel"])
if (devicechanged['SetSecurity'] == 'On') then
print('Wanna arm:')
print(otherdevices["Domoticz Security Panel"])
otherdevices['Domoticz Security Panel'] = 'Arm Home'
print(otherdevices["Domoticz Security Panel"])
end
if (devicechanged['SetSecurity'] == 'Off') then
print('Wanna disarm:')
print(otherdevices["Domoticz Security Panel"])
otherdevices['Domoticz Security Panel'] = 'Normal'
print(otherdevices["Domoticz Security Panel"])
end
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
--Arm Home
return commandArray
2018-02-08 16:01:33.888 User: XXXXinitiated a switch command (1388/SetSecurity/Off)
2018-02-08 16:01:34.009 dzVents: Device based event fired on 'SetSecurity', value 'Off'
2018-02-08 16:01:34.019 dzVents: All based event fired
2018-02-08 16:01:34.025 dzVents: ______________________________________________________________
2018-02-08 16:01:34.025 dzVents: Arm Home
2018-02-08 16:01:34.025 dzVents: Wanna disarm:
2018-02-08 16:01:34.025 dzVents: Arm Home
2018-02-08 16:01:34.025 dzVents: Normal
2018-02-08 16:01:34.025 dzVents: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2018-02-08 16:01:34.026 (DummyHardware) Lighting 2 (SetSecurity)
2018-02-08 16:01:52.793 User: XXXXinitiated a switch command (1388/SetSecurity/On)
2018-02-08 16:01:52.907 dzVents: Device based event fired on 'SetSecurity', value 'On'
2018-02-08 16:01:52.917 dzVents: All based event fired
2018-02-08 16:01:52.924 dzVents: ______________________________________________________________
2018-02-08 16:01:52.924 dzVents: Arm Home
2018-02-08 16:01:52.924 dzVents: Wanna arm:
2018-02-08 16:01:52.924 dzVents: Arm Home
2018-02-08 16:01:52.924 dzVents: Arm Home
2018-02-08 16:01:52.924 dzVents: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2018-02-08 16:01:52.925 (DummyHardware) Lighting 2 (SetSecurity)
2018-02-08 16:02:00.506 dzVents: Time based event fired
2018-02-08 16:02:00.513 dzVents: All based event fired
https://snag.gy/dpIt7D.jpg
I made a dummy switch(name: SetSecurity) to toggle the alarm status. It triggers the LUA script, but it doesn't really work. It seems tot change the "otherdevices['Domoticz Security Panel'" to normal state, but will not set the status. It seems not to remember....
What am i doing wrong?
Tnx
commandArray = {}
print("______________________________________________________________")
print(otherdevices["Domoticz Security Panel"])
if (devicechanged['SetSecurity'] == 'On') then
print('Wanna arm:')
print(otherdevices["Domoticz Security Panel"])
otherdevices['Domoticz Security Panel'] = 'Arm Home'
print(otherdevices["Domoticz Security Panel"])
end
if (devicechanged['SetSecurity'] == 'Off') then
print('Wanna disarm:')
print(otherdevices["Domoticz Security Panel"])
otherdevices['Domoticz Security Panel'] = 'Normal'
print(otherdevices["Domoticz Security Panel"])
end
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
--Arm Home
return commandArray
2018-02-08 16:01:33.888 User: XXXXinitiated a switch command (1388/SetSecurity/Off)
2018-02-08 16:01:34.009 dzVents: Device based event fired on 'SetSecurity', value 'Off'
2018-02-08 16:01:34.019 dzVents: All based event fired
2018-02-08 16:01:34.025 dzVents: ______________________________________________________________
2018-02-08 16:01:34.025 dzVents: Arm Home
2018-02-08 16:01:34.025 dzVents: Wanna disarm:
2018-02-08 16:01:34.025 dzVents: Arm Home
2018-02-08 16:01:34.025 dzVents: Normal
2018-02-08 16:01:34.025 dzVents: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2018-02-08 16:01:34.026 (DummyHardware) Lighting 2 (SetSecurity)
2018-02-08 16:01:52.793 User: XXXXinitiated a switch command (1388/SetSecurity/On)
2018-02-08 16:01:52.907 dzVents: Device based event fired on 'SetSecurity', value 'On'
2018-02-08 16:01:52.917 dzVents: All based event fired
2018-02-08 16:01:52.924 dzVents: ______________________________________________________________
2018-02-08 16:01:52.924 dzVents: Arm Home
2018-02-08 16:01:52.924 dzVents: Wanna arm:
2018-02-08 16:01:52.924 dzVents: Arm Home
2018-02-08 16:01:52.924 dzVents: Arm Home
2018-02-08 16:01:52.924 dzVents: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2018-02-08 16:01:52.925 (DummyHardware) Lighting 2 (SetSecurity)
2018-02-08 16:02:00.506 dzVents: Time based event fired
2018-02-08 16:02:00.513 dzVents: All based event fired
https://snag.gy/dpIt7D.jpg
-
- Posts: 10
- Joined: Friday 17 July 2015 10:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Cannot change Alarm state in LUA script
Did another try today, but did not succeed ... anybody?
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Cannot change Alarm state in LUA script
it is NOT 'Normal'
it is 'Disarm'
it is 'Disarm'
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 10
- Joined: Friday 17 July 2015 10:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Cannot change Alarm state in LUA script
Hi Emme,
Thank you for your reply.
Disarm isn't working either. The value of otherdevices["Domoticz Security Panel"] is "Normal" if i use the Panel with a code.
That's why I was using "Normal".
Thank you for your reply.
Disarm isn't working either. The value of otherdevices["Domoticz Security Panel"] is "Normal" if i use the Panel with a code.
That's why I was using "Normal".
-
- Posts: 10
- Joined: Friday 17 July 2015 10:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Cannot change Alarm state in LUA script
mmm, cannot insert image
Link image of different states of the varable:
https://pasteboard.co/H7LK93n.jpg
Link image of different states of the varable:
https://pasteboard.co/H7LK93n.jpg
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Cannot change Alarm state in LUA script
I'm quite sure it should be 'Disarm'
do Arm Home and Arm Away work as they are supposed to?
is the panel name correct?
Are you using a linux based hardware?
do Arm Home and Arm Away work as they are supposed to?
is the panel name correct?
Are you using a linux based hardware?
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Cannot change Alarm state in LUA script
Correct! the command to get the state to Normal/DIsarmed is "Disarm".
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 10
- Joined: Friday 17 July 2015 10:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Cannot change Alarm state in LUA script
I'm indeed on a Raspberry Pi. Does that make a difference?
The screenshot above is a when i Arm/disarm manualy with a code in de security panel.
But setting it to Disarm doesn't make a difference. It's like it doesn't rememeber it after I leave the Lua script
The screenshot above is a when i Arm/disarm manualy with a code in de security panel.
But setting it to Disarm doesn't make a difference. It's like it doesn't rememeber it after I leave the Lua script
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Cannot change Alarm state in LUA script
uh oh.... I think I got it!
print(otherdevices["Domoticz Security Panel"])
otherdevices['Domoticz Security Panel'] = 'Disarm'
print(otherdevices["Domoticz Security Panel"])
please note that the second print will STILL display Armed Home... the commandarray is executed at the end of the script so, you will see Armed Home, but if tyou check the log you should see Normal!!!
the script runs correctly (except tha tyou have to issue Disarm and not Normal) but you cannot get the right state
print(otherdevices["Domoticz Security Panel"])
otherdevices['Domoticz Security Panel'] = 'Disarm'
print(otherdevices["Domoticz Security Panel"])
please note that the second print will STILL display Armed Home... the commandarray is executed at the end of the script so, you will see Armed Home, but if tyou check the log you should see Normal!!!
the script runs correctly (except tha tyou have to issue Disarm and not Normal) but you cannot get the right state
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Cannot change Alarm state in LUA script
this is the same script in dzVents
I have only added a second check to arm/disarm only in case the system is not already armed/disarmed
Code: Select all
return {
on = {
devices = { 'SetSecurity' },
},
logging = {
level = domoticz.LOG_INFO,
marker = '[SET SECURITY]'
},
execute = function(dz, device)
dz.log('______________________________________________________________')
local secPanel = dz.devices('Domoticz Security Panel')
dz.log('Actual security State ==> '..secPanel.state)
if device.state == 'On' and secPanel.state:gsub(1,3) ~= 'Arm' then
dz.log('Wanna arm!')
secPanel.armHome()
elseif device.state == 'On' and secPanel.state:gsub(1,3) == 'Arm' then
dz.log('Wanna Disarm!')
secPanel.disarm()
end
dz.log('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
end
}
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 10
- Joined: Friday 17 July 2015 10:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Cannot change Alarm state in LUA script
Thank you for thinking along with me!emme wrote: ↑Thursday 15 February 2018 18:18 uh oh.... I think I got it!
print(otherdevices["Domoticz Security Panel"])
otherdevices['Domoticz Security Panel'] = 'Disarm'
print(otherdevices["Domoticz Security Panel"])
please note that the second print will STILL display Armed Home... the commandarray is executed at the end of the script so, you will see Armed Home, but if tyou check the log you should see Normal!!!
the script runs correctly (except tha tyou have to issue Disarm and not Normal) but you cannot get the right state
But... the second print is displaying it correct:
2018-02-08 16:01:34.025 dzVents: Arm Home
2018-02-08 16:01:34.025 dzVents: Wanna disarm:
2018-02-08 16:01:34.025 dzVents: Arm Home
2018-02-08 16:01:34.025 dzVents: Normal
2018-02-08 16:01:34.025 dzVents: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
it display's "normal", but it seems not to remember the state.
Really don't understand... I will do a new install on another rasp....
-
- Posts: 10
- Joined: Friday 17 July 2015 10:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Cannot change Alarm state in LUA script
Yeah, got it....
ok here goes:
The status of "Security Panel" when disarmed is "Normal"
To change the state of Security Panel, set it to "Disarm"
I used otherdevices['Security Panel'] = 'Normal' and otherdevices['Security Panel'] = 'Disarm'
But they didn't work. Set the status with commandArray, not otherdevices
commandArray['Security Panel'] = 'Disarm' Works like a charm!
ok here goes:
The status of "Security Panel" when disarmed is "Normal"
To change the state of Security Panel, set it to "Disarm"
I used otherdevices['Security Panel'] = 'Normal' and otherdevices['Security Panel'] = 'Disarm'
But they didn't work. Set the status with commandArray, not otherdevices
commandArray['Security Panel'] = 'Disarm' Works like a charm!
Who is online
Users browsing this forum: No registered users and 1 guest