New Jersey. Got solar. They got this thing, "Net Metering".
The electric meter is two meters. One counts up when energy is going out, the other stays still. When energy is coming in, the first stops and the second counts up.
Day one: Start. Meters do their thing. At the end of the month, read the meters. If the Outgoing > Incoming, subtract and that become Surplus. One pays a connection fee, $5.
If Incoming > Outgoing, then Incoming-Outgoing = Amount One Is Billed upon and one pays retail, whatever that is.
Next month, do it again. If Outgoing + Surplus > Incoming, then Surplus = Surplus + (Outgoing - Incoming) and is carried over to the next month.
If (Outgoing + Surplus) < Incoming, then Incoming - (Outgoing + Surplus) = Amount one is billed upon and Surplus goes to Zero.
At the Day 0 date the following year, if there's a surplus, one gets paid wholesale for the amount and the surplus goes to zero to start all over again.
The array on the roof is typically sized so that energy generation is roughly the same as one's usage. Result: What with summer time surpluses carrying through the winter, actual electric charges (other than that $5/month connection fee) are zero, or near-zero. One is allowed to change the Day 0 date to something in the spring, which allows one to accumulate surpluses when the sky is sunny.
There are certainly things wrong with New Jersey, but Net Metering is not one of them.
It's nice not being subject to the vagaries of gas and oil prices.