How to measure consumption of device only when using power grid

Hello,

i have a device to handle the charge of my car. This device can measure also the energy consumption. i would like to create a sensor which count how many energy sensor.presa_ricarica_auto_energy is using only when the overall house has a power consumption > 0 sensor.monit_casa_energy (so take the current from grid instead of sun or battery).
any suggestion?
thanks

Use a utility meter with tariffs. See this explanation: How to use Utility Meter Tariffs to conditionally measure things

If you have any issues with it post what you tried here (not in the community guide) and I’ll help you get it going.