[Solved] media_player.kodi state is always 'off'

media_player.kodi state is always ‘off’ and I am not able to interact with it from HA automations.
IP address is pinging ok from Raspberry Pi where hass.io is running on.

Configuration contains following:

media_player:
  - platform: kodi
    host: 192.168.0.15
    turn_on_action:
      service: media_player.kodi_call_method
      data:
        entity_id: media_player.kodi
        method: Addons.ExecuteAddon
        addonid: script.json-cec
        params:
          command: activate
    turn_off_action:
    - service: media_player.media_stop
      data:
        entity_id: media_player.kodi
    - service: media_player.kodi_call_method
      data:
        entity_id: media_player.kodi
        method: Addons.ExecuteAddon
        addonid: script.json-cec
        params:
          command: standby

What am I missing?

1 Like

Have you enabled web interface on your Kodi installation?

You can test that is is enabled by going to http://192.168.0.15:8080 in your browser, change the port # if you changed it from the default, and seeing if the web interface is working.

1 Like

Thank you vey much! That was the reason.
It appears actually mentioned in Kodi component page but it is so inconspicuous that it is very easy not to notice such a critical requirement.

I enabled web interface in Kodi settings and now I can control it in HA automations.

Hardly inconspicuous, second sentence at the top of the page, but I’ll give you it’s badly worded as it implies you only need to do that to use Discovery :slight_smile:

Yes, you are right that it is there but you probably know that everyone is reading docs diagonally primary noticing what is explicity emphasized or what one is particulary looking for.

That is until some problems surface :slight_smile:

Since discovery is enabled by default, this sentence seems irrelevant for those who have not explicitly disabled discovery.

Yep, is quite staggering how lazy people are nowadays :smile:

Exactly what I said :+1:

For some reason this isn’t working for me… Neither the discovery nor adding it via the configuration.yaml and then enabling the WebGUI (which is enabled by default anyway). I’m running OSMC on a RPI and added Kodi via the config, but the state is always set to “off”. I then checked the “control” settings and the WebGUI was enabled already (port 80). Only the setting “Allow remote control from applications on other systems” is disabled and cannot be enabled. If I enable it, it says “failed to start” and the entire system freezes. Only unplugging helps then.

Debug log: https://paste.kodi.tv/qofesaqunu.kodi
system log: https://paste.osmc.tv/opuyoyaxeh

I can’t say what the issue is tbh. The only error I see is “failed to bind ipv4/6 serversocket” in the debug log. I can access the WebGUI from my laptop though it keps saying “Lost websocket” every few seconds.

Also, discovery isn’t working either. Kodi just won’t show up. Any ideas?

I get this issue intermittently, the media player shows off as the status. If I run a script to pause Kodi, it changes to the correct status again.

1 Like

Just an update that this issue has resolved for me since I tried something mentioned in another post. I changed the port used on Kodi for web control from 8080 to 80.

1 Like

Your welcome :smile:

I’ve since found you can actually use any port that isn’t being used by anything else. I went back to 8080 following a fresh install and whichever side had fixed the issue but when the guilty party broke it again recently I tried other ports as using 80 stopped the Kodi web interface working in Chrome, currently using 8585.

80 (default in my Vero 4k OSMC installation) did not work for me. Chorus web interface was working fine, and I could connect in chrome just indicating the IP with no port. HA did not detect kodi even including the relevant pieces in configuration.yaml.

After changing to 8080 discovery does still not work, but manual configuration is recognized now.