Jump to content

Official emby home assistant integration


skank

Recommended Posts

There is an ermby platform for home assistant but its by far perfect and not very extensive.

Are there any plans to make such an official integration here?

Or is it really up to home assistant 😛

  • Like 3
  • Agree 4
Link to comment
Share on other sites

Cheesegeezer
1 hour ago, skank said:

There is an ermby platform for home assistant but its by far perfect and not very extensive.

Are there any plans to make such an official integration here?

Or is it really up to home assistant 😛

@chef will know this!

Link to comment
Share on other sites

Well actually, i'm having the trouble i always need to restart my HA cause of my emby server.

If i turn my server on, i need to restart my ha so it makes a connection to emby... all is working fine then.

However if i'm running both, and i turn my server off...  off course the connection is broken then, but when i turn it back on, it should make a reconnection but it doesnt., so i have to restart HA.

Would love to see a fix for that. I made a report for that in the past (dont know where anymore, and then people said it could have a future fix but no time yet)..

So...

 

Would love to see the new movies/series added too in the integration... So we can have automations, telling is what is added or something :)

 

Aha!

Edit: Found my topic from the past: https://github.com/home-assistant/core/issues/36512

 

Edited by skank
Link to comment
Share on other sites

seanbuff
5 hours ago, skank said:

Would love to see the new movies/series added too in the integration... So we can have automations, telling is what is added or something

I'm already using a HA component that does this, you can check it out here:

https://github.com/gcorgnet/sensor.emby_upcoming_media

If you have HACS installed, you can install it via the catalogue there.

  • Like 4
Link to comment
Share on other sites

  • 3 weeks later...
Andrew@calvin.it

I've installed the Emby integration in HA and can see, for example,       entity_id: media_player.emby_study

But now what? What can I do with that entity? In other words, what does the Emby integration do? The HA page on it is bereft of any information as to WHY you'd use it.

Link to comment
Share on other sites

seanbuff
9 minutes ago, Andrew@calvin.it said:

But now what? What can I do with that entity? In other words, what does the Emby integration do? The HA page on it is bereft of any information as to WHY you'd use it.

That's entirely up to you and your imagination 😁

For example, you can create a dashboard of all your active Emby sessions if you like (view those sessions any way you prefer)
image.png.adb5444300ecce219d74a38448f6b336.png

 

Or use them to trigger HA's automation, for example:
When: entity_id: media_player.emby_study state changes from "Idle" to "Playing"
Action: Dim lounge room lights / Change lights to blue hue
...and then reverse to bring the lights back up when you "Pause" or finish playing ...


The information is there to use, it's up to you what you wish to do with that information, everyone's requirement is different. Hope that helps.

Link to comment
Share on other sites

  • 1 month later...
TheKamakaZi

I must admit, the official integration works a treat for checking and controlling Emby-connected endpoints.

I do wonder, though. Are there any plans for extending the integration to list Emby as a media source? I have an extensive HEOS ecosystem at home, and would absolutely love to be able to have my media collection available to them.

I tried using DLNA, but because I make use of HTTPS on Emby, Home Assistant is not able to connect to any of the media presented.

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

Here's my main wish:  I want music on my Emby server to play over my smart speakers (e.g., "Hey, Google, play playlist X from Emby.").  For now, I have to play it on my phone and use Bluetooth to connect to the speaker, and while that works for me, no one else in the house can do this without going through the whole set up and pairing process.

As others have noted, it works well on TVs, but the music side is still lacking, though I understand this is a work and progress and have seen improvements recently.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
Baenwort
On 11/28/2022 at 4:38 PM, Jägs said:

Here's my main wish:  I want music on my Emby server to play over my smart speakers (e.g., "Hey, Google, play playlist X from Emby.").  For now, I have to play it on my phone and use Bluetooth to connect to the speaker, and while that works for me, no one else in the house can do this without going through the whole set up and pairing process.

As others have noted, it works well on TVs, but the music side is still lacking, though I understand this is a work and progress and have seen improvements recently.

I'm able to use Chromecast Audios via the built into Chrome, most browsers, and the Emby app "Cast' button. Works from any device on the network and can pull from my Emby media:

