Hi all,
I’ve been looking for a binding for the ELK/NESS M1 home alarm and while I see some discussion on the topic I haven’t found anything working at this time, so I started work on my own solution using the Serial binding.
I’m working on a combination of items and rules along with the serial binding to read the state of my ELK/NESS M1 home alarm and I’d like to be able to mirror the state of my home alarm zone status in OpenHAB. I have the basics working, but I need help with a few things:
- SOLVED What is the best way to set up PIR sensors in OpenHAB? I’ve read about Contact item types but haven’t had much success so I’m using Switch items at the moment.
- I couldn’t solve the problem of having to define the item types multiple times in both the items file and the rules file. Any suggestions would be appreciated. I’ve tried defining a group and them getting the members of that group but couldn’t get that combination to work for me without throwing and error.
- SOLVEDThe sitemap icon doesn’t seem to update with the update of the item state. I’m not sure what is the best way to make this happen
My items file:
Switch AlarmUpdate "Alarm Update" { serial="/dev/ttyUSB0@115200" }
String AlarmMessage "Alarm Message" { serial="/dev/ttyUSB0@115200" }
Group gAlarm_PIR
Switch Alarm_PIR_Zone1 (gAlarm_PIR)
Switch Alarm_PIR_Zone2 (gAlarm_PIR)
Switch Alarm_PIR_FF_MasterBedroom "Master Bedroom" (gAlarm_PIR)
Switch Alarm_PIR_Zone4 (gAlarm_PIR)
Switch Alarm_PIR_Nursery "Nursery" (gAlarm_PIR)
Switch Alarm_PIR_FF_Stairs "Up Stairs" (gAlarm_PIR)
Switch Alarm_PIR_GF_Lounge "Lounge" (gAlarm_PIR)
Switch Alarm_PIR_GF_Stairs "Down Stairs" (gAlarm_PIR)
My rules file:
import java.lang.Integer.*
val AlarmMemoryMessage = "AM"
val ZoneChangedMessage = "ZC"
val NetworkAdapterPing = "XK"
val ZoneStatusTable_NormalUnconfigured = "0"
val ZoneStatusTable_NormalOpen = "1"
val ZoneStatusTable_NormalEOL = "2"
val ZoneStatusTable_NormalShort = "3"
val ZoneStatusTable_TroubleOpen = "5"
val ZoneStatusTable_TroubleEOL = "6"
val ZoneStatusTable_TroubleShort = "7"
val ZoneStatusTable_ViolatedOpen = "9"
val ZoneStatusTable_ViolatedEOL = "A"
val ZoneStatusTable_ViolatedShort = "B"
val ZoneStatusTable_BypassedOpen = "D"
val ZoneStatusTable_BypassedEOL = "E"
val ZoneStatusTable_BypassedShort = "F"
rule "Interpret Alarm Command"
when
Item AlarmMessage received update
then
var lines = AlarmMessage.state.toString.split('\n')
lines.forEach[line |
if(line.length > 6) {
var messageLength = line.substring(0,2)
var commandType = line.substring(2,4)
var checksum = line.substring(line.length-3, line.length-1)
//logInfo("alarm", "Message:" + line + " Len:" + messageLength + " Command:" + commandType)
if(commandType == AlarmMemoryMessage) {
var alarmMemoryAreas = line.substring(4, 12)
}
else if(commandType == ZoneChangedMessage) {
var int zoneNumber = Integer::parseInt(line.substring(4,7))
var zoneStatus = line.substring(7,8)
var zone = Alarm_PIR_GF_Lounge
switch zoneNumber {
case zoneNumber == 1 : zone = Alarm_PIR_Zone1
case zoneNumber == 2 : zone = Alarm_PIR_Zone2
case zoneNumber == 3 : zone = Alarm_PIR_FF_MasterBedroom
case zoneNumber == 4 : zone = Alarm_PIR_Zone4
case zoneNumber == 5 : zone = Alarm_PIR_FF_Nursery
case zoneNumber == 6 : zone = Alarm_PIR_FF_Stairs
case zoneNumber == 7 : zone = Alarm_PIR_GF_Lounge
case zoneNumber == 8 : zone = Alarm_PIR_GF_Stairs
}
var state = "OFF"
switch zoneStatus {
case zoneStatus == ZoneStatusTable_NormalUnconfigured : postUpdate(zone, OFF)
case zoneStatus == ZoneStatusTable_NormalOpen : postUpdate(zone, OFF)
case zoneStatus == ZoneStatusTable_NormalEOL : postUpdate(zone, OFF)
case zoneStatus == ZoneStatusTable_NormalEOL : postUpdate(zone, OFF)
case zoneStatus == ZoneStatusTable_NormalEOL : postUpdate(zone, OFF)
case zoneStatus == ZoneStatusTable_TroubleOpen : postUpdate(zone, ON)
case zoneStatus == ZoneStatusTable_TroubleEOL : postUpdate(zone, ON)
case zoneStatus == ZoneStatusTable_TroubleShort : postUpdate(zone, ON)
case zoneStatus == ZoneStatusTable_ViolatedOpen : postUpdate(zone, ON)
case zoneStatus == ZoneStatusTable_ViolatedEOL : postUpdate(zone, ON)
case zoneStatus == ZoneStatusTable_ViolatedShort : postUpdate(zone, ON)
}
else if(commandType == NetworkAdapterPing) {
}
else {
//logInfo("alarm", "No code match")
}
}
]
end
With this Items file and Rules file I’m able to receive and monitor the state of the PIR sensors on my home alarm using the serial adapter and the Serial binding.
I’ve written up a few points on how I got the serial binding here if anyone is interested. I’m keen to do a small write up once I get the NESS M1 serial device mirroring working as well.
Thanks.