Author Topic: Make the OSD Show the Current Sonos Volume?  (Read 4368 times)

0 Members and 1 Guest are viewing this topic.

krismyklebust

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Make the OSD Show the Current Sonos Volume?
« on: September 01, 2016, 03:14:19 AM »
Hello everyone :)

In my living room I have a Playbar, two Play:1's and a Sonos Sub - grouped together and named Living Room.

I have successfully configured the left trigger (LT) and right trigger (RT) on my Xbox One controller to change my Sonos speakers volume.
This is done by using a combination of a keymapper software (Controller Companion), keyhooks in VoxCommando, and the Sonos.Player.AdjustVol action with changes of +/- 1%.

How would I go about showing an OSD with the current volume after each volume change?

Any and all help greatly appreciated.
Thanks in advance! :)

Kris
« Last Edit: September 01, 2016, 05:05:03 AM by krismyklebust »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Make the OSD Show the Current Sonos Volume?
« Reply #1 on: September 01, 2016, 08:10:28 AM »
Hi Kris,

There are a couple of ways to do it.  Basically you just need to add some actions to your existing command macro which adjusts the volume.

First of all, you said that you are using Sonos.Player.AdjustVol but you may want to use Sonos.Player.AdjustGrpVol instead since you are talking about a group of players.  Unless you only want to adjust the volume one of the players in the group.

Then you can actually just use an OSD action to display {LastInfo} after setting the volume.  If you hover over the action that sets the volume in the history window you can see that the average volume of the group is returned by the action as info (not as a result).

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.6-->
<command id="265" name="Sonos set get group vol with lastinfo" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Sonos.Player.AdjustGrpVol</cmdType>
    <params>
      <param>-1</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastInfo}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

However if you want to be more precise you can show all the individual volumes of each player in the group using Sonos.Player.GetGrpVol which can either return the average group volume or it can return all the volume levels in the group as a list of "matches".

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.6-->
<command id="265" name="Sonos set get group vol" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Sonos.Player.AdjustGrpVol</cmdType>
    <params>
      <param>1</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Sonos.Player.GetGrpVol</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.MatchConcat</cmdType>
    <params>
      <param>,</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

krismyklebust

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Make the OSD Show the Current Sonos Volume?
« Reply #2 on: September 01, 2016, 08:46:12 AM »
Hi! :)

That was a quick reply!  ;D

Duly noted. I will change my command macro to use Sonos.Player.AdjustGrpVol. :)
Not sure if this would make a difference, though?
Correct me if I'm wrong, but my Playbar is linked to the Play:1's and Sub, so any and all changes I do to my Sonos Playbar seem to carry over to them.

In any other room/zone setup with multiple speakers the Sonos.Player.AdjustGrpVol definitely makes sense.

Thanks for the very detailed explanation. I will try this as soon as I get home from work. :)

Kris

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Make the OSD Show the Current Sonos Volume?
« Reply #3 on: September 01, 2016, 09:18:58 AM »
You're probably right. I don't have a Playbar or sub.

krismyklebust

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Make the OSD Show the Current Sonos Volume?
« Reply #4 on: September 01, 2016, 11:45:25 AM »
Looks like I was already using Sonos.Player.AdjustGrpVol, but went ahead and tested Sonos.Player.AdjustVol as well. I can verify that in my scenario, both works. :)

I'm having trouble getting the OSD to show {LastInfo}. What am I doing wrong? :-[



Kris

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Make the OSD Show the Current Sonos Volume?
« Reply #5 on: September 01, 2016, 11:49:18 AM »
You are using an older version of VoxCommando.

{LastInfo} was added in version 2.2.1.7 as Sonos.Player.GetGrpVol

http://voxcommando.com/mediawiki/index.php?title=ChangeLog#Version_2.2.1.7

krismyklebust

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Make the OSD Show the Current Sonos Volume?
« Reply #6 on: September 01, 2016, 11:50:34 AM »
I'm an idiot.... I need a newer version of VC, don't I?



Kris

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Make the OSD Show the Current Sonos Volume?
« Reply #7 on: September 01, 2016, 11:51:07 AM »
Lol

krismyklebust

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Make the OSD Show the Current Sonos Volume?
« Reply #8 on: September 01, 2016, 11:55:06 AM »
So terribly sorry. I am embarrassed now, hehe. :-[
What's the quickest and safest way of upgrading without messing up my current commands? =)

Kris

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando

krismyklebust

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Make the OSD Show the Current Sonos Volume?
« Reply #10 on: September 01, 2016, 12:29:10 PM »
Thanks, that did the trick. :)

I somehow get an "OK" message in there every now and then...Not sure what is causing this
(check out the last action/line in the photo). Ideas?



jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Make the OSD Show the Current Sonos Volume?
« Reply #11 on: September 01, 2016, 12:35:40 PM »
I can't diagnose that from an image. Looks like you have an extra action in your macro or another command is being triggered by the event.

Send me a log if you cant figure it out yourself.

krismyklebust

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Make the OSD Show the Current Sonos Volume?
« Reply #12 on: September 01, 2016, 01:37:51 PM »
I've disabled all other commands but it still occurs.

Like I mentioned in my first post, I'm using Controller Companion to make the LT and the RT on my Xbox One gamepad simulate keystrokes on the keyboard.
I've tried several key combinations but still get the same results.
The macro I've set up in Controller Companion is set to auto-repeat if the triggers are held down.
I wonder if the problem occurs due to the sheer amount of repeated "keystrokes" I'm bombarding VC with...? If I take my sweet time, pressing the triggers, with pauses in between, the "OK" message does not pop up.

As evident from the log file I've attached to my post, this randomly pops up every once in a while:

01/09/2016 18:17:39   329   Action INFO: OK

Kris

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Make the OSD Show the Current Sonos Volume?
« Reply #13 on: September 01, 2016, 04:28:50 PM »
I wonder if the problem occurs due to the sheer amount of repeated "keystrokes" I'm bombarding VC with...? If I take my sweet time, pressing the triggers, with pauses in between, the "OK" message does not pop up.

I guess it's possible that multiple macros are running at the same time and the info from the action in one command is being shown in another.

It shouldn't happen but anything is possible.  If that's the case one thing you can try that might work better is to use the action to get the volume and then show the {LastResult} instead of {LastInfo}.  The only problem with that is that it's adding an extra action to your macro which means it will take a bit longer for each macro to complete.

krismyklebust

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Make the OSD Show the Current Sonos Volume?
« Reply #14 on: September 02, 2016, 03:06:30 AM »
The {LastResult} solution definitely gives me the result I've been looking for, but it is like you said, a tad slow compared to {LastInfo} giving me a significant delay due to the many repeated actions I'm triggering in rapid succession.
The reason for showing the OSD was to have more control of what the actual volume is, at any given time when adjusting it, so I don't accidently blast music out of the speakers at 1am because someone decided to mess about with the gamepad  :biglaugh
Maybe I'll just disable the OSD altogether and set an action on VC.Loaded to reset the Sonos group volume to X using Sonos.Player.SetGrpVol.
I'll keep thinking about how to solve this the best way - VC is insanely flexible and it always amazes me what can be done with it. Expect a donation coming your way in a few minutes.

Thanks again! :)

Kris
« Last Edit: September 02, 2016, 03:41:25 AM by krismyklebust »