diff --git a/adafruit_funhouse/network.py b/adafruit_funhouse/network.py index 10f17c4..17d9885 100755 --- a/adafruit_funhouse/network.py +++ b/adafruit_funhouse/network.py @@ -65,7 +65,6 @@ def __init__( ) self._mqtt_client = None self.mqtt_connect = None - self.mqtt_loop = None self.mqtt_publish = None def init_io_mqtt(self): @@ -95,7 +94,6 @@ def init_mqtt(self, broker, port=1883, username=None, password=None, use_io=Fals if use_io: self._mqtt_client = IO_MQTT(self._mqtt_client) self.mqtt_connect = self._mqtt_client.connect - self.mqtt_loop = self._mqtt_client.loop self.mqtt_publish = self._mqtt_client.publish return self._mqtt_client @@ -107,6 +105,14 @@ def _get_mqtt_client(self): return self._mqtt_client raise RuntimeError("Please initialize MQTT before using") + def mqtt_loop(self): + """Run the MQTT Loop""" + try: + if self._mqtt_client is not None: + self._mqtt_client.loop() + except MQTT.MMQTTException as err: + print("MMQTTException: {0}".format(err)) + @property def on_mqtt_connect(self): """