How to turn on or toggle subtitles in Kodi?

I have Kodi v21.2 running on a Shield Pro 2019, and have the HA Kodi integration configured to access it. I can view/control the Kodi volume from HA, so the link seems to be working. I’m looking for a way to toggle Kodi subtitles in a script, while a media item is playing. The script below doesn’t do anything:

sequence:
  - action: kodi.call_method
    target:
      device_id: 94945da6b04188f3f96d7ee92f49bfbf
    data:
      method: >-
        entity_id: media_player.android_3 
        method: Player.SetSubtitle
        playerid: 1 # Or the current player ID if different subtitle: "next"
        enable: true

Any clues for how to do this?

There is no toggle action but there are on and off actions in the API. Try these:

  - action: kodi.call_method
    data:
      entity_id: media_player.android_3 
      method: Player.SetSubtitle
      playerid: 1
      subtitle: "off"
  - action: kodi.call_method
    data:
      entity_id: media_player.android_3 
      method: Player.SetSubtitle
      playerid: 1
      subtitle: "on"

(untested).

That worked - many thanks!

1 Like