Hey! I’ve made a lot of progress, but I haven’t posted any updates here so now it’s time. I’ve added the alarm_raw channel and I get the json string from that channel as anticipated. I simplified the code you wrote @5iver since I only have one lock (I assume your code included a solution for three locks). It is most probably not the most beautiful piece of code or most efficient, but it works and now it looks like this:
//Rule for updating the lock status based on alarm_raw channel
rule "Lock: Update lock states after alarm_raw event"
when
Item FrontDoor_Alarm_Raw received update
then
logDebug("lock", "Lock: Alarm events: {}=[{}]",FrontDoor_Alarm_Raw,triggeringItem.state.toString)
switch (transform("JSONPATH","$.type",triggeringItem.state.toString)) {
case "ACCESS_CONTROL" : {
switch (transform("JSONPATH","$.event", triggeringItem.state.toString)) {
case "1" : {
LockStatus.postUpdate("Locked")
logDebug("lock", "Lock: Alarm events: {}",LockStatus)
}
case "2" : {
LockStatus.postUpdate("Unlocked from the inside")
logDebug("lock", "Lock: Alarm events: {}",LockStatus)
}
case "4" : {
LockStatus.postUpdate("Unlocked with RFID key tag #" + (transform("JSONPATH", "$.code", triggeringItem.state.toString)))
logDebug("lock", "Lock: Alarm events: {}",LockStatus)
}
case "6" : {
switch (transform("JSONPATH", "$.code", triggeringItem.state.toString)) {
case "0" : {
LockStatus.postUpdate("Unlocked by zwave")
}
case "1" : {
LockStatus.postUpdate("Unlocked by master pin")
}
case "60" : {
LockStatus.postUpdate("Ulocked by family")
}
case "61" : {
LockStatus.postUpdate("Unlocked by cleaner")
sendNotification("martin.koskela@gmail.com", "The lock was unlocked by the cleaner code")
}
default : {
LockStatus.postUpdate("Unknown door lock Event")
logDebug("lock", "Lock: Alarm events: {}",LockStatus)
}
}
logDebug("lock", "Lock: Alarm events: {}",LockStatus)
}
}
}
case "BURGLAR" : {
DoorStatus.postUpdate("The Burglar alarm is active")
logDebug("lock", "Lock: Alarm events: {}",DoorStatus)
}
default : {
DoorStatus.postUpdate("Unknown Type in alarmRawParser")
logDebug("lock", "Lock: Alarm events: {}",DoorStatus)
}
}
end
and the items I use look like this:
String FrontDoor_Alarm_Raw "Alarm Raw [%s]" <shield> { channel="zwave:device:XXXXX:node2:alarm_raw"}
String LockStatus "Test state [%s]" <shield>
So what I’m after is to store the values in my influxDB and therefore I created a virtual item which I populate with the status. I have not added that to the persistence file yet so that’s the next step. I don’t know if it’s even possible to store strings and display them in a nice way in HabPanel.
Anyway, the rule works great and I get the status on the virtual item
I’m eternally greatful to you @chris and @5iver for all the help. Please let me know if I can help you in anyway; testing, sanity check something or perhaps a kidney