Jump to content

Recommended Posts

Seger
Posted (edited)

EMBi – Emby integration for Home Assistant

Hi everyone,

I'd like to share EMBi, a community integration that brings Emby players and library information into Home Assistant. I use it myself and wanted an easy way to see what is playing, control supported players and keep the integration tidy.

What can it do?

  • Show Emby players with titles, artwork and playback progress; play, pause, stop and seek where the client supports remote control.
  • Keep known players visible or show them only while playing or paused.
  • Provide seven selectable sensors: movies, TV series, episodes, albums, tracks, active players and users watching.
  • Configure the connection and sensors through the Home Assistant UI. No YAML is required to create the sensors. The optional dashboard examples below use card YAML.
  • Offer English and German setup, options and sensor translations.
  • Optionally clean up old entries from the Emby device history, manually or automatically. Automatic cleanup is off on a new installation.

Active players are not the same as users watching. One person can use more than one player. The active-player sensor counts different device/app combinations that are playing or paused. Users watching counts each user once and excludes paused sessions. Active players also includes clients you have hidden from Home Assistant's player list.

Installation: Add the repository to HACS as a custom Integration repository, install EMBi and restart Home Assistant. Then open Settings → Devices & services → Add integration → EMBi and enter your Emby connection details and API key. Requires Home Assistant 2026.7.2 or newer. When upgrading, enable the new Active players sensor in EMBi's options if desired; existing selections are preserved.

Please read before using cleanup: Removing old Emby device-history records is at your own risk. Only selected device/client entries are removed — never your libraries, movies, series, music or user accounts. A removed client may need to sign in again. The optional HA cleanup also removes the corresponding EMBi player entries. Active or uncertain sessions are protected, but Emby's separate check/delete requests leave a small unavoidable timing window. Keep suitable backups.

EMBi uses the emby domain and replaces HA's built-in Emby integration, so the custom-integration warning in Home Assistant is expected.

Repository and installation guide: https://github.com/Seger85/home-assistant-embi

Dashboard examples

The first and third examples use community cards: Mushroom, auto-entities and mini-media-player. Install them separately through HACS. EMBi itself does not require them. The library card is a built-in Home Assistant card.

Enable the required sensors and replace example IDs with your own where necessary. The player list follows the server of sensor.emby_active_players; replace that ID in both relevant cards if yours differs. Hidden player entities are absent from the card even when the server-wide sensor counts them. These original screenshots show my German dashboard with a custom theme; the examples use English labels. Colours and rounded corners depend on your theme.

Step-by-step dashboard guide

Active players

active-players.thumb.jpg.947960c4d31d37dac6c21f04eda3b5a7.jpg

double_tap_action:
  action: none
entity: sensor.emby_active_players
hold_action:
  action: none
icon: mdi:cast-connected
multiline_secondary: true
primary: |-
  {% set count = states('sensor.emby_active_players') %}
  {% if count in ['unknown', 'unavailable'] %}Active Emby players currently unavailable
  {% elif count | int == 1 %}1 Emby player is active
  {% else %}{{ count | int }} Emby players are active{% endif %}
secondary: What is playing? Playing and paused devices at a glance.
tap_action:
  action: more-info
type: custom:mushroom-template-card

Library counts

library-counts.thumb.jpg.9f73d33455b3adbad560e30e331ba155.jpg

entities:
- entity: sensor.emby_movie_count
  icon: mdi:movie
  name: Movies
- entity: sensor.emby_tv_series_count
  icon: mdi:television-classic
  name: TV series
- entity: sensor.emby_tv_episode_count
  icon: mdi:television-play
  name: Episodes
title: My Emby library
type: entities

Player cards

media-players.thumb.jpg.21b1821c8def2f6c68c416df672bf409.jpg

card:
  show_header_toggle: false
  state_color: true
  type: entities
filter:
  template: |
    {% set entry = config_entry_id('sensor.emby_active_players') %}
    {% set ns = namespace(rows=[]) %}
    {% for player in expand(integration_entities('emby')) | selectattr('domain', 'eq', 'media_player') | list %}
      {% if entry and config_entry_id(player.entity_id) == entry and player.state in ['playing', 'paused'] %}
        {% set duration = player.attributes.get('media_duration') %}
        {% set position = player.attributes.get('media_position') %}
        {% set updated = as_timestamp(player.attributes.get('media_position_updated_at'), none) %}
        {% set elapsed = ([as_timestamp(now()) - updated, 0] | max) if player.state == 'playing' and updated is not none else 0 %}
        {% set invalid_runtime = duration is not number or position is not number or position < 0 or position + elapsed > duration %}
        {% set ns.rows = ns.rows + [{
          'entity': player.entity_id,
          'type': 'custom:mini-media-player',
          'artwork': 'material',
          'hide': {'controls': false, 'volume': true, 'next': true, 'prev': true, 'runtime': invalid_runtime, 'info': false},
          'tap_action': {'action': 'more-info'}
        }] %}
      {% endif %}
    {% endfor %}
    {{ ns.rows }}
show_empty: false
sort:
  method: friendly_name
type: custom:auto-entities

I'd be happy to hear how it works with your Emby clients. For a problem report, please include your EMBi, Home Assistant and Emby versions and the client app. Check logs and screenshots for personal information before sharing them. GitHub Issues is the best place for reproducible bugs.

EMBi is a community project, not an official Emby or Home Assistant product. Thanks to the Home Assistant, Emby and frontend-card communities for their work!


EMBi – Emby-Integration für Home Assistant

Hallo zusammen,

ich möchte euch EMBi vorstellen: eine Community-Integration, mit der ihr Emby-Player und Informationen zur Mediathek direkt in Home Assistant nutzen könnt. Ich nutze sie selbst und wollte einfach sehen, was gerade läuft, unterstützte Player steuern und die Integration übersichtlich halten.

Was kann EMBi?

  • Emby-Player mit Titel, Cover und Fortschritt anzeigen und steuern: Wiedergabe, Pause, Stopp und Spulen, soweit die jeweilige App Fernsteuerung unterstützt.
  • Bekannte Player behalten oder nur während Wiedergabe und Pause anzeigen.
  • Sieben einzeln wählbare Sensoren bereitstellen: Filme, Serien, Episoden, Alben, Musiktitel, aktive Player und schauende Benutzer.
  • Verbindung und Sensoren über die Home-Assistant-Oberfläche einrichten. Für die Sensoren braucht ihr keinen YAML-Code. Nur die optionalen Dashboard-Beispiele unten verwenden Karten-YAML.
  • Einrichtung, Optionen und Sensornamen auf Deutsch und Englisch anzeigen.
  • Auf Wunsch alte Einträge aus der Emby-Gerätehistorie manuell oder automatisch aufräumen. Bei einer neuen Einrichtung ist die Automatik ausgeschaltet.

Aktive Player sind nicht dasselbe wie schauende Benutzer. Eine Person kann mehrere Player nutzen. Der Player-Sensor zählt unterschiedliche Geräte-/App-Kombinationen mit Wiedergabe oder Pause. Der Benutzersensor zählt jeden Benutzer mit laufender Wiedergabe einmal; Pause zählt dort nicht mit. Auch in HA ausgeblendete Clients können im serverweiten Player-Sensor mitgezählt werden.

Installation: Das Repository in HACS als benutzerdefiniertes Repository der Kategorie Integration hinzufügen, EMBi installieren und Home Assistant neu starten. Danach unter Einstellungen → Geräte & Dienste → Integration hinzufügen → EMBi die Emby-Verbindung und den API-Schlüssel eintragen. Voraussetzung ist Home Assistant 2026.7.2 oder neuer. Beim Update bleibt eure Sensorauswahl erhalten; den neuen Sensor Aktive Player könnt ihr in den EMBi-Optionen einschalten.

Bitte vor dem Aufräumen lesen: Das Entfernen alter Einträge aus der Emby-Gerätehistorie geschieht auf eigene Gefahr. Gelöscht werden nur ausgewählte Geräte-/Client-Einträge — keine Bibliotheken, Filme, Serien, Musikdateien oder Benutzerkonten. Ein betroffener Client muss sich eventuell erneut anmelden. Optional entfernt EMBi auch die passenden eigenen HA-Player-Einträge. Aktive und nicht eindeutig beurteilbare Sitzungen werden geschützt. Zwischen letzter Prüfung und Löschung bleibt wegen der getrennten Emby-API-Aufrufe ein kleines technisches Zeitfenster. Denkt daher an passende Backups.

EMBi verwendet die Domain emby und ersetzt die eingebaute Emby-Integration. Der entsprechende Hinweis auf eine benutzerdefinierte Integration in Home Assistant ist deshalb normal.

