Created
August 7, 2023 04:25
-
-
Save tathamoddie/7b54f53b0e2b25936afcafcbe5ba826c to your computer and use it in GitHub Desktop.
HA automation for a router/modem watchdog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias: "[Tech] Router Watchdog" | |
mode: single | |
trigger: | |
- platform: state | |
entity_id: | |
- binary_sensor.ping_udm_ipv4 | |
to: "off" | |
for: | |
minutes: 15 | |
condition: | |
- condition: state | |
entity_id: binary_sensor.ping_cloudflare_dns_ipv4 | |
state: "off" | |
- condition: state | |
entity_id: binary_sensor.ping_aussie_dns_ipv4 | |
state: "off" | |
action: | |
- repeat: | |
until: | |
- condition: state | |
entity_id: binary_sensor.ping_udm_ipv4 | |
state: "on" | |
sequence: | |
- service: switch.turn_off | |
target: | |
entity_id: switch.udm_power | |
- delay: | |
seconds: 5 | |
- service: switch.turn_on | |
target: | |
entity_id: switch.udm_power | |
- wait_for_trigger: | |
- platform: state | |
entity_id: | |
- binary_sensor.ping_udm_ipv4 | |
to: "on" | |
timeout: | |
hours: 2 | |
- if: | |
- condition: template | |
value_template: "{{ repeat.index >= 10 }}" | |
then: | |
- stop: >- | |
Abandoning after too many attempts, so we don't completely break | |
or corrupt the device. | |
- wait_for_trigger: | |
- platform: state | |
entity_id: | |
- binary_sensor.ping_cloudflare_dns_ipv4 | |
- binary_sensor.ping_aussie_dns_ipv4 | |
to: "on" | |
timeout: | |
minutes: 5 | |
- service: notify.everyone | |
data: | |
title: 🐶 Router Watchdog | |
message: Router is back online thanks to the watchdog power cycling it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment