Jump to content

Official emby home assistant integration


skank

Recommended Posts

seanbuff
3 hours ago, WORMUTHS said:

The counts look off when I did this.  I think the

value_template: '{{ value_json ["MovieCount"] }}

is counting all kinds of movies.  Home Videos, etc...  It's not broken out by library, which I'd prefer.  I suppose I need to know what the API endpoints are.  Right now, it seems as though it adds my videos in "Home Movies" to the total "Movie" count, but they are separate things. 

I noticed the same thing, it's counting all the media in my Documentaries library also (and others), which adds quite a bit.

So while probably not the correct way of doing it, but as the library item count service supports specific a UserId's library access, i created a separate user with access only to my "Movies" library

image.png.243f9924a95b6c936677b01b7c6b9ba1.png


Update the resource endpoint string to include the UserId like so:

http://<Emby_IP>:8096/emby/Items/Counts?UserId=<user_Id>&api_key=<api_key>


To get the UserId, just click on the user in your settings, and grab the end of the URL string
image.png.fadbf7f96184f07f1170dcaa67caa5ea.png


...and the counts are much more accurate.

image.png.c9a4c12a7f2e5e4a6265d14be21ae887.png


Bit of a hack, but it does the job until we can find the proper way 🤷🏽‍♂️

Edited by seanbuff
  • Thanks 1
Link to comment
Share on other sites

HouseOfCards
3 hours ago, seanbuff said:
http://<Emby_IP>:8096/emby/Items/Counts?UserId=<user_Id>&api_key=<api_key>

I think maybe I am formatting this wrong.  When I add the User ID all the sensors show no values, like they are unavailable.  Is it supposed to be a double "&&" or something.  Studio Code Server is highlighting the ampersand like the URL has got bad formatting or something.

Link to comment
Share on other sites

seanbuff
9 minutes ago, WORMUTHS said:

I think maybe I am formatting this wrong.  When I add the User ID all the sensors show no values, like they are unavailable.  Is it supposed to be a double "&&" or something.  Studio Code Server is highlighting the ampersand like the URL has got bad formatting or something.

No double '&&'

You can use the Swagger link at the bottom of your Dashboard to help build the string
image.png.9a1cd7f76e476fc51913494f942818d9.png

Click the 'Try it out' button and add the UserId to the optional field
image.png.dfd05f8e8137ab17888b6db36f5e5ef5.png

Edited by seanbuff
more info
Link to comment
Share on other sites

HouseOfCards

I get a "Failed to load API definition" error when I click API on my dashboard...  Grrrr....  I'm just using the Static View...

Edited by WORMUTHS
Link to comment
Share on other sites

Spaceboy
14 minutes ago, WORMUTHS said:

I get a "Failed to load API definition" error when I click API on my dashboard...  Grrrr....  I'm just using the Static View...

you have to load the api from a https connection

edit - localhost also works. local remote through ip address will result in "Failed to load API definition"

Edited by Spaceboy
Link to comment
Share on other sites

HouseOfCards
15 hours ago, seanbuff said:

No double '&&'

So I did it correctly...  Copying between my text editor and VS Code was copying an "invisible character" and breaking the URL.  🥵

I updated and rebooted, now I need to see if they update the counts correctly.

Link to comment
Share on other sites

Cheesegeezer
2 hours ago, WORMUTHS said:

So I did it correctly...  Copying between my text editor and VS Code was copying an "invisible character" and breaking the URL.  🥵

I updated and rebooted, now I need to see if they update the counts correctly.

To follow on from the api dev request. Just getting the counts will probably yield undesirable returns. So as i states you will probably need to create stricter filters in the requests and so it per library also. The calls are inexpensive in terms of time, 10-20ms as you don’t need images but you would need to create some logic also to specify if the library is ofType movie then apply includeitemtypes “movie”, etc. 

Link to comment
Share on other sites

HouseOfCards

Right now, these sensors would be alright with me as a starting point.  It is accurately counting items, although it doesn't break them out by library.  It's not a dealbreaker.  I still get an accurate count of movies I have, even if it is a total of three separate libraries.  I can live with that for now.

I only have one issue to sort out.  This is what the counts show...

Count.png.cc27a7759bce2ffb5b375670e9bda9f4.png

They are all correct except for "Music Tracks".  That is showing 1,445 more tracks than I have, and I have no idea where it's pulling those additional totals from.

Actual.png.779f77fcc30b073721a71f02d25583ce.png

Almost seems like a bug in the API.

 

  • Like 1
Link to comment
Share on other sites

HouseOfCards
1 hour ago, WORMUTHS said:

Almost seems like a bug in the API.

It's a bug with me.  LOL

It's counting podcasts from the Podcast plug-in as music files.

  • Haha 1
Link to comment
Share on other sites

coreyjohnson75
On 1/1/2023 at 2:34 AM, seanbuff said:
There's currently {{ states("sensor.emby_users_watching") }} active Emby session(s)


image.png.c5a89656b08e7cd7c26e71229d95eb02.png

 

How are you doing this? And in the same card that shows the Active Sessions? I tried adding to the Title but keep getting just the text/state-sensor itself, not the data. Is there an additional card mod?

Link to comment
Share on other sites

seanbuff
7 minutes ago, coreyjohnson75 said:

How are you doing this? And in the same card that shows the Active Sessions? I tried adding to the Title but keep getting just the text/state-sensor itself, not the data. Is there an additional card mod?

Two separate cards. I'm using a Mushroom Title card for the text above the active sessions card. HTH.

image.png.8ac512c15e52a50c0b9ad299d0220400.png

  • Like 1
Link to comment
Share on other sites

seanbuff
On 02/01/2023 at 23:53, Spaceboy said:

