Rule Machine Editing of Individual Lines in a Rule

I have an app in Rule Machine where I use a couple of different expressions to do the same thing, but I don't remember why. Both are to set the volume in one of my Sonos players. The first rule (which seems to work) is "Living Room Sonos --> Set Level to 85". The other rule (which doesn't seem to work) is "Set Volume on Living Room Sonos to 30". I would like to replicate the first rule (and change the volume to 30) but there doesn't seem to be a way to copy that line and paste it where I want. You may say, well, just recreate that first rule where you want it. But the GUI doesn't seem to allow that; it only allows me to create it the format of the my second rule. Yeah, and I don't remember how I did the first one. Am I missing something in the Rule Machine options?

Might the first rule have been created using a custom attribute, rather than the standard ā€œset volumeā€œ action?

I'll try to check that and report back (but not immediately as I have to go somewhere).

Sorry for the confusion. There is a way to copy an individual rule. Male-pattern blindness on my part. But the second implementation of the rule still doesn't reset the volume. ??????????????????

There are at least 3 ways to set volume on music or speech devices:

image

1 Like

OK, well none of those options works when I invoke them to set the volume back to "normal" after my barking dogs routine runs. As stated, the first volume set action works, and I can see it work, because before I run the rule I set it higher and then it sets it back to 1 to kick off the routine, but does not set back to 30 at the end. Any thoughts? I tried all three methods as you can see.

BTW, I set it to 1 for testing so it doesn't drive my wife nuts. It also doesn't seem to matter whether I have that final Delay action before or after the reset volume actions.

Have you test this using Sonos Advanced Controller? I recall it having a ducking feature where an MP3 audio file could play without the need to stop whatever's currently streaming/playing.

No, wasn't aware of it. Will take a look. But not understanding how that will solve my volume resetting problem? Now that I have glanced at the writeup I see if deals with volume issues. Will report back.

Have you checked events and debug-level logging to see what is and isn’t happening?

No, I'm kind of an ignoramus regarding events and logs. Would I do this in the device events and logs? Sorry for dumb question.

In the ā€œSonos Living Roomā€ device’s preference page there (should be) is a way to turn on Debug (or maybe Trace) level logging.

Then run one of the commands and check events and logs from the device page.

I look at the events and it does show the setvolume command being issued, but it's definitely not happening. I'll try to turn on the logs.

Also, try putting a delay after the END-RP command to make sure the track play has really finished.Try 30 seconds to start.

If you are sure that the first volume setting action (to "1") works, I'd try to isolate the problem as follows:

  1. Disable the Repeat and END-REP actions by clicking on their associated X box at the right of the table, to simplify the test rule (BTW, it is possible the Rule never left the loop if the Sonos took longer than 13 seconds to respond to the Play Track action).
  2. Disable the "Set Volume" and "setLevel" actions the same way, leaving only the "Sonos Living Room" action enabled.
  3. Click on "Done with actions", which takes you back to the screen that includes "Update Rule"
  4. Turn on logging of Actions for the Rule in the control near the bottom left of the screen.
  5. Click on "Update Rule" and then test the Rule.

I haven't yet implemented your suggestions as to disabling certain lines, but I have implemented logging and have trouble interpreting all the code, but I do see that the current state of the device is Volume=30, but for some reason the actual Sonos Controller isn't getting the message. :grinning: and thus the volume of the device is actually still at one. I just don't see how the first volume control works fine but the second one doesn't. I don't know if this behavior is a new phenomenon or has always been that way. I just noticed it when I tried to play some real music in that room and almost blew out my ears. See, normally when the dogs barking rule kicks off there is no music playing. OK, now I will try to implement your disabling suggestions, but based on the fact that the last logged event shows volume being set to 30, I don't think it will make any difference. But I shall try.

One last thing: according to the Events, all commands are executing exactly as they should. I think the problem is in the interaction between the Hubitat world and the Sonos Controller world. But strangely, except for the final volume reset, everything else works exactly as it should, timing and all.

"Actions" is the more important logging to review.

Well, I can't interpret the logs as they just show a string of digits/characters that are meaningless to me, but the Events tab show the results of the rule's execution, and all seems to be in order. But it's not.

Just to be clear, your log for your Rule should look something like this (this is the log from the test Rule I posted earlier):

Try adding the delay as I mentioned earlier. You may be trying to change the volume while the device is still working on the previous command.
It may not be ā€œseeingā€ it if it’s still busy.

I tried it. Didn't make any difference. I also temporarily disabled the repeat 4 times action so it just played once.