Control of the electric hot water heater according to net production

Hi all.

I have installed solar panels on the roof of my house, and the panels are connected to a Huawei Sun2000 wlan-compatible inverter. I can get the output of the solar panels through the inverter in real time. I monitor the whole house 15 minutes net electricity consumption (export/import) with a Shelly Pro 3EM meter, and with this data I control the 3 kW hot water heater on/off using Shelly Pro 1 + contactor. This configuration works, but due to my current automation (~when the export amount exceeds a certain threshold) the on/off switching of the contactor happens several times in 15 minutes.

How would you create automation that calculates the excess net energy and turns on the water heater at the right time to bring the net energy close to zero at the end of each 15 minutes?

I also have another Shelly Pro 1 + contactor, so I could control the hot water heater with lower power if needed. One phase connected to one contactor and two phases connected to the other contactor.

I use this :

https://community.home-assistant.io/t/pv-solar-excess-optimizer-auto-control-appliances-wallbox-dish-washer-heatpump-based-on-excess-solar-power/552677

I use Solar Optimizer which is a HACS integration. It works fine for me

Not HA. But i use a solic 200 diverter. It takes any excess and pushes it though the immersion heater. Anything over about 200w gets dverted. If anything else in the house calls for ower, it has priorityover the solic. Great bit of kit.

Thank you for a hint!
I’ve been trying to implement this for a week now, but the problem for such a poor coder has been setting the purchase and sales prices. I get the purchase price via nordpool configuration (sensor.nordpool_kwh_fi_eur_3_095_024), and it includes the additional_costs I have added. But how do I deduct the additional_costs from sensor.nordpool_kwh_fi_eur_3_095_024? I have tried many many things, but no result.

Hi, I am not a code expert myself. And with a Helper you can’t subtract 2 entities.
What I have done to subtract 2 values:

  • Define a Helper of the type Number with a value of -1 (Minus 1)
  • Define a Helper Group with the entitiy you want to subtract and the Helper Minus 1 and choose Multiply as Type (Negative Value)
  • Define a Helper Group with the entitiy you want to subtract from and the Helper Negative Value and choose Sum as Type (Net Value)
    You should now be able to use the Net Value in your Coding