I have a Mi power plug ZigBee (ZNCZ02LM) and I want to use it to reboot my router when my internet goes down. I’m using a ping binary sensor as suggested here, but I want to take it a step further, but I’m not skilled enough to do this. Is anyone able to help me or at least point me in the right direction?
So I currently have my binary sensor as follows
binary_sensor:
- platform: ping
host: 8.8.8.8
count: 2
scan_interval: 900 # 15 minutes
name: "Internet Connection"
And then my current automation is as follows:
id: reboot_router
alias: Reboot Router when Internet Down
trigger:
- platform: state
entity_id: binary_sensor.internet_connection
from: "on"
to: "off"
action:
- service: switch.turn_off
data:
entity_id: switch.0x00158d00028caf80_switch
- delay: 30
- service: switch.turn_on
data:
entity_id: switch.0x00158d00028caf80_switch
Which hasn’t actually triggered yet, so I hope it works!
Anyway, what I would actually ideally like is to have my first binary sensor ping every 15 minutes like it currently does, BUT, when it goes down, I would like to trigger another binary sensor to ping the exact same every 30 seconds, and if it stays down for more than 2 minutes, then trigger the reboot and start the cycle all over again. I’m just at a loss with how to add the second trigger in the mix or if this is even possible. Any help would be much apprecited.
TIA