Sonos Multiroom bei Bewegung mit node-sonos-http-api

Hallo zusammen,

bin gerade etwas am basteln. Ziel soll sein, dass wenn im Wohnzimmer der Sonos läuft und ich in die Küche gehe, sich der Sonos in der Küche mit dem im Wohnzimmer gruppiert damit die gleiche Musik läuft…

Das gruppieren klappt schon ohne Probleme. Wo es klämmt ist das auslesen des Statuses vom Sonos im Wohnzimmer. Hat da jemand eine Idee für mich?

Aktuell sieht es so aus:

--[[
%% properties
81 value
255 value
%% events
%% globals
--]]

local startSource = fibaro:getSourceTrigger();
if 
  ( tonumber(fibaro:getValue(81, "value")) > 0 )
and
  fibaro:getValue(255, "ui.lblState.value" ~= STOPPED)
then
  local http = net.HTTPClient()  
http:request('http://192.168.178.47:5005/Kueche/join/Wohnzimmer')
  end


Klappt aber leider nicht :frowning:

Hi,

bisher lese ich den Status direkt über das PlugIn aus.

(fibaro:getValue(5, "state") == "STOPPED") then.....

(fibaro:getValue(5, "state") == "PLAYING") then....

Du oruentierst Dich hieran?
https://forum.fibaro.com/index.php?/topic/21797-tutorial-alternative-sonos-vd-using-node-sonos-api/

Es sollte ja auch den Befehl geben:
(http://jishi.github.io/node-sonos-http-api/)
state (will return a json-representation of the current state of player)

VG Hoggle

So, da bin ich wieder :wink:

Also ich benutzte jetzt dieses VD zum auslesen des Statuses:

https://forum.fibaro.com/index.php?/topic/24949-vd-sonos-players-status-v10-3-step-setup/

Funktioniert auch einwandfrei :slight_smile:

Meine Szene sieht nun so aus:

--[[
%% properties
81 value
306 value
%% events
%% globals
--]]

local startSource = fibaro:getSourceTrigger();
if (
    
  (fibaro:getValue(306, "ui.Label4.value")) == "PLAYING" and
  tonumber(fibaro:getValue(81, "value") > 0))
then
  local http = net.HTTPClient()  
http:request('http://192.168.178.47:5005/Kueche/join/Wohnzimmer')
  end


306 ist das VD und 81 der Bewegungsmelder…
Funktioniert aber nicht :frowning:

Hi,
was genau funktioniert nicht?
Bau mal eine Debug-Zeile für die Überprüfung des Status ein :
print(fibaro:getValue(306, "ui.Label4.value"))

VG Hoggle

Funzt jetzt :slight_smile: Danke!!!

Wenn im Wohnzimmer des Sonos läuft gruppiert sich der aus der Küche mit ihm sobald man diese betritt. Verlässt man die Küche wird die Gruppierung nach 180sec wieder aufgehoben und er verstummt :slight_smile:

Genau das, was ich wollte:

--[[
%% properties
81 value
306 value
%% events
%% globals
--]]
local startSource = fibaro:getSourceTrigger();
if (
 ( tonumber(fibaro:getValue(81, "value")) > 0  and fibaro:getValue(306, "ui.Label4.value") == "PLAYING" and fibaro:getValue(306, "ui.Label2.value") == "STOPPED")
or
startSource["type"] == "other"
)
then
  local http = net.HTTPClient()  
http:request('http://192.168.178.47:5005/Kueche/join/Wohnzimmer')

else
if (( tonumber(fibaro:getValue(81, "value")) == 0 )) then
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(81, "value");
if (( tonumber(fibaro:getValue(81, "value")) == 0 ) and (os.time() - deviceLastModification0) >= 180) then
	delayedCheck0 = true;
end
local startSource = fibaro:getSourceTrigger();
if (
 ( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
    local http = net.HTTPClient()  
http:request('http://192.168.178.47:5005/Kueche/leave') 
end
end, 180000)
end
end

Perfekt!

Hier der Code vom Sonos im Bad. Wenn man den Raum betritt spielt er tagsüber den favorisierten Radiosender. Die Lautstärke wird dabei langsam von 0 auf 10 hochgefadet. Läuft der Sonos im Wohnzimmer und man betritt das Bad gruppieren sich die Speaker. Nach 3 Minuten ohne Bewegung schaltet sich der Sonos im Bad von allein wieder aus.

--[[
%% properties
65 value
306 value
%% events
%% globals
Tageszeit
--]]
local startSource = fibaro:getSourceTrigger();
if (
 ( tonumber(fibaro:getValue(65, "value")) > 0  and fibaro:getValue(306, "ui.Label4.value") == "STOPPED" and fibaro:getValue(306, "ui.Label3.value") == "STOPPED" and fibaro:getGlobalValue("Tageszeit") == "Tag")
or
startSource["type"] == "other"
)
then
  local http = net.HTTPClient()  
http:request('http://192.168.178.47:5005/Bad/Favorite/JAM%20FM');
  fibaro:call(306, "pressButton", "21")

else
  if (
 ( tonumber(fibaro:getValue(65, "value")) > 0  and fibaro:getValue(306, "ui.Label4.value") == "PLAYING" and fibaro:getValue(306, "ui.Label3.value") == "STOPPED")
or
startSource["type"] == "other"
)
then
  local http = net.HTTPClient()  
http:request('http://192.168.178.47:5005/Bad/join/Wohnzimmer')
    
else
if (( tonumber(fibaro:getValue(65, "value")) == 0 )) then
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(65, "value");
if (( tonumber(fibaro:getValue(65, "value")) == 0 ) and (os.time() - deviceLastModification0) >= 180) then
	delayedCheck0 = true;
end
local startSource = fibaro:getSourceTrigger();
if (
 ( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
    local http = net.HTTPClient()  
http:request('http://192.168.178.47:5005/Bad/leave') 
end
end, 180000)
end
end
end