Sensor status that lasts over time and notification

Hi,
I have a Co2 sensor and it’s configured to send me a notification on my phone when it reach a value of 1000.

This is the script:

type: carbon_dioxide
device_id: ***
entity_id: ***
domain: sensor
above: 1000
for:
  hours: 0
  minutes: 5
  seconds: 0
trigger: device

I’d need to receive the notification when the value is stable above the value of 1000 for 5 minutes, otherwise I get too many notifications.
I thought that the “for” part was for this but seems that it is sending me the notification even if it reaches the value for an instant. Am I doing this wrong?

Thanks :slight_smile:

What happens if you start over with a new automation in the GUI, select Entity as the trigger, using a Numeric state? With MY temperature sensor as the entity, that would look like this:

description: test automation
mode: single
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.crawlspace_temperature_t4
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 30
conditions: []
actions:
  - action: notify.notify
    metadata: {}
    data:
      message: "it is below 30 degrees"