Show fed in Energy into the grid during night period

Hello together,

I am using a battery with a micro inverter to feed my nightly energie consumption.
I have a switch which goes to “on” state when there is no sun available in the evening. This switch change its state to “off” in the morning when the sun is back.
I am using a shelly plug s, which can measure the whole energy.
Is it possible to connect it somehow with the on/off switch to show how much energy was fed into the grid throught the inverter in the night for the last period?

thanks in advance

Yes, feed your energy sensor to a utility meter with two tariffs, ‘day’ and ‘night’. Switch the tariffs with an automation based on your day night switch state.

This will create two sensors. One for day energy and one for night energy.