Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Question

Posted (edited)

hi there,

I recently switched from a HC2 to a HC3, since the switch I'm struggling to get a simple quickapp for my sonos speakers.

I would like a quickapp just like the native sonosplayer (screenshot attached) but with the option to add one or two extra buttons to start a spotify playlist or sonos favorite.

 

I downloaded a lot of codes, quickapps and tried to adjust the code but im not that good in coding......

 

Does anybody hs a simple QA like the native sonos QA that can be adjusted?

 

 

 

thx!

Please login or register to see this attachment.

Edited by pbtinus
typed to quick :-)

3 answers to this question

Recommended Posts

  • 0
Posted

Why not just use an existing quickapp, like this one

 

Please login or register to see this link.

 

or other existing quickapps. 
 

Or what do you want to adjust? 

  • 0
  • Inquirer
  • Posted
    37 minutes ago, SmartHomeEddy said:

    Why not just use an existing quickapp, like this one

     

    Please login or register to see this link.

     

    or other existing quickapps. 
     

    Or what do you want to adjust? 

    Hi, thx for the quick answer.

    I just want a simple player like the one that can be used by adding a sonos speaker as a device. (sonos player provied by fibaro)
    with the extra option to open one or two favorites by pressing a button.

     

    I will try the QA you mentioned, thx

    • 0
  • Inquirer
  • Posted

    I tried the QA you mentioned and also another QA called sonos hub, both work 100% but I can not get it to work as i want.

    I now use a standard sonos player that I can adjust and add funtions , like selecting the line-in on my sonos five to play a record

    but now im struggling to get spotify working. (or playing a sonos favorite)

    The QA I would like to create is a simple player with a couple of buttons to select playlists or favorites (layout as attachment)

    Is there anybody that can help me with the correct code? (chatgpt has helped me a lot but i cant get it to work ... )

    the URI im using that doestnt work: "x-sonos-spotify:spotify:playlist:7jBDsDWvg7FXEqo91CcUpE?sid=9"  

    if I change it into a single track, it works.

     

    complete code for the button:

     

    function QuickApp:hard()
        -- De URI van de Sonos-favoriet voor Tinus Soft
        local favoriteUri = "x-sonos-spotify:spotify:playlist:7jBDsDWvg7FXEqo91CcUpE?sid=9"  

        -- Controleer of favoriteUri een geldige string is
        if not favoriteUri or type(favoriteUri) ~= "string" then
            print(" Ongeldige favorite URI")
            return
        end

        -- Controleer of AVTRANSPORT_URI is ingesteld
        if not self.AVTRANSPORT_URI then
            print(" Fout: AVTRANSPORT_URI is niet ingesteld.")
            return
        end

        -- Log de URI voor debugging
        print("📡 Verzenden van URI naar Sonos: " .. favoriteUri)

        -- Maak het XML-verzoek voor de AVTransport-service
        local function createAvTransportBody(uri)
            return string.format(
                '<u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">' ..
                '<InstanceID>0</InstanceID>' ..
                '<CurrentURI>%s</CurrentURI>' ..
                '<CurrentURIMetaData></CurrentURIMetaData>' ..
                '</u:SetAVTransportURI>',
                uri
            )
        end

        local requestBody = createAvTransportBody(favoriteUri)

        -- Verzend het verzoek naar Sonos om de URI in te stellen
        self:sendRequest(
            self.AVTRANSPORT_URI, 
            '"urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"', 
            requestBody, 
            function(data)
                if data then
                    print(" Tinus Soft favorite is succesvol ingesteld!")
                    
                    -- Controleer of de play-functie bestaat
                    if self.play and type(self.play) == "function" then
                        print("▶️ Afspelen van de playlist...")
                        self:play()
                    else
                        print("⚠️ Fout: play-functie bestaat niet of is niet aanroepbaar.")
                    end
                else
                    print("⚠️ Geen respons van Sonos bij het instellen van de favorite.")
                end
            end,
            function(error)
                print(" Fout bij verzenden van verzoek naar Sonos: " .. tostring(error))
            end
        )
    end

     

     

     

     

     

    Please login or register to see this attachment.

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...