[New Binding] EMBY Server Binding - Alpha

I’m facing the same issue since a few weeks. Random connection lost but restores itself after some time can be minutes or even hours still don’t know exactly what the issue is. If I adjust something in the config of the server thing and save it its online again.

Hey sorry guys i have been away on this for a bit. Going to get back to this. Are you guys running the most recent version from the addons?

Hey @volfan6415

Glad you are back!
Meanwhile, I just found an another solution to connect Emby to openHAB.
The Scripter-X plugin from the Emby plugin catalog does the job for me.
On play and on Stop event, it runs some shell scripts with curl command to update my items via restAPI. I gladly share the “knowhow” if anyone is interested.

But let’s talk about the binding. too. I played around the emby’s API recently and notice that, the http GET request with “deviceid” in it give back empty json response sometimes. My “deviceid” in this case is my andriod TV device. Seems, android TV device can disappear from the system after awhile. Probably because of the auto logout feature.
So the question is, How do the bindings handle the empty “[]” json response?

1 Like

Would love to know more, and also how it’s better than just using Emby’s built-in Webhooks feature. I’ve been planning to look at that, but maybe Scripter-X is a better way to go?

There are 2 problem with Webhook in this scenario.

1; The built-in Webhook is made for out of the homenetwork (https) service. It’s ok if you want to use service like IFTTT and similar.
2; You can point the http address to OH in the Emby Webhook plugin, but it will send the data in json format and OH can’t handle it. Acceptable format here is only plain text.

Conclusion: Scripter-X is definitely the better way to go and keeping data inside your network.
If the binding remains broken. Sorry @volfan6415

1 Like

So what the binding is doing is subscribing to the emby notification server. It is the same notification server that the webhooks plugin is using. I’m not actually doing any direct json responses via gets. Essentially what happens is every 10 seconds (or whatever you configure it to be via the refresh interval) Emby will send out a very large json packet about the currently playing media for all devices. The default is 10.

THe binding then parses this data and passes it off to the various devices.v I think where i have been running into stability issues and where i have been trying to fix it, but it has been tough to nail down. Is that i get overflow issues on the buffer sometimes and the binding closes the socket and doesn’t restart it gracefully.

This way…
Tutorial to sent play state and content type from Emby

It’s been a few days to put it together.

I see you removed the new repository, did you gave up on the plugin? I like the plugin idea more than the webhook or scripter-X, also Home Assitant also uses the websocket, so it should be able to work.

And I guess you don’t use the refreshInterval anymore, at least I don’t see it connected to anything, and the websocket should be push based anyways.

Emby also has a java api, it has a bit of android dependencies, but it might be useful

I’m finally getting around to setting up a new machine to run OpenHAB3, but now I’m wondering if I should wait for an updated Emby binding (or is it abandoned, @volfan6415 ?) or if I should “roll my own” using the Scripter-X instructions.

What’s the latest recommendation?

The binding is not abandoned. And the OH3 version above works well in production.

I do however still need to iron out the kinks in why the websocket is closed. And that has proven difficult.

1 Like

Great, thanks!

My home theater depends on this extension, I really don’t want to have to go back to doing things manually (ugh!). Without this, I’d stay at OH2.5.

Which version is the latest for OH3.1.0.M2?

openhab> bundle:list | grep -i "(gson|emby)"
 27 │ Active    │  80 │ 2.8.2.v20180104-1110    │ Gson: Google Json Library for Java
274 │ Installed │  80 │ 2.5.5.202005060445      │ openHAB Add-ons :: Bundles :: Emby Binding

2021-03-31 15:23:29.662 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.emby-2.5.5-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.emby [274]
  Unresolved requirement: Import-Package: org.eclipse.smarthome.config.core

        at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
        at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

I ended up having to keep an OH2.5 server running so I could use the org.openhab.binding.emby-2.5.0-SNAPSHOT.jar binding - the only one that works for me.

Is this binding abandoned now? Checked the repo and looks like last change was made 2 years ago, it’s a pity…

Thanks given the binding is not working I’d give a try on my Qnap…

Sorry for not responding exactly to your request, but,
You could try jellyfin ?

I wouldn’t say abandoned yet. Life has gotten in the way and i haven’t had much time to work on it recently.

Ok i am back at developing for this binding.

Here is a link to the new github for the changes.

volfan6415/openhab-addons at embydev (github.com)

And here is a link to a new version of the binding that should run under oh3.

org.openhab.binding.emby-3.4.0-SNAPSHOT.jar

Please test and let me know any bugs that you have. I am going to run this for awhile myself and squash any bugs i can before making the formal pull request.

pull request created for binding

[emby] Initial contribution by volfan6415 · Pull Request #13340 · openhab/openhab-addons (github.com)

Any updates @volfan6415
When is it available?