Help measuring energy only when a different sensor has a particular state

Background, I have a meter measuring home consumption but the electricity supply can come from 2 separate sources I cannot meter myself. A grid or a generator. I have a remote sensor that will tell me if the power from the grid is on, so if I have power at home and the sensor state is off/low I know it’s the generator supplying.

I want to be able to measure power from the generator separately and power from the grid separately in two different sensors.

so when switch is high sensor one increments
and when switch is low sensor two increments.