Kodi specific service to call Kodi API methods (#2635)
* Kodi specific services to call Kodi API methods - Doc for new service: `kodi_execute_addon` to run a Kodi Addon with optional parameters. Results of the Kodi API call, if any, are redirected in a Home Assistant event: `kodi_execute_addon_result`. - Doc for new service: `kodi_run_method` to run a Kodi JSONRPC API method with optional parameters. Results of the Kodi API call are redirected in a Home Assistant event: `kodi_run_method_result`. - Add `timeout` parameter to yaml config (needed to make slow queries to the JSONRPC API, default timeout is set to 5s). - Examples for using the new services: one simple yaml example to call `kodi_execute_addon`and turn on the TV attached to Kodi; and other, more complex, to query the Kodi library and make a dynamic input select. * remove `kodi_execute_addon` service; change example to work with `kodi_run_method` * naming changes * complex example to cookbook * Update media_player.kodi.markdown
This commit is contained in:
parent
651f429bd1
commit
1bb8aeccd1
2 changed files with 200 additions and 0 deletions
|
@ -37,6 +37,7 @@ Configuration variables:
|
|||
- **password** (*Optional*): The XBMC/Kodi HTTP password.
|
||||
- **turn_off_action** (*Optional*): The desired turn off action. Options are `none`, `quit`, `hibernate`, `suspend`, `reboot`, or `shutdown`. Default `none`.
|
||||
- **enable_websocket** (*Optional*): Enable websocket connections to Kodi via the TCP port. Defaults to `true`. The websocket connection allows Kodi to push updates to Home Assistant and removes the need for Home Assistant to poll. If websockets don't work on your installation this can be set to `false`.
|
||||
- **timeout** (*Optional*): Set timeout for connections to Kodi. Defaults to 5 seconds.
|
||||
|
||||
|
||||
### {% linkable_title Service `kodi_add_to_playlist` %}
|
||||
|
@ -51,3 +52,46 @@ Add music to the default playlist (i.e. playlistid=0).
|
|||
| `media_name` | no| Optional media name for filtering media. Can be 'ALL' when `media_type` is 'ALBUM' and `artist_name` is specified, to add all songs from one artist.
|
||||
| `artist_name` | no | Optional artist name for filtering media.
|
||||
|
||||
|
||||
### {% linkable_title Service `kodi_call_method` %}
|
||||
|
||||
Call a [Kodi JSONRPC API](http://kodi.wiki/?title=JSON-RPC_API) method with optional parameters. Results of the Kodi API call will be redirected in a Home Assistant event: `kodi_call_method_result`.
|
||||
|
||||
| Service data attribute | Optional | Description |
|
||||
| ---------------------- | -------- | ----------- |
|
||||
| `entity_id` | no | Name(s) of the Kodi entities where to run the API method.
|
||||
| `method` | yes | Name of the Kodi JSONRPC API method to be called.
|
||||
| any other parameter | no | Optional parameters for the Kodi API call.
|
||||
|
||||
|
||||
### {% linkable_title Event triggering %}
|
||||
|
||||
When calling the `kodi_call_method` service, if the Kodi JSONRPC API returns data, when received by Home Assistant it will fire a `kodi_call_method_result` event on the event bus with the following `event_data`:
|
||||
|
||||
```yaml
|
||||
entity_id: "<Kodi media_player entity_id>"
|
||||
result_ok: <boolean>
|
||||
input: <input parameters of the service call>
|
||||
result: <data received from the Kodi API>
|
||||
```
|
||||
|
||||
### {% linkable_title Kodi services samples %}
|
||||
|
||||
#### Simple script to turn on the TV with the Kodi JSON-CEC Addon
|
||||
|
||||
```yaml
|
||||
script:
|
||||
activate_tv:
|
||||
alias: Turn on TV
|
||||
sequence:
|
||||
- alias: TV on
|
||||
service: media_player.kodi_call_method
|
||||
data:
|
||||
entity_id: media_player.kodi
|
||||
method: Addons.ExecuteAddon
|
||||
addonid: script.json-cec
|
||||
params:
|
||||
command: activate
|
||||
```
|
||||
|
||||
For a more complex usage of the `kodi_call_method` service, with event triggering of Kodi API results, you can have a look at this [example](/cookbook/kodi_dynamic_input_select/)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue