Set security armed/disarmed by switch

Moderator: leecollings

Niekoesj
Posts: 5
Joined: Friday 14 February 2014 6:22
Target OS: Linux
Domoticz version:
Contact:

Set security armed/disarmed by switch

Post by Niekoesj »

Hi all,

Just purchased a keychain remote controller http://www.klikaanklikuit.nl/shop/produ ... -akct-511/

I tried to build a event that if the remote is presses I, the security turns to "Armed". And if i press O, the security gets disarmed.
But it seems that the security panel can't change from status by switches or other conditions? :)
Luuc_a
Posts: 24
Joined: Tuesday 16 July 2013 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Set security armed/disarmed by switch

Post by Luuc_a »

You have to do this with a lua script

Example

Code: Select all

commandArray = {}
if (devicechanged['<Switch Name>'] == 'On') then
        commandArray['Security panel'] = 'Arm Away'
end
if (devicechanged['<Switch Name>'] == 'Off') then
    commandArray['Security panel'] = 'Disarm'
end
Return commandArray
Niekoesj
Posts: 5
Joined: Friday 14 February 2014 6:22
Target OS: Linux
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by Niekoesj »

Hi Luuc_a !

Thanks for the tip, i'll check this later today to see if this works :mrgreen:
Niekoesj
Posts: 5
Joined: Friday 14 February 2014 6:22
Target OS: Linux
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by Niekoesj »

I tried this but it ain't seems to work yet :(

Code: Select all

print('this will end up in the domoticz log')

commandArray = {}
if (devicechanged['Sleutel 1'] == 'Group On') then
        commandArray['Security'] = 'Armed Away'
end
if (devicechanged['Sleutel 1'] == 'Group On') then
    commandArray['Security'] = 'Disarmed'
end
Return commandArray
Vicne
Posts: 4
Joined: Saturday 21 December 2013 15:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by Vicne »

Hi,

I'm currently playing with the same feature (using revision 1522) and I admit the behaviour is somewhat puzzling.

