Shark vacuum nfc tag toggle

Hi, I am trying to create a simple toggle for a nfc tag for my shark vacuum. Currently it will toggle between starting the vacuum and returning it to its base, but it requires two triggers of the tag to return it to its base here is my YAML file I am new to home assistant so any help would be great.


alias: New Automation
description: ""
trigger:
  - platform: tag
    tag_id: 04c5ac33-1e41-430d-a98f-445df8601105
condition: []
action:
  - if:
      - condition: state
        entity_id: vacuum.ryeattach
        state: docked
    then:
      - service: vacuum.start
        data: {}
        target:
          device_id: b98ad8a8bd11bb6a9cbd8c97f689fa14
          entity_id: vacuum.ryeattach
    else:
      - service: vacuum.return_to_base
        data: {}
        target:
          device_id: b98ad8a8bd11bb6a9cbd8c97f689fa14
          entity_id: vacuum.ryeattach
mode: single