[Ping binary sensor] Ability to pragmatically set ping host


The current bianry_sensor ping integration requires a specific IP in the configuration. This can be an IP or a hostname (which is then resolved) but has to be provided explicitly.

Since that sensor is used as some kind of “network health” indication, it would be good to be able to provide an IP address that is

  • topologically close
  • reliable


A typical choice would be some kind of unicast IP, such as which will be topologically close, but not fixed. This means that the ping RTT can change in time and it is not known whether this is due to a change in the network quality, or simply another route.

A solution to that could be to provide the next hop IP fro one’s network. No other IP will be closer and if it is not live, then the network is guaranteed to be down.

The problem is that this address can change if someone has no fixed IP addressing (with a fixed gateway IP).


In such a case it would be fantastic to be able to provide the IP to be pinged as the output of a command (usually from traceroute, or by querying the gateway IP on one’s router).