OH2 Z-Wave refactoring and testing... and SECURITY

Not a rule expert, but using a JSON transform or split in a rule is fairly easy. I currently use both in my rules. Cart before horse, but here are some possible examples (Lock_Alarm and Lock_Event would be Number items):

rule "Lock: String updated"
when
    Item Lock_String received update
then
    Lock_Alarm.postUpdate(transform("JSONPATH", "$.alarm", Lock_String.state.toString) as DecimalType)
    Lock_Event.postUpdate(transform("JSONPATH", "$.event", Lock_String.state.toString) as DecimalType)
    
    val String[] splitString = Lock_String.state.toString.split(",")
    Lock_Alarm.postUpdate(splitString.get(0) as DecimalType)
    Lock_Event.postUpdate(splitString.get(1) as DecimalType)
end
1 Like