Repository und deutsche Anleitung: https://github.com/Seger85/home-assistant-embi/blob/main/README.de.md

Beispiele für euer Dashboard

Für die erste und dritte Karte braucht ihr diese Community-Erweiterungen: Mushroom, auto-entities und mini-media-player. Ihr könnt sie separat über HACS installieren. EMBi selbst benötigt sie nicht. Die Mediathekskarte ist eine normale Home-Assistant-Karte.

Schaltet die benötigten Sensoren ein und passt bei Bedarf die Beispiel-IDs an. Die Playerliste gehört zum Server von sensor.emby_active_players; ersetzt diese ID gegebenenfalls in beiden betreffenden Karten. Ausgeblendete Player erscheinen nicht in der Kartenliste, können aber im serverweiten Sensor mitzählen. Die Originalbilder zeigen mein Dashboard mit eigenem Theme. Farben und Rundungen können bei euch anders aussehen.

Schritt-für-Schritt-Anleitung für die Karten

Aktive Player

active-players.thumb.jpg.947960c4d31d37dac6c21f04eda3b5a7.jpg

double_tap_action:
  action: none
entity: sensor.emby_active_players
hold_action:
  action: none
icon: mdi:cast-connected
multiline_secondary: true
primary: |-
  {% set count = states('sensor.emby_active_players') %}
  {% if count in ['unknown', 'unavailable'] %}Aktive Emby-Player derzeit nicht verfügbar
  {% elif count | int == 1 %}1 Emby-Player ist aktiv
  {% else %}{{ count | int }} Emby-Player sind aktiv{% endif %}
secondary: Was läuft gerade? Wiedergabe und Pause im Überblick.
tap_action:
  action: more-info
type: custom:mushroom-template-card

Mediathek

library-counts.thumb.jpg.9f73d33455b3adbad560e30e331ba155.jpg

entities:
- entity: sensor.emby_movie_count
  icon: mdi:movie
  name: Filme
- entity: sensor.emby_tv_series_count
  icon: mdi:television-classic
  name: Serien
- entity: sensor.emby_tv_episode_count
  icon: mdi:television-play
  name: Episoden
title: Meine Emby-Mediathek
type: entities

Wiedergabekarten

media-players.thumb.jpg.21b1821c8def2f6c68c416df672bf409.jpg

card:
  show_header_toggle: false
  state_color: true
  type: entities
filter:
  template: |
    {% set entry = config_entry_id('sensor.emby_active_players') %}
    {% set ns = namespace(rows=[]) %}
    {% for player in expand(integration_entities('emby')) | selectattr('domain', 'eq', 'media_player') | list %}
      {% if entry and config_entry_id(player.entity_id) == entry and player.state in ['playing', 'paused'] %}
        {% set duration = player.attributes.get('media_duration') %}
        {% set position = player.attributes.get('media_position') %}
        {% set updated = as_timestamp(player.attributes.get('media_position_updated_at'), none) %}
        {% set elapsed = ([as_timestamp(now()) - updated, 0] | max) if player.state == 'playing' and updated is not none else 0 %}
        {% set invalid_runtime = duration is not number or position is not number or position < 0 or position + elapsed > duration %}
        {% set ns.rows = ns.rows + [{
          'entity': player.entity_id,
          'type': 'custom:mini-media-player',
          'artwork': 'material',
          'hide': {'controls': false, 'volume': true, 'next': true, 'prev': true, 'runtime': invalid_runtime, 'info': false},
          'tap_action': {'action': 'more-info'}
        }] %}
      {% endif %}
    {% endfor %}
    {{ ns.rows }}
show_empty: false
sort:
  method: friendly_name
type: custom:auto-entities

Ich freue mich über eure Erfahrungen mit unterschiedlichen Emby-Clients. Wenn etwas nicht klappt, nennt bitte EMBi-, Home-Assistant- und Emby-Version sowie die verwendete Client-App. Prüft Logs und Screenshots vor dem Teilen auf persönliche Angaben. Nachvollziehbare Fehler meldet ihr am besten über GitHub Issues.

EMBi ist ein Community-Projekt und kein offizielles Produkt von Emby oder Home Assistant. Danke an die Home-Assistant-, Emby- und Karten-Community für ihre Arbeit!

Edited by Seger
Original screenshots embedded; YAML formatting checked.
  • Like 1
Eigeplackter
Posted

I‘m curious where this is going, so far I get this information by using media_player entities.

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