Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

SONOS PLAYBAR support TV optical input #2410

Open
Marty56 opened this issue Nov 5, 2016 · 68 comments
Open

SONOS PLAYBAR support TV optical input #2410

Marty56 opened this issue Nov 5, 2016 · 68 comments

Comments

@Marty56
Copy link

Marty56 commented Nov 5, 2016

The sonos PLAYBAR supports a TV optical input which should be made usable by openhab probably similar like the "playlinein" command for PLAY5, CONNECT, CONNECTAMP.

Use Case: User watches TV and PLAYBAR is getting a notification. After the notification SONOS should be set back by OH to TV optical input reception.

@kgoderis
Copy link
Contributor

kgoderis commented Nov 6, 2016

@Marty56 To be investigated, but if I remember well this is implemented by Sonos by means of a special grouping of Sonos players, rather than a 'switch' that is toggled

@lolodomo
Copy link
Contributor

@kgoderis : the information was given by someone how to select the optical line-in of the playbar. It is just anoher special URI. Unfortunately, I don't succeed finding the information again.
So, if true, @Marty56 suggestion is good.
PS: I own no playbar to test that.

@kgoderis
Copy link
Contributor

@Marty56 is it only the playbar you want to switch or also a sub and play:1's?

Sent from my iPhone

On 12 Nov 2016, at 11:27, lolodomo [email protected] wrote:

@kgoderis : the information was given by someone how to select the optical line-in of the playbar. It is just anoher special URI. Unfortunately, I don't succeed finding the information again.
So, if true, @Marty56 suggestion is good.
PS: I own no playbar to test that.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@lolodomo
Copy link
Contributor

I found information again:
https://community.openhab.org/t/sonos-save-and-restore/15949
jishi/node-sonos-http-api#109
Apparently, URI to be used would be: x-sonos-htastream:RINCON_XXXXXXXXXXXX01400:spdif

@Marty56
Copy link
Author

Marty56 commented Nov 12, 2016

@kgoderis
I only own a playbar.

@lolodomo
Copy link
Contributor

Please note that a general support for the optical line-in is requested by this issue, meaning the notication mechanism should work as well.

The playbar has only 1 line-in that is the optical line-in ? Or 2 line-in, one digital + one analog ?

@lolodomo
Copy link
Contributor

@Marty56 : if I update the code iand provide it through a new branch in my fork, would you be able to compile and test it ?
PS: I have no mean to test it myself.

@Marty56
Copy link
Author

Marty56 commented Nov 25, 2016

No, I cannot compile. I do not have the IDE installed nor do I know how to do this

@maggu2810
Copy link
Contributor

nor do I know how to do this

The instructions for the IDE setup could be found here: http://www.eclipse.org/smarthome/documentation/development/ide.html

@Marty56
Copy link
Author

Marty56 commented Nov 28, 2016

I am aware on these documentation but I since I am not using Java in my profession this amount of engagement is not justified for the time being.
Maybe situation is looking different in half a year

@lolodomo
Copy link
Contributor

lolodomo commented Dec 17, 2016

@Marty56 : I tried to implement this feature for you but I need you for testing. Please download and deploy the following jar (first uninstall the Sonos feature): http://lg.hc.free.fr/openHAB/org.eclipse.smarthome.binding.sonos-0.9.0-SNAPSHOT.jar
What needs to be tested:

  • channel linein should be set to ON for your Playbar thing (meaning that there is something connected to the optical line-in of your playbar)
  • sound notification should now work correctly when your playbar is playing the optical line-in
  • try to send a command ""RINCON_XXXXXXXXXXXX01400" to the channel playlinein of one Sonos thing (using the UDN of your playbar): you should hear the sound of your TV on this Sonos
  • try the ON command on the channel publicaddress of your playbar thing: it should play the optical line-in in all your rooms

@Marty56
Copy link
Author

Marty56 commented Dec 17, 2016

Great!
Not sure whether I can follow you correctly

  1. I have deinstalled the old sonos binding then

  2. I have added the jar. file into the addons directory
    Hopefully it has installed it correctly how can I check it.
    Sonos binding shows uninstalled in paper UI

  3. getting tons of error message. Log attached
    Archiv.zip

@Marty56
Copy link
Author

Marty56 commented Dec 17, 2016

also I do not really understand your third point.

