I am trying to get into Home Assistant and I’m having a hard time configuring mqtt. Every time HA starts, I am getting this in my logs:
2018-04-24 00:30:00 INFO (MainThread) [homeassistant.setup] Setting up mqtt
2018-04-24 00:30:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=mqtt, service=publish>
2018-04-24 00:30:00 INFO (MainThread) [homeassistant.setup] Setup of domain mqtt took 0.2 seconds.
2018-04-24 00:30:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=mqtt>
2018-04-24 00:30:00 ERROR (Thread-2) [homeassistant.components.mqtt] Unable to connect to the MQTT broker: Connection Refused: not authorised.
.....
2018-04-24 00:30:23 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to stat/sonoff/POWER
2018-04-24 00:30:23 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 258, in _async_add_entity
await entity.async_added_to_hass()
File "/usr/lib/python3.6/site-packages/homeassistant/components/switch/mqtt.py", line 115, in async_added_to_hass
self._qos)
File "/usr/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 241, in async_subscribe
topic, msg_callback, qos, encoding)
File "/usr/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 559, in async_subscribe
await self._async_perform_subscription(topic, qos)
File "/usr/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 594, in _async_perform_subscription
_raise_on_error(result)
File "/usr/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 680, in _raise_on_error
'Error talking to MQTT: {}'.format(mqtt.error_string(result_code)))
homeassistant.exceptions.HomeAssistantError: Error talking to MQTT: The client is not currently connected.
I know that I am missing something silly… just can’t put a finger on it.
Oh, I should probably state that I am running:
H/W: Raspberry Pi 3
OS: Hass.io
HA Version: 0.67.1
Mosquitto version: 1.4.12 (build date 2017-06-01 13:03:46+0000) (running in a docker container on my Synology NAS)
I was trying to see where mqtt python module lives on hass.io, but could not find it. My thought process was to write a quick python script that would connect to my mqtt broker. Just trying to rule out one thing at a time.
with HASSiO mqtt configuration has been made really simple and you no longer need to ssh it or direct it to your broker ip, just enable it from your "HASS.io tab from your front end.
so, is core-mosquitto an internal broker or an external one? I have a broker configured on another machine and I would like to use that and not a broker on the same machine as hass.
I guess you’d have to direct your yaml to the external mqtt broker and there would be no need for any additional set up on the HASS RPI but I’m no expert on this…
I have tried your suggested setup (keepalive and protocol) and I’m having the same issue
Interestingly enough, when I look at my mosquitto logs, all I see is this:
1524675709: Socket error on client <unknown>, disconnecting.
1524676392: New connection from 172.17.0.1 on port 1883.
Which leads me to believe that connection is made. (Socket error line is when I restarted hass)
So, the question is: why does hass report:
2018-04-25 10:13:12 ERROR (Thread-2) [homeassistant.components.mqtt] Unable to connect to the MQTT broker: Connection Refused: not authorised.
As for your question re: separate broker:
I have a synology nas and I’ve dockorized a lot of service I am using within my home setup (various web servers, etc). Since all my infrastructure is tied to that nas, it would be:
Easier to manage (everything’s in one place)
Easier to monitor logs (same reason as above)
When I drill holes in my firewall for external access, fewer internal IPs are exposed.