Really gotten into home-assistant spent hours of testing this Project to trigger DHCP should my VM ISP go down and a new IP needs to be pulled. Their were a lot of pit holes trying to make this work and a extreme reboot of home-assistant in order to pull this off but that might be be down to either a bug or not. The smart plug I got was a Eightree which is under tuya and Requires Internet I have a backup ISP with EE and Zyxel USG with the needed rules but there where problem getting home-assistant to work on a fail over routing rule not sure why so the only way was when VM connection went down have home-assistant reboot and then connect on EE.
Things you need to understand for all this to work right
VM have DNS IP’s that EE can’t ping which is impotent
ping 1.1.1.1 to work when on EE but disconnected on VM but you also need time for this ping to stay on VM that it is disconnected and does not go to EE or the reboot of home-assistant will not happen
So in home-assistant ping for 194.168.8.100 and 1.1.1.1 with count 6 interval 30 which for now I can’t make work lower? Seems to be the minimum?
Routeing rules on my USG note ping for VM DNS will always go out WAN and TCPandUDP with ping Connectivity Check disabled on fail to go to my backup EE
Ping rule 1.1.1.1 with period 60 seconds timeout 1 and fail tolerance 2
TCPand UDP rule with period 5 seconds timeout 1 and fail tolerance 2
First automations home-assistant reboot other ISP
When
192.168.8.100 disconnected
smart plug turned on or off
1.1.1.1 disconnected
And if
194.168.8.100 disconnected
1.1.1.1 disconnected
smart plug turned on
Then do
Home Assistant Supervisor 'Reboot the host system
Next automations wait for 194.168.8.100 to be connected
When
192.168.8.100 disconnected
smart plug turned on or off
When Home Assistant is started
And if
192.168.8.100 disconnected
Then do
Repeat an action until 1 condition matches
repeat type until
194.168.8.100 is connected
Actions
smart plug turned off
delay 1 minute
smart plug turned on
delay 5 minute