Waiting for last_changed doesn't work as expected

I created this script:

alias: Test
sequence:
  - wait_template: >-
      {{ states.switch.kitchen_light.state == 'on' and
      states.switch.kitchen_light.last_changed < now() - timedelta(seconds=60) }}
    timeout: "00:02:00"
    continue_on_timeout: false
  - service: persistent_notification.create
    data:
      message: test
mode: single

I expected it to wait until switch.kitchen_light has been turned on for at least 60 seconds. But if I turn on switch.kitchen_light, then wait 20 seconds and then run the script, it waits for 60 seconds instead of the expected 40 seconds. Why?

I believe this is likely due to the fact that templates based around now() don’t update continuously. From the docs:

If you use non-deterministic functions like now() in the template it will not be continuously re-evaluated, but only when an entity ID that is referenced is changed.

Try setting up a timer helper to start a countdown when the light turns on.

That was my first thought as well (I edited my question later) but the time was almost precisely the given duration that I now think something else is up. But I guess I’ll have to try it with a 10 minute duration or so.