eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
866 stars 782 forks source link

[SONOS] Playbar add support for NightMode and DialogLevel #4156

Open kTitan opened 7 years ago

kTitan commented 7 years ago

I am currently migrating my fhem installation to openhab. Here I have noticed that the SONOS Binding is missing the possibility to set the NightMode and DialogLevel Status. I am using this in fhem for switching the status in the night, to not disturb the neighbors. As far as I know these options are only supported for the Playbar.

It would be nice to get these options added.

Here is the link to the module of fhem (perl): https://github.com/mhop/fhem-mirror/blob/05af8e7afc91f0d166241b446d5d2d39fb7b4ec3/fhem/FHEM/00_SONOS.pm#L7585-L7605

pdcemulator commented 5 years ago

These mode are available on Playbar, Playbase and Beam.

lolodomo commented 5 years ago

As a side note, support for playbase and bean devices was not yet been added.

lolodomo commented 5 years ago

For owners of playbase and bean devices, please run and provide the result of http://<deivce IP>:1400/xml/device_description.xmlreplacing by the IP address of your Sonos device.

lolodomo commented 5 years ago

For adding new specific features, this will at least require the help of someone owning such a device and having the technical skill to play with the UPnP tool "device spy" to identify what are the specific UPnP actions available to get/set the night mode for example. Sorry but I have no such Sonos devices.

lolodomo commented 5 years ago

Half the work could even be done by anyone that would like to help me to add these new features. To help, log to the openHAB console and enable TRACE logs for the binding with this command: log:set TRACE org.eclipse.smarthome.binding.sonos and then run "log:tail". Then go in your Sonos control application and play with the new modes. See in the openHAB logs all logs starting with "Received pair". One certainly matches the night mode and another the speech enhancement mode. Show me the full line for each possible modes.

I suppose that these modes are only ON or OFF modes. I suppose the values are 0 and 1 and the service is RenderingControl but no idea of the name of the property.

As an example for volume mute, here are the interesting lines:

13:22:17.442 [TRACE] [os.internal.handler.ZonePlayerHandler] - Received pair 'MuteMaster':'1' (service 'RenderingControl') for thing 'sonos:CONNECT:salon'

13:22:26.753 [TRACE] [os.internal.handler.ZonePlayerHandler] - Received pair 'MuteMaster':'0' (service 'RenderingControl') for thing 'sonos:CONNECT:salon'

When done, don't forget to restore INFO level for the binding logs.

pdcemulator commented 5 years ago

please run and provide the result of http://:1400/xml/device_description.xml

