I have a Ping Binary Sensor set up like follows to ping Google so I can keep a track of my internet connection;
binary_sensor:
- platform: ping
host: 8.8.8.8
count: 4
scan_interval: 60
name: Ping Google DNS
This sensor exposes some attributes that I would like to display on a history graph. So, I tried to set up a Template Sensor like follows to give me something to graph;
If anyone else comes here, the example from tom_l is not correct (or no longer works in 0.107.5) The correct value_template syntax for state_attr() should not include the states. prefix. The correct syntax is:
I just found this thread while trying to create a statistics graph for a ping sensor. I attempted to do this by writing the suggested code into configuration.yaml, but when I restarted HA, I got a ârepairâ alert in the UI stating:
The Ping YAML configuration is being removed
This stops working in version 2024.6.0. Please address before upgrading.
Configuring Ping using YAML is being removed.
Your existing YAML configuration has been imported into the UI automatically.
Remove the ping configuration from your configuration.yaml file and restart Home Assistant to fix this issue.
If the Ping YAML configuration is being removed, and the ping configuration is being automatically imported into the UI, will there be any method for creating ping graphs going forward? There are no options in the UI for getting a graph of ping RTT as far as I can see.
template:
- sensor:
- name: Ping Google Average
state: "{{ state_attr('binary_sensor.ping_google_dns', 'round_trip_time_avg') }}"
unit_of_measurement: ms