[Kodi](https://kodi.tv) (formerly known as XBMC) is a free and open source (GPL) software media center for playing videos, music, pictures, games, and more.
Kodi runs on Linux, OS X, BSD, Windows, iOS, and Android.
It allows users to play and view most videos, music, podcasts, and other digital media files from local and network storage media and the internet.
The Kodi Binding integrates Kodi media center support with openHAB, allowing both controlling the player as well as retrieving player status data like the currently played movie title.
The Kodi binding is the successor to the openHAB 1.x xbmc binding.
## Preparation
In order to allow Kodi to be controlled through this binding, you need to enable the Kodi application remote control feature.
Please enable "Allow remote control from applications on this/other systems" in the Kodi settings menu under:
| `callbackUrl` | Callback URL | URL to use for playing notification sounds, e.g. `http://192.168.0.2:8080` | no |
### Thing Configuration
The Kodi thing requires the IP address of the device hosting your Kodi media center instance, the TCP port to access it (default: `9090`) and the HTTP port to build URLs to the Kodi webinterface for downloading thumbnail and fanart images (default: `8080`).
You optionally can define a `httpUser` and a `httpPassword` parameter if the access to your Kodi webinterface is protected.
The IP address will be found by the auto-discovery feature.
You can use the `notificationVolume` property for setting a default volume (in %) as well as a `notificationTimeout` (in s) to be used to play notifications.
A manual setup through a `things/kodi.things` file could look like this:
| volume | Dimmer | Read or control the volume of your playback |
| control | Player | Control the Kodi player, e.g. `PLAY`, `PAUSE`, `NEXT`, `PREVIOUS`, `FASTFORWARD`, `REWIND` |
| stop | Switch | Write `ON` to this channel: Stops the Kodi player. If this channel is `ON`, the player is stopped, otherwise Kodi is in another state (see control channel) |
| title | String | Title of the currently played song/movie/tv episode |
| originaltitle | String | Title of the currently played song/movie/tv episode in local language |
| showtitle | String | Title of the currently played tv-show; empty for other types |
| album | String | Album name of the currently played song |
| artist | String | Artist name of the currently played song or director of the currently played movie |
| playuri | String | Plays the file with the provided URI. The URI can be amended by `#timestamp=<s>` where `s` is position in seconds at which the video should be started. |
| playfavorite | String | Plays or opens the favorite with the provided title (channel's state options contains available favorites) |
| pvr-open-tv | String | Opens the PVR TV channel with the provided name (channel's state options contains available PVR TV channels) |
| pvr-open-radio | String | Opens the PVR Radio channel with the provided name (channel's state options contains available PVR Radio channels) |
| pvr-channel | String | Title of the currently played PVR channel |
| shownotification | String | Shows the provided notification message on the screen |
| input | String | Sends a key stroke to Kodi to navigate in the UI. Valid commands are: `Back`, `ContextMenu`, `Down`, `Home`, `Info`, `Left`, `Right`, `Select`, `ShowCodec`, `ShowOSD`, `ShowPlayerProcessInfo` and `Up`. `ExecuteAction` and `SendText` should be used with the dedicated channels `inputaction` and `inputtext`. |
| inputtext | String | Sends a generic input (unicode) text to Kodi. |
| inputbuttonevent | String | Send a button press event. The parameter can have the format "`<button>`", "`<button>;<keymap>`" or "`<button>;<keymap>;<holdtime>`". For details see <https://kodi.wiki/view/JSON-RPC_API/v12#Input.ButtonEvent> |
| systemcommand | String | This channel allows to send system commands to `Shutdown`, `Suspend`, `Hibernate`, `Reboot` or `Quit` Kodi (channel's state options contains available system commands) |
| mediatype | String | The media type of the current file. Valid return values are: `unknown`, `channel`, `episode`, `movie`, `musicvideo`, `picture`, `radio`, `song`, `video` |
| mediaid | Number | The media_id in database of Kodi |
| mediafile | String | Full path and file name of the current file |
| uniqueid-imdb | String | IMDB link ID of currently playing media **(Advanced)** |
| uniqueid-tmdb | String | TheMovieDB link ID of currently playing media **(Advanced)** |
| uniqueid-douban | String | Douban link ID of currently playing media **(Advanced)** |
| uniqueid-imdbtvshow | String | IMDB link ID of the season of currently playing tv episode **(Advanced)** |
| uniqueid-tmdbtvshow | String | IMDB link ID of the season of currently playing tv episode **(Advanced)** |
| uniqueid-tmdbepisode | String | IMDB link ID of single episode of currently playing tv episode **(Advanced)** |
| season | Number | Season number if currently playing tv episode |
| episode | Number | Episode number if currently playing tv episode |
| genreList | String | A comma-separated list of genres of the current file |
| thumbnail | Image | The URL to the thumbnail of the current file |
| fanart | Image | The URL to the fanart of the current file |
| playnotification | String | Plays the notification sound by a given URI |
| title | Text | openHAB | Title of the notification |
| displayTime | Integer | 5000 | Time the notification is shown (in ms) |
| icon | Text | | Icon to use (e.g. "alarm"). One of the openHAB icons (as listed [here](https://www.openhab.org/docs/configuration/iconsets/classic/)). |
## Audio Support
All Kodi instances are registered as an audio sink in the framework.
Audio streams are sent to the `playnotification` channel and will change the volume of the audio sink using the `notificationVolume` defined in the properties for the thing, not the `volume`.
URL audio streams (e.g. an Internet radio stream) are an exception and do not get sent to the `playnotification` channel.
Instead, these will be sent to the `playuri` channel.
## Full Example
A manual setup through a `things/kodi.things` file could look like this: