Skip to content

Commit

Permalink
Ignore deleted mails in IMAP unread count (#6394) (#6395)
Browse files Browse the repository at this point in the history
Message deletion in IMAP is a two step process: first delete, then expunge.
Deleting a message just sets a flag that usually makes the mail client hide
the message. It is the expunge that actually removes the message.

Thus, exclude the deleted messages so that the unread count matches up with
that of most mail clients.
  • Loading branch information
amelchio authored and balloob committed Mar 5, 2017
1 parent de038ba commit 660e777
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion homeassistant/components/sensor/imap.py
Expand Up @@ -85,7 +85,7 @@ def update(self):
try:
self.connection.select()
self._unread_count = len(self.connection.search(
None, 'UnSeen')[1][0].split())
None, 'UnSeen UnDeleted')[1][0].split())
except imaplib.IMAP4.error:
_LOGGER.info("Connection to %s lost, attempting to reconnect",
self._server)
Expand Down

0 comments on commit 660e777

Please sign in to comment.