Trying to work out PV usage

I have a storage-heated house that can draw lots of Amps. I got a new 10kWp solar installation that does 14kW when sunny, the switched heating system can draw up to 18kW in total. I’m pretty close to optimal usage using a timetable, I have several dozen timed automations like this:

- id: '1711540718498'
  alias: Haus(2a) EIN 12:05 <23.0
  description: ''
  - platform: time
    at: '12:05:00'
  - condition: numeric_state
    entity_id: input_number.aa_temp_24h_0300_morgens
    below: 23
  - type: turn_on
    device_id: 39bc377754f536398d9291f31f0d6e63
    entity_id: 1df9d1374b6ed61b849b6434ac301b1d
    domain: switch
  mode: single

What it does is trigger a high-Voltage contactor (three, actually) based on a manual timetable. I’m working on getting this automated better, but essentially, I store 24h linear temperature reading at 03:00 am, and then, every now and then, in sequence, the three circuits trigger the storage heating systems when the sun is (likely) shining.

I do get rather good forecast data on sunshine, I have established values for storage heating “on-time” for set outdoor temperature ranges, so my idea is, based on outdoor temperature past 24h, I make three variables, “heating_time_1” to 3.

No idea how to do that.

Based on these varaibles, you can calculate kW needed, and since HA knows prospective sunshine, it can - at 03:00am - plan ideal switch times (no idea how to do that, either). This should be triggered every 15 minutes or so (no idea how to do that, either), maybe based on actual PV generation (HA knows that, too).

Essentially, if my PV generates less than half I need, my timetable system (about 42 automations) uses >95% of PV energy; there’s also a 6.6kW Battery. If it generates what I need or more, efficiency drops vastly; I still buy energy, then sell energy for 1/6th of the price. This certainly can be optimized, but I do need help doing that.

What I need to know:

How do I “make” the calculations and “set” the three “heating time” variables?
How do I (automatically) “adjust” the timetable, seuqentially, based on expected sunshine?
How do I make an automation (or three) that switches based on the calculated timetable and self-adjusts on actual sunshine?

Oh, an there’s the curcuit breaker problem, it’ll blow if more than 27.7kW are dran.- The switched parts are 18kW in total, but there’s non-switched parts consisting of randomly working 7kW water boilers, additional heaters totalling ~5kW, and of course about 8kW stove. I already have a “Watchdog” running ‘if total Power >27kW then switch everything switchable off’, but that really may disturb my scheduling if someone decides to cook at 12 noon when the schedule isn’t sequential.

Yes, this is in Europe, and yes, everything was done by an electrician, and yes, the house came with 2x3-phase 32A fuses, and it won’t need more than 44kW at any time. But with the PV, you can’t have two three-phase circuits, and one three-phase circuit is limited to 40A max, so there you are with the 27.7A. Homeassistant is faster than the fuse, the fuse will take an overload for up to 8 seconds.