How can I execute a built-in function (CECActivateSource) from the JSON RPC?
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?
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 in the same folder) will do what I need:
#!/usr/bin/env python3

from xbmcclient import *

# Set Kodi's hostname or IP address
host = "Kodi-hostname"
port = 9777
addr = (host, port)
sock = socket(AF_INET,SOCK_DGRAM)

# Send built-in action
packet = PacketACTION("CECActivateSource")
packet.send(sock, addr)

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:
service: kodi.call_method
  method: Input.ButtonEvent
  button: start
  keymap: XG
  entity_id: media_player.kodi_device

Now I can build my wanted Home Assistant automation. Smile

Logout Mark Read Team Forum Stats Members Help
How can I execute a built-in function (CECActivateSource) from the JSON RPC?0
This forum uses Lukasz Tkacz MyBB addons.