Request the data of energy meter in Home Assistant(modbus/tcp), trigger the Sonoff in realtime.
Video tutorial about how to control a sonoff relay from a modbus tcp sensor in Home Assistant
https://www.youtube.com/watch?v=DCPXFEpm5vs
The most advantage of the Modbus/TCP sensor in Home Assistant is it supports requesting the data every 1 second, which can be used as a real-time sensor feedback value in a control loop. The 1-second sample interval makes it can be used in many interesting things.
Reference:
How to use the modbus tcp function in IAMMETER products
How to read the data of WiFi energy meter from the modbus tcp sensor of home assistant