diff --git a/SunGather/exports/mqtt.py b/SunGather/exports/mqtt.py index ba3685f..0ca0747 100644 --- a/SunGather/exports/mqtt.py +++ b/SunGather/exports/mqtt.py @@ -68,8 +68,11 @@ class export_mqtt(object): return name.lower().replace(' ','_') def publish(self, inverter): - if not self.mqtt_client.is_connected(): - logging.warning(f'MQTT: Server Disconnected; {self.mqtt_queue.__len__()} messages queued, will automatically attempt to reconnect') + try: + if not self.mqtt_client.is_connected(): + logging.warning(f'MQTT: Server Disconnected; {self.mqtt_queue.__len__()} messages queued, will automatically attempt to reconnect') + except Exception as err: + logging.warning(f'MQTT: Server Error; Server not configured') # qos=0 is set, so no acknowledgment is sent, rending this check useless #elif self.mqtt_queue.__len__() > 10: # logging.warning(f'MQTT: {self.mqtt_queue.__len__()} messages queued, this may be due to a MQTT server issue')