State and time trigger

I’m trying to write an automation that fires when a sensor’s state value changes for 10 minutes, and that state is not “ABC”. The following isn’t working. Anytime the state changes, the 10 minute requirement should restart, but that doesn’t appear to be happening.


  - alias: "My Trigga" 
    trigger:
      - platform: template
        value_template: "{{ states('sensor.mysensor') != 'ABC' }}"
        for:
          minutes: 10

Would this trigger fire on every state change of the sensor that persists for 10 minutes, with the exception of state ABC?


  - alias: "My Trigga" 
    trigger:
      platform: state
      entity_id: 'sensor.mysensor'
    for:
      minutes: 10
    condition:
      - condition: template
        value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"
      - condition: template
        value_template: "{{ states('sensor.mysensor') != 'ABC' }}"
    action: