Help with Automation Action: Kodi method ExecuteAction with parameter

Hello, I am trying to configure an automation where I want the action to be a Kodi command “Channel UP” while I watch the Live TV (PVR). I thought this would be correct, but it doesn’t do anything:

- id: '1566813012275'
  alias: IR Channel UP
  trigger:
  - payload: '{"IrReceived":{"Protocol":"PANASONIC","Bits":48,"Data":"0x400401002C2D"}}'
    platform: mqtt
    topic: tele/RedStars/RESULT
  condition: []
  action:
  - data:
      entity_id: media_player.kodi
      method: Input.ExecuteAction
      params:
        action: ChannelUp
    service: media_player.kodi_call_method

I am sure that the MQTT part is correct because I have other automations that work (for example the “OK” button calls the method Input.Select on media_player.kodi )
Do you know how to do this? Or how to debug where and what is wrong?
Thank you a lot in advance!
Dario

To test your action you can fire the automation manually. Either by using the trigger automation servcie in the developer tools services page or using the toggle button in the more info pop-up box if your automation is displayed as an entity on the front end.

Looking at the API, I could not find a Channel up mehod. Is it not just the navigate up button?

    - service: media_player.kodi_call_method
      data:
        entity_id: media_player.kodi
        method: Input.Up

Unfortunately not… I have already mapped the Input.Up with another button and it works…
Here is the Kodi documentation that I found about this action:
https://kodi.wiki/view/Keymap#Commands

ChannelUp PVR Used to switch up to the next channel. Works only if you playback TV or radio (v13 Gotham addition)

An ActionId is different to an API call. According to this https://www.home-assistant.io/components/kodi/#service-kodi_call_method you need an API call, not an ActionID.

Beyond that, I can’t help. I should have a play. I don’t really use live tv in Kodi much. Record what you want to watch, watch it when you want to. :slight_smile:

I called it action, but I should have called it Keymap names… Anyway I found in the Kodi Forum that the keyboard key “0” performs a “previous channel”, and they also posted the JSON code

{"jsonrpc":"2.0","method":"Input.ExecuteAction","id":884484246,"params":{"action":"number0"}}

I tried to directly use that URL in the browser but I get

error	
code	-32099
message	"Bad client permission."
id	884484246
jsonrpc	"2.0"

I read that

BlockquoteA major change for Leia onwards is that JSON-RPC no longer accepts many of the commands via HTTP

so I’m kind of stuck. I wonder how does a remote control like “yatse” performs the “channel up”… Any clue?

I managed to send an HTTP Post with curl but now I get “Parse Error”:

pi@hassbian:~ $ curl -X POST -H "content-type:application/json" 192.168.1.73:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Input.ExecuteAction","id":1,"params":{"action":"number0"}}
{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}

Try:

    service: media_player.kodi_call_method
    data:
      entity_id: media_player.cinema_kodi
      method: Input.ExecuteAction
      playerid: 1
      action: "number0"

Or maybe:

    service: media_player.kodi_call_method
    data:
      entity_id: media_player.cinema_kodi
      method: Input.ExecuteAction
      playerid: 884484246
      action: "number0"

It works in the following configuration:

{
  "action": "number0",
  "entity_id": "media_player.kodi",
  "method": "Input.ExecuteAction"
}

No playerid.

Unfortunately it does not exactly what I was looking for, because it toggles between the last two used channels… I wonder if there is somewhere a list of kodi actions somewhere…

https://kodi.wiki/view/Keyboard_controls

This is the default:

{
  "action": "Up",
  "entity_id": "media_player.kodi",
  "method": "Input.ExecuteAction"
}

You can use the Keymap Editor kodi addon to assign any key though:

https://kodi.wiki/view/Add-on:Keymap_Editor

The keyboard key that does the job is “PageUp”. I tried two different ways to call the action but both didn’t work:

{
  "entity_id": "media_player.kodi",
  "method": "Input.ExecuteAction",
  "params": {
    "action": "pageup"
  }
}

This provides the following error:

Run API method media_player.kodi.Input.ExecuteAction({'params': OrderedDict([('action', 'pageup')])}) error: {'code': -32602, 'data': {'method': 'Input.ExecuteAction', 'stack': {'message': 'Missing parameter', 'name': 'action', 'type': 'string'}}, 'message': 'Invalid params.'}

Otherwise I tried this:

{
  "action": "PageUp",
  "entity_id": "media_player.kodi",
  "method": "Input.ExecuteAction"
}

it gives the following error:

Run API method media_player.kodi.Input.ExecuteAction({'action': 'PageUp'}) error: {'code': -32602, 'data': {'method': 'Input.ExecuteAction', 'stack': {'message': 'Received value does not match any of the defined enum values', 'name': 'action', 'type': 'string'}}, 'message': 'Invalid params.'}

Use the Keymap editor to remap up and down to keys you know work. Like the number keys.

I understood your strategy and I will use it as plan B if I really can’t manage to get it done with PageUp.
On the other hand, in the Kodi Forum they say that this should work:

http://192.168.1.70:8082/jsonrpc?request={ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "pageup" }, "id": 1 }

So I am wondering how to translate this to Home Assistant…

    service: media_player.kodi_call_method
    data:
      entity_id: media_player.kodi
      method: Input.ExecuteAction
      playerid: 1
      action: "pageup"

Also just FYI, be aware that the next release of home assistant (0.98) will change:

media_player.kodi_call_method

to

kodi.call_method

I tried the action “pageup” and for the first time I don’t get any error code (once again without the playerid: 1). On the other hand it doesn’t make anything on my Kodi… Is it possible that the key is not coded on my Kodi?

I finally got it:

{
  "action": "channelup",
  "entity_id": "media_player.kodi",
  "method": "Input.ExecuteAction"
}

The mistake was… that it is case sensitive! And the correct name is channelup

2 Likes