Hey guys,
I’m working on a rule that reads the state of my Elk/NESS home alarm state over serial and updates the state of a switch item.
I’ve run in to some issues when trying to set the state of my alarm Items from my rule.
The documentation of the sendCommand function says that it takes two strings as inputs but I can’t seem to pass a string to this function without it throwing an error. Here is my code that isn’t working:
alarm.items
Switch Alarm_PIR_GF_Lounge "Lounge"
Switch Alarm_PIR_GF_Stairs "Down Stairs"
Switch Alarm_PIR_FF_Stairs "Up Stairs"
Switch Alarm_PIR_FF_MasterBedroom "Master Bedroom"
alarm.rules
val ZoneArray = newArrayList("0","1","2","3","4","5","6","Alarm_PIR_GF_Lounge", "Alarm_PIR_GF_Stairs", "9", "10", "11", "12", "13", "14")
switch zoneStatus {
case zoneStatus == ZoneStatusTable_NormalOpen : sendCommand(ZoneArray.get(zoneNumber).toString, OFF)
case zoneStatus == ZoneStatusTable_NormalEOL : sendCommand(ZoneArray.get(zoneNumber).toString, OFF)
case zoneStatus == ZoneStatusTable_ViolatedOpen : sendCommand(ZoneArray.get(zoneNumber).toString, ON)
}
The above does not work, I get the error:
Rule ‘Interpret Alarm Command’: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(java.lang.String,java.lang.String) on instance: null
The below does work which is confusing because the documentation says that all I need to pass the sendCommand function is the string that matches the item name.
switch zoneStatus {
case zoneStatus == ZoneStatusTable_NormalOpen : sendCommand(Alarm_PIR_GF_Lounge, OFF)
case zoneStatus == ZoneStatusTable_NormalEOL : sendCommand(Alarm_PIR_GF_Lounge, OFF)
case zoneStatus == ZoneStatusTable_ViolatedOpen : sendCommand(Alarm_PIR_GF_Lounge, ON)
}
Any help or thoughts would be much appreciated.
Thanks