Kodi (On/Shutdown) automations not working

I looked through several previous posts here, but it was unclear if anyone got this working.

As above, I am trying to set up automations to turn on and shutdown a Kodi box. I followed the guide for the automations. Hopefully, someone else can share some tips.

Here is my automations.yaml [updated]

- id: '1661306317495'
  alias: kodi_turn_on
  description: 'Kodi: turn on'
  trigger:
  - platform: device
    device_id: 3ff4f8b23626591a9adf701582858245
    domain: kodi
    entity_id: media_player.kodi_9c18780de34aae3fb9a983f5c86b8be6
    type: turn_on
  condition: []
  action:
  - service: script.turn_on
    data: {}
  mode: single
- id: '1661306445047'
  alias: kodi_turn_off
  description: 'Kodi: turn off'
  trigger:
  - platform: device
    device_id: 3ff4f8b23626591a9adf701582858245
    domain: kodi
    entity_id: media_player.kodi_9c18780de34aae3fb9a983f5c86b8be6
    type: turn_off
  condition: []
  action:
  - service: kodi.call_method
    data:
      method: System.Shutdown
  mode: single

Your first automations does not seem to make sense.

For the kodi_turn_on automation you have:
Trigger: kodi media player turning on
Action: Shut down kodi host.

So this will shut down kodi as soon as you turn it on. I’m pretty sure you don’t want to do that.

For the kodi_turn_off automation:
Trigger: kodi media player turning off
Action: shut down kodi host.

Better. But does the media player turn off or does its state become idle. That’s what mine do.

FYI: there’s no point redacting your device or entity ids. They are no use to anyone.

Thanks for pointing out the kodi_turn_on error. Not sure what happened there. I corrected my automations.yaml. I still haven’t seen any changes in Kodi History outside of when I play/pause media.

When you run the actions manually does the action work?

I tried stopping Kodi via HA media player without success. Also manually triggering the automations did not change the KODI state. It remains paused.

Then the integration is not set up correctly.

Did or did not?

I can play/stop media, but the turn off button on the media player does nothing.

My bad. Did not change the KODI state.

not sure if this is a path for you I built a switch that powers on and turns off my kodi which is on a PC running windows I then just use the automation to turn the switch on or off as needed

  - platform: wake_on_lan
    # mac: "10:BF:48:71:58:63"
    mac: "D4:5D:64:B3:1A:FE"
    name: HTPC
    host: 192.168.1.129
    turn_off:
      service: kodi.call_method
      data:
        entity_id:  media_player.htpc
        method: System.Shutdown
1 Like

[quote=“Paulsy, post:7, topic:453697”]

Stopping is not the same as turning off. Please try to describe your issue accurately.

I believe your automation issue is that you have not specified which media player to shut down. You need to provide an entity id, try this:

  - service: kodi.call_method
    data:
      entity_id: media_player.kodi_9c18780de34aae3fb9a983f5c86b8be6
      method: System.Shutdown

[quote=“tom_l, post:6, topic:453697”]

You are correct. Adding the entity_id fixed my shutdown problem.

Now I have to work on the WOL power on.

Thanks for sharing this! The shutdown script works perfectly. Now I just need to add the WOL.