Extracting device events or Hubitat Logs for RM use?

Hey all,

Are we able to pull device events or Hubitat Logs for use in Rule Machine (either legacy or 5.0)?

My situation is as follows - My Yale lock only shows the following device states:

  • "lastCode" (Whatever the last user code that was used)
  • "lock" (if the lock is currently locked/unlocked)
  • Few other code-related things that are unrelated to this post, really

So using Rule Machine, I can't really create a notification that says "Lock was physically locked" or "Lock was locked via Z-Wave", etc. That being said, it appears as though Device Events and Hubitat Logs has this information, so it's definitely provided via Z-Wave:

dev:3152021-07-28 18:56:32.815 infoFront Door Lock was manually locked [physical][6:1]
dev:3152021-07-28 18:56:22.072 infoFront Door Lock was manually unlocked [physical][6:2]
dev:3152021-07-28 18:27:28.404 infoFront Door Lock was manually locked [physical][6:1]
dev:3152021-07-28 18:27:21.561 infoFront Door Lock was unlocked by Jane Doe[6:6]
dev:3152021-07-28 18:27:09.052 infoFront Door Lock was autolocked[6:9]
dev:3152021-07-28 18:26:31.855 infoFront Door Lock was manually unlocked [physical][6:2]
dev:3152021-07-28 17:58:09.633 infoFront Door Lock was manually locked [physical][6:1]
dev:3152021-07-28 17:57:20.767 infoFront Door Lock was manually unlocked [physical][6:2]
dev:3152021-07-28 17:54:08.813 infoFront Door Lock was manually locked [physical][6:1]
dev:3152021-07-28 17:53:57.623 infoFront Door Lock was unlocked by John Doe[6:6]
dev:3152021-07-28 17:53:03.136 infoFront Door Lock was manually unlocked [physical][6:2]

I could at this point send a notification when the door is locked or unlocked, but anything beyond "door is unlocked/locked" is impossible. It's also really not doable to say how the door was locked or unlocked, as

ASK

How can I leverage these logs or Device Events in a Rule Machine message action? At the very least, I'd love to be able to send that raw log message, and my stretch goal is to use regex, etc to modify the message to remove pieces of the string, etc.

Of course, a driver update to incorporate this info would be ideal, but hoping I can work around the issue short-term using RM.

Thanks!

A while back I wrote a quick app to help someone get around an issue with a fingerprint lock that wouldn’t return the lastcode name. It may be something that you could use or quickly modify to do what you want.

https://raw.githubusercontent.com/thebearmay/hubitat/main/apps/lockHistory.groovy

Rule 5.0 added a feature where the a new, built-in %text% variable contains the event description. This is likely what you see as those "info" logs you copied/pasted above, but check the "Events" button on the device page to be sure (specifically, check the "description text" column there--that's what this really refers to, though most drivers log the same text). You can't do much directly with this variable for comparisons, but you could assign %text% to a local string variable in the rule (or a hub variable if you need to), then do a "contains" operation on that variable to search for "[physical]" (or "[digital]") and act accordingly on that result--assuming you didn't name your device something weird that would put this text in the event description, which usually contains the device name (it's sort of a low-tech way to get this info). :slight_smile:

The other thing I'd do is make sure that your lock actually reliably reports this information in the way that you expect. Z-Wave locks are tricky for many people and might to surprising things sometimes...but it sounds like you've done at least a little digging and aren't shocked by anything you've found.

2 Likes

This worked like an absolute charm. Thanks for the info!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.