Fix bug with imap sensor (#2546)
Fixed bug where the new connection was not saved when a reconnect attempt was made; broadended the exception catching.pull/2550/head
parent
a8f34eb728
commit
1da94928c6
|
@ -90,12 +90,11 @@ class ImapSensor(Entity):
|
|||
self.connection.select()
|
||||
self._unread_count = len(self.connection.search(
|
||||
None, 'UnSeen')[1][0].split())
|
||||
except imaplib.IMAP4.abort:
|
||||
except imaplib.IMAP4.error:
|
||||
_LOGGER.info("Connection to %s lost, attempting to reconnect",
|
||||
self._server)
|
||||
try:
|
||||
self._login()
|
||||
self.update()
|
||||
self.connection = self._login()
|
||||
except imaplib.IMAP4.error:
|
||||
_LOGGER.error("Failed to reconnect.")
|
||||
|
||||
|
|
Loading…
Reference in New Issue