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

First Installation

B Synnerlig edited this page Dec 5, 2018 · 30 revisions

Installation

Prerequisits

The following should be installed, configured, tested and working before continuing with installing ideAlarm:

Check that the currently logged in user has the environment variable $OPENHAB_CONF set

For this instruction to work, the currently logged in user must have the environment variable $OPENHAB_CONF set to the value of your openHAB configuration directory. If it's not set, do not continue further. Below is a linux example command that you can use to check this condition. It should return the name of the directory.

echo $OPENHAB_CONF

Download mapping files

Download the mapping files in the language of your choise and save them on your system where you keep your mappings files (in the transform folder) Example linux commands for downloading the English mapping files followed by changing file owner and group information.

sudo mkdir -p $OPENHAB_CONF/transform
sudo chown openhab:openhab $OPENHAB_CONF/transform
sudo wget -O $OPENHAB_CONF/transform/en_armingmode.map https://raw.githubusercontent.com/OH-Jython-Scripters/ideAlarm/master/transform/en_armingmode.map
sudo chown openhab:openhab $OPENHAB_CONF/transform/en_armingmode.map
sudo wget -O $OPENHAB_CONF/transform/en_zonestatus.map https://raw.githubusercontent.com/OH-Jython-Scripters/ideAlarm/master/transform/en_zonestatus.map
sudo chown openhab:openhab $OPENHAB_CONF/transform/en_zonestatus.map

Create the following Item Groups

Some Items need to be persisted for ideAlarm to work. It's convenient to set up persistence to certain item groups. The naming of the first two groups below is just a suggestion. You may name them differently but we recommend you to use these names. The important thing is that items belonging to the groups following gets persisted to restore your system after a restart.

Group G_PersistOnChange // Persist on change and system start up
Group G_PersistOnUpdate // Persist on change and system start up. For temp, humidity sensors etc.

Group G_VirtualDevice 		(G_PersistOnChange)
Group G_Timer
Group G_Alarm 			(G_PersistOnChange)
Group G_Alarm_Z1 		(G_Alarm)
Group G_Alarm_Z2 		(G_Alarm)
Group G_AlarmArmingMode 	(G_Alarm)
Group G_AlarmStatus 		(G_Alarm)

Create Items for each alarm zone you intend to use

For each alarm zone that you wish to define, create the following items through text .items files located in the $OPENHAB_CONF/items folder. You are advised to keep the naming convention suggested at least until everything is set up and works well. Your first zone's items get item names starting with 'Z1'. Prepend your second zone items with 'Z2' etc.

Number Z1_Arming_Mode 		"Z1 Arming Mode: [MAP(en_armingmode.map):%s]" 		<alarm> 	(G_AlarmArmingMode)
Number Z1_Status 		"Z1 Status: [MAP(en_zonestatus.map):%s]" 		<alarm> 	(G_AlarmStatus)

Switch Toggle_Z1_Armed_Away 	"Toggle Z1 Armed Away" 					<switch> 	(G_VirtualDevice) 	{expire="1s,command=OFF"}
Switch Toggle_Z1_Armed_Home 	"Toggle Z1 Armed Home" 					<switch> 	(G_VirtualDevice) 	{expire="1s,command=OFF"}

Number Z1_Open_Sections 	"Z1 open sections [%.0f]" 				<door> 		(G_VirtualDevice)

Switch Z1_Entry_Timer 		"Z1 entry timer [%s]" 					<time> 		(G_Timer) 		{expire="15s,command=OFF"}
Switch Z1_Exit_Timer 		"Z1 exit timer [%s]" 					<time> 		(G_Timer) 		{expire="2m,command=OFF"}
Switch Z1_Nag_Timer 		"Z1 nag timer [%s]" 					<time> 		(G_Timer) 		{expire="4m,command=OFF"}
Switch Z1_Alert_Max_Timer 	"Z1 alert maximum time [%s]" 				<time> 		(G_Timer) 		{expire="20s,command=OFF"}

Create the ideAlarm library directory and files

NOTE!!! The EXTRA_JAVA_OPTS environment variable that you previously have set up in /etc/default/openhab2 tells python where to find library files. The jsr223 documentation suggests adding -Dpython.path=/etc/openhab2/lib/python You might have chosen -Dpython.path=/etc/openhab2/automation/lib/python instead. Both works, but the important thing here is that you remember your choice. Restart openHAB if you change the EXTRA_JAVA_OPTS environment variable.

Instructions will be followed by examples

  • Set a temporary user variable named $OH_PY_LIB to point on your python library directory. It should match whatever directory that you have set up in the EXTRA_JAVA_OPTS environment variable above.
  • Check that your user variable is now pointing to a valid directory.
  • Create the directory $OH_PY_LIB/idealarm
  • Set the directory permissions to 775.
  • Set the directory group to openhab and owner to openhab.
  • Download The library init file and save it by the name OH_PY_LIB/idealarm/__init__.py
  • Change file owner to openhab and group information to openhab

Example linux commands for doing all of the above:

export OH_PY_LIB=$OPENHAB_CONF/automation/lib/python # Change this line to match your EXTRA_JAVA_OPTS
ls -ld $OH_PY_LIB # Should output a valid directory
sudo mkdir $OH_PY_LIB/idealarm
sudo chmod 775 $OH_PY_LIB/idealarm
sudo chown openhab:openhab $OH_PY_LIB/idealarm
sudo wget -O $OH_PY_LIB/idealarm/__init__.py https://raw.githubusercontent.com/OH-Jython-Scripters/ideAlarm/master/automation/lib/python/idealarm/__init__.py
sudo chown openhab:openhab $OH_PY_LIB/idealarm/__init__.py

Create the config file

Example linux commands for doing all of the above:

sudo wget -nc -O $OH_PY_LIB/idealarm/config.py https://raw.githubusercontent.com/OH-Jython-Scripters/ideAlarm/master/automation/lib/python/idealarm/2_zones_example_config.py
sudo chown openhab:openhab $OH_PY_LIB/idealarm/config.py

Edit the config file to suit your system

  • Make your changes to the configuration file. See configuration
  • Copy and paste your configuration file into the form on PythonBuddy to verify that the Python syntax. The two org.eclipse.smarthome imports will fail but you can safely ignore that.
  • Save the file.

Create a custom library script

  • Download the custom template and save it by the name $OH_PY_LIB/idealarm/custom.py
  • Change file owner to openhab and group information to openhab

Example linux commands for doing all of the above:

sudo wget -nc -O $OH_PY_LIB/idealarm/custom.py https://raw.githubusercontent.com/OH-Jython-Scripters/ideAlarm/master/automation/lib/python/idealarm/custom_template.py
sudo chown openhab:openhab $OH_PY_LIB/idealarm/custom.py

Download the 001_ideAlarm.py script

  • Download the 001_ideAlarm.py and save it by the name $OPENHAB_CONF/automation/jsr223/001_ideAlarm.py
  • Change file owner to openhab and group information to openhab

Example linux commands for doing all of the above:

sudo wget -O $OPENHAB_CONF/automation/jsr223/001_ideAlarm.py https://raw.githubusercontent.com/OH-Jython-Scripters/ideAlarm/master/automation/jsr223/001_ideAlarm.py
sudo chown openhab:openhab $OPENHAB_CONF/automation/jsr223/001_ideAlarm.py