How does exactly `count` work in Ping platform for presence detection and binary sensor?

Hi,

as in topic, does anybody knows how exactly variable count in integration Ping works.
In documentation one can find only:

Number of packets to send.

Number of packet used for each device (avoid false detection).

But when using more packets the

  1. even only one
  2. most or
  3. only when all

missed packets are considered as not reached?

I’m actually wondering this too
there is now a ping count
image
I assume 3 years back this was just count.
but it’s not in the documentation at all

It looks like there is an answer in code:

class PingDataSubProcess(PingData):
    """The Class for handling the data retrieval using the ping binary."""

    def __init__(
        self, hass: HomeAssistant, host: str, count: int, privileged: bool | None
    ) -> None:
        """Initialize the data object."""
        super().__init__(hass, host, count)
        self._ping_cmd = [
            "ping",
            "-n",
            "-q",
            "-c",
            str(self._count),
            "-W1",
            self.ip_address,
        ]

so the count goes as a -c parameter

Go to https://linux.die.net/man/8/ping

-c count
Stop after sending count ECHO_REQUEST packets. With deadline option, ping waits for count ECHO_REPLY packets, until the timeout expires.

So the answer is - this is the amount of pings to send in one go.

And it looks like that at least one returned ping is enough

        self.is_alive = self.data is not None
2 Likes