Is there a way to get an app notification with the name of the code that was used whenever a lock is unlocked with a code? It looks like I should be able to set up a rule for each code, but that is cumbersome. How can I set up one rule that would insert the name into the notification? I am thinking variables may be the answer here, but I don't know enough about how they work.
Yeah but you have to create the text for the notification. I don't know what to put in the text that will cause the system to insert the actual name assigned to whichever code is used. That's what I'm asking here.
I want the notification to be something like "[name] has unlocked Front Door" where [name] is the name assigned to whichever code was used.
I don't understand your problem. Let's say in Lock Code Manager you had 4 codes assigned. They were named: Bob, Sue, Frank, Mary
Trigger: Any lock code entered
IF lock code entered is Bob, then
send message "Bob unlocked the door"
Else-IF lock code entered is Sue, then
send message "Sue unlocked the door"
Else-IF lock code entered is Frank, then
send message "Frank unlocked the door"
Else-If lock code entered is Mary, then
send message "Mary unlocked the door"
Let's say you didn't name your codes, Bob, Sue, Frank, and Mary. But instead just named them by their code. The above still works fine. Just change to:
IF lock code entered is 1234, then
send message "Bob unlocked the door"
Yes, that works.
The only problem is I would have to alter the rule any time I add a code.
What I am wondering is if there is a universal built-in way to send a notification for any code and the system automatically inserts the name of the code, specifically to avoid this kind of cumbersome programming.
Sure, in the notification use:
%value% has unlocked the back door.
%value% will be the Name of the User that you assigned in Lock Code Manager.
Thank you! That's what I was getting at. I figured it was going to be something a long those lines, I just wasn't sure exactly what it would be.
Glad I could help. Whenever I am sending a notification out from Rule Machine I often will first send out a test notification written like this: %device%, %value%
I see what gets sent in the message and see if it would be useful to use. What gets sent seems to always have to do with the triggering device.
You can use %device%, %value%, %time%, %date%, %now%, %nameoftheglobalvariable%
You may want to use %time% in the rule you are making above. There might be more of these you can use but the ones above are mentioned in RM, they can also be used in other areas of Hubitat including HSM.
It actually looks like the only parameter in I need in the message is %text% .
When I use the following:
%device%, %value%, %text%, %time%, %date%
Front Door, Ken, Front Door was unlocked by Ken, 05:55pm, 10/18/20.
I really had no idea what %text% would contain, but I'm glad I tested it!
%text% at %time% on %date%.
Front Door was unlocked by Ken at 05:58 PM on 10/18/2020.
This is exactly what I was looking for! Thank you so much for pointing me in the right direction!
Turns out it gets even better!
If I use Lock instead of Lock Code as the type of device to get notifications for and all I put in the notification text is %text%, I get all of the following types of notifications, depending on how the lock was actually unlocked:
Front Door was unlocked manually [physical]
Front Door was unlocked via command [digital]
Front Door was unlocked by Ken
I was planning on trying to figure out the best way to get notifications when the door was unlocked manually, without doubling up on notifications when unlocked by code. Glad to discover that this method encompasses manually and code without duplicate rules. This is all in the Notifications app, by the way, not in RM. Notifications allows for some simple conditions, so I can get these notifications only when the mode is Away. If I want to have more complex conditions, I'll have to move over to RM. I'd love to see presence supported in the Notifications app. I can't find that anywhere.
What if i want it to say something different when the door is unlocked manually as opposed to having a code entered?
So for manual it would say: The front door was just unlocked (i.e., if someone unlocks it from the inside to go out)
And for code it would say: The front door was unlocked by %value%
IS that possible?
Use Lock as the type of device instead of Lock Code.
Yes I saw that above, but then the message can't be changed right? It would have to be whatever %text% is preprogrammed to be? I'm wondering how flexible i can get with the messages to be clear. Thanks for the quick response also.
%text% provides the description. You can type anything before or after... that %text% is just a variable to display the description.
Use %device% to include event device name, %value% to include event value, %text% to include event description, %time% to include event time, and %date% to include event date.
Use lock code as the device type and use value as the user name
Correct but i think the "problem" is the %text% expression is "Front Door was unlocked by (and then whatever way it was unlocked).
Let me see if i can make it a little clearer as my messages above is admittedly a little confusing.
Let's say on manual unlock i want it to say "The front door was just unlocked".
And on code entry i want it to say "welcome home %value". How could i do that? IF i put %text% it's going to say "The front door was just unlocked by (whatever method)" Haha sorry if i'm still not clear.
What I'm saying is %text% says the entire phrase "Front Door was unlocked" and then it says the method according to what @kosmicken says.
What you really want is a custom notification which you'll have to do in RM4 since you want to combine the variables from the different device attributes. Which means you'll have to come up with your own logic.
Got it. ok thanks for your patience, i'll try it out!
It'll make it a lot easier too if you do two separate rules for your particular condition matching. One for when the device is unlocked manually and one for when a code is used.
Agreed, RM will need to be used for advanced logic.
To each their own, but I have been perfectly happy with the very detailed description provided by just using %text%.
I'm happy that my tinkering is helping someone else!