KODI on/off-button configuration

Hi,
I am struggeling to configure the on/off-button of my KODI-integration.

Following the example give in the documentation, I came up with this (in the frontend):

type: media-control
entity: media_player.10_112_59_112
automation:
  - alias: "Kodi: turn on"
    triggers:
      - trigger: device
        domain: kodi
        entity_id: media_player.10_112_59_112
        device_id: d4bf3c89d06720f08bbac20659dc99a0
        type: turn_on
    actions:
      - action: shell_command.start_kodi
        data: {}
  - alias: "Kodi: turn off"
    triggers:
      - trigger: device
        device_id: d4bf3c89d06720f08bbac20659dc99a0
        domain: kodi
        entity_id: media_player.10_112_59_112
        type: turn_off
    actions:
      - action: rest_command.switch_kodi_off
        metadata: {}
        data: {}

The log tells me that an action has been fired: “[homeassistant.components.kodi.media_player] Firing event to turn on device” and “[homeassistant.components.kodi.media_player] Firing event to turn off device”.
The actions to ‘turn-on’ and ‘turn-off’ are defined in configuration.yaml and working by themself.

Where can I find a stable ‘device-id’?
Do I have to go via an Automation, instead of a ‘shell_command’ or ‘rest_command’-action?
Any idea what I am doing wrong?

Thanks for your help!

What type of device is Kodi running on?

Kodi is running on a NanoPC-T6 (a quite powerful SBC) on the same LAN-segment…

The reason I ask is because HASS.Agent 2 gives HA a lot of control over your PC and you can customize commands.

I’ll have to experiment a bit to see if it’s possible via that method.

Unless the PC has no Windows based OS.

Not sure, as I am not using Windows

What is the OS?

You don’t need to find the device id yourself. That’s what device triggers are for.

HomeAssistant: on Raspberry 4B, running Home Assistant OS,

Kodi on NanoPC-T6 running Ubuntu 24.04

In general it’s running fine, just this on/off-button is causing problems

The example shows ‘device-id’ - so I was looking for it

I can remove it, but it still does not run …

What am I missing?

Try creating a script like this and execute it

sequence:
  - action: kodi.call_method
    metadata: {}
    data:
      method: Application.Quit
    target:
      entity_id: media_player.10_112_59_112
alias: Kodi Quit
description: ""

Then you can build your automation to execute the script

Use the UI to build your automation. Go to the device page for your Kodi instance (btw, if you want to stay with YAML, the address on that device page will give you the device id), and lick the + button in the “Automations” section, and choose “Use device as trigger” from the pop-up.

Thanks for you valuable inputs!
I was able to fix the problem!