Extra event 'data' properties

Some events, like unlocking a door with a code on the keypad, store additional metadata about the event in a data attribute when the event is generated. The data attribute from events is now exposed in the ‘Extra Data’ context variable in rules!

When using Context Variables for Event → Device, you’ll now see an ‘Extra Data’ option which will prompt you for the extra data ‘property’ that you are trying to access. If you’re not sure what property to use, see the ‘How to find data property names’ section below.

Like other context variables, the ‘Event Data’ value can be used in conditions as well as actions like notifications. In the case of door locks, common* properties include:

  • codeId - which code ‘slot’ was used to unlock the door
  • codeName - the name of the code (if you named it while creating it in SmartThings)
  • method - indicates if it was unlocked with a keypad, auto, manual, command`, etc

:warning: These properties are not standardized, so you should check the documentation for your hub or device driver to confirm.

Example Rule

In the example rule below, I’m using a trigger of lock changes to unlocked so I can get the numeric codeId (slot) that was used for unlocking the door.

 

Video Demonstration (tap to open)

One of our community members was asking how they could get the codeId that was used to unlock their door and send that over to an HTTP API, so I put together the video below.

It was originally intended this as a brief video, but I guess I got a bit carried away showing a few approaches!

How to find data property names

One approach is to check the documentation for your hub or device driver to see if the ‘data’ property is documented.

SmartThings

These additional properties don’t show up directly in the SmartThings capabilities documentation , but if you tap the JSON link in the top-right corner of a documented capability, you may see additional data documented until the attribute schema.

fmkiMVMpVK

Hubitat

This seems to vary widely across different device drivers and does not appear to be well documented, so either check with the author of your driver or try setting up a sample trigger as noted below.

Also note that many of the built-in lock drivers include a separate lastCodeName property which will be set if you created the code for your door using the Hubitat interface (rather than on the lock itself).

However, you may find it easier to setup a rule with your desired trigger (eg. lock changes to unlocked) and save it. Then trigger the rule, for example by unlocking your door with a keypad code. At that point, you can review the rule logs for the trigger line (the first line) where you should be able to see the raw event, including the data property under the Runtime Data section.

If you’re still having difficulty, feel free to create a new thread with the details of the driver you are using

5 Likes