Automation to use multiple TRVs to control single heating pump

I have Homematic heating system using a Thermostat and TRV pair in each room to control the water pumps for each floor. Each TRV has a valve position sensor to indicate when it is calling for heat. This then activates a pump which turns on the oil-fired heating system. The automation currently runs on the Homematic CCU, but I want to move it to HA for greater flexibility.
So far, I have created an automation that triggers when any valve (level) is greater than 15% and turns on the pump - see below.
Where I’m stuck is that I need to turn off the pump when ALL the TRV valves are less than 15%, which is an AND condition, so I can’t use a trigger. What is the best way to achieve this?

alias: Ground Floor Heating Automation
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.front_livingroom_group_level
    above: 15
  - platform: numeric_state
    entity_id: sensor.rear_livingroom_group_level
    above: 15
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: switch.raspberrymatic_ccu_sv_summer_heating_mode
        state: "off"
      - condition: state
        entity_id: switch.central_heating_controller_groundfloor_heating_pump
        state: "off"
      - condition: state
        entity_id: switch.central_heating_controller_central_heating_state
        state: "on"
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.central_heating_controller_groundfloor_heating_pump
mode: single

OK, this is hilarious. I posted my question to ChatGPT and it gave me back a solution that I have adapted and it works. Here is the code it produced:

- id: turn_on_switch_when_sensors_reach_threshold
  alias: Turn on switch when sensors reach threshold
  trigger:
    - platform: state
      entity_id:
        - sensor.sensor1
        - sensor.sensor2
        - sensor.sensor3
      to: '15'
      or: true
  condition:
    - condition: and
      conditions:
        - condition: state
          entity_id: sensor.sensor1
          state: '15'
        - condition: state
          entity_id: sensor.sensor2
          state: '15'
        - condition: state
          entity_id: sensor.sensor3
          state: '15'
  action:
    - service: switch.turn_on
      entity_id: switch.example_switch

- id: turn_off_switch_when_sensors_fall_below_threshold
  alias: Turn off switch when sensors fall below threshold
  trigger:
    - platform: state
      entity_id:
        - sensor.sensor1
        - sensor.sensor2
        - sensor.sensor3
      below: '15'
      or: true
  condition:
    - condition: not
      conditions:
        - condition: state
          entity_id: sensor.sensor1
          state: '15'
        - condition: state
          entity_id: sensor.sensor2
          state: '15'
        - condition: state
          entity_id: sensor.sensor3
          state: '15'
  action:
    - service: switch.turn_off
      entity_id: switch.example_switch

The automation turns on the pump if any one TRV valve is open more than 15%. It does not turn off the pump until all TRV are below 15%. Here is the adapted automation which works but I still need to add a few features, so for the moment it just turns off a dummy input_boolean:

alias: Heating Automation
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.front_livingroom_group_level
      - sensor.groundfloor_bathroom_group_level
      - sensor.hallway_group_level
      - sensor.rear_livingroom_group_level
      - sensor.study_group_level
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: switch.raspberrymatic_ccu_sv_summer_heating_mode
        state: "off"
      - condition: state
        entity_id: switch.central_heating_controller_central_heating_state
        state: "on"
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.ground_floor_heating_pump_dummy
            state: "on"
          - condition: template
            value_template: "{{ trigger.to_state.state | int < 15 }}"
          - condition: and
            conditions:
              - condition: numeric_state
                entity_id: sensor.front_livingroom_group_level
                below: 15
              - condition: numeric_state
                entity_id: sensor.groundfloor_bathroom_group_level
                below: 15
              - condition: numeric_state
                entity_id: sensor.hallway_group_level
                below: 15
              - condition: numeric_state
                entity_id: sensor.rear_livingroom_group_level
                below: 15
              - condition: numeric_state
                entity_id: sensor.study_group_level
                below: 15
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.ground_floor_heating_pump_dummy
      - conditions:
          - condition: state
            entity_id: input_boolean.ground_floor_heating_pump_dummy
            state: "off"
          - condition: template
            value_template: "{{ trigger.to_state.state | int >= 15 }}"
        sequence:
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.ground_floor_heating_pump_dummy
mode: restart

Wondering what did you end up doing. I need a solution for the same problem

While the solution I posted above worked, it would occasionally fail if one of the TRVs failed to report the valve position. I went back to running the script on the CCU as it needed to be reliable and anyway, I will be tearing out the entire system shortly to install underfloor heating with an air to water heat pump and KNX controls.