Kodi Power on/off

Currently the Kodi media player does not support power_on/power_off commands. It was commented somewhere that kodi is too general of a platform for that to make sense. I agree with that to a point but I think this topic requires more consideration.

There are two real use cases of Kodi. The first is where Kodi is used as an application on a more general purpose machine. Shutting down the machine via Kodi makes little sense hereand without a way to restart Kodi from HA, closing the application is also useless. The second common use case is in stand-alone platforms such as OpenElec. In this case the Kodi box can be treated as any other media center device, and a power on/off switch makes perfect sense.

Powering on a Kodi stand-alone box is already easily done via WoL, so that is not much of an issue (can WoL be added as part of a universal media player entity?). Shutting down Kodi however can be done via the same API used to send commands to Kodi by the rest of the component.

I guess what I am getting at is: would it be considered worthwhile to implement at least power_off for Kodi using the kodi API shutdown command? Maybe an optional config to enable it or to specify that the system is a stand-alone kodi box?

In fact, it already does: https://github.com/balloob/home-assistant/blob/dev/homeassistant/components/media_player/kodi.py#L186

I almost requested the opposite. Kodi runs on a multi-purpose box at my place. This box is always on (web/mail/DNS/DHCP server…), and turning off the group where this Kodi instance is turns off the whole box. I made the mistake more times than I would admit…

I’m in a similar situation - I use a multi-purpose box to run both home-assistant and kodi, as well as run steam games in big picture mode. I’d love to be able to turn Kodi on and off via HA to free up memory when I’m running steam games.

No shutdown in the front-end, maybe the front-end only shows shutdown if power on is also supported?

From what I understand, you have to actively give shutdown permission to Kodi. If the Kodi app is running as a non-root user, there should be ways from preventing Kodi itself from shutting down the system.

See https://github.com/home-assistant/home-assistant/pull/2224

0.28 broke the template switch I had been using for the other half of this (WoL combined with media_player.turn_off) I not sure what broke, but who cares! The correct fix is to add media_player.turn_on to the kodi platform.

There are a few issues.

Firstly, Kodi is run one of three ways

  1. As an appliance via something like rasBMC, openElec (forked to libreELEC by now). This is where power on and off is key, and would be done via WoL.

  2. As an application that is closed/launched on demand, maybe part of a media server that provides other functions but the user does not desire to run Kodi fulltime to reduce system load.

  3. Always on media center, maybe a dedicated raspi or something. Not an issue.

So I think my is to figure out a way to call command_line and wol from kodi. Problem is I want to do this without needing additional entities in the configuration. Can this be done?

Same here.
As for now I have to add a additional switch with WOL to turn my Mediacenter (kodi) on.
I turn it of via the kodi entity…
It would help a lot if we could integrate the WOL for power on into the kodi template.

Especially with Alexa I run into the issue to have two commands for kodi.
ON: Alexa turn on HTPC (WOL kodi)
OFF: Alexa turn off kodi (kodi template)

Thats kind of anoying… :frowning:

I can’t get the WOL on my kodi working? Along with HA, I use Yatse remote control. Wol works with Yatse just fine, but I want it to work in HA too. I have Kodi working on an Androidbox. In the Yatse configuration I have to add a WOL port number, so a launcher on my Android device can startup Kodi on the same device.

Example off Yatse

- platform: kodi
  host: !secret kodi_woonkamer
  name: kodi_W
  port: 8080
  turn_on_action:
- service: wake_on_lan.send_magic_packet
  data:
    mac: !secret kodi_woonkamer_mac
    port: 5600
    broadcast_address: !secret kodi_woonkamer
  turn_off_action:
service: media_player.kodi_call_method
data:
  entity_id: media_player.kodi_w
  method: System.Suspend

I have added the Wake on LAN component on my configuration.yaml, and added port number 5600 on the datafield to turn_on_action. I could be that this option isn’t available in the components/media_player/kodi.py.

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/media_player/kodi.py