asumptions
Let’s say a modern battery has more or less 6000 charge cycles. The cost per Kwh of a battery ranges depending on several aspects. At the time of this publication, we can find batteries at more or less 400€/Kwh taxes included. For large duration of the battery we asume that the state of charge ranges between 30% and 90%, that is, for each Kwh of storage we are utilising 60%. And, finally, we must consider the efficiency of the energy conversion, that is, the energy lost when charging and discharging. Lets asume we lose 15% of the energy, therfore the performance is aroundd 85%.
A simple calculation gives us the cost per Kwh obtained from a battery = 400€/Kwh / 6000 cicles / 0,6 / 0,85 = 0,13€/Kwh
So, if we have a tariff lower than the cost of the energy stored in the batteries, the best option is actuate in the system in order to set it to import from the grid.
ACTUATION BY software configuration OF THE INVERTER
In this use case the inverter supports a setting that allows the definition of periods in witch you can set when the inverter should import from the grid or get energy from the battery. In the case of my Goodwe inverter, there is a kind of setting, but it has drawbacks, because for each period, you set two things: if the battery should be charged or discharged and the power rate. Therefore, if I want to charge the battery and use energy from the grid from 23oo to 08oo and use the PV or discharge the battery the rest of the day, I’ve found that, the inverter starts to discharge the battery to the grid in the 08oo:23oo period, incredible!!

ACTUATION BY ELECTRIC COMMUTATION
NOTE: Please read update at the end of the post!!!
If the inverter doesn’t support a flexible configuration, one possible option is to disconnect the inverter primary line from the grid using a contactor with NC contacts.
In normal operation, the main circuit from the inverter to the house is closed, the operation is as usual.

When we want to consume energy from the grid, because its price or wharever easaon, we actuate over the coil of the contactor forcing to open the main line between the inverter and the house/grid.




This operation can be done in the moments we wanted, As we can see in the diagram, when the solution is activated, the voltage in the inverter main line is cero.




Update:
The combination of shelly + contactor doesn’t work because the circuit needs to be broken by a magnetic-thermic breaker, therefore I bought a WiFi enabled device as follows:

That’s all, hope it helps!!! 🙂