mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Improve MQTT failed connection error message (#13184)
This commit is contained in:
parent
3e7a737bff
commit
5958e6a60f
@ -515,16 +515,20 @@ class MQTT(object):
|
|||||||
This method is a coroutine.
|
This method is a coroutine.
|
||||||
"""
|
"""
|
||||||
result = None # type: int
|
result = None # type: int
|
||||||
|
try:
|
||||||
result = await self.hass.async_add_job(
|
result = await self.hass.async_add_job(
|
||||||
self._mqttc.connect, self.broker, self.port, self.keepalive)
|
self._mqttc.connect, self.broker, self.port, self.keepalive)
|
||||||
|
except OSError as err:
|
||||||
|
_LOGGER.error('Failed to connect due to exception: %s', err)
|
||||||
|
return False
|
||||||
|
|
||||||
if result != 0:
|
if result != 0:
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
_LOGGER.error('Failed to connect: %s', mqtt.error_string(result))
|
_LOGGER.error('Failed to connect: %s', mqtt.error_string(result))
|
||||||
else:
|
return False
|
||||||
self._mqttc.loop_start()
|
|
||||||
|
|
||||||
return not result
|
self._mqttc.loop_start()
|
||||||
|
return True
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_disconnect(self):
|
def async_disconnect(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user