Playtextandrestore and rule machine 5.1

I have used the playtextandrestore custom action on my sonos hub a fair bit with rulemachine 5.0, and I think I have found an issue with the handling of variables and this function under 5.1

Under rulemachine 5.1, I write a rule that does this

PlayTextAndRestore("this is a test", Announcement volume) on Living Room Sonos

where Announcement volume is a hub variable set to 75. when I create the rule, I get the following

If a change the variable to a hardcoded 75, it works fine. I used this exact same action under 5.0 without any issues

Might be old eyes, but it looks like the error message has a period separating the values instead of a comma.

There is a bug with variables in Custom Action that has been fixed. Will be released soon...

1 Like

Hi there, I'm assuming this (PlayTextAndRestore) restores the speaker back to what it was playing prior to making the annoncement?? Can you provide an example of how to right the rule to do this?? Been wondering for years. I can't find this as an option when I add the Action in the Rule. Or do I just write - PlayTextAndRestore("what ever the announcement is', 50)
as what is to be announced??
Thanks heaps in advance

Select Custom Action as your action in Rule Machine.

Thanks, I'm up to 'Select Parameter Type' - I've selected - String - & put in the text I want announced
Then how do I set the volume?? for the speaker ??

first parameter is string, which is the message you want to say
second parameter is a number, which corresponds to the volume from 0-100

Thanks didn't see this prior to editing previous. Do I need to select 'Use Last Event Device?'

It seems to be working now with the latest version but I now get this error in my logfiles

Here is the rule

Please turn on Action logging in that rule, and post another screenshot of the logs.

Thanks, I will track that down.

Just in in case it matters, I was clicking on "run actions", not rebooting the hub to trigger this.

BTW, you don't need a custom action to do this. You can use the Speak from Send Message; it does the playTextAndRestore on a Sonos.

But, thanks for pointing out the bug...

1 Like

For what it's worth, I'm seeing the exact same error when I try to use the "setTemperature" custom action for a virtual thermostat using a number variable.

Thanks, Bug has been found and fixed, for next release.

Hi, I have this rule, the radio does not start playing again after an announcement -

This is the RM 5.1 Rule -

This is the log, shows nothing, I guess the rule is not correct? -

Hi, are you saying it is supposed to PlayTextAndRestore auotomatically on Sonos?? If it is, it definately doesn't work any more. I recall it used to restart the radio after an announcement, doen't any more. I just altered the rule I jsut made in RM5, definately doesn't work there either

No, I was just pointing out that Speak in Send Message uses playTextAndRestore, assuming the Sonos is selected as a Music Player, so there is no need to use a custom action to get that command sent. Whether or not that works on a given Sonos at a given moment is beyond my pay grade.

2 Likes