Automation Loops - DHW Preparation PV Surplus

Hello everyone,

I would need a little help from automation experts. I am currently programming an automation for the hot water preparation of my heat pump. Here is the current state:

It checks if the feed-in power is > 3 kW for 5 minutes. If yes, the hot water one-time charge is activated if certain conditions are met.

alias: WW-Einmalladung bei PV-Überschuss
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.psupply_2
    for:
      hours: 0
      minutes: 5
      seconds: 0
    above: 3000
condition:
  - condition: and
    conditions:
      - condition: time
        before: "17:00:00"
      - condition: numeric_state
        entity_id: sensor.sn_3002897465_battery_soc_total
        above: 50
      - condition: numeric_state
        entity_id: sensor.wohnzimmer_temperature
        above: 20.8
      - condition: numeric_state
        entity_id: sensor.esstisch
        above: 20.8
      - condition: numeric_state
        entity_id: sensor.kuche_temperature
        above: 20.8
action:
  - device_id: 4b7bc7500605307cfab2b98929aeaaf4
    domain: number
    entity_id: b7fb5e40b08b4d0b9c8de0cda4e58c01
    type: set_value
    value: 60
  - device_id: 8880ad74e640ca7e3e857c5070793bfe
    domain: number
    entity_id: d8f5d2ecbd271c43be1be8c856d55305
    type: set_value
    value: 60
  - type: turn_on
    device_id: 4b7bc7500605307cfab2b98929aeaaf4
    entity_id: f8b98b0f797c0efb31c6d7b40ba418eb
    domain: switch
mode: single

I now want to adjust it so that the following is implemented:
1 Kelvin before the hot water target temperature is reached, it should be checked whether the PV generation power (not feed-in, because it is likely close to 0 due to hot water preparation) is still sufficiently high, and further conditions should be checked → What components do I need to use here?
If all conditions are met, the hot water target temperature should be reset (10 Kelvin higher than before) → This should be executed as a loop until either the conditions are no longer met or a maximum target temperature is reached (90 degrees).
Additionally, I need an abort condition: If the room temperatures fall below a certain threshold at any time during hot water preparation, it should be aborted.

Does anyone have an idea on how to best implement this?

Thank you in advance.