Skip to main content

Kodi smart home integration, free and open source

Kodi integration for Gladys Assistant

Follow and control Kodi: what plays, volume, buttons, scenes when a movie starts.

Follow and control Kodi, the free media center (LibreELEC, OSMC, CoreELEC, Kodi on a PC, an Android TV box or an NVIDIA Shield), from Gladys: what plays, its progress, the volume, the playback buttons, and scenes that react when a movie starts, pauses or stops.

Everything stays on your local network: the integration talks to Kodi directly, through its JSON-RPC interface.

Tested against Kodi 20 and 21 running in Docker, not yet on LibreELEC, OSMC, CoreELEC or an Android box: feedback welcome on the Gladys forum.

Requirements​

  • Gladys Assistant 5.1 or later.
  • Kodi 19 or later (tested on 20 and 21), on the same local network as Gladys.
  • In Kodi, Settings → Services → Control:
    • Allow remote control via HTTP: on. Note the port (8080 by default), the user name (kodi by default) and the password, if you set one.
    • Allow remote control from applications on other systems: on. It opens port 9090, through which Kodi tells Gladys in real time what happens. Without it, the integration still works but reads Kodi every 10 seconds.
  • To be found automatically: Settings → Services → General → Announce services to other systems on (the default).
  • Give the device running Kodi a fixed IP address (a DHCP reservation in your router).

Configuration​

  1. Install the integration from the Gladys store, then open its Configuration tab.
  2. Click Find Kodi on the network: each Kodi found takes a free slot (three at most). Reload the page to see their addresses. Or type the address yourself, e.g. 192.168.1.40, or 192.168.1.40:8081 if the web server of Kodi does not use port 8080.
  3. If Kodi asks for a password, fill in the User name (empty means kodi) and the Password of the slot, then save.
  4. Test the connection: one line per Kodi, with its name, its version and what it does.
  5. In the Discovery tab, add each Kodi to Gladys.

The Language option picks the language of the feature names and of the texts the integration creates (French by default). Feature names are set when the device is added.

On its first start without any address, the integration searches the network once by itself. A scan from the Discovery tab searches again.

The Kodi device​

One device per Kodi, named as Kodi names itself (Settings → Services → General → Device name). The slot number is its identity: a Kodi that changes address keeps its device and its history.

FeatureTypeContent
PlaybacktextPlaying, Paused, Stopped, Off or unreachable
Now playingtextMovie (2024), Show S01E02 – Title, Artist – Song...
Media typetextMovie, TV episode, Music, TV channel, Video, None
ProgresspercentagePosition in the media, 0 for a live stream
Time leftminutesUntil the end of the media, 0 for a live stream
Volumeslider 0–100Kodi's volume, follows the remote
Play, PausebuttonsResume, pause
StopbuttonStops playback
Previous/NextbuttonsPrevious or next item of the playlist
MutebuttonMutes or unmutes

"Video" is what Kodi plays outside its library: a file opened from a folder, a stream, an add-on. Movies and episodes of the library are "Movie" and "TV episode".

Kodi reports its changes in real time (port 9090); while something plays, the progress is read every 10 seconds. With port 9090 closed, everything is read every 10 seconds over HTTP.

Dashboard widget​

The Kodi widget (choose the Kodi in its settings) shows the artwork of what plays (when it comes from the library), the title, the media type, the state, the position, the end time and the volume. Its buttons follow the media: play/pause, then stop (video) or next (music), and volume down / up by 5 %.

Without artwork, a progress gauge takes its place once the device is added to Gladys.

Scene triggers​

TriggerWhen
Playback startedKodi starts a media after nothing played, or the next one of a list
Playback pausedKodi pauses
Playback resumedKodi resumes after a pause
Playback stoppedPlayback stops or reaches its end, and nothing follows

Each trigger can be limited to one Kodi and to some media types (movie, TV episode, music, TV channel, other video). Variables for the next steps: Title, Media type, Kodi name, and for a stop, Reached the end.

Between two episodes of a playlist, Kodi stops then starts again within a tenth of a second: the integration waits 1.5 seconds before saying "stopped", so the next episode is a "started" and the lights do not flash.

The triggers follow what Kodi really does, whatever started it: the remote, the widget or a scene action. Nothing fires for what was already playing when the integration started, nor when Kodi is turned off.

Scene actions​