This is the xml output for a Sonos Beam `

10urn:schemas-upnp-org:device:ZonePlayer:1192.168.1.2 - Sonos BeamSonos, Inc.http://www.sonos.comS14Sonos BeamSonos Beamhttp://www.sonos.com/products/zoneplayers/S1447.2-591201.23.1.10-234-7E-5C-XX-XX-XX:Buuid:RINCON_347E5CXXXXXX014000image/png484824/img/icon-S14.png46.0-0000036.0-000001.8.01.1.09.3WohnenBeam160x000040000x11a187320x00010008A1002950.0000.00010241024650urn:schemas-upnp-org:service:AlarmClock:1urn:upnp-org:serviceId:AlarmClock/AlarmClock/Control/AlarmClock/Event/xml/AlarmClock1.xmlurn:schemas-upnp-org:service:MusicServices:1urn:upnp-org:serviceId:MusicServices/MusicServices/Control/MusicServices/Event/xml/MusicServices1.xmlurn:schemas-upnp-org:service:DeviceProperties:1urn:upnp-org:serviceId:DeviceProperties/DeviceProperties/Control/DeviceProperties/Event/xml/DeviceProperties1.xmlurn:schemas-upnp-org:service:SystemProperties:1urn:upnp-org:serviceId:SystemProperties/SystemProperties/Control/SystemProperties/Event/xml/SystemProperties1.xmlurn:schemas-upnp-org:service:ZoneGroupTopology:1urn:upnp-org:serviceId:ZoneGroupTopology/ZoneGroupTopology/Control/ZoneGroupTopology/Event/xml/ZoneGroupTopology1.xmlurn:schemas-upnp-org:service:GroupManagement:1urn:upnp-org:serviceId:GroupManagement/GroupManagement/Control/GroupManagement/Event/xml/GroupManagement1.xmlurn:schemas-upnp-org:service:HTControl:1urn:upnp-org:serviceId:HTControl/HTControl/Control/HTControl/Event/xml/HTControl1.xmlurn:schemas-tencent-com:service:QPlay:1urn:tencent-com:serviceId:QPlay/QPlay/Control/QPlay/Event/xml/QPlay1.xmlurn:schemas-upnp-org:device:MediaServer:1192.168.1.2 - Sonos Beam Media ServerSonos, Inc.http://www.sonos.comS14Sonos Beam Media ServerSonos Beamhttp://www.sonos.com/products/zoneplayers/S14uuid:RINCON_347E5CXXXXXX01400_MSurn:schemas-upnp-org:service:ContentDirectory:1urn:upnp-org:serviceId:ContentDirectory/MediaServer/ContentDirectory/Control/MediaServer/ContentDirectory/Event/xml/ContentDirectory1.xmlurn:schemas-upnp-org:service:ConnectionManager:1urn:upnp-org:serviceId:ConnectionManager/MediaServer/ConnectionManager/Control/MediaServer/ConnectionManager/Event/xml/ConnectionManager1.xmlurn:schemas-upnp-org:device:MediaRenderer:1Wohnen - Sonos Beam Media RendererSonos, Inc.http://www.sonos.comS14Sonos Beam Media RendererSonos Beamhttp://www.sonos.com/products/zoneplayers/S14uuid:RINCON_347E5CXXXXXX01400_MRurn:schemas-upnp-org:service:RenderingControl:1urn:upnp-org:serviceId:RenderingControl/MediaRenderer/RenderingControl/Control/MediaRenderer/RenderingControl/Event/xml/RenderingControl1.xmlurn:schemas-upnp-org:service:ConnectionManager:1urn:upnp-org:serviceId:ConnectionManager/MediaRenderer/ConnectionManager/Control/MediaRenderer/ConnectionManager/Event/xml/ConnectionManager1.xmlurn:schemas-upnp-org:service:AVTransport:1urn:upnp-org:serviceId:AVTransport/MediaRenderer/AVTransport/Control/MediaRenderer/AVTransport/Event/xml/AVTransport1.xmlurn:schemas-sonos-com:service:Queue:1urn:sonos-com:serviceId:Queue/MediaRenderer/Queue/Control/MediaRenderer/Queue/Event/xml/Queue1.xmlurn:schemas-upnp-org:service:GroupRenderingControl:1urn:upnp-org:serviceId:GroupRenderingControl/MediaRenderer/GroupRenderingControl/Control/MediaRenderer/GroupRenderingControl/Event/xml/GroupRenderingControl1.xmlurn:schemas-upnp-org:service:VirtualLineIn:1urn:upnp-org:serviceId:VirtualLineIn/MediaRenderer/VirtualLineIn/Control/MediaRenderer/VirtualLineIn/Event/xml/VirtualLineIn1.xmlurn:rhapsody-real-com:device-id-1-0:sonos_1:RINCON_347E5CXXXXXX01400QPlay:2image/png484824/img/icon-S14.png

`

pdcemulator commented 5 years ago

Night Mode enabled 14:10:09.978 [TRACE] [os.internal.handler.ZonePlayerHandler] - Received pair 'LastChange':'<Event xmlns="urn:schemas-upnp-org:metadata-1-0/RCS/"><InstanceID val="0"><DialogLevel val="0"/><SurroundLevel val="0"/><MusicSurroundLevel val="0"/><AudioDelay val="0"/><AudioDelayLeftRear val="0"/><AudioDelayRightRear val="0"/><NightMode val="1"/><SurroundEnabled val="1"/><SurroundMode val="0"/></InstanceID></Event>' (service 'RenderingControl') for thing 'sonos:zoneplayer:RINCON_347E5CXXXXXX01400'

Night Mode disabled 14:11:38.615 [TRACE] [os.internal.handler.ZonePlayerHandler] - Received pair 'LastChange':'<Event xmlns="urn:schemas-upnp-org:metadata-1-0/RCS/"><InstanceID val="0"><DialogLevel val="0"/><SurroundLevel val="0"/><MusicSurroundLevel val="0"/><AudioDelay val="0"/><AudioDelayLeftRear val="0"/><AudioDelayRightRear val="0"/><NightMode val="0"/><SurroundEnabled val="1"/><SurroundMode val="0"/></InstanceID></Event>' (service 'RenderingControl') for thing 'sonos:zoneplayer:RINCON_347E5CXXXXXX01400'

