mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
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
@ -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…
x
Reference in New Issue
Block a user