Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users

    Controlling Sonos using HTTP requests?

    General Discussion
    7
    20
    27411
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bambi2000
      bambi2000 last edited by

      You can control a Sonos device using the UPnP protocol over HTTP. Some examples can be found on:
      http://forum.universal-devices.com/topic/11739-sonos-integration/

      But how do I send these kind of commands using the Internet request action in the Flic app for IOS? What goes in the URL field and what goes in the Body field when using POST mode? And does the content of the body have to be encoded or escaped?

      If you have successfully programmed your Flic for controlling Sonos using UPnP commands, I would appreciate an example with the exact contents of your Internet request settings.

      -Dennis

      1 Reply Last reply Reply Quote 0
      • thomas204
        thomas204 @bambi2000 last edited by

        @bambi2000 Thanks. I did manage to get the basics working (as well as find the streams for P3 and P4 ๐Ÿ™‚ ). I also managed to group players by setting CurrentURI of the "slave" IP to the UUID of the "master".

        <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI>x-rincon:RINCON_XXXXXXXXXXXX1400</CurrentURI><CurrentURIMetaData /></u:SetAVTransportURI></s:Body></s:Envelope>

        Now I just wish Flic would create some sort of copy function to make it easier to reuse those commands:-) And that Sonos would open their official API for better integration and remote control.

        1 Reply Last reply Reply Quote 0
        • bambi2000
          bambi2000 @thomas204 last edited by

          @thomas204 It's DR P1. Metadata is not needed to play the stream. I tried to use the metadata-tag to show the real name of the station rather than the file name (in this case A03H.mp3), but I didn't succeed.

          -Dennis

          thomas204 1 Reply Last reply Reply Quote 0
          • thomas204
            thomas204 @bambi2000 last edited by

            @bambi2000 er det P3? Den prรธver jeg at kopiere ๐Ÿ™‚
            Doesn't it need metadata?

            bambi2000 1 Reply Last reply Reply Quote 0
            • bambi2000
              bambi2000 @thomas204 last edited by

              @thomas204 I haven't tested case sensitivity, but I have got a lot of "internal server errors" too, while trying to get the commands working, so I have have just followed the examples I have come across literally. Also, in my setup the contents of the body field is one long string.

              Then following example selects a specific radio stream (the rest of the fields are identical to those in my previous post):

              Body: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI>x-rincon-mp3radio://live-icy.gss.dr.dk/A/A03H.mp3.m3u</CurrentURI><CurrentURIMetaData /></u:SetAVTransportURI></s:Body></s:Envelope>

              -Dennis

              thomas204 1 Reply Last reply Reply Quote 0
              • thomas204
                thomas204 last edited by

                Hmm. (minor) Progress. I managed to send a "play" command to one player but I am not able to tune it to a radio station or add a player to a group (I found a thread mentioning that setting currentURI to x-rincon:{UUID of master} should do the trick).
                Any attempt at setting currentURI returns error 500:-(

                /Thomas

                bambi2000 1 Reply Last reply Reply Quote 0
                • thomas204
                  thomas204 @bambi2000 last edited by

                  @bambi2000 thanks! Apparently this is over my capabilities:( All I get is an internal server error (500). And I also have a little trouble actually desciphering the command part of the code.
                  How sensitive is the code to case? And should it all be one long string or are there any CR's (looks like there is one).

                  /Thomas

                  1 Reply Last reply Reply Quote 0
                  • bambi2000
                    bambi2000 @thomas204 last edited by bambi2000

                    @thomas204 Sure, I havn't tried to group or ungroup players using requests, but here is the request that selects Line-In as input:

                    URL: http://192.168.172.67:1400/MediaRenderer/AVTransport/Control

                    Method: POST

                    Body: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI>x-rincon-stream:RINCON_000E5887151E01400</CurrentURI><CurrentURIMetaData /></u:SetAVTransportURI></s:Body></s:Envelope>

                    Content type: text/xml

                    Key: SOAPACTION

                    Value: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"

                    You will have to replace 192.168.172.67 with the IP address of your Sonos device, and RINCON_000E5887151E01400 with the identifier assigned to your Sonos device (I think the last part is the MAC address).

                    -Dennis

                    thomas204 1 Reply Last reply Reply Quote 0
                    • thomas204
                      thomas204 @bambi2000 last edited by

                      @bambi2000 Any chance you could post an example with the exact contents of (one of) your internet request settings?

                      I would like to have (for a start):

                      • A Flic button group 3 players, then start a specific radio station
                      • Another button that ungroups if grouped and then starts playback of a different favorite on a single player
                        Is that possible?

                      I am sure if I could get an example of the basic "framework" needed then i should be able to tweak the commands myself

                      /Thomas

                      bambi2000 1 Reply Last reply Reply Quote 0
                      • bambi2000
                        bambi2000 @anton last edited by bambi2000

                        @anton Custom headers was implemented some time ago, and I have successfully created requests that allows me to toggle between playing from line in, the queue and radio stations -- my own preset button for Sonos! ๐Ÿ™‚

                        -Dennis

                        thomas204 1 Reply Last reply Reply Quote 0
                        • Jaap
                          Jaap last edited by

                          Anything happening here?

                          1 Reply Last reply Reply Quote 0
                          • Jaap
                            Jaap last edited by

                            Hi Anton,

                            I'm jumping in on this topic.
                            Since I have Sonos in multiple rooms I got myself 4 flic's but the options are not sufficient for what I thought would be possible.

                            The scenario's I was thinking about;

                            1. Leaving the house;
                              I placed a Flic at our entrance. By pressing it, it should stop all Sonos players from playing. Some of them may be in a group, some stand alone.
                              There is an option for "toggle" but that would start not-playing speakers.

                            The I thought of using "pause". Same problem here. When there's another sonos not playing, that one would start playing.

                            It would be wonderfull to have an option like "Stop all playing speakers"

                            1. Turn on specific channel or spotify playlist on set-volume

                            In the morning we listen to a news radio station. I intended to put a button in the bathroom which, when clicked once, would a) remove the bathroom speaker from any groups (so music only plays there) b) select the desired radiostation c) set the speaker to a fixes volume.

                            At the same time I would also like to be able to do the same for a Spotify playlist and have it play my "Starred" list on shuffle.

                            I was thinking of solving it on my own by installing a Raspberry Pi and running something like https://github.com/SoCo/SoCo but seeing you're looking into this I was thinking it might help to share my ideas with you.

                            Kind regards,

                            Jaap

                            1 Reply Last reply Reply Quote 0
                            • anton
                              anton FlicTeam @johan213 last edited by

                              @johan213 @mail174 Thanks for the suggestions! We are looking at it.

                              1 Reply Last reply Reply Quote 0
                              • johan213
                                johan213 @anton last edited by

                                @anton I would love to see some more Sonos actions. These are the tasks I do everyday:

                                • With bedroom, Replace queue with Sonos playlist "good night Ebba"
                                • With bedroom, Set Volume to 10
                                • With Lukas, Replace queue with Sonos favorite "goodnight.mp3"
                                • With Lukas, Set Volume to 15
                                • With Lukas, Set Crossfade to On
                                • With Lukas, Set Repeat On
                                • With Lukas, Set sleep timer to 45 min

                                And on my wish list I also would like to have a toggle button for two different Volume levels for the Sonos playing my TV sound. Watching movies when the kids are asleep I always have to turn the volume up and down (slow) when there is loud music or car crashes or someone whispers. TV remotes miss the button "Semi mute" and having this option with the press of a button would be super awesome!

                                anton 1 Reply Last reply Reply Quote 0
                                • mail174
                                  mail174 @anton last edited by

                                  @anton features request for Sonos integration:

                                  • support grouping of speakers
                                  • allow to play saved favorites
                                  • support to set the volume level for playing favorites/playlist
                                  • set the max play duration (sleep timer)
                                  • let you inspire by features of Macronos
                                  1 Reply Last reply Reply Quote 0
                                  • anton
                                    anton FlicTeam @bambi2000 last edited by

                                    @bambi2000 Btw, are there any particular features that you are looking for when it comes to the Sonos integration? I am actually working on it at the moment, so if you have any suggestions (beyond those already mentioned) then let me know!

                                    mail174 johan213 2 Replies Last reply Reply Quote 0
                                    • bambi2000
                                      bambi2000 @anton last edited by

                                      @anton Thanks for the update!

                                      -Dennis

                                      anton 1 Reply Last reply Reply Quote 0
                                      • anton
                                        anton FlicTeam @bambi2000 last edited by

                                        @bambi2000 Improvement to the Internet Request action is in our roadmap, but I can not comment on when it will be released. Although custom headers it is a commonly requested feature so I hope we will be able to add it soon. We are currently also looking at making improvements to the Sonos action itself in order to extend the features there. For example to select songs and playlists.

                                        bambi2000 2 Replies Last reply Reply Quote 0
                                        • bambi2000
                                          bambi2000 last edited by

                                          My Sonos devices already have a button for play/pause/next, so I would like to use my Flic to select what to play, like a predefined radio station, the line-in or the queue.

                                          I thought I saw a post saying that custom headers for the Internet request was added recently, but apparently it isn't true. Is it in the works?

                                          -Dennis

                                          anton 1 Reply Last reply Reply Quote 0
                                          • oskar
                                            oskar FlicTeam last edited by

                                            Hi!

                                            Although it should be possible to do this, the Internet Request action doesn't have support for adding custom request headers, which is needed for Sonos. It would also be a real pain to set Sonos up like this.

                                            May I ask why you are not using the Sonos action? Is it something you are missing?

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post