Speech Enhancement enabled 14:14:16.747 [TRACE] [os.internal.handler.ZonePlayerHandler] - Received pair 'LastChange':'<Event xmlns="urn:schemas-upnp-org:metadata-1-0/RCS/"><InstanceID val="0"><DialogLevel val="1"/><SurroundLevel val="0"/><MusicSurroundLevel val="0"/><AudioDelay val="0"/><AudioDelayLeftRear val="0"/><AudioDelayRightRear val="0"/><NightMode val="0"/><SurroundEnabled val="1"/><SurroundMode val="0"/></InstanceID></Event>' (service 'RenderingControl') for thing 'sonos:zoneplayer:RINCON_347E5CXXXXXX01400'

Speech Enhancement disabled 14:14:19.477 [TRACE] [os.internal.handler.ZonePlayerHandler] - Received pair 'LastChange':'<Event xmlns="urn:schemas-upnp-org:metadata-1-0/RCS/"><InstanceID val="0"><DialogLevel val="0"/><SurroundLevel val="0"/><MusicSurroundLevel val="0"/><AudioDelay val="0"/><AudioDelayLeftRear val="0"/><AudioDelayRightRear val="0"/><NightMode val="0"/><SurroundEnabled val="1"/><SurroundMode val="0"/></InstanceID></Event>' (service 'RenderingControl') for thing 'sonos:zoneplayer:RINCON_347E5CXXXXXX01400'

lolodomo commented 5 years ago

Excellent ! I can already add the automatic discovery of Sonos Bean. I can already add 2 new switch channels for NightMode and DialogLevel., at least as read only channels. Or for the control from the binding, I could make the hypothesis that the actions SetDialogLeveland SetNightModeare available for these devices.

lolodomo commented 5 years ago

For the Sonos Bean, we could have the same problem as with the Playbar, that is the correct detection of the connected line in (which is even different on the Bean because it is HDMI and not optical) and the correct way to start the playback of the line-in (TV sound) on other Sonos devices. With the same binding logs enabled (TRACE), could you please stop the binding with bundle:stop xxx and then start it bundle:start xxx and finally search after few seconds for LineInConnectedor TOSLinkConnectedor even something else like HDMILinkConnected???

lolodomo commented 5 years ago

I will also certainly need your value for the channel currenttransporturi when your Sonos Bean is playing the TV sound.

lolodomo commented 5 years ago

Rather than restarting the binding, you can unplug the HDMi link and check what values are received by the binding.

pdcemulator commented 5 years ago

after plugin HDMI: 17:15:17.388 [TRACE] [os.internal.handler.ZonePlayerHandler] - Received pair 'TOSLinkConnected':'true' (service 'HTControl') for thing 'sonos:zoneplayer:RINCON_347E5CXXXXXX01400'

value for channel currenttransporturi is x-sonos-htastream:RINCON_347E5CXXXXXX01400:spdif

My Beam is connected with optical SPDIF and a Sonos Adapter to HDMI port on Beam because my TV does not have a HDMI ACR port.

lolodomo commented 5 years ago

In this case, it looks fully similar to playbar. Unfortunately I was told that restore after TTS is not working well with playbar so we can expect similar issue with playbase and bean. I will add some debug logs to help understanding with your help what's wrong.

lolodomo commented 5 years ago

Unfortunately, it is difficult for me to guess the name and accepted values for the actions. The probability that I made the good choice is very low. If someone could use device spy (UPnP tool) to check that, that would help.

lolodomo commented 5 years ago

Anyone owning a Sonos playbase ?

lolodomo commented 5 years ago

@pdcemulator : if you could install the UPnP developer tools and start Device Spy, we could discover the actions behind night mode and speech enhabcement ... rather than having me trying to guess...

lolodomo commented 5 years ago

What I would need is the equivalent of this: sonosdevicespy

lolodomo commented 5 years ago

A topic on the forum leads me tp https://github.com/jishi/node-sonos-http-api/issues/108

I have now what I need. I will update my PR.