Created At

Sep 26, 2020

Last Update

Aug 25, 2021

Platforms

HC 3 Lite, Z-box Hub, Yubii Home Pro, Yubii Home, Venture WISE, HC 3

Views

9725

Download

1210

Type Quick App

Sonos Player v0.2 (c) tinman

 

This QA provides all the simple functionality one might need to simply play something without any overhead of things that might be not necessary for lot of situations.
The idea behind : keep it simple!


Settings:

  IPAddress -> the IP of your Sonos (master if any) speaker

  interval-volume -> refresh time for volume slider (and "volume" property). If you don't need to watch volume update set to 0 (value in second)

  interval-status -> refresh time for "state" property (see below). If you don't need the status, set it to 0 (value in seconds)

Changelog:

 - 0.1 - initlial release
 - 0.2 - fixed bug with volume, duplicated QA BUI controls removed

HOW TO USE:

  This QA shows up in block scene with "play", "stop", "pause", "next", "prev", "mute" and "setVolume" functionality. You might use them of course from LUA as well.

  Additionally to these you might call below function (LUA only) to play from URI or CFIS like:

  play from radio source: 

       fibaro.call(SonosQAID, "playFromUri","stream.laut.fm/hiphop-forever")

  play from http source:

       fibaro.call(SonosQAID, "playFromUri","http://192.168.199.11/mp3/dog.mp3")

  play from network share source:

       fibaro.call(SonosQAID, "playFromCIFS","192.168.199.33/2Pac/Me and My Girlfriend.mp3")

  

You can get the current player status (PLAYING, STOPPED, PAUSED_PLAYBACK, TRANSITIONING) from your LUA code, to get some more control, like "when playing do stop", or e.g. when "TRANSITIONING" after "PLAYING" change source (e.g. ding dong played once, than radio/cifs stream)

       fibaro.getValue(SonosQAID, "state")

You can get the current URI (to play it later, e.g. after ding-dong.mp3) with code below. I decided to not update it automatically, to save resources. When you need it, call it:

fibaro.call(SonosQAID, "getCurrentSourceURI")
fibaro.sleep(1000) -- if necessary
fibaro.getValue(SonosQAID, "currentSourceURI")

You can even trigger in LUA scenes based on Sonos state, to e.g. turn party light on when Sonos is playing like this (1234 is the Sonos QA id)

{
  conditions = { {
      id = 1234,
      isTrigger = true,
      operator = "anyValue",
      property = "state",
      type = "device"
    } },
  operator = "all"
}

local
 trigger = sourceTrigger
if trigger.type=='device' then
    if trigger.value == "PLAYING" then
        print("sonos playing something, let's turn on some party lights")
    elseif trigger.value == "PAUSED_PLAYBACK" or trigger.value == "STOPPED" then
        print("sonos not playing, let's turn off party lights now")
    end
end

:)

For comments and questions visit:
https://forum.fibaro.com/topic/49113-hc3-quickapps-coding-tips-and-tricks/?do=findComment&comment=216584 

Oder hier: https://intuitech.de/intuitech-forum/topic/sonos-player-quick-app/


Btw, if you need much more advanced Sonos Zone Controller, check 
https://marketplace.fibaro.com/items/sonos-zone-controller

 

0 Comments,  Want to add comment please login
Load more comments
© 2024. Nice-Polska Sp. z o.o.Privacy policyTerms & ConditionsFeedback