Announcement

Collapse
No announcement yet.

Improving on the past

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

  • Improving on the past

    So a long time back, before my final year became incredibly difficult - I created some amazing screens using your plugin.

    They were:

    (1) Artists - Music stored on my NAS
    (2) Playlists - Music stored on my NAS
    (3) Radio - Using TuneIn on SONOS
    (4) Favorites - Using Spotify on SONOS

    I have had some brilliant luck making scripts for remotes for multiple rooms using virtual devices. Imagine taking all those icons creating a virtual device, in the same layout and only using one event:

    when the virtual device changes, then run a script.
    I have seen massive speed improvements so I basically want to do the same.
    Attached Files

  • #2
    So the events fall into 3 groups:

    Music - SONOS Favourites
    Music - SONOS Playlist
    Music - SONOS Radio

    As you can see they take a long time to load (a minute in the web editor)
    and that's because each logo has a separate event for each speaker, which makes adding new speakers a slow and awful process.

    So the first of three bits I need to know is:

    How can I script
    Sonos Action lay Favourites - for player (variable 1); favourite name: (variable 2)?

    If you did not want to share, i would be happy to contribute/donate for the code snippet.

    I really do believe I could get a huge increase in performance reducing a couple of hundred events, and even make it easier to add speakers in the future.
    Attached Files

    Comment


    • #3
      So the first snippet is:

      Sonos Action Play Playlist

      The other two events:

      Sonos Action Play Favorite
      Sonos Action Play RadioStation


      if you could help me put this into a script, i can do the rest

      Comment


      • #4
        Originally posted by smokeycoles View Post
        So the first snippet is:

        Sonos Action Play Playlist

        The other two events:

        Sonos Action Play Favorite
        Sonos Action Play RadioStation


        if you could help me put this into a script, i can do the rest
        Checkout posts like this:

        https://forums.homeseer.com/showthre...ic#post1287086

        The function call takes following parameters
        Public Sub PlayMusic(ByVal Artist As String, Optional ByVal Album As String = "", Optional ByVal PlayList As String = "", Optional ByVal Genre As String = "", Optional ByVal Track As String = "", Optional ByVal StartWithArtist As String = "", Optional ByVal StartWithTrack As String = "", Optional ByVal TrackMatch As String = "", Optional ByVal AudioBook As String = "", Optional ByVal PodCast As String = "", Optional ByVal ClearPlayerQueue As Boolean = False, Optional QueueAction As QueueActions = QueueActions.qaDontPlay)

        Most parameters are old remnants from the HS2 days and are not supported. For favorites use:
        Public Sub PlayFavorite(Favorite As String, Optional ByVal ClearPlayerQueue As Boolean = False, Optional QueueAction As QueueActions = QueueActions.qaDontPlay)

        For Radiostations make sure the name has the "RadioStation: "prefix in front of the name.

        Do note, I have NO time to support NOR do I guarantee I won't change functions over time. Anyone who want to call functions directly is on his own. If you user Microsoft Visual Studio, you can include the plugin in your project and you can see all the public calls.

        Dirk

        Comment


        • #5
          I was using the Smokeycoles approach at first but had an idea, and wanted to share that here.

          I have a screen for each player, and a single screen for music selection.

          I have two virtual devices, one for the room, and one for the station/artist.

          I have my system set up such that you start at an overview page (I might lose the play/fwd/ect buttons, it's very busy) then, pick a player by pressing it, then from that page you can go to the music selection screen.

          I set the room virtual device as I go in and out of any player's screen. When I go to the Office player, I set the room device to office.

          When I then hit the change music button, I know I'm in the office.

          I have a button for each playlist/Pandora station, and each one runs a script when pushed, which sets the string value of my station artist virtual device, and then runs a script to play that value on the player I'm controlling.

          The script is this;

          Sub Main(ByVal Parms as String)

          Dim TargetPlayer As String
          Dim Station As String = hs.devicestring (4732)

          If(hs.devicevalue (4712))=1 then
          TargetPlayer = "RINCON_949F3E1AD3CE01400"
          else
          If(hs.devicevalue (4712))=2 then
          TargetPlayer = "RINCON_000E58796ED201400"
          else
          (......... and so on)

          End If
          End If

          hs.PluginFunction("Sonos", TargetPlayer, "PlayMusic", {"", "",Station,"","","","","","","",false,0})

          End Sub

          Hope these pics make that a bit clearer

          Now when add a new player I just add it to the script and do a screen for it, and a virtual room value to set, the music selection pages don't change.

          I expect I could add a room selection ribbon to the top of the screen too, to save having to exit the music selection screen and go back in under a different player, so you could pick different music for different rooms... it never ends this HS Touch thing...
          Attached Files

          Comment


          • #6
            Greg

            This is brilliant work! Well Done.
            And thanks Dirk for the link to enable it.

            I am going to adjust mine to something similar, I just got to work out how to use the hs.PluginFunction to do the following:
            Music - SONOS Favourites
            Music - SONOS Playlist
            Music - SONOS Radio
            using Dirk's commands above.

            hs.PluginFunction("Sonos", "RINCON_B8E93790FCEC01400", "PlayMusic", {"", "","Pandora - Dinner Jazz Radio","","","","","","","",false,0})

            I hope I can feed back and show an improvement too!


            P.S Greg - I love your setup - its great. You need meed more music! I'd look forward to seeing the finished result.
            Last edited by smokeycoles; April 14th, 2017, 02:55 AM.

            Comment


            • #7
              Solved

              Just wanted to thank you both.

              I am very happy with my new selectors, and lost loads of events! (784 to be exact)

              Code:
              '---------------------------------------------------------------------------
              ' Play Music Playlist 
              '---------------------------------------------------------------------------
              Sub playPlaylistItem(parm As String)
              
              	Dim targetPlayer As String = getRINCONbyID(647)
              	Dim playlistSelected As String = hs.DeviceVSP_GetStatus(412, hs.DeviceValueEx(412), ePairStatusControl.Status)
              
              	hs.WriteLog("SONOS Player", "Target Player is: " & targetPlayer & " and the playlist selected is: " & playlistSelected)
              
              	' Artist, Album, Playlist, Genre, Track, StartwithTrack, TrackMatch, AudioBook, PodCast, ClearPlayerQeue, 
              	hs.PluginFunction("Sonos", targetPlayer, "PlayMusic", {"", "",playlistSelected,"","","","","","","",true,1})
              
              End Sub
              
              
              '---------------------------------------------------------------------------
              ' Play Music Radio 
              '---------------------------------------------------------------------------
              Sub playRadioItem(parm As String)
              
              	Dim targetPlayer As String = getRINCONbyID(647)
              	Dim playlistSelected As String = hs.DeviceVSP_GetStatus(401, hs.DeviceValueEx(401), ePairStatusControl.Status)
              
              	hs.WriteLog("SONOS Player", "Target Player is: " & targetPlayer & " and the playlist selected is: " & playlistSelected)
              
              	' Artist, Album, Playlist, Genre, Track, StartwithTrack, TrackMatch, AudioBook, PodCast, ClearPlayerQeue, Play
              	hs.PluginFunction("Sonos", targetPlayer, "PlayMusic", {"", "",playlistSelected,"","","","","","","",true,1})
              
              End Sub
              
              
              
              '---------------------------------------------------------------------------
              ' Play Favourite (SPOTIFY)
              '---------------------------------------------------------------------------
              Sub playFavouriteItem(parm As String)
              
              	Dim targetPlayer As String = getRINCONbyID(647)
              	Dim favouriteSelected As String = hs.DeviceVSP_GetStatus(414, hs.DeviceValueEx(414), ePairStatusControl.Status)
              
              	hs.WriteLog("SONOS Player", "Target Player is: " & targetPlayer & " and the playlist selected is: " & favouriteSelected)
              
              	' Favourite, ClearQueue , Play 
              	hs.PluginFunction("Sonos", targetPlayer, "PlayFavorite", {favouriteSelected,true,1})
              
              
              End Sub
              
              
              '---------------------------------------------------------------------------
              ' Get Player RINCON
              '--------------------------------------
              Public Function getRINCONbyID(virtualDevicePlayerID As Integer)
              
              	Dim getPlayerSelected As Integer = hs.DeviceValueEx(virtualDevicePlayerID)
              
              	Select Case getPlayerSelected
              
              		Case "0"
              					'Master Bedroom	
              					Return "RINCON_...."
              		Case "1"
              					'Bathroom
              					Return "RINCON_...."
              		Case "2"
              					'Front Room
              					Return "RINCON_...."
              		Case "3"
              					'Living Room
              					Return "RINCON_...."
              		Case "4"
              					'Hallway
              					Return "RINCON_...."
              		Case "5"
              					'Front Door
              					Return "RINCON_...."
              		Case "6"		
              					'Ensuite
              					Return "RINCON_...."
              		Case Else
              					hs.WriteLogEx("SONOS Player", "Room Not Found", "#ff0000")
              		End Select
              
              End Function
              Attached Files

              Comment


              • #8
                You're welcome, your work on this inspired me, and thanks for making it even better.

                I've added some more music now, but wanted to get this working as I wanted before adding much more - as the repetition of editing items wasn't appealing. I don't have to tell you that, given how many you had to modify... :-)

                Now it's pretty efficient I'll start adding more buttons/stations.

                I did see one issue with radiostations, actual radio stations via the TuneIn Sonos source, in that they wouldn't automatically play like a Pandora station would. Have you seen that?

                Comment


                • #9
                  That radio station not automatically starting is no longer repro'ing for me once I switched to your script. Not sure why, but I'm not complaining. :-)

                  Comment


                  • #10
                    Originally posted by smokeycoles View Post
                    Just wanted to thank you both.

                    I am very happy with my new selectors, and lost loads of events! (784 to be exact)
                    Sorry for the rookie questions:

                    1) When you created the virtual devices for Radio/Playlists/Favorites, you setup a "Device Status" for each radiostation, playlist & favorite, I'm confused because in grtaylor post, he is setting the device string in the VD and using it as a value holder from with in HST, are you doing the same as well? If so, is it necessary to set the "Device Status"? If so, I'm guessing you must have events that set the device string when a radio selection has been made? It looks like you guys set things up differently so I'm trying to figure out the best way to setup mine.

                    2) In the Get Player RINCON sub, are the Case numbers referring to the virtual device numbers in your Speaker Selector device?

                    3) Where did you get the art for Playlists and radio stations? I've been trying to figure out how to get them from Spotify/Pandora and just a Google search of them but no luck.

                    Thank you for posting your solution!
                    HS3 3.0.0.548 &HSTouch Designer 3.0.71 with 887 Devices, 515 Events
                    Plugin's:
                    BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee,
                    EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
                    weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave 3.0.1.252

                    Comment


                    • #11
                      Hi, happy to help if I can (and can remember! :-) )

                      So yes, each of my virtual devices for radiostation, playlist etc have a value set for each radiostation, playlist etc.

                      Then the ActionWhenReleased event in HST for each button/station/etc has a Control a HS Device action, setting the appropriate VD to the appropriate value. Press Pandora Taylor Swift, the button sets the Radiostation VD to Pandora - Taylor Swift Radio.

                      The next action is to run the Sonos Play Selection vb script, calling the playradioitem block. That takes the value from the VD I just set and plays it.

                      The artwork is just images grabbed from the Interweb and resized in Paint.Net, and then set as the ImageNormal property for the button.

                      Comment


                      • #12
                        Updated pics of my screens. Not much has changed. I still need to spend some time over the holidays this year adding some stuff.
                        Attached Files

                        Comment


                        • #13
                          Originally posted by grtaylor View Post
                          Hi, happy to help if I can (and can remember! :-) )

                          So yes, each of my virtual devices for radiostation, playlist etc have a value set for each radiostation, playlist etc.

                          Then the ActionWhenReleased event in HST for each button/station/etc has a Control a HS Device action, setting the appropriate VD to the appropriate value. Press Pandora Taylor Swift, the button sets the Radiostation VD to Pandora - Taylor Swift Radio.

                          The next action is to run the Sonos Play Selection vb script, calling the playradioitem block. That takes the value from the VD I just set and plays it.

                          The artwork is just images grabbed from the Interweb and resized in Paint.Net, and then set as the ImageNormal property for the button.
                          Thank you so much for helping me out! I think I'm almost there and just have a couple questions:

                          In the action editor you have a script that sets the VD "String", however that doesn't change the device "Value" or status, correct? When I look at Smokeycoles screen shots, I see the list of device status that equate to each playlist or radiostation but when you select a radio station in HST you are only changing the VD "String"? So I'm wondering if your device status of the VD is changing when you select the music in HST or not? Ultimately, is the device status lists needed?

                          Example:
                          If you notice in my screenshot below, I've selected RadioStation 1 status from the Device Web viewer screen and it has set the VD Status/value to RadioStation 1 but the String field is empty. It will populate when you make your selection in HST but I would assume the device status/value stays the same?

                          Thank you for your time helping me out!
                          Attached Files
                          HS3 3.0.0.548 &HSTouch Designer 3.0.71 with 887 Devices, 515 Events
                          Plugin's:
                          BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee,
                          EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
                          weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave 3.0.1.252

                          Comment


                          • #14
                            Originally posted by grtaylor View Post
                            Updated pics of my screens. Not much has changed. I still need to spend some time over the holidays this year adding some stuff.
                            Your Music Selector screen has changed quite a bit! I like how you've orgainized them, I also like Smokeycoles screens too so I'm trying to figure out which would work best for my family.

                            At the top of your Music Selector screen, I like that the selected speaker shows up red! Is it possible from that screen to change which speaker your selecting? At that point the script hasn't run yet so it's possible...?

                            Also, what can you do with the Group Players button? Obviously "Group Players" but can you select specific player to group together from another screen? Wouldn't mind seeing how you accomplished that next.
                            HS3 3.0.0.548 &HSTouch Designer 3.0.71 with 887 Devices, 515 Events
                            Plugin's:
                            BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee,
                            EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
                            weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave 3.0.1.252

                            Comment


                            • #15
                              So it looks like I changed the way my actions work since I posted the screenshots - that might explain it.

                              So I first set the device to the Station/Value I set up, then I run the script to start it playing. Hope that works better.

                              On the Music Selector screen the current player is in red as you saw, and yes, if you hit one of the buttons for one of the other rooms, it becomes the focus and whatever music you pick will play in that room, despite you getting to that page via some other player, if that makes sense.

                              Then grouping players. Not ideal as HST limits what I can do here compared to the Sonos app, but I'll do another post for that so as not to cross the streams.
                              Attached Files

                              Comment

                              Working...
                              X