https://www.home-assistant.io/integrations/cast/

Most of the house doesn't use it via the HASS interface but rather via a app on their device or via one of the Raspberries with touchscreens that are running either the Emby image or for the Raspberry Pi 4's the Emby web client directly. 

Link to comment
Share on other sites

2 hours ago, Baenwort said:

I'm able to use Chromecast Audios via the built into Chrome, most browsers, and the Emby app "Cast' button. Works from any device on the network and can pull from my Emby media:

https://www.home-assistant.io/integrations/cast/

Most of the house doesn't use it via the HASS interface but rather via a app on their device or via one of the Raspberries with touchscreens that are running either the Emby image or for the Raspberry Pi 4's the Emby web client directly. 

Yeah, I've done that too, but it's not functionally that different from using Bluetooth because I still have to use a device to send the audio to the smart speaker.  I'd rather use it like I can with YouTube Music, Spotify, etc., by asking the speaker directly to play the music.

Link to comment
Share on other sites

  • 3 weeks later...
Baenwort
On 12/9/2022 at 7:22 PM, Jägs said:

Yeah, I've done that too, but it's not functionally that different from using Bluetooth because I still have to use a device to send the audio to the smart speaker.  I'd rather use it like I can with YouTube Music, Spotify, etc., by asking the speaker directly to play the music.

 

It isn't coming from the device.  I often start it from my phone and then disconnect from Wi-Fi by leaving the house and it keeps on playing. Your Emby server directly sends to the Chromecast device without any intermediary. 

Link to comment
Share on other sites

HouseOfCards

One thing I'd like is for it to provide entities that show the count of media in each library. 

Television Shows: 6,344 Shows
Music Collection: 845 Albums, 10,455 Tracks

Etc....

It would be nice to have long-term statistics to visualize how your library changes over time...  And shouldn't be too difficult to push over to the integration...

Link to comment
Share on other sites

Spaceboy
On 29/09/2022 at 03:59, seanbuff said:

That's entirely up to you and your imagination  😁

For example, you can create a dashboard of all your active Emby sessions if you like (view those sessions any way you prefer)
image.png.adb5444300ecce219d74a38448f6b336.png

 

Or use them to trigger HA's automation, for example:
When:  entity_id: media_player.emby_study state changes from "Idle" to "Playing"
Action: Dim lounge room lights / Change lights to blue hue
...and then reverse to bring the lights back up when you "Pause" or finish playing ...


The information is there to use, it's up to you what you wish to do with that information, everyone's requirement is different. Hope that helps.

hi - looking into this in my own HA setup and i was wondering if you could give a bit more information on this. in your example i can see how to count the number of active sessions but as far as i can see you have to explicitly identify the emby devices that should be counted. this doesnt seem very practical as new devices may be used all the time. is there a way to open count all emby devices playing?

second the cards below - again, do you only have 2 devices or is there some way to only show playing devices? i can see how to list each device using the media players but not how to limit it to playing devices only.

finally - what are you trying to show in that card? it doesnt really make sense to me given the title above. or is it just an example of what can be shown?

edit - ok i can see that you can collapse the mini media player when the device is off. but that still leaves the issue of needing to manually maintain the list of media players. i currently have c70 of them

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

seanbuff
13 hours ago, Spaceboy said:

in your example i can see how to count the number of active sessions but as far as i can see you have to explicitly identify the emby devices that should be counted. this doesnt seem very practical as new devices may be used all the time. is there a way to open count all emby devices playing?

hey @Spaceboy, you are correct the number of emby devices is very dynamic, so in order to get an accurate count without having to specify every single device, I created a state-based template sensor to capture all of my "media players", and then only count the active ("playing") emby related ones, and ignore the rest. You can learn more about templates here.

Here is my code snippet for that, template sensors are only supported in YAML and not via the UI, so you would add this to your configuration.yaml file:

