This post extends the script used in this article:

Multiplus II – Tibber – Dynamic Electricity Tariff – Automatically Charging and Discharging Battery

I have supplemented a YouTube video. It’s a bit older; the current script is more extensive.

In the latest version, I create a list at the beginning and every half an hour indicating how the State of Charge (SoC) will be set. This allows for checking the behavior in advance or transferring it into a diagram. Additionally, the script can be imported, and then the paths only need to be changed in a central location rather than throughout the entire script.

I think I have found a usable, simple solution to expand the script for the summer. In addition to the electricity price-based decision logic, the data from the PV Forecast is now integrated. The “pvforecast” adapter offers two providers. You input your solar surfaces with orientation, angle, and of course, the location, and receive an estimate of how many kWh will be generated throughout the day. Both providers worked equally “ok” for me. Sometimes one is closer to the actual production, sometimes the other. I have created two instances and then use the average of both forecasts.

To keep the logic simple, I created a threshold that decides when only the battery is used and the Tibber logic is skipped. I have a maximum daily consumption of 7 kWh. The battery holds 10 kWh. So, I need to generate 14 kWh throughout the day to fully charge the battery and cover my own consumption. Of course, this is a simplified approach but has worked so far.

If the PV forecasts for today or tomorrow report more than 14 kWh, I set the minimum SoC (State of Charge) to 20%. The battery can discharge because it will be recharged by the sun the next day.

One provider also reports the estimated yield so far. I subtract this from today’s estimation. If today’s estimation then falls below 14 kWh, only tomorrow’s forecast counts.

If the threshold for tomorrow also falls below 14 kWh, the normal Tibber logic takes over again, deciding when to discharge and charge based on the price. As soon as tomorrow’s forecast exceeds 14 kWh again, the battery is discharged and ready to absorb the sun. The discharge is therefore only withheld until it is recharged soon enough, ensuring there is always enough buffer for expensive times.

By the way, I only discharge and charge using the Tibber logic between 20% and 80%. If I understand correctly, the battery (Pylontech) then has up to 12,000 cycles, and from 80% to 100%, the solar system can still fill up.

Now about the script:

I have inserted placeholders again that need to be replaced with your own IDs:

<TIBBER-HOME> with the Tibber Home ID. You can find it under Objects in the Tibber Adapter.

<VICTRON_ID> with the Victron ID. It’s also found under Objects in the MQTT Client folder.

Overwrite with search/replace in the text file beforehand and then import it, otherwise, the import will be annoying with error messages stating that the path is invalid.

The previous adapters from the first post are required, and, of course, the pvforecast adapter should be set up and ready.

I hope my description is sufficient for successful usage. Feel free to ask questions or provide suggestions in the comments.

Happy saving on electricity.

Best regards,