Why won't this template switch off after 20 minutes

hi,

my automated morning script:

scene_opstaan:
  alias: Call Opstaan scene
  sequence:
    - service: homeassistant.turn_off
      entity_id: 
      - input_boolean.motion_detection
      - input_boolean.home_mode_locked
    - service: switch.turn_off
      entity_id: switch.sw_master_bedroom_template
    - service: switch.turn_on
      entity_id:
        - switch.master_bedroom_motion_sensor_switch
    - service: scene.turn_on
      entity_id: scene.opstaan

calls this extremely simple scene just fine:

- name: Opstaan
  entities:
    light.kist:
      state: on
      transition: 4
      brightness: 47
      hs_color: [14,83]
    light.master_bedroom:
      state: on
      transition: 4
      brightness: 30
      hs_color: [14,83]

I want an automation to switch the light.master_bedroom off after 20 min of non-movement, and notify:

  - id: Switch Bedside table off when room left
    alias: "Switch Bedside table off when room left"
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: binary_sensor.master_bedroom_motion
      to: 'off'
      for:
        minutes: 20
    condition:
      - condition: state
        entity_id: binary_sensor.activity_opstaan
        state: 'on'
      - condition: state
        entity_id: light.master_bedroom
        state: 'on'
    action:
      - service: light.turn_off
        data:
          entity_id: light.master_bedroom
      - condition: state
        entity_id: input_boolean.notify_notify
        state: 'on'
      - service: notify.notify
        data_template:
         message: '{{as_timestamp(now()) | timestamp_custom("%X") }}: Bedside table is turned down.'

I think (might sleep through it…) it switches off quite alright, but i never get notified…

What is wrong in this automation?

If I trigger the automation by dev-tools, or switch the light on, walk in and out, after 20 min it just works…

Ive also taken care the Hue app itself doesnt switch off earlier than 20 min, so it cant frustrate the automation.

please have a look?
thx,
Marius

Don’t know if it’s necessary in your case, I’ve been told both ways in the past, but a similar trigger I use is…

from: 'on'
to: 'off'
for: 
  minutes: 5 

and that works perfectly.

ok thanks, will test for sure…

i dont understand though, why it switches off just fine and notifies (just tested again) when i turn the light on manually (in opstaan-mode, and with binary sensor on) and when it turns in automatically in the morning, it doesnt… could it be the order of things, or maybe even the timing?