"not_tampered" notification only if "tampered" lasted longer than 10 seconds

Hi, my smoke detector can indicate whether the device is tampered. It publishes the “tamper” status, which can be either true or false.
I have set two separate notifications if the tamper is ON and OFF. However, the device sometimes “goes stupid” and the tamper turns on for a second, even though no one is touching the device. Therefore, I set the notification delay to 10 seconds when tampering is ON.
However, I have a problem with setting the notification when the device stops detecting tampering because I cannot set the notification to be sent only if the tampering lasted longer than 10 seconds.
Here is my notification when tmaper is ON:

alias: Tamper start notification
description: ""
trigger:
  - type: tampered
    platform: device
    device_id: xxx
    entity_id: xxx
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 10
condition: []
action:
  - service: notify.mobile_app_iphone
    data:
      message: TAMPER
      title: Smoke detector
  - service: notify.mobile_app_ipad
    data:
      message: TAMPER
      title: Smoke detector
mode: single

This is Notification when tamper goes OFF (It is sent anyway, even if the tamper lasted less than 10 seconds, but it is sent with a 10-second delay).

alias: Tamper end notification
description: ""
trigger:
  - type: not_tampered
    platform: device
    device_id: xxx
    entity_id: xxx
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 10
condition: []
action:
  - service: notify.mobile_app_iphone
    data:
      message: End of tamper
      title: Smoke detector
  - service: notify.mobile_app_ipad
    data:
      message:  End of tamper
      title: Smoke detector
mode: single

I guess the solution is simple, you just have to find it.
Maybe one of you has already set something like this and can help me.

This may not be a good way, but I did this:

  • I turned off the “tamper end notification” automation
  • I added enable automation: “tamper end notification” action at the end of “tamper start notification” automation
  • in the “tamper end notification” automation, I added disabling itself at the end.

Works.