Announcement

Collapse
No announcement yet.

Grouping Control

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

    Grouping Control

    Hi ,

    would it be possible to have something that monitor if a group is active or not? Sometimes I forgot about groups , and i have some surprises.

    What would be nice ( at least for me) is something that mimics the chromecast groups

    So if i choose to play something in a group it would play on that group of speakers. Then , if two minutes later i decides to play something in only one speaker then the group will be canceled and it would play on that speaker only.


    ---

    The problem now is that it is hard to know if a group is formed or not. Unless i did predict it in events ( but sometimes it is hard to predict everything ).



    #2
    You can retrieve the current groupings by sending the following CLI command using the CLI plugin call in a script: “syncgroups ?”. See the Squeezebox Plugin’s help file for details on how to do the scripting call.
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Thanks a lot. Will chek the help file

      Comment


        #4
        Click image for larger version

Name:	image_74424.png
Views:	81
Size:	35.0 KB
ID:	1268733 Ok it is the first time I create a script by ''myself''. And not sure is is ok because i got weird formatting as a response.

        is there a way to send this reply to a device as a value?


        I think i will create a device with all possible value ( I have 3 players)?

        Thank you


        Attached Files

        Comment


          #5
          Yes, there's a way to send to a device. With 3 players, there should only be 4 possible combinations and never more than one syncgroup (where the letters not separated by a dash means that they are in a syncgroup together):

          A-B-C
          AB-C
          A-BC
          ABC

          The command returns a URLEncoded string, so you need to convert those %xy values into text. VB.NET has an easy way to do so:


          Code:
          Imports System.Web
          
          Sub Main(ByVal Parms as String)
              Dim Debug As Boolean = True
              Dim logName As String = "SqueezeBox Syncgroups"
              Dim SBCommand As String = "syncgroups ?"
              Dim SyncGroups As String = ""
          
              Try
                  Dim pa = New HomeSeerAPI.PluginAccess(hs, "SqueezeBox", "")
          
                  If Debug Then hs.writelog(logName, SBCommand)
                  If pa.Connected Then
                      If Debug Then hs.WriteLog(logName, "Interface name: " & pa.Name & " Interface status: " & pa.InterfaceStatus.intStatus.ToString)
                      SyncGroups = pa.PluginFunction("ServerQueryCLICommand",New Object(){SBCommand}).ToString
                      If Debug Then hs.writelog(logName, SyncGroups)
                      SyncGroups = HttpUtility.URLDecode(SyncGroups)
                      If Debug Then hs.writelog(logName, SyncGroups)
                  Else
                      If Debug Then hs.WriteLog(logName, "Syncgroups Not Retrieved - Plugin not found")
                  End If
              Catch ex As Exception
                  hs.WriteLog(logName, "Exception " & ex.ToString)
              End Try
          
          End Sub
          You may need to do some further processing to strip text out, but since in your case you can only have on syncgroup at a time, you may not need to. You could likely just do something like:

          Code:
          If syncgroups.Contains("PlayerA) And syncgroups.Contains("PlayerB) And syncgroups.Contains("PlayerC) Then
              hs.SetDeviceValueByRef(1234, 100, True)
          ElseIf syncgroups.Contains("PlayerA) And syncgroups.Contains("PlayerB) Then
              hs.SetDeviceValueByRef(1234, 75, True)
          ElseIf syncgroups.Contains("PlayerB) And syncgroups.Contains("PlayerC) Then
              hs.SetDeviceValueByRef(1234, 50, True)
          Else
              hs.SetDeviceValueByRef(1234, 0, True)
          End If
          Substitute 1234 with the reference ID of the virtual device that you have created for this and then change 100,75,50 and 0 to match whatever values you've assigned to the 4 possible values.




          PS In the future, please post your scripts as text, rather than a screenshot, as text makes it much easier to suggest code changes as someone can just cut and paste from your code.
          HS 4.2.8.0: 2134 Devices 1252 Events
          Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

          Comment


            #6
            Here's a version of the script that will create String Collections that can be checked to see if they contain the sync group that you are looking for. This will then also work for systems that have more than 3 players which will support more than one simultaneous sync group.

            Code:
            Imports System.Web
            Imports System.Text.RegularExpressions
            Imports System.Collections.Specialized
            
            Sub Main(ByVal Parms as String)
                Dim Debug As Boolean = False
                Dim logName As String = "SB SyncGroups"
                Dim SBCommand As String = "syncgroups ?"
                Dim SyncGroups As String = ""
                Dim i As Integer = 0
                Dim SyncGroupPlayers As StringCollection = New StringCollection()
                Dim SyncGroupAddresses As StringCollection = New StringCollection()
                Dim PlayerAddresses As String = ""
                Dim PlayerNames As String = ""
            
                Try
                    Dim pa As HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "SqueezeBox", "")
                    If pa.Connected Then
                        If Debug Then hs.WriteLog(logName, pa.Name & " Interface status: " & pa.InterfaceStatus.intStatus.ToString)
                        SyncGroups = Replace(pa.PluginFunction("ServerQueryCLICommand",New Object(){SBCommand}).ToString,"syncgroups ","")
                        If Debug Then hs.writelog(logName, SyncGroups)
            
                        Dim RegexObj As New Regex("sync_members%3A([^\s]+) sync_member_names%3A([^\s]+)")
                        Dim MatchResult As Match = RegexObj.Match(SyncGroups)
                        While MatchResult.Success
                            PlayerNames = HttpUtility.URLDecode(MatchResult.Groups(2).Value)
                            SyncGroupPlayers.Add(PlayerNames)
                            If Debug Then hs.writelog(logName, PlayerNames)
            
                            PlayerAddresses = HttpUtility.URLDecode(MatchResult.Groups(1).Value)
                            SyncGroupAddresses.Add(PlayerAddresses)
                            If Debug Then hs.writelog(logName, PlayerAddresses)
            
                            MatchResult = MatchResult.NextMatch()
                        End While
            
                        If SyncGroupPlayers.Contains("Master Bedroom 1,Master Bedroom 2") Then
                            'do something
                        ElseIf SyncGroupPlayers.Contains("Office,Kitchen") Then
                            'do something else
                        Else
                            'do another thing
                        End If
            
                    Else
                        If Debug Then hs.WriteLog(logName, "Sync Groups Not Retrieved - Plugin not found")
                    End If
                Catch ex As Exception
                    hs.WriteLog(logName, "Exception " & ex.ToString)
                End Try
                SyncGroupPlayers = Nothing
                SyncGroupAddresses = Nothing
            
            End Sub
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment


              #7
              sparkman Wow thank you so much.

              I will try trhis script when I arrive home and will post back after .

              Yes in the future I will post scripts in code, not with a picture

              Comment


                #8
                Hi Sparkman, I tired to copy paste the your scripts but got that error in hs log:

                Code:
                 [TABLE="cellspacing: 0"]
                [TR]
                [TD="colspan: 1, align: left"][COLOR=#FF0000]Dec-22 22:21:50[/COLOR][/TD]
                 			[TD="colspan: 1, align: left"][COLOR=#FF0000] [/COLOR][/TD]
                 			[TD="colspan: 3, align: left"][COLOR=#FF0000]Error[/COLOR][/TD]
                 			[TD="colspan: 8, align: left"][COLOR=#FF0000]Compiling script /HomeSeer/scripts/callversion.vb: http://mono-project.com/Bugs)[/COLOR][/TD]
                 		[/TR]
                [/TABLE]
                [TABLE="cellspacing: 0"]
                [TR]
                [TD="colspan: 1, align: left"][COLOR=#FF0000]Dec-22 22:21:50[/COLOR][/TD]
                 			[TD="colspan: 1, align: left"][COLOR=#FF0000] [/COLOR][/TD]
                 			[TD="colspan: 3, align: left"][COLOR=#FF0000]Error[/COLOR][/TD]
                 			[TD="colspan: 8, align: left"][COLOR=#FF0000]Compiling script /HomeSeer/scripts/callversion.vb: Variable declaration without an 'As' clause; Object type assumed.[/COLOR][/TD]
                 		[/TR]
                [/TABLE]
                [TABLE="cellspacing: 0"]
                [TR]
                [TD="colspan: 1, align: left"][COLOR=#FF0000]Dec-22 22:21:50[/COLOR][/TD]
                 			[TD="colspan: 1, align: left"][COLOR=#FF0000] [/COLOR][/TD]
                 			[TD="colspan: 3, align: left"][COLOR=#FF0000]Error[/COLOR][/TD]
                 			[TD="colspan: 8, align: left"][COLOR=#FF0000]Compiling script /HomeSeer/scripts/callversion.vb: The import 'System.Core' could not be found.[/COLOR][/TD]
                 		[/TR]
                [/TABLE]
                [TABLE="cellspacing: 0"]
                [TR]
                [TD="colspan: 1, align: left"][COLOR=#000000]Dec-22 22:21:50[/COLOR][/TD]
                 			[TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD]
                 			[TD="colspan: 3, align: left"][COLOR=#000000]Event[/COLOR][/TD]
                 			[TD="colspan: 8, align: left"][COLOR=#000000]Running script in background: /HomeSeer/scripts/callversion.vb("Main")[/COLOR][/TD]
                 		[/TR]
                [/TABLE]
                maybe I should have said I was on linux?

                Comment


                  #9
                  Hi AI,

                  unfortunately i am not sure to understand scripting yet.

                  With this code :

                  Code:
                  Imports System.Web
                  
                  Sub Main(ByVal Parms as String)
                      Dim Debug As Boolean = True
                      Dim logName As String = "SqueezeBox Syncgroups"
                      Dim Command As String = "syncgroups ?"
                  
                      Try
                          Dim pa As HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "SqueezeBox", "")
                          Dim syncgroups As String = ""
                  
                          If Debug Then hs.writelog(logName, Command)
                          If pa.Connected Then
                              If Debug Then hs.WriteLog(logName, "Interface name: " & pa.Name & " Interface status: " & pa.InterfaceStatus.intStatus.ToString)
                              SyncGroups = Replace(pa.PluginFunction("ServerQueryCLICommand",New Object(){SBCommand}).ToString,"syncgroups ","")
                              If Debug Then hs.writelog(logName, syncgroups)
                              syncgroups = HttpUtility.URLDecode(syncgroups)
                              If Debug Then hs.writelog(logName, syncgroups)
                          Else
                              If Debug Then hs.WriteLog(logName, "Syncgroups Not Retrieved - Plugin not found")
                          End If
                      Catch ex As Exception
                          hs.WriteLog(logName, "Exception " & ex.ToString)
                      End Try
                  
                  End Sub
                  i got this error. Will need to analyse the script first
                  Dec-28 23:41:44 Error Compiling script /HomeSeer/scripts/callversion.vb: 'SBCommand' is not declared. It may be inaccessible due to its protection level.
                  Dec-28 23:41:44 Error Compiling script /HomeSeer/scripts/callversion.vb: The import 'System.Core' could not be found.
                  Dec-28 23:41:43 Event Running script in background: /HomeSeer/scripts/callversion.vb("Main")
                  Dec-28 23:41:43 Event Event Trigger "Squeezebox New Event"
                  Dec-28 23:41:43 Event Event Squeezebox New Event triggered by the event page 'Run' button.
                  Dec-28 23:40:15 Error Compiling script /HomeSeer/scripts/callversion.vb: 'SBCommand' is not declared. It may be inaccessible due to its protection level.
                  Dec-28 23:40:15 Error Compiling script /HomeSeer/scripts/callversion.vb: The import 'System.Core' could not be found.
                  Dec-28 23:40:15 Event Running script in background: /HomeSeer/scripts/callversion.vb("Main")

                  Comment


                    #10
                    Hi Matt, I had used the variable name "Command" in the first version of the script I posted (post #5), but had changed it to "SBCommand" in the second version (post #6). The changes I had documented were intended for the script in post #6. However, the scripts in both posts have now been updated with the new syntax, so you could just cut and paste the whole script from post #5, or search for "SBCommand" in your script and replace with "Command".

                    Cheers
                    Al
                    HS 4.2.8.0: 2134 Devices 1252 Events
                    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                    Comment


                      #11
                      Hi Ai,

                      this is what I get with the script in post 5!

                      Code:
                       [TABLE="cellspacing: 0"]
                      [TR]
                      [TD="colspan: 1, align: left"][COLOR=#000000]Dec-29 17:23:41[/COLOR][/TD]
                       			[TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD]
                       			[TD="colspan: 3, align: left"][COLOR=#000000]SqueezeBox Syncgroups[/COLOR][/TD]
                       			[TD="colspan: 8, align: left"][COLOR=#000000]syncgroups sync_members:mac adress , mac adress (edit by me) sync_member_names:Salon,Hallway[/COLOR][/TD]
                       		[/TR]
                      [/TABLE]
                      [TABLE="cellspacing: 0"]
                      [TR]
                      [TD="colspan: 1, align: left"][COLOR=#000000]Dec-29 17:23:41[/COLOR][/TD]
                       			[TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD]
                       			[TD="colspan: 3, align: left"][COLOR=#000000]SqueezeBox Syncgroups[/COLOR][/TD]
                       			[TD="colspan: 8, align: left"][COLOR=#000000]syncgroups sync_members%3Ab8%3A27%3Aeb%3Aad%3A94%3A4c%2Cb8%3A27%3Aeb%3A5d%3Aea%3Af1 sync_member_names%3ASalon%2CHallway[/COLOR][/TD]
                       		[/TR]
                      [/TABLE]
                      [TABLE="cellspacing: 0"]
                      [TR]
                      [TD="colspan: 1, align: left"][COLOR=#000000]Dec-29 17:23:41[/COLOR][/TD]
                       			[TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD]
                       			[TD="colspan: 3, align: left"][COLOR=#000000]SqueezeBox Syncgroups[/COLOR][/TD]
                       			[TD="colspan: 8, align: left"][COLOR=#000000]Interface name: SqueezeBox Interface status: OK[/COLOR][/TD]
                       		[/TR]
                      [/TABLE]
                      [TABLE="cellspacing: 0"]
                      [TR]
                      [TD="colspan: 1, align: left"][COLOR=#000000]Dec-29 17:23:41[/COLOR][/TD]
                       			[TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD]
                       			[TD="colspan: 3, align: left"][COLOR=#000000]SqueezeBox Syncgroups[/COLOR][/TD]
                       			[TD="colspan: 8, align: left"][COLOR=#000000]syncgroups ?[/COLOR][/TD]
                       		[/TR]
                      [/TABLE]

                      Comment


                        #12
                        Thanks a lot !| I think with some courage and all the info in this post, i'll be able to send those infos to a device !

                        Ps : I edited the two mac adress

                        Comment


                          #13
                          Ok got it working!
                          with this script I know exactly what group are synced.

                          Thanks again!!

                          Code:
                          Imports System.Web
                          
                          Sub Main(ByVal Parms as String)
                              Dim Debug As Boolean = True
                              Dim logName As String = "SqueezeBox Syncgroups"
                              Dim SBCommand As String = "syncgroups ?"
                              Dim SyncGroups As String = ""
                          
                              Try
                                  Dim pa = New HomeSeerAPI.PluginAccess(hs, "SqueezeBox", "")
                          
                                  If Debug Then hs.writelog(logName, SBCommand)
                                  If pa.Connected Then
                                      If Debug Then hs.WriteLog(logName, "Interface name: " & pa.Name & " Interface status: " & pa.InterfaceStatus.intStatus.ToString)
                                      SyncGroups = pa.PluginFunction("ServerQueryCLICommand",New Object(){SBCommand}).ToString
                                      If Debug Then hs.writelog(logName, SyncGroups)
                                      SyncGroups = HttpUtility.URLDecode(SyncGroups)
                                      If Debug Then hs.writelog(logName, SyncGroups)
                                  Else
                                      If Debug Then hs.WriteLog(logName, "Syncgroups Not Retrieved - Plugin not found")
                                  End If
                          If SyncGroups.Contains("Salon") And SyncGroups.Contains("Hallway") And SyncGroups.Contains("Bedroom") Then
                              hs.SetDeviceValueByRef(7866, 100, True)
                          ElseIf SyncGroups.Contains("Salon") And SyncGroups.Contains("Hallway") Then
                              hs.SetDeviceValueByRef(7866, 75, True)
                          ElseIf SyncGroups.Contains("Hallway") And SyncGroups.Contains("Bedroom") Then
                              hs.SetDeviceValueByRef(7866, 50, True)
                          ElseIf SyncGroups.Contains("Salon") And SyncGroups.Contains("Bedroom") Then
                              hs.SetDeviceValueByRef(7866, 25, True)
                          Else
                              hs.SetDeviceValueByRef(7866, 0, True)
                          End If
                              Catch ex As Exception
                                  hs.WriteLog(logName, "Exception " & ex.ToString)
                          
                          
                              End Try
                          
                          End Sub
                          Attached Files

                          Comment


                            #14
                            Great, glad you got it working and you're welcome!
                            HS 4.2.8.0: 2134 Devices 1252 Events
                            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                            Comment

                            Working...
                            X