Connect to MQTT server and wait for server to acknowledge

def connect(self):
        """Connect to MQTT server and wait for server to acknowledge"""
        if not self.connect_attempted:
            self.connect_attempted = True
            self.client.connect(self.host, port=self.port)
            self.client.loop_start()

            while not self.connected:
                log.info('waiting for MQTT connection...')
                time.sleep(1)