@lolodomo
Copy link
Contributor

I see nothing relative to Sonos in your logs !
Please log to the console and run these commands:

feature:list | grep onos
bundle:list | grep onos

@lolodomo
Copy link
Contributor

lolodomo commented Dec 17, 2016

My third point is the use of the channel in order to ask the playback of the line-in.
Give me already a feedback for the other points.

@Marty56
Copy link
Author

Marty56 commented Dec 17, 2016

I have to leave now and have to postpone further analysis until tomorrow.

@lolodomo
Copy link
Contributor

lolodomo commented Dec 17, 2016

No problem, I will wait for the result of your commands.
Don't forget to suppress sonos from your line "binding=" in your conf/services/addons.cfg file in case this line is uncommented in your config.
Please enable DEBUG logs for the binding and restart OH:

log:set DEBUG org.eclipse.smarthome.binding.sonos

I am curious to see if susbcription to HTControl succeeded.

@Marty56
Copy link
Author

Marty56 commented Dec 18, 2016

I have created a new OH2 instance on another computer, have added your binding in the addons folder, additional I have added a things, items and a small rule file.
The installation creates an error. See logs.
Archiv.zip

The computer is a Macbook Air running macOS Sierra
Java is Version 8 Update 112

@Marty56
Copy link
Author

Marty56 commented Dec 18, 2016

also

feature:list | grep onos

esh-binding-sonos | 0.9.0.SNAPSHOT | | Uninstalled | openhab-aggregate-xml |
openhab-binding-sonos | 0.9.0.SNAPSHOT | | Uninstalled | openhab-aggregate-xml | Sonos Binding

@lolodomo
Copy link
Contributor

lolodomo commented Dec 18, 2016

@Marty56 : are you confortable with new jar deployment in OH 2 ?
What version of OH 2 are you running ?
Please run the following console commands:

bundle:list -s | grep oogle
bundle:list | grep onos
bundle:list -s | grep upnp

I am using this jar in my production environment with no such problem.

Anyone else to give it a try ?

@lolodomo
Copy link
Contributor

@Marty56 : First install OH 2 without the jar. When OH 2 is running well, stop it. Put my jar in addons subdirectory and restart OH.

@Marty56
Copy link
Author

Marty56 commented Dec 18, 2016

Did exactly this using standard package. Restarted same result. see log.
Archiv.zip

@lolodomo
Copy link
Contributor

lolodomo commented Dec 18, 2016

Please run the requested commands. Here is what you should get:

openhab> bundle:list -s | grep oogle
 12 | Active   |  80 | 2.3.1                 | com.google.gson
 13 | Active   |  80 | 18.0.0                | com.google.guava
 14 | Active   |  80 | 3.0.0.v201312141243   | com.google.inject
openhab> bundle:list | grep onos
197 | Active   |  80 | 0.9.0.201612171240    | Sonos Binding
openhab> bundle:list -s | grep upnp
160 | Active   |  80 | 2.2.0                 | org.jupnp
187 | Active   |  80 | 0.9.0.201612171108    | org.eclipse.smarthome.io.transport.upnp

and please confirm what OH version you are running.

@Marty56
Copy link
Author

Marty56 commented Dec 18, 2016

openhab> bundle:list -s | grep oogle
12 | Active | 80 | 2.3.1 | com.google.gson
13 | Active | 80 | 18.0.0 | com.google.guava
14 | Active | 80 | 3.0.0.v201312141243 | com.google.inject
openhab> bundle:list | grep onos
179 | Installed | 80 | 0.9.0.201612171240 | Sonos Binding
openhab> bundle:list | grep UPnP
160 | Active | 80 | 2.2.0 | JUPnP Library
openhab>

the last "org.eclipse.smarthome.io.transport.upnp" seems to be missing

@maggu2810
Copy link
Contributor

@lolodomo I own some Sonos devices and also a Playbar, too.
If you give me the URL to your branch and the steps I should test with the Playbar, I can do it as well.

@lolodomo
Copy link
Contributor

com.google.guava is active so I don't understand your resolv error.

@lolodomo
Copy link
Contributor

@maggu2810 : excellent, I will push my branch.

@lolodomo
Copy link
Contributor

The changes are now available in my branch "sonos" in https://github.com/lolodomo/smarthome.git

@maggu2810
Copy link
Contributor

