Wait_template shows unexpected behavior

HI,

using this automation action:

    action:
      - service: light.turn_on
        entity_id: light.master_bedroom
        data:
          profile: relax
      - service: switch.turn_on
        entity_id: switch.master_bed_outlet
      - wait_template: >
          {{ is_state('binary_sensor.master_bedroom_motion_sensor_timed_day','off')}}
      - service: light.turn_off
        entity_id: light.master_bedroom
      - service: switch.turn_off
        entity_id: switch.master_bed_outlet

and this binary_sensor:

      master_bedroom_motion_sensor_timed_day:
        friendly_name: 'Master bedroom motion sensor timed day'
        value_template: >
          {{ is_state('binary_sensor.master_bedroom_motion_sensor','on')}}
        delay_off:
          minutes: 3
        device_class: motion

I’d expect the the wait_template to continue after the binary_sensor has been off for 3 minutes. I have another automation set on 1 minute delay working just fine like that. It should restart timing when within the timeframe of that delay motion has been detected.

With this automation, the action hits fine, but immediately continues after the wait template when motion is detected. Seems the opposite of what I want… it waits until the next motion and then continues, while, as said, it should wait 3 minutes of non motion to continue.

Please have a look if I am doing something incorrectly here?