Ping 8.8.8.8 connectivity check

Thank you for this. Kind what I searched for.

Is it also possible to ping other ip adresses. Like for example. We have multiple Active Directories running in our school production environment, we want to show the connectivity between these, whether they’re online or not online. Just a simple reply like the 8.8.8.8 is enough.

Thanks in advance.

Yes you can add as many ping binary sensors as you need.

@jzh - I implemented 2, one pinging my router (which has been crashing due to bad firmware) for LAN and one to Google DNS for WAN:

EDIT: The super huge latency is due to lots of reboots due to a zwave update that broke my system.

This is what I added to my configuration.yaml:

- platform: ping
    host: 8.8.8.8
    name: "Google DNS Ping"
    count: 5
    scan_interval: 60

  - platform: ping
    host: 192.168.1.1
    name: "Router Ping"
    count: 5
    scan_interval: 60

template:
  - sensor:
      - name: "WAN Ping"
        icon: "mdi:speedometer"
        unit_of_measurement: "ms"
        state: "{{ state_attr('binary_sensor.google_dns_ping', 'round_trip_time_avg')|round(2) }}"

  - sensor:
      - name: "LAN Ping"
        icon: "mdi:speedometer"
        unit_of_measurement: "ms"
        state: "{{ state_attr('binary_sensor.router_ping', 'round_trip_time_avg')|round(2) }}"

When I add your code to my configuration.yaml it says the following:


bad indentation of a mapping entry at line 14, column 13:
      - platform: ping
                ^

I tried adding the following to my configuration.yaml file but I get nothing on my card.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

- platform: ping
    host: 8.8.8.8
    name: "Google DNS Ping"
    count: 5
    scan_interval: 60

  - platform: ping
    host: 192.168.1.1
    name: "Default Gateway Ping"
    count: 5
    scan_interval: 60

template:
  - sensor:
      - name: "WAN Ping"
        icon: "mdi:speedometer"
        unit_of_measurement: "ms"
        state: "{{ state_attr('binary_sensor.google_dns_ping', 'round_trip_time_avg')|round(2) }}"

  - sensor:
      - name: "LAN Ping"
        icon: "mdi:speedometer"
        unit_of_measurement: "ms"
        state: "{{ state_attr('binary_sensor.router_ping', 'round_trip_time_avg')|round(2) }}"

Please don’t post pictures of text. Post the text and format it correctly.

The binary sensor configuration is correct. The template sensor configuration is not. template: needs to be hard up against the margin. If you had posted the text I could have copied and pasted it and shown you. I can’t do that with an image.

Edited the post.

Now you are missing binary_sensor: above the ping sensors.

binary_sensor:
  - platform: ping
    host: 8.8.8.8
    name: "Google DNS Ping"
    count: 5
    scan_interval: 60

  - platform: ping
    host: 192.168.1.1
    name: "Default Gateway Ping"
    count: 5
    scan_interval: 60

template:
  - sensor:
      - name: "WAN Ping"
        icon: "mdi:speedometer"
        unit_of_measurement: "ms"
        state: "{{ state_attr('binary_sensor.google_dns_ping', 'round_trip_time_avg')|round(2) }}"

  - sensor:
      - name: "LAN Ping"
        icon: "mdi:speedometer"
        unit_of_measurement: "ms"
        state: "{{ state_attr('binary_sensor.router_ping', 'round_trip_time_avg')|round(2) }}"

Is there a reason that is causing the following error? :

bad indentation of a mapping entry at line 14, column 13:
- platform: ping
^

I tried to edit it in a few ways but its still there and it puts HAS in safemode.

Yes, see my answer above.

Alright, I’ve added the code into the configuration.yaml. Thank you.

But it still doesn’t show on the dashboard.

I’ve added the following into a manual card. As said above.

color_thresholds:
  - color: '#e45e65'
    value: 40
  - color: '#e0b400'
    value: 30
  - color: '#0da035'
    value: 20
  - color: '#039BE5'
    value: -1
color_thresholds_transition: hard
entities:
  - entity: binary_sensor.ping
group: false
height: 300
hour24: true
line_width: 4
name: Ping
points_per_hour: 10
show:
  extrema: true
  average: true
  fill: fade
  icon: true
  labels: false
  name: true
  state: true
