From ce47b58a8bfed3cd560893fc9fac24bf77def6bf Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 29 Sep 2015 23:34:17 -0700 Subject: [PATCH] Report MQTT connect issues --- homeassistant/components/mqtt.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/homeassistant/components/mqtt.py b/homeassistant/components/mqtt.py index 7c7a12c2ac3..25f4f2044f2 100644 --- a/homeassistant/components/mqtt.py +++ b/homeassistant/components/mqtt.py @@ -209,6 +209,17 @@ class MQTT(object): # pragma: no cover def _mqtt_on_connect(self, mqttc, obj, flags, result_code): """ On connect, resubscribe to all topics we were subscribed to. """ + if result_code != 0: + _LOGGER.error('Unable to connect to the MQTT broker: %s', { + 1: 'Incorrect protocol version', + 2: 'Invalid client identifier', + 3: 'Server unavailable', + 4: 'Bad username or password', + 5: 'Not authorised' + }.get(result_code)) + self._mqttc.disconnect() + return + old_topics = self.topics self._progress = {} self.topics = {}