# Active Emby Users
- platform: template
  sensors:
    emby_users_watching:
      friendly_name: 'Active Emby Users'
      value_template: 
        "{{ states.media_player
          | selectattr('state', 'eq', 'playing')
          | rejectattr('entity_id', 'eq', 'media_player.dining_room_sonos')
          | rejectattr('entity_id', 'eq', 'media_player.lounge_sonos')          
          | rejectattr('entity_id', 'eq', 'media_player.bedroom_sonos')
          | rejectattr('entity_id', 'eq', 'media_player.shield')
          | list
          | count
        }}"

It will count all my media players (hundreds of them) which are "playing" but reject my Sonos speakers and my Shield if its playing something other than Emby.

Once that is ready, you can test it by filtering for it in the 'States' page in the Developer Tools, should look like this:
image.png.7d248caf9f8d2be347b4813c718ac8e6.png


And then in the UI for my card view, I simply refer to that new sensor to display a count as text at the top of that card:

There's currently {{ states("sensor.emby_users_watching") }} active Emby session(s)

 

13 hours ago, Spaceboy said:

second the cards below - again, do you only have 2 devices or is there some way to only show playing devices? i can see how to list each device using the media players but not how to limit it to playing devices only.

For the cards itself, I am using a custom card called auto-entities that populates a card with entities based on a certain criteria, you can filter on almost anything and include or exclude what you wish to show up on the card. For this purpose, I am choosing to filter media player entities with "emby" in the title, and with a state of "playing" or "paused".
I also use the custom mini-media-player with a few options to give a minimalist look for each player.

image.png.b020ed852a7ccda075535d01d8638412.png

Here is the code I used to achieve that:

type: custom:auto-entities
card:
  type: entities
  show_header_toggle: false
  state_color: true
filter:
  include:
    - entity_id: media_player.emby_*
      options:
        type: custom:mini-media-player
        shortcuts:
          attribute: app_name
        hide:
          controls: true
          volume: true
          power: true
      state: playing
    - entity_id: media_player.emby_*
      state: paused
  exclude: []
sort:
  method: none

 

13 hours ago, Spaceboy said:

finally - what are you trying to show in that card? it doesnt really make sense to me given the title above. or is it just an example of what can be shown?

Sorry for the confusion, the title of the card is only counting "active" sessions - in the original image you can see 4 entities, but two of them are paused, meaning there are only 2 "active" sessions. That's all it means, you can obviously tailor it to show anything you like, you can remove paused sessions if you prefer not to see them.


Hopefully that helps give you a better idea of what can be achieved, and how customizable it can be. Let me know if you get stuck on anything, or have anymore queries.

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

Spaceboy
3 hours ago, seanbuff said:

hey @Spaceboy , you are correct the number of emby devices is very dynamic, so in order to get an accurate count without having to specify every single device, I created a state-based template sensor to capture all of my "media players", and then only count the active ("playing") emby related ones, and ignore the rest. You can learn more about templates here .

Here is my code snippet for that, template sensors are only supported in YAML and not via the UI, so you would add this to your configuration.yaml file:

   
  
          
            
                      
            
            
          

It will count all my media players (hundreds of them) which are "playing" but reject my Sonos speakers and my Shield if its playing something other than Emby.

Once that is ready, you can test it by filtering for it in the 'States' page in the Developer Tools, should look like this:
image.png.7d248caf9f8d2be347b4813c718ac8e6.png


And then in the UI for my card view, I simply refer to that new sensor to display a count as text at the top of that card:



		

 

For the cards itself, I am using a custom card called auto-entities that populates a card with entities based on a certain criteria, you can filter on almost anything and include or exclude what you wish to show up on the card. For this purpose, I am choosing to filter media player entities with "emby" in the title, and with a state of "playing" or "paused".
I also use the custom mini-media-player with a few options to give a minimalist look for each player.

image.png.b020ed852a7ccda075535d01d8638412.png

Here is the code I used to achieve that:



		

 

Sorry for the confusion, the title of the card is only counting "active" sessions - in the original image you can see 4 entities, but two of them are paused, meaning there are only 2 "active" sessions. That's all it means, you can obviously tailor it to show anything you like, you can remove paused sessions if you prefer not to see them.


Hopefully that helps give you a better idea of what can be achieved, and how customizable it can be. Let me know if you get stuck on anything, or have anymore queries.

great info ta. part of the problem with HA is knowing whats possible :)

  • Like 2
Link to comment
Share on other sites

Spaceboy

ok - nice. spent some time on this and have it all implemented. starting to get the hang of yaml a bit more and using custome components.

as i was reading on templates i noticed that apparently you are using the old style format. if you are interested (not sure its needed yet) the new style to get the same as what you have is

# Active Emby Users
template:

    - sensor:
    - name: "emby_users_watching"
      state:
        "{{ states.media_player
           |  selectattr ( 'state' , 'eq' , 'playing' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.living_room_tv' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.bedroom_speaker_2' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.unnamed_room' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.bathroom' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.bedroom' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.living_room' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.sonos_roam' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.shield' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.mogo_pro' )
          |  list
           |  count
         }}"

and my emby page looks like this

image.thumb.png.56a1250588f3c10771f290e9011a6932.png

one odd thing i notice is that when using the mini media player card for the playing devices it doesnt fit properly into the wrapper card. not sure why that is or its not evident from your pics. perhaps the theme you are using doesnt have that problem - i havent looked at themes at all other than to make it dark.

i'm also using the emby integration in a couple of automations, nothing different than what has already been described here tbh. i have an automation that checks if the sun has gone down and if so dims my living room lights when i'm playing anything on the living room tv. And toggles adaptive lighting back on when it stops.

would also be interested to hear from others on how they are using the emby integration. i'm happy to be "inspired" by other people :D

Edited by Spaceboy
  • Like 1
Link to comment
Share on other sites

seanbuff

Well done looks good, thanks for the tip on the new templating format - i'm not surprised it's changed since my code is quite old now but still working somehow. I'll look to update it, cheers.
 

41 minutes ago, Spaceboy said:

one odd thing i notice is that when using the mini media player card for the playing devices it doesnt fit properly into the wrapper card. not sure why that is or its not evident from your pics. perhaps the theme you are using doesnt have that problem - i havent looked at themes at all other than to make it dark.

all I can think of is theme differences at this point, if you have HACS installed, its easy to grab some themes and try them out to see if it makes a difference.

Link to comment
Share on other sites

seanbuff
On 01/01/2023 at 03:36, WORMUTHS said:

One thing I'd like is for it to provide entities that show the count of media in each library. 

Television Shows: 6,344 Shows
Music Collection: 845 Albums, 10,455 Tracks

Etc....

It would be nice to have long-term statistics to visualize how your library changes over time...  And shouldn't be too difficult to push over to the integration...

I had a quick play with this, and while it's not part of the default integration. You can still pull that data using a rest sensor in HA that consumes the LibraryService endpoint of your Emby Servers API.

The code would look something like this:

# Emby Media Counts
rest:
  - resource: http://<Emby IP>:8096/emby/Items/Counts?api_key=<Your_API_Key>
    method: GET
    scan_interval: 3600
    sensor:
      - name: "Emby Movie Count"
        value_template: '{{ value_json ["MovieCount"] }}'
      - name: "Emby TV Series Count"
        value_template: '{{ value_json ["SeriesCount"] }}'
      - name: "Emby TV Episode Count"
        value_template: '{{ value_json ["EpisodeCount"] }}'
      - name: "Emby Album Count"
        value_template: '{{ value_json ["AlbumCount"] }}'
      - name: "Emby Song Count"
        value_template: '{{ value_json ["SongCount"] }}'    


Once you have the individual sensors, the output in the UI would be:

image.png.813a5d8c41bb6de07da0eedd2ab42667.png


I currently have mine polling Emby every hour, so I imagine after some amount of time I'll have enough data to populate a graph to visualize this over a longer time-frame.
(just as an example)
image.png.a631ed1d36a54a93c76151d902fd1131.png

  • Thanks 2
Link to comment
Share on other sites

Spaceboy

nice - couple of good additions there and also makes me think of 2 other things i'd be interested in capturing

  1. something around user play counts/ recently watched. essentially replicating the playback reporting plugin user tab/view
  2. 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.

seems like both of these are achieveable. time for some reading :)

Link to comment
Share on other sites

HouseOfCards

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. 

  • Agree 1
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...