From 1da94928c667771e726ae84c6aedd068785968a5 Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 17 Jul 2016 16:02:14 -0400 Subject: [PATCH] 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. --- homeassistant/components/sensor/imap.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sensor/imap.py b/homeassistant/components/sensor/imap.py index 2d5a1484d14..c458799215f 100644 --- a/homeassistant/components/sensor/imap.py +++ b/homeassistant/components/sensor/imap.py @@ -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.")