Vera and Emby

Here is a list of remote control commands from the Emby API you can use with my code snippets.

Like the PlayPause command I got working in Lua code which you could add to a Vera scene or PLEG action.

[code]local http = require(“socket.http”)

– 5 Second timeout
http.TIMEOUT = 5

– The return parameters are in a different order from luup.inet.wget(…)
result, status = http.request(“http://192.168.1.101:8096/emby/Sessions/9e69a4c0f6308d51692434f33779fa5f/Playing/PlayPause?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”, “run=run”)[/code]

I guess this can not progress much further without the assistance of someone like Rippa (who is currently on vacation). Excited and keen to get a beta test app tho…

I’ve got 10+ current and supported public plugins in the Vera world (and most also run on openLuup, goal is all), and a couple that aren’t in general release yet. As long as their API exposes the necessary functions, I don’t foresee any problems. Since my last reply I’ve put up a VM and have a running emby server that’s scanning media now. To set expectations with regard to plugin timing, I’ve got a vacation coming up (second and third weeks of September), so short of a preliminary/“work in progress” early look before I leave, I would not be releasing anything until later in September.

So tell me, what do you want to do with it on Vera? What functions and features are expected?[/quote]
Hi Rigpapa,
I hope you had an enjoyable break!
Are you back on deck?

[quote=“PrincessCleavage, post:23, topic:199693”]Hi Rippa,
I hope you had an enjoyable break!
Are you back on deck?[/quote]

Yup, I’m back! I’ve got a pretty full development schedule between now and the end of the year, so stay tuned, but I’ll get at least a beta done before Halloween, I’m pretty sure. It’s high on my list.

[quote=“rigpapa”][quote=“PrincessCleavage, post:23, topic:199693”]Hi Rippa,
I hope you had an enjoyable break!
Are you back on deck?[/quote]

Yup, I’m back! I’ve got a pretty full development schedule between now and the end of the year, so stay tuned, but I’ll get at least a beta done before Halloween, I’m pretty sure. It’s high on my list.[/quote]
Welcome back!
Exciting stuff, looking forward to testing
Thanks

[quote=“rigpapa”][quote=“PrincessCleavage, post:23, topic:199693”]Hi Rippa,
I hope you had an enjoyable break!
Are you back on deck?[/quote]

Yup, I’m back! I’ve got a pretty full development schedule between now and the end of the year, so stay tuned, but I’ll get at least a beta done before Halloween, I’m pretty sure. It’s high on my list.[/quote]
Hi Rigpapa,
Just touching base to see if I can help with any testing?

[quote=“PrincessCleavage, post:26, topic:199693”][quote=“rigpapa”][quote=“PrincessCleavage, post:23, topic:199693”]Hi Rippa,
I hope you had an enjoyable break!
Are you back on deck?[/quote]

Yup, I’m back! I’ve got a pretty full development schedule between now and the end of the year, so stay tuned, but I’ll get at least a beta done before Halloween, I’m pretty sure. It’s high on my list.[/quote]
Hi Rigpapa,
Just touching base to see if I can help with any testing?[/quote]

Emby is scheduled behind my current development work on Reactor. I’ve done some cursory research, and have it set up in my own environment. I should start work in earnest as soon as I get Reactor 2.0 out for public testing (I expect a month or more before a full release).

[quote=“rigpapa”][quote=“PrincessCleavage, post:26, topic:199693”][quote=“rigpapa”][quote=“PrincessCleavage, post:23, topic:199693”]Hi Rippa,
I hope you had an enjoyable break!
Are you back on deck?[/quote]

Yup, I’m back! I’ve got a pretty full development schedule between now and the end of the year, so stay tuned, but I’ll get at least a beta done before Halloween, I’m pretty sure. It’s high on my list.[/quote]
Hi Rigpapa,
Just touching base to see if I can help with any testing?[/quote]

Emby is scheduled behind my current development work on Reactor. I’ve done some cursory research, and have it set up in my own environment. I should start work in earnest as soon as I get Reactor 2.0 out for public testing (I expect a month or more before a full release).[/quote]
Curious what your doing with reactor, where can I read new features?
Edit: found that your adding a scene builder to v2.0 nice

[quote=“rigpapa”][quote=“PrincessCleavage, post:26, topic:199693”][quote=“rigpapa”][quote=“PrincessCleavage, post:23, topic:199693”]Hi Rippa,
I hope you had an enjoyable break!
Are you back on deck?[/quote]

Yup, I’m back! I’ve got a pretty full development schedule between now and the end of the year, so stay tuned, but I’ll get at least a beta done before Halloween, I’m pretty sure. It’s high on my list.[/quote]
Hi Rigpapa,
Just touching base to see if I can help with any testing?[/quote]

Emby is scheduled behind my current development work on Reactor. I’ve done some cursory research, and have it set up in my own environment. I should start work in earnest as soon as I get Reactor 2.0 out for public testing (I expect a month or more before a full release).[/quote]
Hi Rigpapa,
Anything to release for testing yet ?

Reactor took me a bit longer due to some family and gainful employment matters, and at the moment I’m travelling, but I’m on this. Sit tight.

Thanks!

Just a heartbeat ping… showing signs of life. I’m on a straight-line path at the moment to get session controls working (play/pause/volume). Then I will circle back and retest the startup process (login, discovery, etc.). But I’m the house baker, so I will need to take a break for cookies and confections. Priorities!

Stay Merry and happy Xmas!
P.s don?t get taken in too often by temptation;-)

