DLNA / UPNP binding


(Scott Rushworth) #81

Thank you for putting this binding together! I am currently using some scripts to control my renderers, but using a binding would be great. My speakers were discovered and I could use them as an audio sink. I was hoping for a channel to send the URI to, but I can work on that. I understand this is just a very rudimentary POC binding. However, I’m not able to control the volume on my speakers, but the initial states were updated properly. I’ve set the logging for the binding set to debug, but I still don’t see anything being logged. I’ll take a look into the binding in next couple weeks, but was wondering if this functionality was expected to be working?


(Mark Herwege) #82

Scott,

Volume is working for me. But I have not tested on many players. There is no specific channel for a URI. Other people have been succesful though with sending the audio to the sink in rules.
The logging is for the binding. Sending something to an audiosink is really outside of the binding. Adding the renderer as an audio sink is really only a convenience enabling more scenarios. The binding should work without.
The second part of the binding is connecting to a upnp media server. You should be able to navigate through the media tree (use select to go into the next level) and server the media in the selection (or all media in the folder). If you do this in paperUI, hou may need to refresh the page after selecting as it does not take the update of the list dynamically.
Again, this is very rudimentary. Ideally, the upnp search should be implemented and it should be possible to add a selection to a playlist.
Let me know what you think.

Regards
Mark


(Scott Rushworth) #83

I had been able to send audio to one of the renderers as an audio sink through Karaf… so that was working. But when looking at the volume, there was nothing in the log. I’m using Sony SA-NS400 speakers. At one point I had started converting the Sonos binding to be more generic, but it was right as they moved it to ESH so I dropped it and finished up my scripts instead. The one uses search to find playlists by name, so may be insightful for use in the binding. I ended up converting the renderer scripts over to use the Twonky API so that I didn’t have to implement subscriptions.

I’m exited to get into this… just need to put some other projects down first!


(Andreas Beistle) #84

Hey Mark,
just created an log and found out something About the behaviour.
When my device is online everything is fine, but wen it´s switched off, i have to relink it after openhab has started. Also when I Restart openhab after switching it on it works. The Status (Online Offline) is workin in every case. For the log I did the following steps:

  • Openhab is running and device is Online
  • Start Streaming -> OK
  • Stop Streaming -> OK
  • Shutdown the device and wait for Status Offline
  • Restart Openhab
  • Restart the device and wait for Status Online
  • Start Streaming -> Error
  • Deleated Thing
  • Added Thing
  • Start Streaming -> OK

find the log here:
https://1drv.ms/f/s!AinkhR9eG80Hjgi4sk03wwOiSyA7

I hope you can work with this Information, and thanks for your efforts. If you Need more detais let me know.

Greetings Andy


(Andreas Beistle) #85

Last for this night :frowning:
after cleaning the Cache the feature is uninstalled

Looks like this till i clean the Cache, then it´s uninstalled again…is this normal behaviour?

esh-io-transport-upnp                       │ 0.10.0.oh230     │ x        │ Started     │ distro-2.3.0 

dont think this has anything to do with your binding…., cause after installing again everything is fine.
Greetings Andy


(Scott Rushworth) #86

In my experience, this is normal behavior. If you had a binding installed that lists it as a dependency, it should install itself. This can be added to the upnpcontrol binding.


(Mark Herwege) #87

Losing the transport when deleting the cache is normal. I will try to add the dependency. I am not sure how that works. It is resolved automatically when the binding is part of the distribution.

I looked at your log file, but do not see logs matching the full sequence of what you did. I see the registration of the audio sink in the log, the deregistering and the registration again. The full binding consists of 4 OSGI bundles being registered and deregistered (UpnpParticipant, HandlerFactory, DybnamicStateDescriptionProvider and AudioSink). I see all these, but don’t see them 3 times (for registration).


(Andreas Beistle) #88

got it with the dependency, tought cause of the x in column required in the feature:list openhab keeps it :slight_smile:

i created an new log and put it in my ondrive, Maybe you can see something there.
also tested another device, same bahvior. I took the log from the log Folder after the error occured:
see also actual time there.

2018-06-28 14:37:57.161 [WARN ] [core.audio.internal.AudioManagerImpl] - Failed playing audio stream 'http://mp3channels.webradio.rockantenne.de/rockantenne' as no audio sink was found.
  • Restart device on
  • Steram ok
  • Restart dvice off
  • Switch device on
  • error, no Audi sink

Thanks for your support in this case. If you Need anythin more just let me know.
Greetings Andy


(Mark Herwege) #89

@Andreas_Beistle
I couldn’t figure it out from the logs yet.
I have created a new version with, I hope, more extensive and clear logging. It is loaded in the same place. There are also a few logic changes that may have an impact.
Can you test with this version and let me know?

EDIT: I have just done a few more changes. Please test with the version loaded at 18:14.


(Andreas Beistle) #90