ActionWhat it does
Control the playbackPlay, pause, play/pause, stop, next, previous
Set the volumeVolume from 0 to 100
Mute or unmuteMute, unmute or toggle
Show a notification on KodiA message with a title in the corner of the screen
Play a mediaA file, a folder or a stream, by its path or URL as Kodi knows it
Update the libraryKodi scans its video or music sources for new media
Read what Kodi playsState, title, media type, progress, minutes left, volume

"Control the playback" returns Applied: false when nothing was playing, without failing the scene. "Read what Kodi plays" gives the next steps what they need for an "only continue if" condition: state (off, stopped, playing, paused), media type (movie, episode, music, tv, video)...

Scene examples​

  • Movie night: trigger "Playback started" on the living room Kodi, media type Movie and Other video → dim the living room lights to 10 %. Trigger "Playback paused" → lights to 50 %. Trigger "Playback resumed" → back to 10 %. Trigger "Playback stopped" → lights to 100 %.
  • Doorbell: when the doorbell rings → "Show a notification on Kodi" ("Someone at the door") and "Control the playback: pause".
  • Bedtime: at 11:30 pm → "Read what Kodi plays", only continue if the state is stopped → turn off the TV plug.
  • New downloads: when your download box says it finished → "Update the library" (videos).

Do not start a playback from a "Playback started" scene: it would start itself again and again.

Troubleshooting​

  • "no answer (turned off, or remote control disabled)": Kodi is off, or "Allow remote control via HTTP" is off, or the address or port is wrong. Open http://<address>:8080 in a browser: Kodi's web interface (or its login prompt) must appear.
  • "user name or password refused": check the user name and password of Settings → Services → Control. An empty user name means kodi.
  • "password refused by the web server, no artwork": everything works through port 9090, but the artwork comes through the web server: fix the password.
  • "Test the connection" says "no live updates": turn on "Allow remote control from applications on other systems". Kodi's port 9090 cannot be changed from its menus.
  • Nothing found on the network: turn on "Announce services to other systems", or type the address. The search needs Gladys on the same network as Kodi (Docker in host network mode, the usual setup).
  • No artwork in the widget: Kodi only serves the artwork of its library; a file opened from a folder has none. An image over 300 KB is not shown either.
  • "Update the library" does nothing: Kodi only scans the sources whose content type is set (Videos → Files → the source → Set content).

Limits​

  • Three Kodi at most.
  • The WebSocket port is 9090 (Kodi's default, only changed in advancedsettings.xml).
  • No power on/off: Kodi cannot be woken up through its interface. A Kodi turned off shows "Off or unreachable" and fires no trigger.
  • Pictures (slideshows) are ignored; when music plays behind a video, the video wins.
  • The artwork is shown when Kodi serves it under 300 KB (Kodi caches posters at 720 px).
  • Not affiliated with the Kodi Foundation (XBMC Foundation), owner of the Kodi trademark.

Configuration settings​

These are the settings Kodi asks for in its configuration screen in Gladys.

SettingTypeRequiredDescription
Connect your KodisectionNoIn Kodi, open Settings, Services, Control and turn on "Allow remote control via HTTP" and "Allow remote control from applications on other systems". Then click "Find Kodi on the network" below, or type its address. Up to three Kodi.
Kodi addressstringNoIP address of the device running Kodi. Add :port if its web server does not use 8080.
User namestringNoOf Kodi's web server. Empty: kodi.
PasswordsecretNoLeave empty if Kodi asks for none.
Kodi 2 (optional)sectionNoAnother Kodi, set up the same way.
Kodi address 2stringNo
User name 2stringNo
Password 2secretNo
Kodi 3 (optional)sectionNoAnother Kodi, set up the same way.
Kodi address 3stringNo
User name 3stringNo
Password 3secretNo
OptionssectionNoLanguage of the names and texts the integration creates (feature names are set when a device is added).
LanguageselectNo

How to install Kodi in Gladys​

  1. In Gladys, open Integrations: Kodi appears in the catalog, next to the native integrations, with a community badge.
  2. Click Install. Gladys pulls the Docker image (ghcr.io/guim31/gladys-kodi:1.0.1), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration).
  3. Open the Configuration screen of the integration, fill in the settings, and save.
  4. You can also install it directly from its repository URL: https://github.com/guim31/gladys-kodi.

Kodi requires Gladys >=5.1.0. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.

Not running Gladys yet? It is free and open source: follow the installation guide to get started.

About external integrations​

Kodi is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by guim31, not by the Gladys core team.

Subscribe to the Gladys Assistant newsletter

A few emails per month about new releases and project news. Sent by Pierre-Gilles Leymarie, founder of the project. Unsubscribe anytime 🙂