Schlage BE469 - Zwave binding with security - missing features

A couple of comments:

Try temporarily removing the whole “if (transform …” for the no longer jammed. That’s the only place using previousState. This is nice to have, but you don’t absolutely need it. Do all of your issues go away?

I do not like to put the raw alarm into persistence. If you do, you’ll find that if the system restarts, and your cases do anything interesting, you’ll make those things happen again depending on the last activity. For me this could mean turning on or off the alarm or sending unwanted messages. I did the following so I get history without using persistence. If there is a restart, the entries will be null, but I don’t care too much about the jammed state during a restart.

At the top of the rule:

import java.util.Map
// retain the old event for each lock
// not using persistence as don't want the rule to fire
// on an update at startup and do weird things
var Map<String, Number> messageOldEvents = newHashMap

Then, at the case “ACCESS_CONTROL” I add this:

            val messageEvent    = transform("JSONPATH","$.event",triggeringItem.state.toSt
ring)
            // should be null if not in hashmap, won't compare below
            var messageOldEvent = messageOldEvents.get(actionItem.name.toString)
            messageOldEvents.put(actionItem.name.toString, messageEvent)

Finally, my test for unjammed looks like this:

            if (messageOldEvent == "11" && messageEvent != "11") {
                val String message = actionItem.label + " is no longer jammed"
                logInfo("Rules", "Lock: Alarm events: {}",message)
                sendMail("myemail@email.com",actionItem.label, message)
            }
1 Like