Messages in RM

Is there a way to generate a text message that can dynamically pull a particular attribute value from a particular device in the body of the text.

What I am trying to do is generate simple messages that say "[Person A]'s code has been entered on [lock device]"

I can easily do this with the notification app, but that app doesn't provide the necessary flexibility I need to integrate it into other automations that already exist within Rule Machine.

You can do this with conditional actions in Rule Machine. If [Lock Code is entered] Then [Update a variable or write to a local file]. A hub Variable will be the most useful for using with other RM rules.


Yeah, I was thinking Hub Variables might be the direction I have to go. I was hoping there was some wildcard or variable where I could just do something like %device_[device#]% %attribute_lastCodeName% or something cool and already baked in for this type of purpose.

I think this can be done with set variable tokens, but I'm not familure with actually using that functionality. Perhaps @bravenel could give some pointers, or propose a better way to achieve this.

I got it working perfectly using a hub variable. The nice thing about the variable is that I can use it not just for notification purposes but also a way to keep track of the last code entered that wasn't my code or my wife's code.

Token is used if a variable contains element - I have one variable with three elements delimited with colons, and then in another rule I extract the three string variables using “set variable/token #”, And then convert two of them to numbers.

It’s a little bit of a PIA but only had to be set up once, then in other rules I only need to set one variable instead of three.


Damn, that is extremely useful. I already have a perfect use case for tokens. Thanks for that!

1 Like

So I'm trying to do something here and I think it may be similar to your usage.

I'm trying to make a variable that can store the last three code names in a variable with three elements. So at the moment I created a string variable with an initial value of "A;B;C". What I'm trying to do is store the last three codes entered, where the latest code is always the first, then the previous first token becomes the second, the previous second token becomes the third, and the previous third value is discarded.

However, when I try to "set variable" and select "token", it appears to work the other way only. I can pull a value from a token and apply it to another variable, but I can't seem to figure out how to take a device attribute and apply it to a token slot...

1 Like

You are correct. In my scenario I am am setting all three tokens with a single set variable command and then the other rule extracts them.

I do not think there is a method to set or replace a token.

I believe you will need to extract the tokens, shift them while adding your new token and then concatenate them and use a single set variable to get it back in there.

It may be easier in your case to use three separate variable and to shift the data through them.

Or maybe someone on here can correct us both.

1 Like

So I figured out how to do what I needed. I had to make a rule with tons of local variables to store the elements I needed separately, and then write them in one string to a global variable with semicolons to delimit the elements. Then I can extract the various elements from other rules using tokens. Worked perfectly. Thanks for your help!

1 Like