OK. Wow. The product looks good on the user side, but their API is clearly geared toward building clients, and the remote control API documentation is so full or errors that it’s less than useless. Fortunately, they’ve got a swagger-based API test tool that works OK, so that fills in holes where the docs fail, and you can play with it to feel out what ends up working.

Here’s the download link to the first plugin release: https://www.toggledbits.com/assets/emby/Vera-Emby-0.1-181221.zip

What it currently does:

[ul][li]Finds your Emby server(s) using network discovery;[/li]
[li]Allows you to log in to each server, which generates an auth token that is stored in the Vera device (EmbyServer);[/li]
[li]Inventories the known, remote-controllable sessions (clients) on each server, and creates EmbySession devices;[/li]
[li]For each session, you can pause, unpause, skip forward/back, change volume, mute/unmute;[/li]
[li]Each session displays current playing media, position, and runtime, if any.[/li][/ul]

What it currently doesn’t do: A lot, but what you might be expecting that is currently absent includes:

[ul][li]Start playback of media on a client/session. Unlike Sonos, for example, a stopped Emby client doesn’t preserve its queue, so you can’t have the API “play” and have the last queue start/resume. “Play” in the Emby API requires the specification of one or more “items” (a generic term for some kind of media, or a playable media-related object like an album, playlist, etc.). That means that “Play” in this world is going to require a UI that allows you to select what media to play (or for a Vera action, tell it what to play). Creating a GUI that can browse the media library and let you choose what to play is, basically, creating an other Emby client, and it’s a big job, and it’s going to be a while before you see that in this plugin. I do plan on implementing play by (user-provided) title, with optional media type, but that will be optimized for starting playback via action (e.g. from Lua, Reactor, etc.); that’s where I’m headed next.[/li]
[li]To-the-moment updates on what is playing, client/session state, media position, etc., are not feasible in the Vera UI; there will be a lag. Aside from the two-second update interval of the UI itself, the only way to know what’s going on is to poll, which increases Vera’s load (and your Emby server’s). Polling frequency also affects timeliness of the displayed data, so it’s a balancing act. When a session is playing, the plugin polls more frequently (5 seconds default, configurable); but to avoid needlessly knocking the Vera, it polls at longer intervals when it last sees no active clients (nobody playing anything). That means when the client starts playing from a dead stop, it can take time before Vera displays that fact. An additional complication is that the Emby API does not have a way (at least, not that I’ve yet found) to query a single session, you have a single query that dumps the information for ALL of them, so there’s no way just to query the ones that are active/playing something, and that unfortunately makes frequent polling even more costly;[/li]
[li]The plugin does not provide a UI for, or implement in actions, the key-interface/navigation part of the remote control API, and I’m not planning on doing it. It doesn’t make sense to me, given the brutal sluggishness of the current Vera UI, that you would want to use the Vera UI to navigate menus on the client player, etc… “Down”. Wait three seconds. “Down”. Wait three seconds. “Left”. Wait three seconds. “Enter”. Wait three seconds… The thought of doing it that way makes a vein in my temple throb. It doesn’t seem like a use case this plugin should address.[/li][/ul]

Other matters:

Clients are going to be a bit of wildcard. Since each one is its own project, likely implemented by different product teams/developers who have their own approaches and inconsistencies, each client is going to function a little differently, but there’s no way for the server or the plugin to know that. For example, there are three commands to pause/unpause: Pause, Unpause, and Play/Pause (which toggles). A client is not required to implement all of them. The API will tell you the client can pause, but not tell you which to use. The docs recommend, but do not require, that clients implement PlayPause, so that is what the plugin uses, but I’m sure we’ll soon discover which clients ignore this guidance.

Another example: up/down volume control basically doesn’t work (at all) on the current Android client, but are functional on the Chrome desktop client but perhaps inconvenient/useless, because they use tiny (maybe 1%?) increments. I haven’t tried my Roku or others yet to see how they fare, but to make it better make sense for the Vera UI and actions, I’ve implemented a workaround: set the “SmartVolume” state variable in the session/client device to a value (0-100) that you want to use as a volume increment. When it’s non-zero, the up/down actions will not use the API up/down commands, but rather an absolute SetVolume command, incrementing or decrementing from the current level as needed.

Skip forward and backward are also hobbled for clients. The skip commands in the remote control API will skip to the next or previous song for audio, but do nothing when video is playing (and there is no separate “chapter skip” API command). So, like the volume issue above, I’ve implemented a workaround that, for video playback, ignores the API skip commands and instead does a seek using the chapter list and current position information.

Another thing I’m very interested in figuring out, if I can, is how this might be used for text-to-speech. Given that every TV, phone, tablet and desktop can be a controllable client, it seems like a great opportunity for TTS notifications. But for the moment, I’m off to figure out how to get playback of a known title started for version 0.2.

Oh… how to install it… it’s the usual for ZIP packages: once you’ve downloaded the ZIP file, unZIP it. The upload the files using the uploader at Apps > Develop apps > Luup files (remember to turn off the “Reload Luup when done” checkbox until the last file). Make sure you reload after the last file. If this is the first install of the plugin, you need to create the first device manually: go to Apps > Develop apps > Create Device and enter the following fields (leave the rest blank): set Description to [tt]Emby Interface[/tt], set Device Filename to [tt]D_Emby1.xml[/tt], and set Implementation Filename to [tt]I_Emby1.xml[/tt], and create the device (submit button). The reload Luup again (I just enter and run [tt]luup.reload()[/tt] in the Lua code test tool). After the reload, you can go in to the Emby Interface device and hit the “Run Discovery” button. It should find your local Emby server(s), and will create EmbyServer devices for them. On each server device, go in and log in with username and password. Once logged in, it will inventory the server or sessions/clients and be off and running. The discovery and inventory processes will cause Luup reloads themselves, and that’s expected–when you create child devices on Vera, it reloads. Fact of life. So take your time with the process and don’t be surprised if there are pauses in UI responsiveness while that’s going on.

Bugs and suggestions here in the thread, or PM or email me (email on my profile here).

Outstanding!

My server could not be discovered automatically and I had to enter I.p address which then states that you will have to manually generate and api key and manually assign it. How do I do this?

[quote=“PrincessCleavage, post:35, topic:199693”]Outstanding!

My server could not be discovered automatically and I had to enter I.p address which then states that you will have to manually generate and api key and manually assign it. How do I do this?[/quote]
Shame, but there are little differences in the network stack between various Vera models. What type of Vera are you using?

Just go into the server device (on Vera) and use the login fields. That will log in and have your Emby server generate an API key for the plugin to use.

[quote=“rigpapa”][quote=“PrincessCleavage, post:35, topic:199693”]Outstanding!

My server could not be discovered automatically and I had to enter I.p address which then states that you will have to manually generate and api key and manually assign it. How do I do this?[/quote]
Shame, but there are little differences in the network stack between various Vera models. What type of Vera are you using?

Just go into the server device (on Vera) and use the login fields. That will log in and have your Emby server generate an API key for the plugin to use.[/quote]
Vera Edge, manual login did the trick;-)
How do I do a re-discovery of new clients?
Edit: doesn?t matter just had to wait and they showed up after performing ?reload Engine? on the emby server device/ new service/ reload engine button. Android functions seem to work except for chapter skip and mute.

Xbox one controls work as expected. Missing stop button on all clients tho.
Edit: Found that you have to enter into each client device to see the stop function

After several engine reloads and a reboot of Vera the plugin doesn?t seem to pick up my htpc client (which is also emby server)

To save the Vera on polling emby server when it is not being used and in a low power sleep state would it be possible to add in a ping check every polling period and if no response then don?t run any further code until next polling period? Or perhaps you already have some code efficiency built it if there is no response from the emby server?