Help with a rule

I created a simple rule for an Echo device to play a greeting to the person who opens the door. There are 4 of us here and the rule works perfectly, but I would like the greeting to use "good morning", "good afternoon" or "good evening" instead of "hello" depending on the event trigger time.

I imagine I could use variables to the time question and to the users, but I have no idea where to start or how to implement this solution.

Could someone help me? Thank you very much in advance!

Do you have an existing rule already? If so, posting that here would make it easier for someone to suggest modifications.

If you don't, the general idea would be to trigger on "Lock code" for either "Any Lock Code" or the specific users you are interested in. There is a way to access the code name without needing to create a variable yourself: the built-in %value% variable will contain the event value (the lock code name) for the last triggering event (the lock code event, in this case).

Then, in your actions, you don't necessarily need variables to test time; you can just test the time (or mode, etc.) directly with conditional actions. A fully working example might look like this:

That being said, you also could put text like "morning" or "evening" into a variable, then concatenate it into a string later, but you'd probably need conditional actions to set that anyway, so it's probably easier to just do it all at once.

1 Like

Hi @bertabcd1234! Firstly, thanks for sharing your apps, I'm an user of CoCoHue and Device Activity check, they´re awesome!

Today I use the rule below, but your proposal achieves the desired result in a much simpler and more elegant way!

I used a workaround to identify the user replacing the returned value with the username, once my lock isn´t compatible with Lock Code Manager. I´m using an app developed by @thebearmay to receive the code associated to the event, and used it in the rule. So how should be that variables, something like this?

image

Basically, the lock driver returns the following data when it is unlocked: ** unknown codeNumber: 1, unknown codeNumber: 2, untill ** unknown codeNumber: 8**

So I have 8 codes that I need to associate to users. I know that I need a variable that set the user name in function of the code used to unlock the door, but I don´t know how do I set the multiple values to the variable, if I should use a Hub, Local or Connector variable, and concatenate it to the rule. I was searching the community but I´m not proficient enough to do it.

What is that screenshot from? Are those hub variables? I'm not familiar with the app you mentioned. But if you have the data you need somewhere (a hub variable, a device attribute, etc.), you should be able to use it.

For example: a hub variable would work--you'd need a hub variable to pass values between rules (local variables won't work; they are specific to the rule, and you don't need a connector, which is just a way to create a device to work with apps if that app can't work with variables directly--Rule Machine, and many apps nowadays can). But if it's a device attribute, you can use a local variable (set the variable to that device attribute value using built-in Rule Machine operations). Then, you can concatenate/interpolate that variable value into a string, either another string variable (using the operations in the UI) or notification/speech text directly (using %variable-name% as above, except with your own local or hub variable name).

Robert, thanks a lot!

With your guidance I achieved the result I wanted!

I created another rule to manage the three hub variables that I am using. After I understood the logic of variables I see that it isn´t so difficult!

Thanks again my friend!

1 Like

Download the Hubitat app