What I see is that :
- the two armed statuses should be spelled "Arm Home" and "Arm Away", like Luuc_a wrote, not "Armed" like you did. On the security panel screen, both expressions are present: http://screencast.com/t/TYK6fW4VVomO
- although the button on the panel is named "Disarm" and X10 security send the "Disarm" command and the status displayed on the security panel is then "Disarmed", the actual status of the security panel in disarmed mode is "Normal", not "Disarm"
- of course, the name you gave the Security Panel in your UI should match the one in your scripts. It seems domoticz can handle only one device of type "Security panel", so no matter the name you give it, if you open it using the "/secpanel" page (by clicking on its icon on the dashboard or via Setup > More Options > Security panel, you will change the status of that only security panel
- note that when switching to "Arm Home" or "Arm Away" (using the Security Panel UI or a lua script), there will be a delay before it triggers any script or changes state in the UI, depending on your settings in Setup > Application Settings > Security Panel > Delay. There is no delay when disarming however.
- since revision 1.1023, there are 3 types of lua scripts: "device", "time" and "security". When I arm/disarm using the control panel, both the "device" and "security" scripts are triggered (ok, well, ...). However the security one still logs the Security Panel in the previous state :-( ! So if you change from Normal (Disarm) to Arm Home, the security script receives it in "Normal" state while the device script receives it in "Arm Home". I think that is a bug.

If others can confirm this behaviour, i think it would be interesting to file a bug for the last point that renders security scripts useless...

Hope it helps

Vicne
Vicne
Posts: 4
Joined: Saturday 21 December 2013 15:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by Vicne »

More observations:
The wiki says
The state of the Domoticz built in security system can be checked via globalvariables['Security']. This will return "Disarmed", "Armed Home" or "Armed Away". It is not a true device, so it will not be picked up as one in a device script. Use a security script to trigger on security status changes.
The middle part is strange as the security panel is, in fact, part of the devices and arming/disarming actually does trigger device scripts. However, it's true that checking the "globalvariables['Security']" variable does return the three status mentioned above (this time in their past form, "Armed" or "Disarmed")

I have two scripts (one device, one security), each logging the values of both the "Security Panel" device and the "Security" variable. Here is the log when disarming/arming from the Security Panel:

Code: Select all

Sun Feb 23 16:53:04 2014 LUA: Security script - otherdevices['Security Panel'] = 'Arm Home' and globalvariables['Security'] = 'Disarmed'
Sun Feb 23 16:53:04 2014 LUA: Device script - otherdevices['Security Panel'] = 'Normal' and globalvariables['Security'] = 'Disarmed'
Sun Feb 23 16:53:04 2014 (System) Domoticz Security Status (Security Panel)

Sun Feb 23 16:53:09 2014 LUA: Security script - otherdevices['Security Panel'] = 'Normal' and globalvariables['Security'] = 'Armed Home'
Sun Feb 23 16:53:09 2014 LUA: Device script - otherdevices['Security Panel'] = 'Arm Home' and globalvariables['Security'] = 'Armed Home'
Sun Feb 23 16:53:09 2014 (System) Domoticz Security Status (Security Panel)
Best regards,

Vicne
Last edited by Vicne on Sunday 23 February 2014 17:22, edited 1 time in total.
Vicne
Posts: 4
Joined: Saturday 21 December 2013 15:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by Vicne »

OK, anyway, here is my script to arm/disarm Domoticz's security from my X10 KeyChain remote:

Code: Select all

commandArray = {}
for device, value in pairs(devicechanged) do
	if (device == 'KeyChain') then
		print ("Setting 'Security Panel' to '" .. otherdevices[device] .. "' state")
		commandArray['Security Panel'] = otherdevices[device]
	end
end
return commandArray
And here is the corresponding log with an Arm/Disarm cycle (delay = 0) :
Sun Feb 23 17:00:57 2014 LUA: Setting 'Security Panel' to 'Arm Away' state
Sun Feb 23 17:00:57 2014 Script event triggered: /volume1/misc/domoticz/scripts/lua/script_device_CheckSecurity.lua
Sun Feb 23 17:00:57 2014 (RfxTrx433) Security 1 (KeyChain)
Sun Feb 23 17:00:57 2014 (System) Domoticz Security Status (Security Panel)

Sun Feb 23 17:01:03 2014 LUA: Setting 'Security Panel' to 'Disarm' state
Sun Feb 23 17:01:03 2014 Script event triggered: /volume1/misc/domoticz/scripts/lua/script_device_CheckSecurity.lua
Sun Feb 23 17:01:03 2014 (RfxTrx433) Security 1 (KeyChain)
Sun Feb 23 17:01:03 2014 (System) Domoticz Security Status (Security Panel)
Seems to work pretty well. Hope it helps.

Best regards,

Vicne
Niekoesj
Posts: 5
Joined: Friday 14 February 2014 6:22
Target OS: Linux
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by Niekoesj »

Hi Vicne,

Ah good investigation! I'll check the script later this evening.
I need to learn a bit more about the LUA scripting :)
pecora
Posts: 12
Joined: Monday 13 July 2015 12:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by pecora »

I'm not get it work... This is the script I have
---------
commandArray = {}

if (devicechanged['RemoteHJ'] == 'On') then
commandArray['Domoticz Security Panel'] = 'Arm Away'

end

return commandArray
--------

What do I wrong
daryah
Posts: 15
Joined: Thursday 09 June 2016 22:43
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by daryah »

This is a 2 year old discussion that was brought to life in April 2016 and I seem to be having an issue related to this as well. Will try to provide more info. though

I have created a dummy device switCh called "SystemARMnDISARM" as an on/off switch. I would like this to control the security panel state. The following is my code sample

Code: Select all

commandArray = {}
 if (devicechanged['SystemARMnDISARM'] == 'On') then
    print('AlarmPanel Arm Away')
    commandArray['Security Panel'] = 'Arm Away'
 end
 if (devicechanged['SystemARMnDISARM'] == 'Off') then
    print('AlarmPanel Disarming')
    commandArray['Security Panel'] = 'Disarm'
end
return commandArray
My log states the following when I try to toggle the switch.
2016-06-18 14:28:09.839 EventSystem: reset all events...
2016-06-18 14:28:33.165 User: Admin initiated a switch command
2016-06-18 14:28:33.172 LUA: AlarmPanel Arm Away
2016-06-18 14:28:33.166 (DummyHW) Lighting 1 (SystemARMnDISARM)
2016-06-18 14:29:00.022 Error: EventSystem: in System Arm and Disarm: [string "-- ..."]:26: attempt to index global 'devicechanged' (a nil value)
This error then continues to occur until I make the Event inactive.
Line 26 is the first line of the first if..then statement
Can anyone spot the missing trick?
setup: Domoticz@SynNAS; RFXTRX 433; Response E. Alarm, Teqin IP PTZ Camera, Mercury Socket, 1byOne Chime; SSE smart meter
plan: Lightwave RF Dimmers & PIR, integ. evohome heating
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: Set security armed/disarmed by switch

Post by jvdz »

Is this a script made with the internal Script Editor? If so, change the dropdown box below LUA from All to Device.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
daryah
Posts: 15
Joined: Thursday 09 June 2016 22:43
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by daryah »

wow - yes it was done in the script editor and making the change to Device has indeed removed the constant error. I would ask why this has worked but I would like to save your invaluable help for the next question.

If the security panel status has successfully changed state then should the actual security panel also show the changed state? Unfortunately it hasn't and a script I have currently running to turn on / off a device (which works when I activate using the actual panel) does not seem to run. This makes me feel the panel is not actually being activated / deactivated - My LUA skills are rudimentary so I would print the actual state of the panel in my lua code after the declaration - but afraid I don't know the command! :-)
setup: Domoticz@SynNAS; RFXTRX 433; Response E. Alarm, Teqin IP PTZ Camera, Mercury Socket, 1byOne Chime; SSE smart meter
plan: Lightwave RF Dimmers & PIR, integ. evohome heating
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: Set security armed/disarmed by switch

Post by jvdz »

daryah wrote:wow - yes it was done in the script editor and making the change to Device has indeed removed the constant error. I would ask why this has worked but I would like to save your invaluable help for the next question.
It is quite simple ones you know it: All means that the script is shelled with each event, which means for Device, Time and Variable change events. Looking at the log records you posted it was pretty clear this was a time event and the DeviceChanged table isn't available in Time events.. hence the error. :)

To check the Security panel changes you simply should see an entry in the domoticz log, but could also write a script that is triggered when the security panel changes by selecting "Security" in the dropdownbox and then create your own print of its status.

Code: Select all

print('### SecPanel: status changed to ' .. globalvariables['Security'])
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
daryah
Posts: 15
Joined: Thursday 09 June 2016 22:43
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by daryah »

ok - i see why the error may have occured... devicechanged should only be used for device based events... but I trying to figure that out from the error response needs fluency in domoticz errors speak - which I unfortunately lack

updated the code to following:-

Code: Select all

commandArray = {}
 if (devicechanged['SystemARMnDISARM'] == 'On') then
    print('gonna attempt to arm away')
    commandArray['Security Panel'] = 'Arm Away'
    print('### SecPanel: status changed to ' .. globalvariables['Security'])
 end
 if (devicechanged['SystemARMnDISARM'] == 'Off') then
    print('gonna attempt to disarm')
    commandArray['Security Panel'] = 'Disarm'
    print('### SecPanel: status changed to ' .. globalvariables['Security'])
end
return commandArray
and getting following:-
2016-06-19 18:36:43.094 EventSystem: reset all events...
2016-06-19 18:36:50.663 User: Admin initiated a switch command
2016-06-19 18:36:50.669 LUA: gonna attempt to arm away
2016-06-19 18:36:50.670 LUA: ### SecPanel: status changed to Disarmed
2016-06-19 18:36:50.663 (DummyHW) Lighting 1 (SystemARMnDISARM)
2016-06-19 18:37:08.297 User: Admin initiated a switch command
2016-06-19 18:37:08.303 LUA: gonna attempt to disarm
2016-06-19 18:37:08.303 LUA: ### SecPanel: status changed to Disarmed
2016-06-19 18:37:08.298 (DummyHW) Lighting 1 (SystemARMnDISARM)
2016-06-19 18:37:38.547 User: Admin initiated a switch command
2016-06-19 18:37:38.554 LUA: gonna attempt to arm away
2016-06-19 18:37:38.554 LUA: ### SecPanel: status changed to Disarmed
So suspicion correct. The script is simply not affecting the security panel state. Am I using the right english tense? ie "Arm Away" vs Arming, Armed...
setup: Domoticz@SynNAS; RFXTRX 433; Response E. Alarm, Teqin IP PTZ Camera, Mercury Socket, 1byOne Chime; SSE smart meter
plan: Lightwave RF Dimmers & PIR, integ. evohome heating
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: Set security armed/disarmed by switch

Post by jvdz »