Mark, Looks like you mad it. The binding is working now and the Status detection as well as the controls are fuckin fast :slight_smile:. Awesome Work. Ive done a few Restarts with two devices in different states switched them on and off, etc. everything is fine. Do you Need logs anyway?. Also if you Need some more test or something else just let me kow.

BTW: One Thing I recognized, when the device is Offline, the volume is set to 0 and not updated anymore when it goes Online again. But thats no Problem for my usecase.

Again Thank´s very much for this efforts, exactly what I was Looking for a Long time.

greetings Andy


(Mike Perry) #91

@Mherwege, this binding is fantastic, thank you.

One bug report: I use Emby as a upnp server. The binding seems to momentarily detect it as it flashes up in my inbox, but then disappears again. It’s not a feature I am immediately after, but it happens every 30 seconds.

2018-07-01 11:21:10.408 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' to inbox.
2018-07-01 11:21:10.510 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' to inbox.
2018-07-01 11:21:10.610 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' to inbox.

2018-07-01 11:21:10.409 [home.event.InboxAddedEvent] - Discovery Result with UID 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' has been added.
2018-07-01 11:21:10.487 [me.event.InboxRemovedEvent] - Discovery Result with UID 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' has been removed.
2018-07-01 11:21:10.511 [home.event.InboxAddedEvent] - Discovery Result with UID 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' has been added.
2018-07-01 11:21:10.513 [me.event.InboxRemovedEvent] - Discovery Result with UID 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' has been removed.
2018-07-01 11:21:10.610 [home.event.InboxAddedEvent] - Discovery Result with UID 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' has been added.
2018-07-01 11:21:10.612 [me.event.InboxRemovedEvent] - Discovery Result with UID 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' has been removed.

(Mark Herwege) #92

@mjptec
I don’t do anything special here. I rely on the upnp discovery functionality in the framework to discover all upnp device for me an pick the ones that are servers and renderers. I don’t have code to remove them. So at first it looks like a framework problem.
You couldctry to switch on debug logging for the binding, as it will list a bit more info on what is being detected.
Also, I saw the underlying upnp library just got upgraded. That may solve some issues. It is not in 2.3 stable yet though.


(Mike Perry) #93

Thanks @Mherwege, I’m on a 2.4 snapshot anyway so will update tonight and post some debug logs if it is still doing it.


(Mike Perry) #94

Not sure why at the moment, but on reinstalling I got build 1307 again, so no change from before. I’ll try again tomorrow.

Unfortunately the debug output only adds the following:

02-Jul-2018 23:09:40.385 [DEBUG] [internal.discovery.UpnpControlDiscoveryParticipant] - Device type MediaServer, manufacturer Emby, model Emby Server, SN# 263de70f43c34416927ed0dd159a399a
02-Jul-2018 23:09:40.385 [DEBUG] [internal.discovery.UpnpControlDiscoveryParticipant] - Media server found: Emby, Emby Server
02-Jul-2018 23:09:40.418 [DEBUG] [internal.discovery.UpnpControlDiscoveryParticipant] - Device type MediaServer, manufacturer Emby, model Emby Server, SN# 263de70f43c34416927ed0dd159a399a
02-Jul-2018 23:09:40.419 [DEBUG] [internal.discovery.UpnpControlDiscoveryParticipant] - Media server found: Emby, Emby Server
etc

I am now for some reason able to add the thing, but it doesn’t change the above log and the event log now spits out the following every 30 seconds:

2018-07-02 23:17:16.548 [hingStatusInfoChangedEvent] - 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Communication lost with Emby - eek2
2018-07-02 23:17:16.548 [hingStatusInfoChangedEvent] - 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' changed from OFFLINE (COMMUNICATION_ERROR): Communication lost with Emby - eek2 to ONLINE
2018-07-02 23:17:16.607 [hingStatusInfoChangedEvent] - 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Communication lost with Emby - eek2
2018-07-02 23:17:16.641 [hingStatusInfoChangedEvent] - 'upnpcontrol:upnpserver:263de70f43c34416927ed0dd159a399a' changed from OFFLINE (COMMUNICATION_ERROR): Communication lost with Emby - eek2 to ONLINE
etc

(Mark Herwege) #95

I don’t know why your media server’s visibility changes like that.
I receive this status from the underlying upnp transport bundle and switch the device online/offline accordingly. The transport is doing polling for this.
You could try setting debug level logging for org.eclipse.smarthome.io.transport.upnp. That should provide much more info.


(Mike Perry) #96

Thanks for the pointer. I can at least confirm it is a problem at the framework level:

