-
Notifications
You must be signed in to change notification settings - Fork 1
Arming and disarming
There are a few ways that you can arm and disarm an ideAlarm zone
You can of course use the openHAB web GUI to switch the arming mode. This is not very convenient though and is probably useful only for testing.
You can make scrips in any of openHAB's scripting environments. Below is a jsr223 Jython script example:
from openhab.rules import rule, addRule
from openhab.triggers import ItemStateChangeTrigger
@rule
class bedRoomArming(object):
def getEventTriggers(self):
return [ItemStateChangeTrigger('Bedroom_Switch'), 'ON']
def execute(self, modules, inputs):
self.log.info('Bedroom button pushed')
events.sendCommand('Toggle_Z1_Armed_Home', 'ON')
addRule(bedRoomArming())
If you have a physical button device that you want to push 3 times to toggle the arming mode. You may want to do like this to make things more obscure, for example if you just use a lighting switch beside the entrance door for arming and disarming. Security through obscurity In the example below, that physical button item is named 'Spider_Pig_Button'. It's also using the getItemValue
function from mylib.
from openhab.rules import rule, addRule
from openhab.triggers import ItemStateChangeTrigger
from mylib.utils import getItemValue
@rule
class spiderPig(object):
"""
Keeps track of how many times the Spider Pig Button has been pressed
Counter will be reset by the expire binding.
"""
def getEventTriggers(self):
return [ItemStateChangeTrigger('Spider_Pig_Button', 'ON')]
def execute(self, modules, inputs):
qty = getItemValue('Count_Spider_Pig', 0)
self.log.info('Spider pig was pressed. Qty='+str(qty+1))
if qty == 2:
events.sendCommand('Toggle_Z1_Armed_Away', 'ON')
events.postUpdate('Count_Spider_Pig', str(qty+1))
addRule(spiderPig())
Here is what the 2 items look like:
'''python Number Count_Spider_Pig {expire="10s,command=0"} Switch Spider_Pig_Button "Spider pig button" {channel="zwave:device:XXXXXXX:nodeNN:sensor_binary1"} '''