channel linein should be set to ON for your Playbar thing (meaning that there is something connected to the optical line-in of your playbar)

Need to check again later, but ATM I don't see that channel (I used the PaperUI and also looked at the advanced channels).

@lolodomo
Copy link
Contributor

lolodomo commented Dec 18, 2016

Note that the Sonos binding is not yet able to update channels immediately after a new item is linked. The REFRESH command is even not handled in handleCommand().
So your channels have to be linked when the thing is initializing and the binding is receiving all information from subscribed services. If linking is done later, the items will be updated when the Sonos is notifying a change.
In our use case, I assume that if you disconnect your optical line-in, a new notification should be received; same thing when connecting it again and the channel will be updated.

@lolodomo
Copy link
Contributor

lolodomo commented Dec 18, 2016

@maggu2810 : you have clearly identified a new problem with this binding: the channels are not immediately updated when a new item is linked to a channel.
The "linein" channel would for example require to subscribe again to HTControl when the item is linked or would require to store internally the connection status of the line-in.
Can you create a separate issue asking for a correct handling of new linked channels (handling of the REFRESH command) ?

PS: I was not aware about this limit of the simple mode (I don't use it).

@lolodomo
Copy link
Contributor

lolodomo commented Dec 18, 2016

In fact, the current connection status of the line-in is already stored and what we have to implement is the handling of the REFRESH command.

@lolodomo
Copy link
Contributor

lolodomo commented Dec 18, 2016

@maggu2810 : I created the issue #2669 for your problem.

@maggu2810
Copy link
Contributor

Thanks @lolodomo, I will test your other points tomorrow...

  • channel linein should be set to ON for your Playbar thing (meaning that there is something connected to the optical line-in of your playbar)
  • sound notification should now work correctly when your playbar is playing the optical line-in
  • try to send a command ""RINCON_XXXXXXXXXXXX01400" to the channel playlineincontent of one Sonos thing (using the UDN of your playbar): you should hear the sound of your TV on this Sonos
  • try the ON command on the channel publicaddresscontent of your playbar thing: it should play the optical line-in in all your rooms

@lolodomo
Copy link
Contributor

Please note that there is no "content" in the channel names. I corrected my initial message.

@lolodomo
Copy link
Contributor

An additional check would be to check the value of the channel currenttransporturi when the line-in is playing: it should be x-sonos-htastream:RINCON_XXXXXXXXXXXX01400:spdif.

@maggu2810
Copy link
Contributor

linein does not seems to be changed while running (but set on first time)

16:10:20.597 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:138] - Polling job
16:10:20.626 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:685] - RINCON_xxx: Subscribing to service DeviceProperties...
16:10:20.627 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:685] - RINCON_xxx: Subscribing to service AVTransport...
16:10:20.628 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:685] - RINCON_xxx: Subscribing to service ZoneGroupTopology...
16:10:20.629 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:685] - RINCON_xxx: Subscribing to service GroupManagement...
16:10:20.629 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:685] - RINCON_xxx: Subscribing to service RenderingControl...
16:10:20.630 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:685] - RINCON_xxx: Subscribing to service AudioIn...
16:10:20.631 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:685] - RINCON_xxx: Subscribing to service HTControl...
16:10:20.656 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:714] - RINCON_xxx: Subscription to service GroupManagement succeeded
16:10:20.665 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:714] - RINCON_xxx: Subscription to service HTControl succeeded
16:10:20.666 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:714] - RINCON_xxx: Subscription to service RenderingControl succeeded
16:10:20.666 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:714] - RINCON_xxx: Subscription to service ZoneGroupTopology succeeded
16:10:20.666 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:714] - RINCON_xxx: Subscription to service AVTransport succeeded
16:10:20.667 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:714] - RINCON_xxx: Subscription to service DeviceProperties succeeded
16:10:20.693 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_zonename updated to Wohnzimmer
16:10:20.695 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_zonename changed from NULL to Wohnzimmer
16:10:20.707 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_linein updated to ON
16:10:20.709 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_linein changed from NULL to ON
16:10:20.770 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_zonename updated to Wohnzimmer
16:10:20.793 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_volume updated to 10
16:10:20.793 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_volume changed from NULL to 10
16:10:20.806 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currenttransporturi updated to x-sonos-htastream:RINCON_xxx:spdif
16:10:20.806 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currenttransporturi changed from NULL to x-sonos-htastream:RINCON_xxx:spdif
16:10:20.821 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currentartist updated to 
16:10:20.822 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currentalbum updated to 
16:10:20.823 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currentartist changed from NULL to 
16:10:20.826 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currenttitle updated to  
16:10:20.828 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_control updated to PLAY
16:10:20.829 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currentalbum changed from NULL to 
16:10:20.830 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currenttitle changed from NULL to  
16:10:20.830 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_control changed from NULL to PLAY

