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.
This commit is contained in:
parent
a8f34eb728
commit
1da94928c6
1 changed files with 2 additions and 3 deletions
|
@ -90,12 +90,11 @@ class ImapSensor(Entity):
|
||||||
self.connection.select()
|
self.connection.select()
|
||||||
self._unread_count = len(self.connection.search(
|
self._unread_count = len(self.connection.search(
|
||||||
None, 'UnSeen')[1][0].split())
|
None, 'UnSeen')[1][0].split())
|
||||||
except imaplib.IMAP4.abort:
|
except imaplib.IMAP4.error:
|
||||||
_LOGGER.info("Connection to %s lost, attempting to reconnect",
|
_LOGGER.info("Connection to %s lost, attempting to reconnect",
|
||||||
self._server)
|
self._server)
|
||||||
try:
|
try:
|
||||||
self._login()
|
self.connection = self._login()
|
||||||
self.update()
|
|
||||||
except imaplib.IMAP4.error:
|
except imaplib.IMAP4.error:
|
||||||
_LOGGER.error("Failed to reconnect.")
|
_LOGGER.error("Failed to reconnect.")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue