Global Variables... I'm almost there

What I'm trying to do is send a song name ($songname) to a rule so that I can play it on the sonos. This way I have one rule that plays on the sonos and all other trigger rules I can send different sounds to sonos, kind of like using a function or module.

in RM, I defined a global variable "songname" string with no value initially.
I have a rule "test song name" that will set this variable to a name of a song (echo.ogg), then in run actions it will run another rule called "test global var".

rule "test global var" will "play track" on the sonos and in set track name, I have:
(BTW, if I use x-file-cifs://qnap-1/nas/!!/sonos/Ringtones/echo.ogg this works)

When I run "test song name" then go to RM global variables, I see "songname' being set, in this case to echo.ogg. so in my mind "songname" now has a value in the scope of RM.

However, when I run these rules, the song in the variable "songname" doesn't get played. Only the last song that I played without using variables plays.

What am I doing wrong? I've tried variations on {songname} like %songname%, (%songname%), maybe I'm down the wrong rabbit hole.


I just tried using a variable in the "Set Track" action/command from Rule Machine, and it gives me the literal text, not the interpolated value of the string with the variable (if it did work, %songname% would be the correct format here). I'm not sure what to suggest as a workaround here (besides a custom app) except a feature request that RM be expanded to support this, but I could see this getting messy if any "regular" URIs/tracks you'd specify contain percent symbols. Maybe someone else can think of another workaround...

1 Like

I need to be able to do this with my zooz siren.

I have created a variable but when I try to set the sound "number" it does not allow me to enter the variable (%vSound%) , which is a number