Easiest way to update variable string with current mode

I am trying to make a variable string which value follows the currently selected mode. If mode changes to "Home", the variable value also changes to "Home". What is the best method to accomplish this?

The idea is that I can then use the variable value to generate messages with the current mode included in the text.

A simple rule like this should work:

Trigger on mode change, set variable to '%value%'

(The key is that the built-in value variable, accessible like any variable via %value%, will be a string value set to the current mode if the trigger is a mode change. You can assign it to a "real" variable in this way, making it usable globally or however else you want.)

2 Likes

Yup that worked.

Funny thing is I actually tried that first, and it showed a value of 0 would be applied, which I figured meant using %value% was not going to work as I had wanted.. I never actually RAN the rule though. As soon as I did, the value changed to the correct value.

Yeah, the values of most built-in variables relate to trigger events and will not normally show an expected value if the rule was not actually trigged (including "Run Actions," where there isn't a real trigger event, either).

2 Likes

This is good to know, as I do this a lot with commonly run actions that I can bundle together in a trigger-less rule and just run it from other rules.