Now I changed from line-in to a amazon prime stream.

16:11:08.997 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currenttransporturi updated to x-sonosapi-radio:catalog%2fstations%2fA2XVUZI2XP6X0N%2f%23chunk-q8WQsJ-_RdeqqApnY2L3cQ?sid=201&flags=8300&sn=5
16:11:08.998 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currenttransporturi changed from x-sonos-htastream:RINCON_xxx:spdif to x-sonosapi-radio:catalog%2fstations%2fA2XVUZI2XP6X0N%2f%23chunk-q8WQsJ-_RdeqqApnY2L3cQ?sid=201&flags=8300&sn=5
16:11:08.998 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_control updated to PAUSE
16:11:08.999 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_control changed from PLAY to PAUSE
16:11:10.978 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_control updated to PLAY
16:11:10.979 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_control changed from PAUSE to PLAY
16:11:20.753 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:138] - Polling job
16:12:20.832 DEBUG o.e.s.b.s.h.ZonePlayerHandler[:138] - Polling job

Now I changed from a amazon prime stream to line-in.

16:12:46.452 INFO  smarthome.event.ItemStateEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currenttransporturi updated to x-sonos-htastream:RINCON_xxx:spdif
16:12:46.453 INFO  s.event.ItemStateChangedEvent[:43] - sonos_PLAYBAR_RINCON_xxx_currenttransporturi changed from x-sonosapi-radio:catalog%2fstations%2fA2XVUZI2XP6X0N%2f%23chunk-q8WQsJ-_RdeqqApnY2L3cQ?sid=201&flags=8300&sn=5 to x-sonos-htastream:RINCON_xxx:spdif

@lolodomo
Copy link
Contributor

That's normal, linein channel is not expected to be updated when you change source of playback. It is just expected to show whether the line-in is connected or not. I assume (to be checked) that it should be updated when you disconnect or reconnect your line-in. To be honest, I have not checked the same thing for the analog line-in of a Play:5 for example but I should. This channel is not set to ON when the line-in is being played but when the line-in is (physically) connected.

Your logs confirm the expected URI when the optical line-in is playing. Another good point.

I am now relatively confident that everything should work well.

@maggu2810
Copy link
Contributor

Ah okay, sorry. Didn't know the meaning of all that channels. 😉
So, is there still something that should be tested?

I tried to play the doorbell.mp3 using the command line, but it does not succeed.
Do I need to enable some missing stuff in the Eclipse SmartHome launch configuration?

@lolodomo
Copy link
Contributor

To play a sound from the console, you need to define your Sonos as the default audio sink. I do it with Paper UI.

@maggu2810
Copy link
Contributor

To play a sound from the console, you need to define your Sonos as the default audio sink. I do it with Paper UI.

Really? As i tested the Chromecast binding it has been enough to add the correct sink on the command line itself.

@lolodomo
Copy link
Contributor

Yes, you are probably right, I probably do a mismatch with the say command.
Does the play command work when your playbar is not playing the line-in ? If it does not work, that means you have something not well setup because it is something that works for me (even without the current changes). If it does not work only when the line-in is playing, that means that I missed something and my changes are insufficient.

@maggu2810
Copy link
Contributor

@lolodomo It seems the smarthome audio play implementation of the Sonos binding needs further testing.
After adding all of my Sonos players, I used smarthome audio play <sink> doorbell.mp3 to test it on different players.
I received exceptions all the time (stack trace shows that it was caused by the Sonos binding).
After that I restart the runtime (so, it could be related to the issue you already entered -- but it could be a little bit different, because I don't add some channels after adding the thing) I can play the doorbell on a Play 5 (the command line returned seconds after the audio file already stopped -- IIRC you already discussed that somewhere) but if I do the same for a Play 1 the command line returned immediately and nothing is played (at least I didn't hear something).

