Help with binary sensor

I need help about configuring one binary sensor.
I did it to check if my kodi on raspberry is active or not:

- platform: ping
  name: Kodi
  scan_interval: 2
  count: 2

and then i added this as input_boolean:

  name: Kodi Status
  icon: mdi:raspberrypi

added this in groups as:

- input_boolean.retropie_status

But i get it always off also if kodi is running.
Where am i wrong and how to get it working?
And how to create a switch with these configs to power on and power off the kodi on raspberry?

what happens when you ping your Kodi box manually from a shell terminal?
Note that your Raspberry Pi is going to respond to a ping request even if Kodi is not running, so not sure this is actually what you want. Have you looked at the Kodi component?

Yes, you’re right. So what to do if i want to check if raspberry where is kodi installed is running or not? I need to know this for automating some things…

ah this is different, you can use the ping sensor to know if your RPi is up or not, but that won’t give you any info on Kodi itself
what happens if you try to ping your RPi from a shell terminal on the machine where your HA is installed
If it answers than HA should also get that info.
The other thing is that you ping your RPI quite frequently (every 2 sec), I would try and reduce this as your RPi is going to be busy responding all the time.
If it works then you can try and increase the ping requests

If i ping from where HA is installed, RPi with kodi installed is answering. Now how to configure all to check this in HA?

then it should also work in HA. If not check your logs to see if anything obvious shows up?
By the way you may need to give it some time, it take about 5 min to update for me

Will you please share the codes you use to control kodi? I am looking at the kodi component but i am still confuse about it… thanks in advance.

I’ve just declared the IP Address of my RPi in my config:

  - platform: kodi

and then it shows up as a media player:


Ok, thanks… and how you handle this? I mean how you turn off or turn on. I am asked this because i have the same configs as yours but cannot understand how to automate many options about kodi like reboot or suspend or shutdown… I’d like to have an input_boolean with kodi so with it control some automations. I read all the docs in the kodi components, but still don’t understand where they go (in which part of configuration). How to create switches or scripts with all the kodi command available for HASS?

Kodi is part of the media_player components so you can control it using the media_player services:

Reboot/suspend/shutdown aren’t supported commands

Hmmm… but following the kodi docs in the kodi component page of HA i see there are those commands. My fault is WHERE to put those codes…

My bad. You can’t actually send the message/command to suspend etc, you need to setup your Kodi in HA such as when you turn it off, it performs one action of your choice
See Turn off Kodi with API calls section in the Kodi docs

Then once you’ve chosen your action, simply send the command to turn it off:

  - service: media_player.turn_off
    entity_id: media_player.kodi

So if i understand right all those commands in kodi section goes to the media_palyer section into configuration.yaml? May i put more than one of them or only one? And then i will have other services to use into automations?

as far as I know you can only assign 1 command to be executed when you turn your Kodi off in HA… Sorry

So i must choose only between turning on or turning off the kodi and how? Hmmm… very poor choice…

No you must choose an action to perform when you turn off media_player.kodi, whether it is shutdown, suspend etc
Check the doc again for kodi…