[solved] Disable automation if user changes device state

I have a garden watering automation setup which activates when a user switches the pump on.
The automation waits for a duration (say 40mins) then will play a notification sound and turn off the pump.

The issue I have is that if the user turns the pump off before the time is complete, the notification will still play.

I assume the condition should fix this, but I cant get it working right…

- id: '1606285797602'
  alias: Bore Timer
  description: ''
  trigger:
  - platform: state
    entity_id: switch.bore_power_switch
    to: 'on'
  condition:
  - condition: state
    entity_id: switch.bore_power_switch
    state: 'off'
  action:
  - delay: 00:{{ states('input_number.bore_timer') | int }}
  - type: turn_off
    device_id: 45e70ee430558d7eb7d4d374eba77bd6
    entity_id: switch.bore_power_switch
    domain: switch
  - service: script.chime_bore_off
    data: {}
  - service: shell_command.speak_bore
    data: {}
  - service: shell_command.notification_bore
    data: {}
  mode: single

Hi there… Try this. als please check for any syntax error, logic should be fine

- id: '1606285797602'
  alias: Bore Timer
  description: ''
  trigger:
  - platform: state
    entity_id: switch.bore_power_switch
    to: 'on'
  condition: []
  action:
  - delay: '00:{{ states(''input_number.bore_timer'') | int }}'
  - condition: state
    entity_id: switch.bore_power_switch
    state: 'on'
  - type: turn_off
    device_id: 45e70ee430558d7eb7d4d374eba77bd6
    entity_id: switch.bore_power_switch
    domain: switch
  - service: script.chime_bore_off
    data: {}
  - service: shell_command.speak_bore
    data: {}
  - service: shell_command.notification_bore
    data: {}
  mode: single

Thanks! I’m playing with timers now as they seem more flexible a solution for the task…