something around the emby pc performance at the OS level. i have a sensor for power used by monitoring a smart plug into which the emby pc is plugged and i have previously done some of this separately through prtg and telegraf/grafana.

I use IOT Link for this, it's lightweight and works well. Will pull in OS level stats into HA for you to display as entities or graph them

image.png.04908cee250346ff0b64948a297c93a6.png

There's a good guide for setting this up here.

Another alternative for other OS's is Glances

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

coreyjohnson75

Thanks! I love HA but have never really added in the customizations so finally getting around to fancying it up :)

  • Like 1
Link to comment
Share on other sites

Spaceboy
14 hours ago, seanbuff said:

I use IOT Link for this, it's lightweight and works well. Will pull in OS level stats into HA for you to display as entities or graph them

image.png.04908cee250346ff0b64948a297c93a6.png

There's a good guide for setting this up here .

Another alternative for other OS's is Glances

this is pretty cool. you can even get a snapshot of the desktop!

Link to comment
Share on other sites

Spaceboy

regarding long term graphing, i've started sending all my HA data to influxdb which i was already using for dashboarding pfsense stats. graphing in HA seems a bit limited

Link to comment
Share on other sites

Has anybody created anything to interact with Emby. I love getting all the data out, but, one thing I'm really missing from Plex is the ability to launch content either automatically or interactively.

For example - when nobody is home, Star Trek Voyager starts playing for our dogs to watch.

For reference - this is how it's done with Plex. The Plex integration has the ability to be used as a media source:

plex://{"library_name": "Movies", "title": "Groundhog Day"}

If someone has a way to do that - I'd really appreciate the help!

Link to comment
Share on other sites

Spaceboy

i imagine its possible through the api but i'm not sure how. its something i've been inteested in myself but never got round to researching

Link to comment
Share on other sites

Spaceboy
18 hours ago, troy_ said:

Obviously a lot of work to do. Plex's implementation here makes it look easy because the heavy lifting is done by their library.

Is their an official library for Emby - I've found this .

i don't think its that difficult. this thread seems to cover it although i tried and get the same result and unfortunately it doesnt seem to have been resolved.

API is accesses at the bottom of the dashboard

i think we want /Sessions/{Id}/Playing

i got the item id by looking at the url when on an media item in the web client

i got the device id from running /Sessions

but i also get a 204 response code and the error message on the target saying no compatible streams available.

Hopefully a knowledgeable api person will tell us where its going wrong. in the other thread luke mentions you need the id from the db. i think thats what the id in the url is but not certain

Edited by Spaceboy
Link to comment
Share on other sites

seanbuff
4 hours ago, Spaceboy said:

but i also get a 204 response code and the error message on the target saying no compatible streams available.

I had no issues running this in cURL or Postman, you just can't start it from Swagger for whatever reason.

So then as a test, I added it to Home Assistant using the 'rest_command' function which creates a service. Then added some buttons to the UI to call the service and instantly trigger media playing on whichever SessionId chosen:

Example:
image.png.c55647f4b50d07fa130491ec53657cbb.png

You could then also use these services in automations as @troy_ requested

Agree, it's not the most elegant solution, and it would be nice to be able to use "friendly" names like the Plex integration provides - but it does the job.

  • Like 1
Link to comment
Share on other sites

Junglejim

This is a nice open source app, I've been playing around with it intermittently for the past few months. Running it in a docker so some things are not as easy as the OS, say on a Raspi but I'm getting there. I've got the standard Emby stuff working, plus my solar data and my lifix lights. 👍

Still got a lot to learn but I enjoy that aspect of software like this. Plus this community help out heaps!

Link to comment
Share on other sites

Spaceboy
14 hours ago, seanbuff said:

I had no issues running this in cURL or Postman, you just can't start it from Swagger for whatever reason.

So then as a test, I added it to Home Assistant using the ' rest_command ' function which creates a service. Then added some buttons to the UI to call the service and instantly trigger media playing on whichever SessionId chosen:

Example:
image.png.c55647f4b50d07fa130491ec53657cbb.png

You could then also use these services in automations as @troy_  requested

Agree, it's not the most elegant solution, and it would be nice to be able to use "friendly" names like the Plex integration provides - but it does the job.

cool - ta. i plan to use this as part of my morning automation. as my withings sleep monitor detects that i am out of bed, turn the lights on in the living room and start playing the news channel on the tv

  • Like 1
Link to comment
Share on other sites

Apologies all - I'm feeling quite dense.

I can't see how I would use the API to cast to an arbitrary endpoint as I have historically done with the Plex integration in Home Assistant.

The API seems like I can start playback on a known/running Emby player.

Can somebody help get an example together of using the API to search for an arbitrary string (eg "Die Hard (1998)") in a library (eg "Movies") and play it on an arbitrary cast endpoint (eg "Living Room TV")

If I know the id of an item, I can play it via an API call - but I can't see how to do anything covered here (Plex Integration).

 

Link to comment
Share on other sites

seanbuff
2 minutes ago, troy_ said:

I can't see how I would use the API to cast to an arbitrary endpoint as I have historically done with the Plex integration in Home Assistant.

You can't, that's why I said this:

On 14/01/2023 at 11:04, seanbuff said:

Agree, it's not the most elegant solution, and it would be nice to be able to use "friendly" names like the Plex integration provides


For the current Emby integration, a number of bits of information need to be known beforehand, like the Media Item ID and a Session ID.

  • Like 1
Link to comment
Share on other sites

2 minutes ago, seanbuff said:

You can't, that's why I said this:


For the current Emby integration, a number of bits of information need to be known beforehand, like the Media Item ID and a Session ID.

Apologies - thank you.

Assuming also not possible to get the media URL to play on an arbitrary endpoint (like a cast device)?

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...