Esphome sprinkler component stio a single valve on an event

i am trying to use the sprinkler component of esphome to turn off a specific valve when my tank is full, my setup uses the same bore pump for irrigation and to fill my house water tank so i do need to co-ordinate the two, but i cant figure out how to turn off the valve “correctly” within esphome when treating it as just one of the irrigation zones and the tank becomes full. i am aware that my current usage of the sensor on_value_range will not work if the tank is already full and the tank filler turns on, that’s a future problem that probably involves on_value instead of on_value_range, or a check when the gpio switch is turned on for that valve.

esphome:
  name: irrigation
  friendly_name: irrigation

esp8266:
  board: nodemcuv2

# Enable logging
logger:
  baud_rate: 0
# Enable Home Assistant API
api:
  actions:
    - action: start_full_cycle
      then:
        - sprinkler.start_full_cycle: sprinkler_ctrlr
    - action: start_single_valve
      variables:
        valve: int
      then:
        - sprinkler.start_single_valve:
            id: sprinkler_ctrlr
            valve_number: !lambda 'return valve;'
    - action: next_valve
      then:
        - sprinkler.next_valve: sprinkler_ctrlr
    - action: previous_valve
      then:
        - sprinkler.previous_valve: sprinkler_ctrlr
    - action: shutdown
      then:
        - sprinkler.shutdown: sprinkler_ctrlr
    - action: shutoff_filler
      then:
        - sprinkler.shutdown: sprinkler_ctrlr




ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Irrigation Fallback Hotspot"

captive_portal:

sensor:
  - platform: "jsn_sr04t"
    name: "Tank Level"
    update_interval: 10s
    on_value_range:
        - above: 1.5
          then:
            - sprinkler.start_single_valve:
                id: sprinkler_ctrlr
                valve_number: 5
                run_duration: 900s
        - below: 0.5
          then:
              #fixme turn off the tank filler valve here

  - platform: template
    name: "Irrigation Zone Remaining Time"
    id: time_remaining_active_valve
    icon: mdi:progress-clock    
    device_class: duration
    unit_of_measurement: min
    update_interval: 2s   
    lambda: |-
      if (id(sprinkler_ctrlr).time_remaining_active_valve().has_value())
      {
        return id(sprinkler_ctrlr).time_remaining_active_valve().value() / 60;
      }
      else
      {
        return 0;
      }

  - platform: template
    name: "Irrigation Total Cycle Time Enabled Valves"
    id: total_cycle_time_enabled_valves
    icon: mdi:progress-clock    
    device_class: duration
    unit_of_measurement: h
    update_interval: 2s  
    lambda: |-
      return id(sprinkler_ctrlr).total_cycle_time_enabled_valves() / 60 / 60;

  - platform: template
    name: "Irrigation Total Cycle Time Incomplete Valves"
    id: total_cycle_time_enabled_incomplete_valves
    icon: mdi:progress-clock    
    device_class: duration
    unit_of_measurement: h
    update_interval: 2s  
    lambda: |-
      return id(sprinkler_ctrlr).total_cycle_time_enabled_incomplete_valves() / 60 / 60 ;


sprinkler:
  - id: sprinkler_ctrlr
    main_switch: "bore pump"
    auto_advance_switch: "irigation Auto Advance"
    valve_overlap: 5s
    multiplier_number: 
      name: "irrigation multiplier"
      id: irrigation_multiplier_number
      initial_value: 1.0
      min_value: 0.1
      max_value: 2


    valves:
      - valve_switch: "Olive Irrigation"
        enable_switch: "Enable Olive Irrigation"
        pump_switch_id: bore_pump_sw
        run_duration_number:
          name: "Olive Irrigation Duration"
          unit_of_measurement: min
          id: olive_irrigation_number
          initial_value: 30
          min_value: 10
          max_value: 120
        valve_switch_id: olive_irrigation_sw
      - valve_switch: "Hazels Irrigation"
        enable_switch: "Enable Hazel Irrigation"
        pump_switch_id: bore_pump_sw
        run_duration_number:
          name: "Hazels Irrigation Duration"
          unit_of_measurement: min
          id: hazels_irrigation_number
          initial_value: 90
          min_value: 10
          max_value: 120
        valve_switch_id: hazel_irrigation_sw
      - valve_switch: "shelterbelt Irrigation and troughs"
        enable_switch: "Enable Shelterbelt Irrigation"
        pump_switch_id: bore_pump_sw
        run_duration_number:
          name: "Shelterbelt Irrigation Irrigation"
          unit_of_measurement: min
          id: Shelterbelt_irrigation_number
          initial_value: 60
          min_value: 10
          max_value: 120
        valve_switch_id: shelterbelt_irrigation_sw
      - valve_switch: "Impact Irrigation"
        enable_switch: "Enable Impact Irrigation"
        pump_switch_id: bore_pump_sw
        run_duration_number:
          name: "Impact Irrigation Irrigation"
          unit_of_measurement: min
          id: Impact_irrigation_number
          initial_value: 70
          min_value: 10
          max_value: 120
        valve_switch_id: impact_irrigation_sw
      - valve_switch: "Garden Irrigation"
        enable_switch: "Enable Garden Irrigation"
        pump_switch_id: bore_pump_sw
        run_duration_number:
          name: "Garden Irrigation Duration"
          unit_of_measurement: min
          id: garden_irrigation_number
          initial_value: 30
          min_value: 10
          max_value: 120
        valve_switch_id: garden_irrigation_sw
      - valve_switch: "Tank Filler"
        enable_switch: "Enable Tank Filler"
        pump_switch_id: bore_pump_sw
        run_duration: 3600s
        valve_switch_id: tank_filler_sw


switch:
  - platform: gpio
    id: bore_pump_sw
    pin: GPIO04
  - platform: gpio
    id: olive_irrigation_sw
    pin: GPIO05
  - platform: gpio
    id: hazel_irrigation_sw
    pin: GPIO12
  - platform: gpio
    id: shelterbelt_irrigation_sw
    pin: GPIO14
  - platform: gpio
    id: impact_irrigation_sw
    pin: GPIO02
  - platform: gpio
    id: garden_irrigation_sw
    pin: GPIO09
  - platform: gpio
    id: tank_filler_sw
    pin: GPIO10

uart:
  tx_pin: D8
  rx_pin: D7
  baud_rate: 9600


    

got it to work:

sensor:
  - platform: "jsn_sr04t"
    name: "Tank Level"
    update_interval: 10s
    on_value_range:
        - above: 1.5
          then:
            - sprinkler.start_single_valve:
                id: sprinkler_ctrlr
                valve_number: 5
                run_duration: 900s
        - below: 0.5
          then:
            - lambda: |-
                auto *sprinkler = id(sprinkler_ctrlr);
                  if (sprinkler->active_valve().has_value() && sprinkler->active_valve().value() == 5) {  // Check if the Tank Filler valve is currently active
                    // Call to stop the active valve
                    sprinkler->control_switch(5)->turn_off();  // Ensure the Tank Filler is turned off
                  }