This is my first time trying to use local variables in a rule machine rule, and I’m stuck even though I feel like it should be fairly simple. Could someone please give me some direction?
What I want to happen is to have a single rule that monitors several switches, and performs a different action based on which switch was actually turned on. Alexa is going to be turning the switch on, and then rule machine should see that it was turned on, and run a corresponding Logitech Harmony routine (which appears as a switch). Anyway, where I am getting stuck is trying to do a conditional action based on the device name. I tried setting a local variable (named whatSwitch) to equal %device%, but that is not working.
You would need a rule action that sets your local variable to the value of %device%. It looks like you may have tried to set it initially/once to that literal text, which is not going to work.
However, if you want to do different actions in response to different devices, then it’s probably better to just make separate rules for each. RM doesn’t really have a concept of devices as variables, so you can really only use their name, as you were trying to do. That is a bit fragile, because things can break if you change a device name, among other concerns.
Thanks, Bert - ironically, I was going to do the separate rules, but thought doing it this way might be easier long-term to keep fewer rules to slog through. :). Ok - so I will probably do the separate rules, then, but since I am in learning mode, could you help me with how to set the variable as an action? I went to do it, and thought I hit the right choice, but don’t see “variable” as an option here:
You should -- it should show as "Set Variable." It will be hidden if you don't have any variables defined, either local variables or hub variables, so I'd assume that would explain what you see above. If not, refresh the page, and see if that helps.
You rock - thank you! I had deleted the whatSwitch variable with the intention of dynamically creating it through the Action, but I guess it does not work that way. Thank you for the help and clarification!