Hey,
Does anyone know how to launch an addon? or the TV guide/recorded episodes? I am using the TVHeadEnd addon on kodi
I have tried and failed at understanding the JSON-RPC API.
Cheers
Danny
Hey,
Does anyone know how to launch an addon? or the TV guide/recorded episodes? I am using the TVHeadEnd addon on kodi
I have tried and failed at understanding the JSON-RPC API.
Cheers
Danny
You have to edit your Kodi settings, see: how to change how much fast forward and rewind skip?
Locations of the advancedsettings.xml
file (you may have to create it) can be found in the table lower down on this page if Kodi is not installed on Windows: https://kodi.wiki/view/HOW-TO:Modify_time_seeking
I just created the advancedsettings.xml
file with this inside:
<advancedsettings>
<video>
<timeseekforward>10</timeseekforward> <!-- Time to seek forward in seconds when doing a short seek. Defaults to 30. -->
<timeseekbackward>-10</timeseekbackward> <!-- Time to seek backward in seconds when doing a short seek. Defaults to -10. -->
<timeseekforwardbig>30</timeseekforwardbig> <!-- Time to seek forward in seconds when doing a long seek. Defaults to 600 (30 minutes). -->
<timeseekbackwardbig>-30</timeseekbackwardbig> <!-- Time to seek forward in seconds when doing a long seek. Defaults to -600 (10 minutes). -->
</video>
</advancedsettings>
And after a restart of Kodi it works perfectly. +10, -10, +30, and -30 second skips.
Tom,
Thank you for responding.
I now get why my changes to the skipstep under player settings in Kodi had no effect as it was an advanced setting.
Do you have a list of the commands that can be used via scripts?
On my physical remote I used right and left to skip the steps under player settings and it was nice to keep and as of now it doesn’t seem to work via the script.
I have also unsuccessful tried to call sendtext with the value e to get the EPG guide showing up but that doesn’t work.
Any links you might have to the commands would be greatly appreciated.
You should be able to use the Kodi Call Method service to call any of the Kodi API commands.
Getting the format right can be tricky and I’m certainly no expert.
Search this topic for some examples. e.g. Billy’s post just a few above uses this:
- type: button
tap_action:
action: call-service
service: kodi.call_method
service_data:
entity_id: media_player.libreelec
method: Player.SetSpeed
playerid: 1
speed: increment
target: {}
hold_action:
action: call-service
service: kodi.call_method
service_data:
entity_id: media_player.libreelec
method: Player.SetSpeed
playerid: 1
speed: decrement
target: {}
Thought I might share my own take on this
kodi.call_method
service call, there’s no need for scripts to execute Kodi commandsinput_boolean.kodi_tv_state
and two template sensorsmedia_player
calls where possibletype: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: entity
entity: sensor.kodi_tv_computed_state
name: Kodi TV
- type: conditional
conditions:
- entity: input_boolean.kodi_tv_state
state: 'off'
card:
type: button
tap_action:
action: call-service
service: script.kodi_power_on
service_data: {}
target: {}
entity: input_boolean.kodi_tv_state
icon: mdi:power
name: Turn on
- type: conditional
conditions:
- entity: input_boolean.kodi_tv_state
state: 'on'
card:
type: button
tap_action:
action: call-service
service: script.kodi_power_off
service_data: {}
target: {}
entity: input_boolean.kodi_tv_state
name: Turn off
icon: mdi:power
- type: horizontal-stack
cards:
- type: conditional
conditions:
- entity: sensor.kodi_tv_is_volume_muted
state: 'false'
card:
type: button
icon: mdi:volume-off
tap_action:
action: call-service
service: media_player.volume_mute
service_data:
is_volume_muted: true
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: conditional
conditions:
- entity: sensor.kodi_tv_is_volume_muted
state: 'true'
card:
type: button
icon: mdi:volume-high
tap_action:
action: call-service
service: media_player.volume_mute
service_data:
is_volume_muted: false
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: button
icon: mdi:volume-minus
tap_action:
action: call-service
service: media_player.volume_down
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: button
icon: mdi:volume-plus
tap_action:
action: call-service
service: media_player.volume_up
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: horizontal-stack
cards:
- type: button
icon: mdi:subtitles-outline
tap_action:
action: call-service
service: kodi.call_method
service_data:
method: Player.SetSubtitle
playerid: 1
subtitle: next
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: button
icon: mdi:stop
tap_action:
action: call-service
service: media_player.media_stop
service_data: {}
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
show_icon: true
- type: button
icon: mdi:play-pause
tap_action:
action: call-service
service: media_player.media_play_pause
service_data: {}
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: button
icon: mdi:open-in-new
tap_action:
action: call-service
service: kodi.call_method
service_data:
method: GUI.SetFullscreen
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: horizontal-stack
cards:
- type: button
icon: mdi:skip-previous
tap_action:
action: call-service
service: kodi.call_method
target:
entity_id: media_player.koditv
service_data:
method: Player.Seek
playerid: 1
value: bigbackward
hold_action:
action: none
show_name: false
- type: button
icon: mdi:rewind
tap_action:
action: call-service
service: kodi.call_method
target:
entity_id: media_player.koditv
service_data:
method: Player.Seek
playerid: 1
value: smallbackward
hold_action:
action: none
show_name: false
- type: button
icon: mdi:fast-forward
tap_action:
action: call-service
service: kodi.call_method
target:
entity_id: media_player.koditv
service_data:
method: Player.Seek
playerid: 1
value: smallforward
hold_action:
action: none
show_name: false
- type: button
icon: mdi:skip-next
tap_action:
action: call-service
service: kodi.call_method
target:
entity_id: media_player.koditv
service_data:
method: Player.Seek
playerid: 1
value: bigforward
hold_action:
action: none
show_name: false
- type: horizontal-stack
cards:
- type: button
icon: mdi:home
tap_action:
action: call-service
service: kodi.call_mathod
target:
entity_id: media_player.koditv
service_data:
method: Input.Home
hold_action:
action: none
show_name: false
icon_height: 40px
- type: button
icon: mdi:chevron-up
tap_action:
action: call-service
service: kodi.call_method
target:
entity_id: media_player.koditv
service_data:
method: Input.Up
hold_action:
action: none
show_name: false
- type: button
icon: mdi:information-outline
tap_action:
action: call-service
service: kodi.call_method
target:
entity_id: media_player.koditv
service_data:
method: Input.Info
hold_action:
action: none
show_name: false
icon_height: 40px
- type: horizontal-stack
cards:
- type: button
icon: mdi:chevron-left
tap_action:
action: call-service
service: kodi.call_method
service_data:
method: Input.Left
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: button
icon: mdi:kodi
tap_action:
action: call-service
service: kodi.call_method
service_data:
method: Input.Select
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
icon_height: 50px
- type: button
icon: mdi:chevron-right
tap_action:
action: call-service
service: kodi.call_method
service_data:
method: Input.Right
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
- type: horizontal-stack
cards:
- type: button
icon: mdi:subdirectory-arrow-left
tap_action:
action: call-service
service: kodi.call_method
service_data:
method: Input.Back
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
icon_height: 40px
entity: media_player.koditv
- type: button
icon: mdi:chevron-down
tap_action:
action: call-service
service: kodi.call_method
service_data:
method: Input.Down
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
show_icon: true
show_state: false
- type: button
icon: mdi:menu
tap_action:
action: call-service
service: kodi.call_method
service_data:
method: Input.ContextMenu
target:
entity_id: media_player.koditv
hold_action:
action: none
show_name: false
icon_height: 40px
- type: custom:mini-media-player
entity: media_player.koditv
volume_stateless: false
hide:
power: true
controls: true
volume: true
icon: true
artwork: full-cover
name: Now Playing
/config/template_sensors.yaml
- name: Kodi TV computed state
state: >
{% if is_state('media_player.koditv', 'idle') and is_state('input_boolean.kodi_tv_state', 'off') %}
Off
{% else %}
{{ states('media_player.koditv')|title }}
{% endif %}
icon: >
{% if is_state('media_player.koditv', 'idle') and is_state('input_boolean.kodi_tv_state', 'off') %}
mdi:television-off
{% elif is_state('media_player.koditv', 'playing') %}
mdi:television-play
{% else %}
mdi:television
{% endif %}
- name: Kodi TV is volume muted
state: >
{% if is_state_attr('media_player.koditv', 'is_volume_muted', true) %}
true
{% else %}
false
{% endif %}
/config/scripts.yaml
kodi_power_on:
alias: 'Kodi: Power on'
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.kodi_tv_state
- service: kodi.call_method
target:
entity_id: media_player.koditv
data:
method: GUI.ActivateWindow
- service: kodi.call_method
target:
entity_id: media_player.koditv
data:
method: Addons.ExecuteAddon
addonid: script.json-cec
params:
command: activate
mode: single
icon: mdi:kodi
kodi_power_off:
alias: 'Kodi: Power off'
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.kodi_tv_state
- service: media_player.media_stop
target:
entity_id: media_player.koditv
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: kodi.call_method
target:
entity_id: media_player.koditv
data:
method: Addons.ExecuteAddon
addonid: script.json-cec
params:
command: standby
mode: single
icon: mdi:kodi
I’ve done a little script to send keyboard input from HA to Kodi just like Kore Remote.
For anyone interested all you need is a input_text helper, use any card you like to edit it (I use custom:text-input-row), and launch this script with a button:
alias: KR_SEND_TEXT
sequence:
- service: kodi.call_method
data:
method: Input.SendText
text: |
{{ states('input_text.kodi_buffer') }} //The helper you choose
done: true //If true kodi will hit select after text input, otherwise it will just show the text on the
keyboard
entity_id: media_player.kodi //Your kodi device
- wait_template: ''
timeout: '0:00:02'
continue_on_timeout: true
- service: input_text.set_value
data:
value: ''
target:
entity_id: input_text.kodi_buffer //The helper you choose
mode: single
Awesome! Do you perhaps know what call method to use calling numeric digits… For changing channels? I have simple PVR Client and I can set everything up except the numeric numbers…
Hi guys,
My remote is working just fine, but I would really like to change my channels on a PVR addon…
So i.o.w if I press the channel numbers on my remote (physical mini keypad) for example 102 it works perfect… How can I simulate this via home assistant? Numbers 0-9… I 'think" it should be relatively simple…
Thanks guys
I think it would be a script like this (untested):
kodi_0:
sequence:
- service: kodi.call_method
data:
method: Input.Action
action: "number0"
Likewise for:
"number1"
"number2"
"number3"
"number4"
"number5"
"number6"
"number7"
"number8"
"number9"
Hi Tom, thanks, yup tried exactly that… It says trigged if fired but not showing the digit been pressed as per mini keyboard… So not responsive as thought… It’s almost as if it’s only listening to “specific” methods" but it doesn’t make sense… scratching my head again because that seemed totally plausible…
What about this?
kodi_0:
sequence:
- service: kodi.call_method
data:
method: Input.ExecuteAction
action: "number0"
It works Tom! Thanks buddy!
Hey, Tom thanks for this! Again it works!! The other thing I’m trying to do is creating an actual keyboard template with alphanumeric keys a-z… Do you perhaps know the method for calling this?
I have updated how my subtitle method works. From this:
lounge_kodi_input_next_subtitle:
sequence:
service: kodi.call_method
data:
entity_id: media_player.lounge_osmc_kodi
method: Player.SetSubtitle
playerid: 1
subtitle: "next"
enable: true
To this:
lounge_kodi_input_next_subtitle:
sequence:
service: kodi.call_method
data:
entity_id: media_player.lounge_osmc_kodi
method: Input.ExecuteAction
action: "nextsubtitle"
Hi, I’m sorry to bring this back after so long time. You did a got job summarizing previous comments in this thread. But I’d need further explanation on the “templating” part.
I created a file templates.yaml with @tom_I’s code, and added to the configuration.yaml with “template: !include templates.yaml” but it is not working. Can you explain a little bit more how you did it?
Thanks in advance.
Holy Necro, Batman! I have a hard time remembering what I did yesterday, let alone a year ago. Reading my post that you quoted, I went to my media dashboard in Lovelace (I’m assuming I created a new dashboard that was initially blank.) Then I clicked the 3 dot menu, edit dashboard, then clicked the 3 dot menu again, raw configuration editor, then I pasted in the button templates from @tom_l. For convenience, here’s that section from my raw Lovelace configuration:
button_card_templates:
icon_button:
aspect_ratio: 4/3
color_type: icon
hold_action:
action: none
layout: vertical
show_label: false
show_name: false
show_state: false
styles:
card:
- border-radius: 10px
- border: solid 1px var(--primary-color)
- box-shadow: none
- padding: 6px 6px
- margin: 0px 0px
- '--paper-card-background-color': rgba(0, 0, 0, 0)
icon:
- width: 28px
name:
- justify-self: middle
- align-self: end
- font-size: 14px
- padding: 0px 0px
- color: var(--secondary-text-color)
tap_action:
action: call-service
menu_button:
aspect_ratio: 4/3
color_type: icon
hold_action:
action: none
layout: vertical
show_label: false
show_name: true
show_state: false
styles:
card:
- border-radius: 10px
- border: solid 1px var(--primary-color)
- box-shadow: none
- padding: 6px 6px
- margin: 0px 0px
- '--paper-card-background-color': rgba(0, 0, 0, 0)
icon:
- width: 28px
name:
- justify-self: middle
- align-self: end
- font-size: 14px
- padding: 0px 0px
- color: var(--secondary-text-color)
tap_action:
action: call-service
I did not create a templates.yaml, so I can’t help you there. I pasted my config directly into the raw editor of the Media dashboard. Hope this helps!
thanks for your quick answer, I’ll give it a try.
off-topic:
checking your name I assume you were born 92. Thats why you probably don’t know Japanese superRobot “Mazinger Z”. Give it try!
I made it work with your comments. And learnt a starting point about button card !! what a profitable evening for me
Thanks so much.
I’m having difficulty trying to get this to work in node red sending it to Home Assistant. For instance, this works:
{
"action": "pageup",
"entity_id": "media_player.kodi_de1dd1bc895a38c",
"method": "Input.ExecuteAction"
}
and it’s even simpler for just pressing the key up:
{"method":"Input.Up"}
EDIT: got smallforward working with:
{
"playerid": 1,
"value": {
"step": "smallforward"
},
"method": "Player.Seek"
}
and including the entity_id doesn’t help either. https://kodi.wiki/view/JSON-RPC_API/v12#Player.Seek mentions a step parameter…