IMAP content sensor - dealing with emails arriving at the same time

So like many others, I’m using the IMAP content sensor to populate some sensors. My issue is that with reasonable frequency I get multiple emails at the same moment (because batching but not combining I guess -_-).

Is it possible to poll for the last ~5 emails or something similar? I’ve seen discussions about how the IMAP sensor USED to work that seem to search the entire inbox.

Cheers in advance!

Are you using just one IMAP sensor or do you have explicit searches for your different sensor needs?

Unfortunately in this case just the one - the incoming emails only differ in what I actually want to pull in =/

I’ve been testing with the generic imap content sensor from the documentation that updates on each new email coming in (for now).

Then, the first thing I would try would be setting up a sensor whose search finds all your sensor-related emails but ignores the other incoming messages. Then copy/paste the search criteria into the trigger of the content sensor.

- platform: event
  event_type: "imap_content"
  event_data:
    search: UnDeleted X-GM-RAW "example only"

Ah, I explained badly. I’ve essentially done that (for now) by restricting the actual emails being forwarded to the IMAP sensor monitored inbox, though I’ll do what you suggest.

I haven’t actually seen the ‘X-GM-RAW’ flag, is it just to allow for gmail specific search terms?

X-GM-RAW is in the IMAP documentation, nevermind.