Announcement

Collapse
No announcement yet.

Feature request

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Feature request

    Is there any way we could have Sonos Trigger or Condition when a TTS announcement is active. Triggers would be "Sonos Announcement begins" and "Sonos Announcement ends". The Condition would be "Sonos Announcement Active". Alternately some hooks into the plug-in that could control a virtual device when TTS is active. This would save a lot of event logic that I have to employ now.

    Another enhancement would be an announcement level child for each sonos device. If I were to build a Linkgroup without setting the volume of each client, it would revert to this child device level. This would allow me to apply levels to announcements based upon different conditions in a room or the house. For example, if we are watching TV in a room, we might want to bump the level up a little.

    Right now I am doing this with linkgroups, but you can imagine how many linkgroups it would take to accommodate one or many of my 10 clients on a case by case basis.
    Last edited by randy; August 9, 2017, 01:30 PM.
    HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

    #2
    I second this idea. Perhaps also allow the child device levels to change based on scripting.

    I have 13 sonos devices and around 50 linkgroups so far.

    Comment


      #3
      Originally posted by prsmith777 View Post
      I second this idea. Perhaps also allow the child device levels to change based on scripting.

      I have 13 sonos devices and around 50 linkgroups so far.
      If it is a HomeSeer device, scripting could be used to control it. While I am dreaming it would be great to have two devices associated with each client - "TTS Level" and "TTS Member". Those two devices could use events or scripting to build an announcement linkgroup on the fly.
      HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

      Comment


        #4
        That would be great and would solve a lot of problems. When I was using Russound for my announcements, I used an occupancy script to only announce in the rooms that were occupied. Not so easy with Sonos when you have multiple devices.

        Comment


          #5
          As you are suggesting you need to script anyway, suggest you do it directly in the sonos.ini file. What you are asking is a major rewrite of the code but I think you can do it quite simple yourself.

          In the ini file, there are 3 sections that are of importance to you:

          SECTION 1
          [LinkgroupNames]
          Names=All

          Suggest you don't make any changes to the LinkgroupNames section, there is really no need. Use the PIs functions to make one or a few linkgroups with your names that you are going to use in your scripts.

          SECTION 2
          [LinkgroupZoneSource]
          All=RINCON_B8E9377C7E2601400;0

          As you can see in this example, you index it with the linkgroupname you created, ie "All" in this example. Then you use the Sonos Unique Device Name (UDN) RINCON_XXXX to determine which player will be the source of the announcement broadcast. I think in most cases, this is always the same so you may never need to change this. The parameters are seperated by ";" semicolons, the second parameter after the UDN indicated whether the source uses its line-input or not. A 1 means use the source players line-input. Don't think too many people are using this anymore so a '0' is probably what you need here.

          Because the ini file is being cashed by HS3, you cannot modify it so use these 2 functions to set/get

          Public Function GetLinkgroupZoneSource(ByVal LinkgroupName As String) As String
          Public Sub SetLinkgroupZoneSource(ByVal LinkgroupName As String, ByVal Value As String)

          SECTION 3
          Here is what you probably want to change each time before you trigger the announcement.

          [LinkgroupZoneDestination]
          All=RINCON_B8E9377C7E2601400;40;1;0|RINCON_000E58FDE7DA01400 ;20;0;0|RINCON_000E58C174F201400;30;1;0|RINCON_000E58C174DE0 1400;;1;1

          As you can see in the example, the index 'All' is the linkgroupname and there are a number of sections separated by '|' characters and in each section you have the parameters for each zone that will be outputting your announcement. In this example, there are 4 potential destination players. If you study your ini file, you will see most likely all players you have.

          Each section holds 4 parameters separated by semicolons ";".
          First parameter is the UDN of the player
          Second parameter is the volume you want the player set to. Leave this parameter blank if you want the volume unchanged.
          Third parameter will be 1 if you want to forcibly unmute the player or 0 if you want to leave the player mute state unchanged
          Fourth parameter is 1 if the player is actually used as a output player. A zero means the player is not involved.

          Here are the functions to set this section.

          Public Function GetLinkgroupZoneDestination(ByVal LinkgroupName As String) As String
          Public Sub SetLinkgroupZoneDestination(ByVal LinkgroupName As String, ByVal Value As String)

          I've also attached a screenshot of the linkgoup info as seen via the PI so you can correlate my example above with what you would see.

          Good luck,

          Dirk
          Attached Files

          Comment


            #6
            Randy, have you had a chance to try this? I have been busy lately and have it on the back burner to work on.

            Comment


              #7
              These script functions work perfectly and allow me to create an "announce" setting in the ini file with custom room combinations and volumes.

              Here's an example:

              hs.pluginfunction("Sonos", "", "SetLinkgroupZoneDestination", {"ANNOUNCE", "RINCON_5CAAFDF3308E01400;85;0;0|RINCON_000E58D5C87601400;75 ;0;1"})

              THANKS!

              Comment


                #8
                Originally posted by prsmith777 View Post
                These script functions work perfectly and allow me to create an "announce" setting in the ini file with custom room combinations and volumes.

                Here's an example:

                hs.pluginfunction("Sonos", "", "SetLinkgroupZoneDestination", {"ANNOUNCE", "RINCON_5CAAFDF3308E01400;85;0;0|RINCON_000E58D5C87601400;75 ;0;1"})

                THANKS!
                I haven't been able to try it, but I will try what you posted. I'll just get a template made from my current configuration and give your function a try.
                HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                Comment


                  #9
                  I tried it and it works well.

                  Now I need to hone up on my scripting skills. I want to build a pair of virtual devices for each client - "Announcement Enabled" and "Announcement Level". Then I want to build a script that will look to those devices to build a linkgroup. Then I can set the values of those virtual devices and call the script.

                  Alternately I might build a series of scripts that will alter the linkgroup specifically for different scenarios.

                  My desire would be to set levels based on if we are watching TV, listening to music in a Sonos zone, adjust the levels based on time of day and importance of the message.

                  Considering how stellar my scripting skills are, I'll post back here in 2018 when I get it figured out
                  HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                  Comment


                    #10
                    This is what I have now. I had created over 50 linkgroups to make these different scenarios work with my 13 zones.

                    Now with this new scripting available I can create a device for each zone/client, as you were thinking about doing. I plan on having a script run any time any one of those devices changes and update the "ANNOUNCE" linkgroup. When there is an announcement, I announce with this linkgroup. This method is preferred as it keeps the updating linkgroup out of the announcement script, which might cause delays.

                    For volume control, I like your idea of having them stored in virtual devices, but I prefer to have both the volume and mute/announce in one device. Could do something like device value 1-100 is volume but muted and 101-200 is volume announced.
                    Attached Files

                    Comment


                      #11
                      Here is what I came up with. I created 8 virtual devices:

                      Click image for larger version

