Trouble getting automation to "cycle" properly
So I have this automation that reboots my router (via zb outlet) if both google and cloudflare DNS pings fail. Then it waits 12 hours, and if the internet is still down when that timer finishes, trigger the automation again and reboot the router.
It works great the first time, but if the ping binary sensors already evaluate as offline when that 12 hour delay finishes, it doesn't cause a trigger. AKA, the automation needs to catch the internet "switching" from online to disconnected rather than just observing if its disconnected when it wakes up from its 12 hour nap.
Alternatively I would be okay with something that limits router reboots to twice/day.
Any advice how to fix?
YAML:
alias: Reboot Router if Internet Offline
description: ""
triggers:
- type: not_connected
device_id: ping google
entity_id: ping google
domain: binary_sensor
trigger: device
- type: not_connected
device_id: ping cloudflare
entity_id: ping cloudflare
domain: binary_sensor
trigger: device
conditions:
- type: is_not_connected
condition: device
device_id: ping google
entity_id: ping google
domain: binary_sensor
- type: is_not_connected
condition: device
device_id: ping cloudflare
entity_id: ping cloudflare
domain: binary_sensor
actions:
- type: turn_off
device_id: outlet
entity_id: outlet
domain: switch
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- type: turn_on
device_id: outlet
entity_id: outlet
domain: switch
- delay:
hours: 12
minutes: 0
seconds: 0
milliseconds: 0
mode: single