Monitoring Emby With Home Assistant. Need some help!

Hi, so I just moved over from plex to Emby, I love it except I REALLY miss Tautulli! Turns out there are really no good monitoring solutions for Emby (that I could find at least). IM using glances/netdata to monitor the server itself but I like to know how many people and whos watching as well. I found a post on here that pulls out all active media players and puts them into a group witch actually works perfect. Except I need to figure out how to exclude some media players, local ones like sonos that arnt emby related. I also need to find a way to dynamicly pull the attribute name out based on what media player is active.

Here is what is pulling active media players:

  • platform: template
    sensors:
    media_players_active:
    friendly_name: ‘Active Media Players’
    value_template: >
    {{ states.media_player
    | selectattr(‘state’, ‘equalto’, ‘playing’)
    | map(attribute =‘entity_id’)
    | join(’, ')
    }}

I know how to create a sensor to get the atrributes I want, but how could I make it dynamic, so it looks at whatever media players are active?

Not exactly sure I followed that, but my guess is you need to list the entity_id’s of the players in the template sensor…

sensor:
  - platform: template
      sensors:
        media_players_active:
          entity_id:
            - media_player.player1
            - media_player.player2
          ...

Thanks but I don’t know all the media players names. Let me try again…

I have quite a few remote emby users ~25
I don’t know all the media payer names if they use a different device a new entity is born.

The little sensor I posted above does good at creating a group that contains only media players that are ‘playing’

Here’s what I’m looking to do.

1: count how many active players there are currently.

2: from these active players extract a couple attributes.

This is what the active players sensor looks like. I need to somehow take each entity id from there and then create a sensor to get the attributes from each…

how can i create a template sensor to for each active media player?

I believe you will need a for loop, there is an example in the template page in the frontend.

Ive gone through the documentation countless times. nothing that helps me here.

the sensor i have that grabs acive media players…it has all the media players as a state, seperated by commas.

if i can figure out a way to create another sensor to seperate those that would work…

Re-reading the thread, you have 25 clients? That is an awful lot for one home!

I have 25 remote users. Each with multiple clients. For 2+ years.

Doesn’t sound particularly legal (depending what you are streaming and what licenses you hold of course)

ok. can you help with the issue?

I am fiddling with my media player entities now :slight_smile:

cool thank you

it creates this group that lists all the entites that are currently playing. you know anyway to take those out one by one, i would then create some magical sensor somehow to grap that couple attributes from each one…something like…

{{ states.media_player.emby_<insert active player name here>.attributes.media_title }}

or any way to use a wild card? I could do something like this sonos sensor but i cant get it to take media_player.emby_*

  • service: media_player.sonos_join
    data_template:
    master: >-
    {% if is_state(“input_select.master_sonos”, “Living Room”) %}media_player.living_room
    {% elif is_state(“input_select.master_sonos”, “Basement”) %}media_player.basement
    {% elif is_state(“input_select.master_sonos”, “Bedroom”) %}media_player.bedroom
    {% elif is_state(“input_select.master_sonos”, “Bedroom”) %}media_player.office
    {% endif %}

or this sensor…entites are seperated by commas but I dont know how to break it up.

i suck at jinja…i think this is the right path, i know im way off here…maybe a super jinja will help out?

From my reading you should be able to pipe the first part of your template in your first post to count or length to get the number of active palyers, something like

{{ states.media_player| selectattr('state', 'equalto', 'playing') | map(attribute ='entity_id')| count}}

or

{{ states.media_player| selectattr('state', 'equalto', 'playing') | count}}

But I just can’t get it quite right.

thanks, this is killing me. i know there is a way to do it, might go bald trying to do this lol

Welp, in case someone wonders by this in the future…finally got it. Or half of it…this looks at all my media players and counts the ones that are playing. I use this to monitor how many active emby users there are.

- platform: template
  sensors:
    emby_users_watching:
      friendly_name: 'Active Emby Users'
      value_template: >
        {{ states.media_player
          | selectattr('state', 'eq', 'playing')
          | rejectattr('attributes.app_name')
          | list
          | count
        }}

***Edit: Formatting

@Darbos can you help me with this i put that but not counting the users…regards