The SecPanel isn't set yet at the time you print its status, so do as I suggested and make it a separate script that is triggered on the Security event!

... oh and make the set security panel look like this:

Code: Select all

commandArray['SecPanel']='Disarm'
commandArray['SecPanel']='Arm Away'
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
daryah
Posts: 15
Joined: Thursday 09 June 2016 22:43
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by daryah »

Hi - I changed the Lua code to say SecPanel and created another lua script to print the status based on a security event.

The print script does NOT get triggered when I press the dummy switch but does when I use the Security Panel directly. I have another blockly script already running that also gets triggered on security events, and this also only runs on panel arm / disarms.

The lua SecPanel sets continue to be ignored.. :-(
setup: Domoticz@SynNAS; RFXTRX 433; Response E. Alarm, Teqin IP PTZ Camera, Mercury Socket, 1byOne Chime; SSE smart meter
plan: Lightwave RF Dimmers & PIR, integ. evohome heating
daryah
Posts: 15
Joined: Thursday 09 June 2016 22:43
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Set security armed/disarmed by switch

Post by daryah »

ok - managed to get it resolved - issue has been raised before here - viewtopic.php?t=8031

I set the password for the security panel and then was able to see it under my devices. Created a switch "IntSecPanel" (could call it anything really) via the green arrow and can now see this switch. My LUA script works after swapping out switch names

If I was more curious and had more time to play around with domoticz e.g. rather then clash of clans, I would test to see if I could use Blockly set commands to flip IntSecPanel rather then Lua

When I switch IntSecPanel from Dashboard I get prompted for the Pin which I can enter using the Android Keyboard.

However, as my dedicated Android device already has a pattern lock to access it, the need for two factor security panel access seems overkill to me.. As such, will just stick to my dummy switch which bypasses the need for a pin.

Next stop perhaps, purchase the Domoticz App Premium license and utilize the NFC capabilities of my device to arm / disarm
setup: Domoticz@SynNAS; RFXTRX 433; Response E. Alarm, Teqin IP PTZ Camera, Mercury Socket, 1byOne Chime; SSE smart meter
plan: Lightwave RF Dimmers & PIR, integ. evohome heating
Stockfisch
Posts: 10
Joined: Wednesday 11 October 2017 11:09
Target OS: Linux
Domoticz version: Beta
Location: NRW
Contact:

Re: Set security armed/disarmed by switch

Post by Stockfisch »

Hi,
trying to set up a simple Alarm System in my new Domoticz I found this Threat.
I'm trying exactly the same as above, but with no success. I don't manage to change the Security Panel status!
I have added a virtual switch to change from disarmed to arm away and vice versa.

Code: Select all

commandArray = {}
 if (devicechanged['HouseMode'] == 'On') then
    print('AlarmPanel Arm Away')
    commandArray['SecPanel']='Arm Away'
 end
 if (devicechanged['HouseMode'] == 'Off') then
    print('AlarmPanel Disarming')
    commandArray['SecPanel']='Disarm'
end
return commandArray
I have used the WebIf event editor and have set the trigger to "device".

Additionally I have added another script with trigger "security" as suggested above:

Code: Select all

commandArray = {}
printlog('###', 'SecPanel: status changed to ' .. globalvariables['Security'])
return commandArray
this seems not be executed after the first script ran.

What am I doing wrong?

Thanks Dirk
NUC5CPYH - Proxmox VE - Ubuntu 18.4
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: Set security armed/disarmed by switch

Post by jvdz »

Couple of questions:
- You do get the LOG entry from the print() statements in the first script?
- You do have a Switch device with the exact name "SecPanel" with the secpanel (Lock&Key) icon?

EDIT: You might want to update the second script to:

Code: Select all

commandArray = {}
print('### SecPanel: status changed to ' .. globalvariables['Security'])
return commandArray
As the printlog() is a Function I use for my logging that might not be available for you.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Stockfisch
Posts: 10
Joined: Wednesday 11 October 2017 11:09
Target OS: Linux
Domoticz version: Beta
Location: NRW
Contact:

Re: Set security armed/disarmed by switch

Post by Stockfisch »

OMG, I' feeling stupid!

My Security Panel is named "Domoticz Security Panel" in the dashboard!
Changing the name in the script did the trick!

Thanks a lot, Dirk
NUC5CPYH - Proxmox VE - Ubuntu 18.4
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests