-
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 two jsr223 Jython script examples. Both of them are based on Jython scripting for openHAB 2.x.
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 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"}
(Untested) You can easily integrate an Alarm Control Panel that communicates using MQTT. For example the MQTT Alarm Control Panel for Home Assistant project might work well for integration with ideAlarm.
PREREQUISITS:
-
You'd need to set up a MQTT server. Unless you already have one you'd probably want to set up a MQTT message broker such as Mosquitto on the same server as the one that runs openHAB.
-
openHAB MQTT Binding should be installed and configured.
-
Add two openHAB items like in the example below:
String Alarm_CPanel_State "Alarm CPanel state [%s]" {mqtt=">[mybroker:home/alarm/set:command:*:default]"} String Alarm_CPanel_Command "Alarm CPanel command [%s]" {mqtt="<[mybroker:home/alarm/set:command:default]"}
In the example above, mybroker is the broker alias as it was defined in the openHAB configuration.
The Alarm Control Panel will send an update to the Alarm_CPanel_Command
item with a payload to notify ideAlarm to arm or disarm. The MQTT service will use the Alarm_CPanel_State
item with the payload to notify the Alarm Control Panel of the current ideAlarm state, which will update the interface accordingly.
When the prerequisites are met, it's time to make a Custom Helper Function that will synchronize your newly created items Alarm_CPanel_State
and Alarm_CPanel_State
with an ideAlarm zone. There is a template custom script that we will use as a starter.