'Check the number of unread emails.'

def update(self):

    import imaplib
    try:
        self.connection.select()
        self._unread_count = len(self.connection.search(None, 'UnSeen    UnDeleted')[1][0].split())
    except imaplib.IMAP4.error:
        _LOGGER.info('Connection    to    %s    lost,    attempting    to    reconnect', self._server)
        try:
            self.connection = self._login()
        except imaplib.IMAP4.error:
            _LOGGER.error('Failed    to    reconnect.')
