How to get a history of ping times?

I would like to test the connectivity from my network to an always-on external IP (8.8.8.8 or 1.1.1.1). For that I added to configuration.yaml the following snippet:

binary_sensor:
  - platform: ping
    host: 8.8.8.8
    name: google.com
    count: 3
    scan_interval: 30

I do see that entity in HA:

image

I wanted to add it to my Lovelace UI in order to get a history of pings. Ideally I would like to graph round_trip_time_avg but even a hit-or-miss graph would be fine:

  - detail: 2
    entities:
      - entity: binary_sensor.google_com
    graph: line
    type: history-graph

What I get, unfortunately, is (it says in French “No history of values found”)

image

Is it possible to get a graph of the ping average trip time?

Create a template sensor based on round_trip_time_avg

1 Like

You’d need a template sensor as suggested above, but you’ll also need to make sure that any sensor is included in your recorder config, if you are using the include option (it doesn’t seem like your ping sensor is and that’s why you get that message).
See the documentation here:

Thank you @francisp (and @Steven_Rollason)

I added

- platform: template
  sensors:
    ping:
      friendly_name: "ping"
      unit_of_measurement: 'ms'
      value_template: "{{ state_attr('binary_sensor.google_com', 'round_trip_time_avg') }}"

to my sensors configuration and it works!

image

@Steven_Rollason: you mentioned that the binary sensor should be in my recorder setup - it was not:

recorder:
  purge_keep_days: 10
  include:
    domains:
      - homemonitor
      - light
      - person
      - sensor
    entities:
      - binary_sensor.0x00158d0002883657_water_leak
      - binary_sensor.0x00158d00028837be_water_leak
  exclude:
    entities:
      - homemonitor.all_monitors

Now, the template sensor is sensor.ping and is included.

1 Like

Thanks everyone for the info. I used it to create a graphed ping monitor as well. :+1: