Anyway to run "ha dns restart" as an automation? Sometimes Pi goes offline and network cable being unplugged/plugged resolves the issue

Basically as per title. God knows why but sometimes my Pi (I’ve tried a second Pi, tried other power supplies, I’ve tried multiple new SD cards* etc etc) appears to go down (in reality it’s still running but just no connectivity) and the only thing that resolves the issue is unplugging then reconnecting the network cable.

I wondered if I could ‘detect’ this using an automation and then basically toggle the network connectivitiy with

ha dns restart

but from an automation!?

'* Oh, and I’ve now also tried a whole new router - it’s happened ONCE since new router and my heart…sank.

The ha command is an extension on a normal command line execution, so a command line script should be possible.