How to recognize when conncetion between Victron Cerbo GX and the grid is lost

We are connected to the grid, have 14 solarpanels, a Victron Multiplus-II, a Victron Cerbo GX box, 12 KWH BYD batteries and the Homey Victron app installed on Homey Pro 23.
We live in central Portugal, and often during thunderstorms the connection to the grid is lost, sometimes for a couple of minutes, sometimes for a couple of hours.

I want to be able to recognize when the grid is lost, because then I want to switch off the Victron EV charger and our water boilers, and, when the connection to the grid is back again, switch them on again.

How can I recognize when the connection with the grid is lost and back on again? I have tried using warnings, but I can“t get that working.

I would use Lightning Detector first.

Ex. rs485 tuya or shelly 3m ?!

One strike could lead to a power (grid) loss of 1 minute or 1 hour (or even more). So Lightning Detector is of no use for me. It has to be a solution with the Victron App in combination with the Verbo GX I think.