Kodi specific services to call Kodi API methods#7603
Conversation
- 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`.
- 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 descriptions in services.yaml.
- Add `timeout` parameter to yaml config (needed to make slow queries to the JSONRPC API, default timeout is set to 5s).
- Trigger events with the results of the Kodi API calls, with:
```
event_data = {
'result': api_call_results,
'result_ok': boolean,
'input': api_call_parameters,
'entity_id': 'media_player.kodi'}
```
|
I like this idea overall. Should reduce the need to keep adding services.
|
|
Hi, @armills
|
| https://home-assistant.io/components/media_player.kodi/ | ||
| """ | ||
| import asyncio | ||
| from collections import OrderedDict |
There was a problem hiding this comment.
'collections.OrderedDict' imported but unused
| _LOGGER.debug('Run API method "%s", kwargs=%s', method, kwargs) | ||
| result_ok = False | ||
| try: | ||
| if kwargs: |
There was a problem hiding this comment.
Should this be (**kwargs) instead of (kwargs)?
There was a problem hiding this comment.
It works both ways, now that I check it, I'll leave it simpler, without the if condition.
And I'll change the names.
|
No problem. I know how code tends to evolve over time and what makes sense starts to change. This will be a great addition, since it will pretty much expose everything Kodi can do. 👍 I suppose instead of |
|
This is so awesome! Thank you very much! |
Description:
New Kodi-specific services for accessing the Kodi JSONRPC API through Home Assistant, in order to simply (and asynchronously) access the full potential of the Kodi API.
Calls to the Kodi API that return results are redirected by triggering events with the information of the call parameters and the results obtained:
The new services are:
kodi_execute_addonto 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.kodi_call_methodto run a Kodi JSONRPC API method with optional parameters. Results of the Kodi API call are redirected in a Home Assistant event:kodi_call_method_result.Also, expose the
timeoutparameter in the Kodi platform yaml config, to be able to make slow queries to the JSONRPC API (default timeout is set to 5s).The documentation PR includes two examples of using these new services, including a simple example of using a Kodi Addon to turn on the TV, and a more complex one with scripts and a small AppDaemon App to form a dynamic
input_selectwith choices of media playback in Kodi.Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2635
Checklist:
If user exposed functionality or configuration variables are added/changed: