IMAP Unread Email with sender and subject

I’m using the https://www.home-assistant.io/components/sensor.imap/ component but I don’t see any content example. The docs are typically vague on this.

sensor:
  - platform: imap
    server: imap.gmail.com
    port: 993
    username: YOUR_USERNAME
    password: YOUR_PASSWORD

I should be able to specify search parameters with from and subject but I can’t seem to hit on the magic configuration to do this…

Hi,
Your code is absolutely correct,

What I was tripping over were two things :

If you haven’t done so already, you have to create a unique password in your google security account settings for the imap access from home assistant, because access is being achieved through a ‘less’ secure method. You use your google account and this unique password to access your emails from home assistant.

Secondly, the following search criteria for ‘test’ in the SUBJECT worked for me (there are no quotation marks or chevrons required) :

search: FROM [email protected], SUBJECT test

As I’d given my IMAP entry a friendly name of email (name: email), this returned a state of 1 from sensor.email (the number of emails that matched the search criteria).

Yeah… year old thread long since solved (and at the time I did a PR to add this info in the docs)

I imagine you can also use BODY in the search: ?

And is there a way of only getting the last 5 minutes of mail or something?