Name:	capture.png
Views:	1
Size:	54.2 KB
ID:	1191824

                      Click image for larger version

Name:	Capture1.jpg
Views:	1
Size:	64.7 KB
ID:	1191825

                      The devices have a value of 0 for Muted, then a range of 1-100 for level.

                      Now I need to figure out how to build a script that can take the values from the virtual devices and create a string that would alter the group. I built an "ANNOUNCE" group with all eight of my Sonos devices. I would then build this command

                      &nhs.pluginfunction("Sonos", "", "SetLinkgroupZoneDestination", {"ANNOUNCE", "RINCON_000E583C92DE01400;40;1;0|RINCON_949F3E1ED0A201400;30 ;1;0|RINCON_000E583177CA01400;40;1;0|RINCON_000E58D8669E0140 0;40;1;0|RINCON_5CAAFD97C8FA01400;30;1;0|RINCON_000E58D92EE2 01400;40;1;0|RINCON_000E58D91EBE01400;40;1;0|RINCON_5CAAFD4F 8BBC01400;30;1;0"})


                      Since each player is the same other than its address I would like to take a string "RINCON_000E583C92DE01400;40;1;0" and replace the first value (40) with the value from the virtual device, then if the virtual device is at 0 or muted then I would set the third value to 0, otherwise set it to 1.

                      I've already tested it and it does exactly what I want. if the final number is 0, the device is not included in the linkgroup, if it is 1 then it is.

                      I would like to have an event set the 8 virtual device values, then run the script to build the text for the ini file.

                      I'll get there, but as I said above my scripting skills are near nil.
                      HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                      Comment


                        #12
                        Looks good. Do you know of any way to have the drop down values increment in steps? I'd like my volume control to go 1-100 step 5.

                        Comment


                          #13
                          Originally posted by prsmith777 View Post
                          Looks good. Do you know of any way to have the drop down values increment in steps? I'd like my volume control to go 1-100 step 5.
                          I can think of two ways, an event that adds or subtracts 5 from the value of the device. The event could be triggered by an "Up" or "Down" control button added to the device. Or make the volume value in the virtual device from 1-20 and take care of it within the script. To me it makes no difference since I plan on arbitrarily setting the levels by an event, I will not be stepping the volume, simply setting its value. For that reason, I decided to make the virtual device mirror the values that will be set into the Linkgroup string.

                          Since I am just getting started, this may change. I need to figure out how to build the linkgroup string within a script. I was thinking about an array of the device IDs then stepping through them to build the linkgroup string.

                          My starting point is
                          Code:
                          'Define Sonos Client and Announce VD Array
                          '5178 	RO	RINCON_000E583C92DE01400 (1)
                          '5179 	USB	RINCON_949F3E1ED0A201400 (2)
                          '5181 	MBR	RINCON_000E583177CA01400 (3)
                          '5184 	MR	RINCON_000E58D8669E01400 (4)	
                          '5174 	MO	RINCON_5CAAFD97C8FA01400 (5)	
                          '5185 	Shed	RINCON_000E58D92EE201400 (6)
                          '5170 	LR	RINCON_000E58D91EBE01400 (7)
                          '5177 	DSB 	RINCON_5CAAFD4F8BBC01400 (8)
                          
                          
                          'current Linkgroup
                          'ANNOUNCE=RINCON_000E583C92DE01400;40;1;0|RINCON_949F3E1ED0A201400;30;1;0|RINCON_000E583177CA01400;40;1;0|RINCON_000E58D8669E01400;40;1;0|RINCON_5CAAFD97C8FA01400;30;1;0|RINCON_000E58D92EE201400;40;1;0|RINCON_000E58D91EBE01400;40;1;0|RINCON_5CAAFD4F8BBC01400;30;1;0
                          
                          'Use the reference ID of the devices in the arrays below
                          
                          dim array_announce() as string = {"5177", "5170", "5181", "5174", "5184", "5178", "5185", "5179}
                          
                          dim array_clients() as string = {"RINCON_000E583C92DE01400", "RINCON_949F3E1ED0A201400", "RINCON_000E583177CA01400", "RINCON_000E58D8669E01400", "RINCON_5CAAFD97C8FA01400", "RINCON_000E58D92EE201400", "RINCON_000E58D91EBE01400", "RINCON_5CAAFD4F8BBC01400"}
                          
                          
                          dim linkgroup as String = ""
                          
                          dim dstr as string = ""
                          Dim dv as Object
                          
                          sub Main(ByVal Parms as Object)
                          Try
                          'Counts thru array to check each client virtual device
                          for each devw as string in array_announce
                          	if hs.DeviceValue(devw) = 0 then
                          		
                          	end if
                          	Else If hs.DeviceValueByName(devw) > 0 then 
                          		
                          	end if
                          End Try
                          End Sub
                          Now I am thinking about how to build the string
                          Last edited by randy; August 5, 2017, 10:26 PM.
                          HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                          Comment


                            #14
                            I ended up making two virtual devices for each sonos player I have, one for mute/play and one for volume.

                            The values are mute =0 and play =1
                            The values for volume range from 1-100

                            I then created this script that pulls the device values for each player and loads them into the string.

                            Code:
                            Sub Main(Parm As Object)
                                
                            dim linkstring as String
                            
                            linkstring = "RINCON_5CAAFDF3308E01400;" & hs.devicevalue(772) & ";0;" & hs.devicevalue(755) & "|"
                            linkstring = linkstring & "RINCON_000E58D5C87601400;" & hs.devicevalue(782) & ";0;" & hs.devicevalue(760) & "|"
                            linkstring = linkstring & "RINCON_5CAAFDF2DE2401400;" & hs.devicevalue(774) & ";0;" & hs.devicevalue(757) & "|"
                            linkstring = linkstring & "RINCON_5CAAFD0DD02A01400;" & hs.devicevalue(783) & ";0;" & hs.devicevalue(761) & "|"
                            linkstring = linkstring & "RINCON_5CAAFD09C92201400;" & hs.devicevalue(773) & ";0;" & hs.devicevalue(768) & "|"
                            linkstring = linkstring & "RINCON_5CAAFDE3104401400;" & hs.devicevalue(771) & ";0;" & hs.devicevalue(766) & "|"
                            linkstring = linkstring & "RINCON_949F3E847A5601400;" & hs.devicevalue(769) & ";0;" & hs.devicevalue(754) & "|"
                            linkstring = linkstring & "RINCON_5CAAFD9B1BDC01400;" & hs.devicevalue(777) & ";0;" & hs.devicevalue(762) & "|"
                            linkstring = linkstring & "RINCON_949F3E848C2E01400;" & hs.devicevalue(775) & ";0;" & hs.devicevalue(763) & "|"
                            linkstring = linkstring & "RINCON_5CAAFD97EA2E01400;" & hs.devicevalue(779) & ";0;" & hs.devicevalue(753) & "|"
                            linkstring = linkstring & "RINCON_5CAAFDE3DD6201400;" & hs.devicevalue(781) & ";0;" & hs.devicevalue(767) & "|"
                            linkstring = linkstring & "RINCON_5CAAFD9B1B6201400;" & hs.devicevalue(780) & ";0;" & hs.devicevalue(764) & "|"
                            linkstring = linkstring & "RINCON_5CAAFD09C89001400;" & hs.devicevalue(773) & ";0;" & hs.devicevalue(768) & "|"
                            linkstring = linkstring & "RINCON_B8E937DED3A601400;" & hs.devicevalue(765) & ";0;" & hs.devicevalue(770)
                            
                            
                            hs.pluginfunction("Sonos", "", "SetLinkgroupZoneDestination", {"ANNOUNCE", linkstring})
                            End Sub

                            Comment


                              #15
                              I took the above script and modified it for my use. It works great.

                              It would still be very helpful if I had some device that could tell me whether Sonos TTS is active or not. This is why I started this thread. If I had some way of being able to determine if TTS is running or not, it would really help with controlling announcements that aren't specifically sent to Sonos, but intercepted from another client.

                              Ideally it would be a device controlled by the plug-in "TTS Active" that could be used as a trigger or condition within an event. It could even be included in Sonos Triggers and Sonos Conditions when any client is "Announcing".
                              HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                              Comment

                              Working...
                              X