Trouble creating a binary sensor using ping

I’m trying to create a sensor to monitor my internet connection. I very frequently have to restart my modem to restore my internet connection. I already have a button on my dashboard that cycles the plug, restarting my modem but would like to automate it. I’ve tried creating a binary sensor template as shown below but it always just shows disconnected.

That is because this is not a template function but an integration that itself creates a binary sensor. You would need to put this in to your configuration.yaml like this:

binary_sensor:
  - platform: ping
    host: [your host ip]
    name: "Router"
    count: 3
    scan_interval: 30