I haven't been able to find any decent OpenHAB binding for the alarm, and after recently giving up on getting my M1XEP serial to network box for my alarm working I've decided to try my hand at rolling my own serial solution. Here I'll discuss how I got the serial configuration up and running.
Installation
Install the binding from the configuration GUII'm using a USB to Serial adapter, but other serial devices should also show up as serial devices if they have been recognised by the kernel. You can check this with the command:
dmesg
Or to view messages relating to the serial port configuration use the command:
dmesg | grep tty
This should tell you what port was assigned to your USB to Serial adapter, in my case ttyUSB0Check which users have access to the serial port with the command:
ll /dev/ttyUSB0
Output should look something like:
crw-rw---- 1 root dialout 188, 0 Mar 27 10:03 /dev/ttyUSB0
sudo adduser openhabian dialout
It's a good time to check the serial connection to make sure it's working as expected. You can use the GNU screen command to view the serial port from the command line:
screen /dev/ttyUSB0 115200
The screen command won't exit with the typical commands like CTRL-X or CRTL-Z, to exit the screen command enter 'CTRL-a' then press '\', then hit 'Y' to exit the screen.
Now that we have the binding installed and confirmed the serial port is working as expected we can continue with the OpenHAB setup
OpenHAB2 Configuration
I created and 'alarm.items' file to store alarm related configuration info: Switch AlarmUpdate "Alarm Update" { serial="/dev/ttyUSB0@115200" }
String AlarmMessage "Alarm Message" { serial="/dev/ttyUSB0@115200" }
and a 'alarm.rules' file with the following:
ule "Interpret Alarm Command"
when
Item AlarmMessage received update
then
logDebug("alarm", "Alarm message updated")
end
Check everything is working with the command:
tail -f /var/log/openhab2/openhab.log -f /var/log/openhab2/events.log
And you should see log messages like the following:
2017-03-27 12:08:27.946 [ItemStateChangedEvent ] - AlarmMessage changed from 0AZC007200C9
1EAS000000001111111100000000000E
0CAM000000007F
to 16XK2708212270117011006C
Now that the serial binding is working we can move on to interpreting the data!