Automate restarting HA once it connects to the network after a drop

Hi,

I want to automate restarting HA once it connects to the network after a drop from the network.
Currently I run HA on virtual box VM on a macbook.
Thanks in advance.

Create ping sensor to the device you consider always on network:

binary_sensor:
  - platform: ping
    host: 8.8.8.8 # using google DNS in this example
    name: "network status"
    count: 1
    scan_interval: 5

This will create binary_sensor.network_status. Then use state change of this sensor from off to on to trigger service homeassistant.restart.

Thanks a lot.