Ignoring sensor values during warm up after periodic wake up

ESPHome is incredibly well thought out and written. Thank you for making this and sharing!

I’m using the PMS7003 sensor by reading it for 1 minute every 15 minutes, and making it sleep for 14mins. Doing this to minimize power as well as preserve the sensor life:

I’m using code like this to implement the sleep-wake-measure-sleep:

The problem is, the sensor needs to warm up for 30sec after it is up. Values for that time period should be ignored. So the cycle needs to look like:

00:00 sleep PMS7003 via set pin
14:00 wake up via set pin; ignore values for the next 30sec*
14:30 start taking measurements, once every two seconds
15:00 sleep PMS7003 via set pin

How can I implement the 30-second warm up period in ESPHome? Thank you.

Stable data should be got at least 30 seconds after the sensor wakeup from the sleep mode because of the fan’s performance.

I tried this idea: to create an interval to handle turning on the sensor, which also sets a (software) switch indicating warm_up is complete. I then attempted to filter the sensor itself on this warm_up switch. That filter unfortunately doesn’t allow anything through at all:

# turn on for 1min every 15min, and flip a switch after a 30sec warm up period
interval:
  - interval: 15min
    then:
      - switch.turn_on: pms_set
      - delay: 30s
      - switch.turn_on: pms_ready_to_read
      - delay: 45s
      - switch.turn_off: pms_ready_to_read
      - switch.turn_off: pms_set

switch:
  - platform: template
    name: "PMSX003 Ready to Read Post Warm-Up"
    id: pms_ready_to_read

sensor:
  - platform: uptime
    name: ${device_full_name} Uptime
    update_interval: 1s
    id: uptime_sensor
    filters:
      - lambda: if (id(pms_ready_to_read).state) { return(x); } else { return {}; };
    on_value:
      then:
        - lambda: |-
            ESP_LOGD("main", "Uptime sensor value is: %d", int(x));

Would this idea work at all? Can anyone help me see if what I’m doing wrong here? Thank you!

Bumping you see if anyone has ideas. Thank you.