Announcement

Collapse
No announcement yet.

Troubles with playing radiostation through hs.PluginFunction

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

    Troubles with playing radiostation through hs.PluginFunction

    I am running HS3 and version 3.1.0.18 of the Sonos plugin.

    I have seen references in the forum to playing music via a script using the PlayMusic plugin function. However I can't seem to find the correct syntax for playing a Pandora Radiostation.

    I am calling the function as follows:

    hs.PluginFunction("Sonos", "RINCON_XXXXX", "PlayMusic", {"", "","RadioStation: <<Pandora - Christian Rock Radio>>","","","","","","","",false,0})

    I have the correct RINCON address. I also have the radio station showing up in the left hand list of the Sonos player after clicking on the 'Radiostation' button.

    The name of the radiostation (between the << >>) is exactly as it shows in the list. I have tried with the << >>, without them, and a number of other combinations.

    Is there a specific syntax for calling the PlayMusic function for a Pandora radiostation?

    Thanks so much!

    Scott

    #2
    Originally posted by ScottM View Post
    I am running HS3 and version 3.1.0.18 of the Sonos plugin.

    I have seen references in the forum to playing music via a script using the PlayMusic plugin function. However I can't seem to find the correct syntax for playing a Pandora Radiostation.

    I am calling the function as follows:

    hs.PluginFunction("Sonos", "RINCON_XXXXX", "PlayMusic", {"", "","RadioStation: <<Pandora - Christian Rock Radio>>","","","","","","","",false,0})

    I have the correct RINCON address. I also have the radio station showing up in the left hand list of the Sonos player after clicking on the 'Radiostation' button.

    The name of the radiostation (between the << >>) is exactly as it shows in the list. I have tried with the << >>, without them, and a number of other combinations.

    Is there a specific syntax for calling the PlayMusic function for a Pandora radiostation?

    Thanks so much!

    Scott
    Please turn debug flag on; run your script and post log.
    Dirk

    Comment


      #3
      Originally posted by dcorsus View Post
      Please turn debug flag on; run your script and post log.
      Dirk
      Sorry, Dirk. I should have done that in the first place. It appears as though the name of the radio station is stripped out between the < >. Thanks in advance for the help!

      Code:
      Jan-13 6:03:20 AM	 	Sonos	PlayMusicOnZone for zoneplayer = Sonos Main found No Tracks
      Jan-13 6:03:20 AM	 	Sonos	PlayMusicOnZone for Zone Sonos Main and query = SELECT * FROM Tracks WHERE Name = 'All RadioStations' AND Artist = 'RadioStation: <>'
      Jan-13 6:03:20 AM	 	Sonos	PlayMusicOnZone for Zone Sonos Main and MusicDBName = C:\Program Files (x86)\HomeSeer HS3/html/Sonos/MusicDB/SonosDB.sdb, ZoneUDN = , Artist = Album = Playlist = RadioStation: <>, Genre = , Track = , StartWithArtist = , StartWithTrack = , TrackMatch = , Favorite = , ClearPlayerQueue = False, QueueAction = qaDontPlay
      Jan-13 6:03:20 AM	 	Sonos	PlayMusic called for Zone - Sonos Main with Artist= and Album= and Playlist=RadioStation: <> and Genre= and Track= and StartWithArtist= and StartWithTrack= and TrackMatch=and Audiobook = and Podcast = and ClearPlayerQueue = False and QueueAction = qaDontPlay
      Jan-13 6:03:20 AM	 	Sonos	PluginFunction called for instance = RINCON_B8E93790FCEC01400 and proc = PlayMusic
      Jan-13 6:03:20 AM	 	Event	Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/PlayMusicFromAlexa.vb
      Jan-13 6:03:20 AM	 	Event	Event Trigger "Manual Triggers/Status Device Changes Play Sonos Music"
      Jan-13 6:03:20 AM	 	Event	Event Manual Triggers/Status Device Changes Play Sonos Music triggered by the event page 'Run' button.
      The script looks like this:
      Code:
      Sub Main(parm as object)
      
      hs.PluginFunction("Sonos", "RINCON_B8E93790FCEC01400", "PlayMusic", {"", "","RadioStation: <<Pandora - Taylor Swift Radio>>","","","","","","","",false,0})
      
      End Sub

      Comment


        #4
        Originally posted by ScottM View Post
        Sorry, Dirk. I should have done that in the first place. It appears as though the name of the radio station is stripped out between the < >. Thanks in advance for the help!

        Code:
        Jan-13 6:03:20 AM         Sonos    PlayMusicOnZone for zoneplayer = Sonos Main found No Tracks
        Jan-13 6:03:20 AM         Sonos    PlayMusicOnZone for Zone Sonos Main and query = SELECT * FROM Tracks WHERE Name = 'All RadioStations' AND Artist = 'RadioStation: <>'
        Jan-13 6:03:20 AM         Sonos    PlayMusicOnZone for Zone Sonos Main and MusicDBName = C:\Program Files (x86)\HomeSeer HS3/html/Sonos/MusicDB/SonosDB.sdb, ZoneUDN = , Artist = Album = Playlist = RadioStation: <>, Genre = , Track = , StartWithArtist = , StartWithTrack = , TrackMatch = , Favorite = , ClearPlayerQueue = False, QueueAction = qaDontPlay
        Jan-13 6:03:20 AM         Sonos    PlayMusic called for Zone - Sonos Main with Artist= and Album= and Playlist=RadioStation: <> and Genre= and Track= and StartWithArtist= and StartWithTrack= and TrackMatch=and Audiobook = and Podcast = and ClearPlayerQueue = False and QueueAction = qaDontPlay
        Jan-13 6:03:20 AM         Sonos    PluginFunction called for instance = RINCON_B8E93790FCEC01400 and proc = PlayMusic
        Jan-13 6:03:20 AM         Event    Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/PlayMusicFromAlexa.vb
        Jan-13 6:03:20 AM         Event    Event Trigger "Manual Triggers/Status Device Changes Play Sonos Music"
        Jan-13 6:03:20 AM         Event    Event Manual Triggers/Status Device Changes Play Sonos Music triggered by the event page 'Run' button.
        The script looks like this:
        Code:
        Sub Main(parm as object)
        
        hs.PluginFunction("Sonos", "RINCON_B8E93790FCEC01400", "PlayMusic", {"", "","RadioStation: <<Pandora - Taylor Swift Radio>>","","","","","","","",false,0})
        
        End Sub
        Did you try to log to disk? HS seems to strip out things between <> thinking it are HTML tags.

        For sure you should remove the "RadioStation: " prefix which is what I add to make it readable. I am surprised however by the <<>>, never seen that before with Pandora Radio.

        Is there a reason why you do this via script and not via the sonos actions that exist and you can select from when creating an event? You could create one of those , take logs of regular event and script and see where the syntax issue might be.

        Dirk

        Comment


          #5
          Originally posted by dcorsus View Post
          Did you try to log to disk? HS seems to strip out things between <> thinking it are HTML tags.

          For sure you should remove the "RadioStation: " prefix which is what I add to make it readable. I am surprised however by the <<>>, never seen that before with Pandora Radio.

          Is there a reason why you do this via script and not via the sonos actions that exist and you can select from when creating an event? You could create one of those , take logs of regular event and script and see where the syntax issue might be.

          Dirk
          Dirk,

          Removing the "RadioStation: " along with the <<>> fixed the problem. The Radiostation name was definitely being stripped out between the <<>>, though.

          The fixed call looks like:
          hs.PluginFunction("Sonos", "RINCON_B8E93790FCEC01400", "PlayMusic", {"", "","Pandora - Dinner Jazz Radio","","","","","","","",false,0})
          To answer your question on why I'm running it from a script, I am using Jon00's Alexa script to parse a command like:

          Alexa, ask Homeseer to play rock music in the living room.

          Since 'rock music' represents multiple Pandora Stations that I have defined, and I want to be able to add more down the road, it seemed like this was the cleanest way to not create a ton of events, one for each radio station. If I have the list of stations, I'll be able to randomize the 'rock' stations and play them through this call.

          Which reminds me - the only way I'll be able to pull of this idea is to be able to get a list of radiostations the Sonos plugin currently sees. Is there a function call that I can make that will return the list of radiostations? Or, do they exist in an .ini file somewhere?

          Thanks for all your work on this plugin. I know you've said it's a hobby, but I'm one that would be more than willing to pay for it. It really is great.

          Scott

          Comment


            #6
            Originally posted by ScottM View Post
            Which reminds me - the only way I'll be able to pull of this idea is to be able to get a list of radiostations the Sonos plugin currently sees. Is there a function call that I can make that will return the list of radiostations? Or, do they exist in an .ini file somewhere?
            They actually are all stored in a standard Sql database that can be found at <hs root>\html\sonos\musicDb

            There should be 2 databases, one for all the music tracks and one for the radiostations learned. Beef up on your SQL knowledge and you can read any track, album, artist, radiostation info from the 2 databases and play via the same function call.

            Dirk

            Comment


              #7
              Originally posted by dcorsus View Post
              They actually are all stored in a standard Sql database that can be found at <hs root>\html\sonos\musicDb

              There should be 2 databases, one for all the music tracks and one for the radiostations learned. Beef up on your SQL knowledge and you can read any track, album, artist, radiostation info from the 2 databases and play via the same function call.

              Dirk
              Ok, I'll definitely head down that path. I notice in the folder there are two files for sonosradiostationsDB. Once has a MS Access extension and the other has .sdb extension (I assume SQLite). The .sdb file is more current (more recent timestamp) than the .mdb file. When I open the .mdb file, it doesn't have all the radio stations in it that are currently showing with the Sonos player. So I assume the SQLite database file is what I should try to access. Does that make sense?

              EDIT: I have been able to retrieve the radio stations just fine from the SQLite version of the database. Thanks again for all your help.
              Last edited by ScottM; January 13, 2017, 12:59 PM.

              Comment


                #8
                Originally posted by ScottM View Post
                Ok, I'll definitely head down that path. I notice in the folder there are two files for sonosradiostationsDB. Once has a MS Access extension and the other has .sdb extension (I assume SQLite). The .sdb file is more current (more recent timestamp) than the .mdb file. When I open the .mdb file, it doesn't have all the radio stations in it that are currently showing with the Sonos player. So I assume the SQLite database file is what I should try to access. Does that make sense?

                EDIT: I have been able to retrieve the radio stations just fine from the SQLite version of the database. Thanks again for all your help.
                One of the differences between the 3.0.x.x. and 3.1.x.x version of this PI, is support for Linux. Because Linus does not support Microsoft Access .mdb files, it got designed out. So what you see is the left over when you were still running the R3.0.x.x version. R3.0.x.x is being phased out, I've stopped adding stuff to it while getting enough people on R3.1.x.x to make sure there are no gotchas before pulling the plug completely on R3.0.x.x

                Dirk

                Comment


                  #9
                  Originally posted by ScottM View Post
                  Dirk,

                  Removing the "RadioStation: " along with the <<>> fixed the problem. The Radiostation name was definitely being stripped out between the <<>>, though.

                  The fixed call looks like:

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

                  Scott
                  I'm trying a command similar to that above (changing RINCON and station of course to one learned in by Sonos) and hitting errors;

                  Running script(2) &hs.PluginFunction("Sonos","RINCON_949F3E1AD3CE01400","PlayM usic",{"","","Pandora - Taylor Swift Radio","","","","","","","",false,0}), init error: Invalid character

                  Not sure why the space is appearing in the PlayMusic error above, just a copy and paste and line wrap issue I think. Looks fine at my end and my script line doesn't have an extra space far as I can tell.

                  Any pointers?

                  Comment


                    #10
                    I figured this out in the end, it runs fine as part of a vb script, but not when called directly from an HS Touch button press or in the Control Panel - Immediate script command.

                    Comment

                    Working...
                    X