This Home Assistant component is used to feed custom cards like Upcoming Media Card, Kodi Playlist Card or Kodi Search Card with data coming from Kodi. It is based on the project of Aaron Godfrey (https://github.com/boralyl/kodi-recently-added). Check the credits section.
- Kodi Recently Added Media for Home Assistant
- Table of Contents
NOTE: This component has been tested with Home Assistant 2021.1.3 only. Additionally Kodi must be setup via the UI in the integrations section of the Home Assistant configuration.
- Search for
Kodi Media Sensors
underIntegrations
in the HACS Store tab. - You will need to restart after installation for the component to start working.
- Go to Integration Installation your sensor using the options.
** This method is not recommended **
- In your
/config
directory, create acustom_components
folder if one does not exist. - Copy the kodi_media_sensors folder and all of it's contents from to your
custom_components
directory. - Restart Home Assistant.
- Go to Integration Installation your sensor using the options.
- After Automatic install or manual install, go to the Integration panel (under Configuration section) and search for the ne component by clicking on the button 'Add Integration'. Enter the name of the component (Kodi Media Sensors).
- During the installation, choose the Kodi entity previously installed.
- Select the sensors you want to use (see Available Sensors)
- Click Submit
- You should now see new entities in Home Assistant (one for each sensor activated)
It's not possible to add new sensors after installation, so if you need new ones (or if you don't need one anymore), just uninstall the integration and add it again. You will then be able to select the sensors you need.
An Options
button will appear on the integration. Clicking this will allow you to
toggle additional options.
Option | Description |
---|---|
hide_watched | Excludes recently added video media that is marked as watched (movie sensors) when option is schecked |
use_auth_url | Adds the kodi username:password in the url's to access ressources from kodi (like images) |
search_limit | Sets the limit of the results returned by a search call. The limits applies to each media type (songs, album, movie, ...) |
Depending on the sensors you added and the custom card you installed, you can use the code below to display information from Kodi.
Here two examples with Upcoming Media Card and Kodi Playlist Card
- type: custom:upcoming-media-card
entity: sensor.kodi_recently_added_tv
title: Recently Added Episodes
image_style: fanart
- type: custom:kodi-playlist-card
entity: sensor.kodi_media_sensor_playlist
sensor.kodi_media_sensor_recently_added_tvshow
tracks your recently added tv showssensor.kodi_media_sensor_recently_added_movie
tracks your recently added moviessensor.kodi_media_sensor_playlist
tracks your playlist in Kodi (audio and video)sensor.kodi_media_sensor_search
tracks your search results
Some sensors come with services you can use. The definition of the services depends on each sensor. The service can be called via call_method
- search(media_type, value)
Searches in the specified media type for the referenced value. The media type 'all' will return result for songs, albums, artists, movies and tv shows.media_type:
{ all | artist | tvshow }value:
{ str (title) | int (artistid) | int (tvshowid) }
Example:
entity_id: sensor.kodi_media_sensor_search
method: search
item:
media_type: all
value: beatles
- clear()
This function clears the data of the sensor
Example:
entity_id: sensor.kodi_media_sensor_search
method: clear
- play(arg)
This function plays the desired object wth the good player. The argument depends on what object has to be played. the argument can be one of songid, albumid, movieid, episodeid.
Examples:
entity_id: sensor.kodi_media_sensor_search
method: play
songid: 1
entity_id: sensor.kodi_media_sensor_search
method: play
movieid: 15
- goto(posn, player)
This function plays the object at the given position for the given player
Example:
entity_id: sensor.kodi_media_sensor_playlist
method: goto
item:
playerid: 0
to: 5
- remove(posn, player)
This function removes an object from the given playlist
Example:
entity_id: sensor.kodi_media_sensor_playlist
method: remove
item:
playlistid: 0
position: 5
The goal is to group all the sensors and have seperate Cards to display the sensors data. The cards that where tested are:
- Upcoming Media Card (kodi_media_sensor_recently_added_tvshow or kodi_media_sensor_recently_added_movie)
- Kodi Playlist Card (kodi_media_sensor_playlist)
- Kodi Search Card (kodi_media_sensor_search)
- Remove any sensors in your
configuration.yaml
that reference thekodi_media_sensors
platform. - Restart Home Assistant.
- Follow the steps from the begining in the section Installation
Below is a list of known issues that either can't be fixed by changes to the component itself due to external factors.
One reason this could occur is if you setup you Home Assistance instance to use SSL and your Kodi instance does not use SSL. When the upcoming-media-card tries to load the artwork it will fail to do so since modern browsers do not allow loading insecure requests. See #6 for more details and possible workarounds.
Currently genres, rating, and studio are only populated for Movies. This is a limitation of the data Kodi stores for TV shows.
Aaron Godfrey is the original developer of this project and did an excellent job. As I needed something similar to display my running playlist in Kodi, I started to enhance the component. Thanks a lot Aaron for letting me enhance your project! Let's hope other people might find it useful. Do not hesitate to support Aaron and his many projects.