03-Jul-2018 21:43:16.501 [DEBUG] [thome.io.transport.upnp.internal.UpnpIOServiceImpl] - Device '263de70f43c34416927ed0dd159a399a' reachability status changed to 'false'
03-Jul-2018 21:43:16.526 [DEBUG] [thome.io.transport.upnp.internal.UpnpIOServiceImpl] - Device '263de70f43c34416927ed0dd159a399a' reachability status changed to 'true'
03-Jul-2018 21:43:16.528 [DEBUG] [thome.io.transport.upnp.internal.UpnpIOServiceImpl] - Device '263de70f43c34416927ed0dd159a399a' reachability status changed to 'false'
03-Jul-2018 21:43:16.528 [DEBUG] [thome.io.transport.upnp.internal.UpnpIOServiceImpl] - Device '263de70f43c34416927ed0dd159a399a' reachability status changed to 'true'

I’ll keep prodding and report back if I find anything.


(Mark Herwege) #97

For all interested.
I have updated my UPnP binding with UPnP server directory search capabilities. Fee free to try. You can find the .jar here. The search works by entering search criteria in UPnP search string format. Examples:

  • dc:title contains “song”
  • dc:creator contains “Springsteen”
  • upnp:class = “object.item.audioItem”
  • upnp:album contains “Born in”

The code is on my personal GitHub page here. It is far from production ready code and I don’t have plans to make it perfect. But you can use it if it is of benefit to you.


Chromecast / Google Home - automatic start playing a stream when motion is detected in a room
Play a stream through openhab event to a Samsung multiroom speaker?
Roadmap to Happiness - What is missing in the core framework
(Scott Rushworth) #98

Thank you! When the binding starts, I get these uncaught exceptions in Karaf, but the Things appear to be online. I’ll focus some testing of this binding in the next few days. I’m using OH snapshot 1325.

493 │ Active   │  80 │ 2.4.0.201808071611     │ UPnPControlPoint Binding
openhab> bundle:restart 493
openhab> [Fatal Error] :1:1: Premature end of file.
[Fatal Error] :1:1: Premature end of file.
[Fatal Error] :1:1: Premature end of file.
[Fatal Error] :1:1: Premature end of file.
[Fatal Error] :1:1: Premature end of file.
[Fatal Error] :1:1: Premature end of file.
[Fatal Error] :1:1: Premature end of file.

EDIT: after some time, there was more to the error…

org.eclipse.jetty.io.EofException: Early EOF
        at org.eclipse.jetty.server.HttpInput$3.noContent(HttpInput.java:898)
        at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:191)
        at java.io.InputStream.read(InputStream.java:101)
        at org.jupnp.util.io.IO.copyLarge(IO.java:980)
        at org.jupnp.util.io.IO.copy(IO.java:954)
        at org.jupnp.util.io.IO.toByteArray(IO.java:402)
        at org.jupnp.util.io.IO.readBytes(IO.java:121)
        at org.jupnp.transport.impl.ServletUpnpStream.readRequestMessage(ServletUpnpStream.java:137)
        at org.jupnp.transport.impl.ServletUpnpStream.run(ServletUpnpStream.java:61)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

(Mark Herwege) #99

I don’t know what this error means. I don’t see it linking back to my code in the error message. It would be useful to get some debug messages from the binding just before these errors included here. I did do an update today, so you may want to try again.
Changes:

  • Made sort order configurable through a server thing parameter.
  • Implemented previous, to go back to previous entry playing on the renderer.
  • Added track duration channel on renderer.
  • Improvements in search, browse and media serving.

(Scott Rushworth) #100

When I restart the binding, I get seven of these…

[Fatal Error] :1:1: Premature end of file.

And in the log, I have seven vaiations of this (note empty string used in log and last entry)…

nding.upnpcontrol.handler.UpnpRendererHandler] - Device UPnP: Master Downstairs supports audio
2018-08-08 12:26:40.481 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable AVTransportURI with value  from service AVTransport
2018-08-08 12:26:40.484 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable CurrentURI with value  from service AVTransport
2018-08-08 12:26:40.485 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable TransportPlaySpeed with value 1 from service AVTransport
2018-08-08 12:26:40.484 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Registering Audio Sink for renderer UPnP: Master Downstairs
2018-08-08 12:26:40.485 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable CurrentTrackURI with value  from service AVTransport
2018-08-08 12:26:40.485 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable InstanceID with value 0 from service AVTransport
2018-08-08 12:26:40.485 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable CurrentTrackMetaData with value  from service AVTransport
2018-08-08 12:26:40.485 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable TransportStatus with value OK from service AVTransport
2018-08-08 12:26:40.486 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable AVTransportURIMetaData with value  from service AVTransport
2018-08-08 12:26:40.486 [DEBUG] [ab.binding.upnpcontrol.handler.UpnpRendererHandler] - Received variable CurrentURIMetaData with value  from service AVTransport
2018-08-08 12:26:40.486 [DEBUG] [openhab.binding.upnpcontrol.internal.UpnpXMLParser] - Could not parse Entries from string ''

Unrelated, but filtering UPnP Things in Habmin, shows that the Thing statuses don’t look to be displaying properly for devices that are offline (Guest Bathroom).

)

The results with the latest version are the same.