Skip to content
This repository was archived by the owner on May 14, 2019. It is now read-only.

Arming and disarming

Richard Roe edited this page Mar 7, 2018 · 9 revisions

There are a few ways that you can arm and disarm an ideAlarm zone

Using the openHAB web GUI

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.

Programatically (E.g. using scripts)

You can make scrips in any of openHAB's scripting environments. Below is two jsr223 Jython script examples. Both of them are based on Jython scripting for openHAB 2.x.

A simple 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())

A little bit more advanced jsr223 jython script:

If you have a physical button device that you want to push 3 times within 10 seconds 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:

Number Count_Spider_Pig  {expire="10s,command=0"}
Switch Spider_Pig_Button "Spider pig button" <switch> {channel="zwave:device:XXXXXXX:nodeNN:sensor_binary1"}
Clone this wiki locally