Sonos Status overview

Hello Community

I am looking for a clever group (items) and/or sitemap configuration (openbab 2.2) to give my wife an “at a glance” overview if, how many/what sonos player(s) are running.

Favoured would be a solution similiar to the one I have for open doors/windows as follows:


// offene Türen	/Fenster					
	Group:Contact:OR(OPEN, CLOSED) gKONTAKT_OPEN "Offene Türen/Fenster [%d]" <contact>	(gH, gFENSTER_DOOR_H)


sitemap ABC label="ABC" 
 Frame label="Kontrollbereich" {
        Group 	item=gKONTAKT_OPEN 			 label="Offene Türen/Fenster [%d]" 					icon="contact"
		Group   item=gTEMPERATUR_IST_BEHEIZT label="Ist-Temperatur Wohnen [%.1f °C]"         	icon="temperature"
		Group	item=gTEMPERATUR_SOLL		 label="Soll-Temperaturen [%.1f °C]"				icon="temperature"
		Group	item=gLUFTFEUCHTIGKEIT		 label="Luftfeuchtigkeit"							icon="humidity"
		Group 	item=gVENTILSTELLUNG		 label="Aktive Heizkörper [%d]"          			icon="heating"
		Group	item=gSONOS_STATUS			 label="Stauts alle Player" 						icon="sonos_state"

At first glance I see that no (or how many) door/window are open. My problem is that the status channel of sonos is a string (representing the statuses; PLAYING, STOPPED or PAUSED_PLAYBACK) and not a switch or number and I am not experienced enough to deal with this.

For our Sonos system (we have 7 Players) I created the following “overview” groups:


// Sonos Spezialgruppen
	Group:Number:SUM 	Sonos_Coords  			"Koordinator"									(gSONOS_H)
	Group:Dimmer:AVG 	gSONOS_VOLUME 			"Lautstärke"		<soundvolume>				(gSONOS_H)
	Group				gSONOS_CONTROL			"Sonos Controller"	<sonos_control>				(gSONOS_H)
	Group				gSONOS_CURRENT_TITLE	"Aktuelle Titel"	<sonos_title>				(gSONOS_H)	
	Group 				gSONOS_STOP				"Alle Player Stop"	<sonos_stop>				(gSONOS_H)
	Group				gSONOS_STATUS			"Stauts alle Player" <sonos_state>				(gSONOS_H)

In the sitemap I created a (group) switch that (should) turn all players off (to the status STOPPED): Switch item=gSONOS_STOP…


Frame label="Musik" {
		Group		item=gSONOS_STATUS			label="Stauts alle Player" 			icon="sonos_state"
		Group		item=gSONOS_CONTROL 		label="Alle Sonos Player"			icon="sonos_control"
		Group		item=gSONOS_VOLUME 			label="Lautstärken Sonos"			icon="soundvolume"
		Group		item=gSONOS_CURRENT_TITLE	label="Aktuelle Titel"				icon="sonos_title"	
		Switch 		item=gSONOS_STOP			label="Alle Player Stop"			mappings=[ON="Alle Stop"]	icon="sonos_stop"
		Group 		item=gSONOS_EG				label="Sonos Geräte im EG"
		Group 		item=gSONOS_UG				label="Sonos Geräte im UG"
		Group 		item=gSONOS_H

Does somebody have a good idea/solution?

Furthermore I am not sure whether I should change the autoupdate"false" value in the stauts channel:


	Switch P5ESZ_Sonos_Stop                    "P5 Essen Stop"             <sonos_stop>         (gSONOS_ESZ, gSONOS_STOP)            {channel="sonos:PLAY5:RINCON_[123]:stop", autoupdate="false"}

Thanks for hints in advance

You will have to create a Proxy Item and Rule to update the state of the Proxy Item based on the states of your seven Sonos players. There is no Group aggregation function that I think will work for you.

However, the Rule is pretty simple. You already have the Sonos in a Group so all you need is to add a Type to the Group:

Group:String gSONOS_STATUS "Stauts alle Player" <sonos_state> (gSONOS_H)

And the following Rule:

rule "Sonos Status"
    Item gSONOS_STATUS received update
    val playing = gSONOS_STATUS.members.filter[sonos | sonos.state == "PLAYING"].size
    val paused = gSONOS_STATUS.members.filter[sonos | sonos.state == "PAUSED_PLAYBACK"].size
    val stopped = gSONOS_STATUS.members.filter[sonos | sonos.state == "STOPPED"].size
    SONOS_Summary.postUpdate("Playing = " + playing + " Paused = " + paused + " Stopped = " + stopped)

Thanks! In the meantime I tried this (so far working) approach, using the {Control} channel:


sitemap Lanzenberg label="Lanzenberg" 
 Frame label="Kontrollbereich" {
		Group	item=gLICHT_EIN	 		 	 label="Lichter eingeschaltet [%d]"    				icon="light"
		Text	item=P5ESZ_Sonos_Control	 label="Sonos Essen läuft [%s]"  						icon="player"	visibility=[P5ESZ_Sonos_Control==PLAY]		
		Text	item=P3WHZ_Sonos_Control	 label="Sonos Wohnen läuft [%s]"  						icon="player"	visibility=[P3WHZ_Sonos_Control==PLAY]		
		Text	item=P1FIO_Sonos_Control     label="Sonos Fiona läuft [%s]"  						icon="player"	visibility=[P1FIO_Sonos_Control==PLAY]		
		Text	item=P1ELT_Sonos_Control	 label="Sonos Eltern läuft [%s]"  						icon="player"	visibility=[P1ELT_Sonos_Control==PLAY]		
		Text	item=CAMPFLY_Sonos_Control   label="Sonos Flynn läuft [%s]"  						icon="player"	visibility=[CAMPFLY_Sonos_Control==PLAY]	
		Text	item=P1BAD_Sonos_Control	 label="Sonos Bad läuft [%s]"  							icon="player"	visibility=[P1BAD_Sonos_Control==PLAY]		
		Text	item=P1BAZ_Sonos_Control	 label="Sonos Basteln läuft [%s]"  						icon="player"	visibility=[P1BAZ_Sonos_Control==PLAY]		
		Text	item=CAMPGAZ_Sonos_Control   label="Sonos Gäste 1 läuft [%s]"  						icon="player"	visibility=[CAMPGAZ_Sonos_Control==PLAY]	
		Text	item=CGAZ_Sonos_Control    	 label="Sonos Gäste 2 läuft [%s]"  						icon="player"	visibility=[CGAZ_Sonos_Control==PLAY]		

sonos.items file:

	Group				gSONOS_CONTROL			"Sonos Controller"	<player>					(gSONOS_H)
	Player P5ESZ_Sonos_Control                 "Play 5 Essen"		 	   <player>      (gSONOS_ESZ, gSONOS_CONTROL)            {channel="sonos:PLAY5:RINCON_000E5880184601400:control"}

This shows the specific players with the control “PLAY” active but only if the player is playing. With the “Stop” switch, all can be stopped (before leaving the house).

I tried your rule also - it (partially). However, I realized that there must be other statuses like “TRANSITIONING” and “UNDEF”.

Again, thanks for the input.