type: custom:mini-graph-card

This is not the name of your sensor (in the card):

entities:
  - entity: binary_sensor.ping

Your sensors will be called:

color_thresholds:
  - color: '#e45e65'
    value: 40
  - color: '#e0b400'
    value: 30
  - color: '#0da035'
    value: 20
  - color: '#039BE5'
    value: -1
color_thresholds_transition: hard
entities:
  - entity: sensor.wan_ping
  - entity: sensor.lan_ping
group: false
height: 300
hour24: true
line_width: 4
name: Ping
points_per_hour: 10
show:
  extrema: true
  average: true
  fill: fade
  icon: true
  labels: false
  name: true
  state: true
type: custom:mini-graph-card

Also your second template sensor seems to be using the wrong binary sensor. Should be:

  - sensor:
      - name: "LAN Ping"
        icon: "mdi:speedometer"
        unit_of_measurement: "ms"
        state: "{{ state_attr('binary_sensor.default_gateway_ping', 'round_trip_time_avg')|round(2) }}"

Hi Tom,
sorry for posting off tpoic.
Can’t figure out whats wrong with my code …

  - sensor:
      - name: "LAN Ping"
        icon: "mdi:speedometer"
        unit_of_measurement: "ms"
        state: "{{ state_attr('binary_sensor.router_ping', 'round_trip_time_avg')|round(2) }}"

    color_thresholds:
      - color: '#e45e65'
        value: 40
      - color: '#e0b400'
        value: 30
      - color: '#0da035'
        value: 20
      - color: '#039BE5'
        value: -1
    color_thresholds_transition: hard
    entities:
      - entity: sensor.wan_ping
      - entity: sensor.lan_ping
        group: false
        height: 300
        hour24: true
        line_width: 4
        name: Ping
        points_per_hour: 10
        show:
            extrema: true
            average: true
            fill: fade
            icon: true
            labels: false
            name: true
            state: true
        type: custom:mini-graph-card   

getting the error:
Invalid config for [template]: [color_thresholds] is an invalid option for [template]. Check: template->color_thresholds.

All of this belongs in the card config, not the sensor config.


    color_thresholds:
      - color: '#e45e65'
        value: 40
      - color: '#e0b400'
        value: 30
      - color: '#0da035'
        value: 20
      - color: '#039BE5'
        value: -1
    color_thresholds_transition: hard
    entities:
      - entity: sensor.wan_ping
      - entity: sensor.lan_ping
        group: false
        height: 300
        hour24: true
        line_width: 4
        name: Ping
        points_per_hour: 10
        show:
            extrema: true
            average: true
            fill: fade
            icon: true
            labels: false
            name: true
            state: true
        type: custom:mini-graph-card   

It all stored in configuration.yaml at the very bottom…

Which is wrong. As I said, this bit goes in a Lovelace card:

    color_thresholds:
      - color: '#e45e65'
        value: 40
      - color: '#e0b400'
        value: 30
      - color: '#0da035'
        value: 20
      - color: '#039BE5'
        value: -1
    color_thresholds_transition: hard
    entities:
      - entity: sensor.wan_ping
      - entity: sensor.lan_ping
        group: false
        height: 300
        hour24: true
        line_width: 4
        name: Ping
        points_per_hour: 10
        show:
            extrema: true
            average: true
            fill: fade
            icon: true
            labels: false
            name: true
            state: true
        type: custom:mini-graph-card   

Remove it from your ping sensor config.

thanks for information.
i opened the “Raw-Configurationeditor” and paste it at the very bottom, restartet it but still the same style
wan ping

The ping sensor goes in your sensor.yaml file.

The card config goes in a Lovelace card, not the raw view. And not indented that far either.

hey @tom_l

with Lovelacecard you mean the card config itself?

Visual editor is not supported for this configuration:

  • Key ‘color_thresholds’ is not expected or not supported by the visual editor.
  • Key ‘color_thresholds_transition’ is not expected or not supported by the visual editor.
  • Key ‘entities’ is not expected or not supported by the visual editor.

You can still edit your config in YAML.

Do i need something like lovelace.yaml?

No. That is correct. The mini graph card does not have a gui editor. You can edit it in that card YAML window (if you ever need to).