Hello,
I am looking into the ‘imap_email_content’ integration and I believe it needs some update. I am working on adding config flow and making it async using aioimaplib. During the re-write I went through the reported issues to better understand what are the issues users are facing with the current email message retrieval process. Here is what I would like this integration to provide and would like your comments to make it more powerful.
The user will have the following options to specify which email message should be considered when updating the sensor:
- Folder name (default is INBOX)
- List of allowed senders (default is blank which means any sender): This is already used in the current integration however, it is a required field. I plan to make it optional and blank by default.
- Select unread message only (default is True): The current integration doesn’t provide the option to specify if only unread messages should be checked. This option allows to look at unread messages only.
As for the search process and updating the sensor here is what I though would be best:
- Upon initial setup the integration will fetch the newest email message from the INBOX folder.
- The user can keep this setting or change the options mentioned above to select the allowed senders and whether to check for unread only or any email.
- In case allowed senders are selected the integration will return the latest email message which would be sent from any allowed sender.
- In case multiple email messages are returned from the search only the newest message is fetched and used to update the sensor state. Unlike the current implementation which iterates through each new message and updates the sensor state I believe it is best to get the latest message only.
There are some considerations which I am still not sure how to deal with so I will list them below for your comments:
- In case the search criteria doesn’t return any messages what should the sensor state update to?
- In case the last fetched message is deleted from the imap server how should the sensor update?
Here are the possible answers:
- List item
- Change state to ‘unknown’
- Make the sensor ‘unavailable’
If there is anything else that I have missed feel free to highlight.