How can I execute a built-in function (CECActivateSource) from the JSON RPC? - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93) +---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174) +---- Thread: How can I execute a built-in function (CECActivateSource) from the JSON RPC? (/showthread.php?tid=365098) |
How can I execute a built-in function (CECActivateSource) from the JSON RPC? - jant90 - 2021-10-23 How do I execute a built-in command from the JSON RPC? Is there some hidden method I can use for that? Is it even possible at all? I would like to execute the function CECActivateSource from Home Assistant to switch my TV to Kodi. The function itself is working as intended when I execute it from my Kodi machine, I just need to execute it remotely. The Android remote app Yatse can do exactly this through its power menu but I don't know how it sends the actual command to Kodi. Does it even use the JSON RPC for that? If now, how does Yatse do it? RE: How can I execute a built-in function (CECActivateSource) from the JSON RPC? - jant90 - 2021-10-23 I realize now that Yatse is using Kodi's EventServer for the built-in actions. It's not as clean as making a JSON RPC call but I can do what I want with the Python EventClient included in the Kodi source. For example this very simple Python script (requires xbmcclient.py in the same folder) will do what I need:
I would prefer to use the JSON RPC API so as a workaround I mapped an unused button to CECActivateSource using a keymap *.xml file on my Kodi machine, for example:
Now I can call Input.ButtonEvent from the JSON RPC API with parameters button (=start) and keymap (=XG, or Xbox Gamepad). In Home Assistant yaml it looks like this:
Now I can build my wanted Home Assistant automation. |