Jump to content

Emby Server api


PrincessClevage

Recommended Posts

cw-kid

@Chef 

 

My Lua coding doesn't get much more complex than this, mainly because I am terrible at coding and I have to use PLEG in Vera for most of my more complex logic. 

 

This is from my "Away" scene in Vera however, it checks the status of a virtual switch, that is linked by logic in PLEG to all my door / windows sensors. 

 

If the status of that virtual switch is 0 then it send a TTS message to my Android tablet running the Imperihome app "Entering away mode in two minutes" and sets the Away mode in Vera and also sends an alert to me via Vera Alerts plugin. 

 

However if the virtual switch is 1 then that means there is a door or window open somewhere in the house, in that case the Lua code sends the TTS message "Warning cancelling away mode another door or window upstairs is still opened" and sends me a notification via Vera Alerts that the Away mode was cancelled and Vera is not put in to Away mode. 

local status = luup.variable_get("urn:dcineco-com:serviceId:MSwitch1","Status2",44)
if status == "0" then
  luup.inet.wget("http://192.168.1.102:8080/api/rest/speech/tts?text=Entering%20Away%20Mode%20in%20two%20minutes")
  luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","SetHouseMode", {Mode = 2}, 0)
  luup.call_action("urn:richardgreen:serviceId:VeraAlert1", "SendAlert", {Message="Entering Away Mode",Recipients="user1"}, 45)
else
  luup.inet.wget("http://192.168.1.102:8080/api/rest/speech/tts?text=Warning%20,%20Cancelling%20Away%20Mode,%20another%20door%20or%20window%20upstairs%20is%20still%20opened")
  luup.call_action("urn:richardgreen:serviceId:VeraAlert1", "SendAlert", {Message="Cancelled Away Mode",Recipients="user1"}, 45)
end

Chef you wrote the Emby plugin for Vera right? I haven't used that plugin myself though as I linked my Kodi HTPC's to Vera using a Vera plugin called KodiRemote and made my own logic in PLEG to control the lights depending on Kodi's current playback status etc. Which is what I believe the main purpose of your Emby plugin is for? But obviously works with all Emby client devices I guess. 

  • Like 1
Link to comment
Share on other sites

chef

Yeah, that luup code works great! Nice work!

 

Now the code will have to be added to the Vera plugin xml and json files.

 

These files allow for the creation of UI configuration elements in the Vera UI.

 

There has to be functions written which parse the server for sessions, then return device names for configuration purposes.

 

Session IDs will change and so will app version, so a list if devices and registered IDs need to be saved in the Vera plugin.

Then we attaching Vera events to certain sessions in emby which match saved devices IDs.

 

Then you can send remote commands via URL to those sessions.

 

Something to keep in mind is (from what I can tell having spent some time reading about Vera plugins) the plug-ins poll their own system for device changes. The system doesn't raise events. Wierd!

 

With that in mind the plugin will have to poll the system for changes.

Edited by chef
Link to comment
Share on other sites

cw-kid

Anyone able to get live tv and channel selection working with a Vera call?

Haven't tried yet for an Emby client.

Edited by cw-kid
Link to comment
Share on other sites

cw-kid

For my TV in the lounge I used the Harmony plugin for Vera. I then created some actions in PLEG for favourite TV channels and then add buttons into the Imperihome app for those channels.

Link to comment
Share on other sites

cw-kid

I'm getting a Playback Error when trying to start video or TV channel playback via the API. 

 

Playback Error 

 

No compatible streams are currently available. 

 

Using the SessionService -> /Sessions/{Id}/Playing Instructs a session to play an item

 

Curl Command Example

curl -X POST "http://192.168.1.101:8096/emby/Sessions/9e69a4c0f6308d51692434f33779fa5f/Playing?ItemIds=c8041c1fd8df87f9b6914dc47722f82b&StartPositionTicks=0&PlayCommand=PlayNow&api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -H "accept: */*" -H "Content-Type: application/json" -d "{\"ControllingUserId\":\"string\",\"SubtitleStreamIndex\":0,\"AudioStreamIndex\":0,\"MediaSourceId\":\"string\",\"StartIndex\":0}"

I tried playing BBC One TV channel and a movie title on my Android tablet with the Emby app and by sending the curl command from my laptop to the Emby server. 

 

Both show the Playback Error in the Emby Android client app. So I am unable to start the playback of those item IDs etc. 

 

Thanks

Edited by cw-kid
Link to comment
Share on other sites

PenkethBoy

have you tried via Swagger as it shows a curl command as well?

Edited by PenkethBoy
Link to comment
Share on other sites

  • 3 months later...
PrincessClevage

Reactor looks really cool!

Yes, if you take some time and logical though it can do a lot, is stable, very light to have multiple reactor devices as they share parent code and can also do actions Edited by PrincessClevage
Link to comment
Share on other sites

PrincessClevage

What does it do?

Reactor is off topic for this thread which is about Vera > Emby iteration through a new Vera plugin made by rigpapa (still in initial release and testing but looks promising) which will provide automation to Emby by linking trigger from home automation device to actions in Emby to selected clients (rigpapa has also hinted at possible automate tts to client devices e.g motion has been detect in garage spoken over media room client while watching a movie etc). One example of integration might be if you have a media or cinema room and you open the door and enter you can trigger Emby to play welcome intro on htpc client and other auto inter action with devices like amp/tv on, light dim etc. in the link I provided rigpapa spells it out in detail better than I can, and also lays out the areas of emby remote api he had struggled with (not sure if you can see any area where slight changes may assist him?) something like this would be a first in my understanding and give an edge to Emby over its competitors.
Link to comment
Share on other sites

cw-kid

Gents we have some action...Rigpapa has made initial release and made some comments that Ebr, Luke, Chef and Cw-kid might find an interesting read:

Vera 2 Emby

https://r.tapatalk.com/shareLink?share_fid=24007&share_tid=103145&url=http%3A%2F%2Fforum%2Emicasaverde%2Ecom%2Findex%2Ephp%3Ftopic%3D103145&share_type=t

 

This link will take you directly to the information about the new Emby plugin for Vera which is being developed. 

 

http://forum.micasaverde.com/index.php/topic,103145.msg434261.html#msg434261

Link to comment
Share on other sites

cw-kid

I've just installed the Emby plug-in for Vera controller Z-Wave hub. 

 

More information and screen shots here. Although you probably have to login to the Vera forum to see the screen shots. So added them below as well. 

 

Presumably you can have Home Automation scenes trigger based on what Emby clients are doing etc. 

 

5c1e4fce2a6b0_VeraEmbyUI7.png

 

5c1e4fe1170ed_VeraEmbyUI7Controls.png

Link to comment
Share on other sites

PrincessClevage

I've just installed the Emby plug-in for Vera controller Z-Wave hub.

 

More information and screen shots here. Although you probably have to login to the Vera forum to see the screen shots. So added them below as well.

 

Presumably you can have Home Automation scenes trigger based on what Emby clients are doing etc.

 

5c1e4fce2a6b0_VeraEmbyUI7.png

 

5c1e4fe1170ed_VeraEmbyUI7Controls.png

Chefs emby plugin for Vera already performs Vera actions based on what emby clients are doing. Rigpapa s Vera plugin on the other hand is being developed to perform actions on Emby clients from Vera device triggers (still yet to get play xyz media working but other functions are working in the initial release).
Link to comment
Share on other sites

PrincessClevage

Looks very neat.

Luke is it much work and/or and option to report on individual client sessions through the api rather than reporting all sessions for every query?

 

Quote below from Rigpapa:

Already working on this. One of the shortcomings of their API is that you can't query individual sessions (client states), the API returns ALL of them for a server, so if ANY client on a server is playing, I have to set a high update rate and it ends up updating all of them. Fortunately, the data isn't too large, but it still kinda socks. Anyway, next version will fall way back when the server is unreachable.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...