Energy Sensors from multiple energy sources (Mains and Generator)

Hi, I need guidance on the best way to setup my energy sensors, my electricity comes from two sources:

  1. Mains: provided by government, post paid low tariff.
  2. Generator: provided by Apartment Complex, prepaid high tariff.

There are frequent blackouts in mains, whenever that happens the Generator takes over, energy from both sources come to my apartment through the same cables, I’m using Shelly 3EM to measure the energy consumption since it’s 3 phase in both cases.
I created a binary sensor to indicate which source is active at any moment, the sensor relies on voltage level because mains is around 220V and generator is around 230V.

I added this to my configuration, but I’m not sure it it’s the right or best way to measure:

 utility_meter:
   daily_energy:
     source: sensor.energy
     cycle: daily
     tariffs:
       - mains
       - generator

I’m cycling between the tariffs based on the value of the binary sensor.

Thank you

Ameen

Yep, that’s a good way to do it.

Will this type of sensor work with Energy Dashboard? I currently see following values:
sensor.daily_energy_generator: 3.82 KWh
sensor.daily_energy_mains: 38.025 KWh
sensor.energy: 15,983.42 KWh

Yes utility meters work with the energy dashboard.