That's just for your information, I don't think it is related to your Playbar changes, but I will test again and open an issue if your PR has been merged (otherwise stack traces with line numbers will be very confusion). Perhaps it would be also better to wait for your "adding things at runtime" fix, too.

Thanks for all your work.

maggu2810 pushed a commit that referenced this issue Dec 20, 2016
@lolodomo
Copy link
Contributor

I am using the say feature daily and it is working well with my Play:5 and my Connect:amp.
I will test again the play console command later today but I think it is working with my 2 Sonos.
But if you can provie a strack trace with an error, of course we will study the problem and fix it.

@lolodomo
Copy link
Contributor

@maggu2810 : I just tried playing the doorbell with my 2 Sonos and it works well without any error in the logs.

@maggu2810
Copy link
Contributor

@lolodomo Thanks for testing.
As written above the errors that are displayed in the log has been thrown only if I don't restart the runtime after adding a Sonos device using the PaperUI. So, I started with a fresh / clean environment, added some Sonos devices using the PaperUI and after adding the devices I tried playing an audio file using the command line.
After a restart, so a start with already added Sonos devices I don't see the errors (just realized non playing audio on some devices).

After your recent PR has been merged, I will start further analysis and open a separate issue if there is one.

@lolodomo
Copy link
Contributor

Apparently my PR #2410 was unfortunately not enough because you are at least 3 to report the sound notification is still not working with the playbar when the line-in is played.
That is probably a stupid error in my code that I don't see but without the ability to test with a playbar, I forgive and I let someone owning a playbar finishing the work.

@Marty56
Copy link
Author

Marty56 commented Dec 23, 2016

Hi lolodomo,
Too sad.
Actually the behavior has changed a bit to the worse side.
If I have watched TV using the spdif interface and also switched off the TV, there is not sound using the say command even though the TV input is not used. It seems the binding is not able to switch to the sound file which was created by the say command.

The binding could switch to the sound file but would not return to TV.

Switching between radio stream and say is working perfectly.

chaton78 pushed a commit to chaton78/smarthome that referenced this issue Dec 23, 2016
@Marty56
Copy link
Author

Marty56 commented Mar 5, 2017

Meanwhile I am using the following workaround:

old_state = Wohnzimmer_linein.state.toString 
    if (old_state == "ON") {                                               // Switch to Playqueue if optical link is used
     Wohnzimmer_playqueue.sendCommand(ON)
     Wohnzimmer_control.sendCommand(PAUSE)
    } 										    
    say(Out,"voicerss:deDE","sonos:PLAYBAR:Wohnzimmer")
    if (old_state == "ON") {                                              // Switch back to TV if is has been used before
       Thread::sleep(4000)                                               // Text out must be shorted than 4 seconds
       Wohnzimmer_linein.sendCommand(ON) 
    }

@Marty56
Copy link
Author

Marty56 commented Mar 6, 2017

While testing the workaround I discovered that I can simplify the above procedure by

Wohnzimmer_playqueue.sendCommand(ON)
Wohnzimmer_control.sendCommand(PAUSE)
say("This is a text to speech IO test","voicerss:deDE","sonos:PLAYBAR:Wohnzimmer")

This is working if the sound is already cached and does not have to be translated into the respective mp3 file anymore.
It seems that basically the binding is ok except for a minor timing issue.

Also I noted that Wohnzimmer_linein.sendCommand(ON) does not work.

@maggu2810
Copy link
Contributor

I let someone owning a playbar finishing the work.

@Marty56 Thanks for your report but I assume we need a volunteer that owns a Playbar and has the time to debug and fix / improve / implement that code.

@kgoderis
Copy link
Contributor

kgoderis commented Mar 9, 2017 via email

@maggu2810
Copy link
Contributor

I will do that asap.

Great!

@Marty56
Copy link
Author

Marty56 commented Mar 27, 2017

Any update so far?

@Marty56
Copy link
Author

Marty56 commented Apr 27, 2017

asap = never ?

@Marty56
Copy link
Author

Marty56 commented May 13, 2017

asap = never.
I gave up: Removed the SONOS binding and installed a local speaker!
No need to hurry anymore. Probably the same fate as the upnp bug of the SONOS 1.8 binding.
Was also never working. Sad!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants