Migrating from 0.57.1 to 0.81.4: embedded MQTT broker not accepting connections

I’m busy migrating my home assistant installation to a new machine (from a raspberry pi to a nuc). I have several esp8266 based devices around the house that send MQTT messages to home assistant.

On the raspberry, I just had this line in configuration.yaml:

mqtt:

and then some sensors like:

sensor:
  - platform: mqtt
    name: "Temperatuur babykamer 2"
    state_topic: "babykamer/temperature2"
    qos: 0
    unit_of_measurement: "°C"

I copied the configuration over to the nuc and assigned the IP that the raspberry used to have to the nuc. I thought everything would be running right away, but it seems the clients can not connect to the mqtt server.

It seems the embedded mqtt server is started, because in the log I see lines like:

Nov 22 16:54:05 nuc hass[1913]: 2018-11-22 16:54:05 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to babykamer/temperature2

any idea why it would not be working?

I believe you now have to specify a password for the embedded broker. It used to use the http password, but that has all changed. Look in the MQTT docs for the exact configuration.

ah, I wasn’t using a password in the old configuration. I would rather like to keep it that way, because otherwise i’d have to reprogram all devices around the house :wink:

I just tried adding a empty password, but it seems it does not like that either.

I do by the way now see errors like these in the log evey few minutes:

Nov 22 17:08:37 nuc hass[1913]: Traceback (most recent call last):
Nov 22 17:08:37 nuc hass[1913]: File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
Nov 22 17:08:37 nuc hass[1913]: result = coro.send(None)
Nov 22 17:08:37 nuc hass[1913]: File “/home/nuc/homeassistant/lib/python3.5/site-packages/hbmqtt/broker.py”, line 343, in stream_connected
Nov 22 17:08:37 nuc hass[1913]: yield from self.client_connected(listener_name, StreamReaderAdapter(reader), StreamWriterAdapter(writer))
Nov 22 17:08:37 nuc hass[1913]: File “/home/nuc/homeassistant/lib/python3.5/site-packages/hbmqtt/broker.py”, line 358, in client_connected
Nov 22 17:08:37 nuc hass[1913]: handler, client_session = yield from BrokerProtocolHandler.init_from_connect(reader, writer, self.plugins_manager, loop=self._loop)
Nov 22 17:08:37 nuc hass[1913]: File “/home/nuc/homeassistant/lib/python3.5/site-packages/hbmqtt/mqtt/protocol/broker_handler.py”, line 129, in init_from_connect
Nov 22 17:08:37 nuc hass[1913]: connect = yield from ConnectPacket.from_stream(reader)
Nov 22 17:08:37 nuc hass[1913]: File “/home/nuc/homeassistant/lib/python3.5/site-packages/hbmqtt/mqtt/packet.py”, line 228, in from_stream
Nov 22 17:08:37 nuc hass[1913]: variable_header = yield from cls.VARIABLE_HEADER.from_stream(reader, fixed_header)
Nov 22 17:08:37 nuc hass[1913]: File “/home/nuc/homeassistant/lib/python3.5/site-packages/hbmqtt/mqtt/connect.py”, line 105, in from_stream
Nov 22 17:08:37 nuc hass[1913]: protocol_name = yield from decode_string(reader)
Nov 22 17:08:37 nuc hass[1913]: File “/home/nuc/homeassistant/lib/python3.5/site-packages/hbmqtt/codecs.py”, line 68, in decode_string
Nov 22 17:08:37 nuc hass[1913]: byte_str = yield from read_or_raise(reader, str_length[0])
Nov 22 17:08:37 nuc hass[1913]: File “/home/nuc/homeassistant/lib/python3.5/site-packages/hbmqtt/codecs.py”, line 52, in read_or_raise
Nov 22 17:08:37 nuc hass[1913]: data = yield from reader.read(n)
Nov 22 17:08:37 nuc hass[1913]: File “/home/nuc/homeassistant/lib/python3.5/site-packages/hbmqtt/adapters.py”, line 146, in read
Nov 22 17:08:37 nuc hass[1913]: data = yield from self._reader.readexactly(n)
Nov 22 17:08:37 nuc hass[1913]: File “/usr/lib/python3.5/asyncio/streams.py”, line 666, in readexactly
Nov 22 17:08:37 nuc hass[1913]: raise IncompleteReadError(incomplete, n)
Nov 22 17:08:37 nuc hass[1913]: asyncio.streams.IncompleteReadError: 574 bytes read on a total of 21536 expected bytes

I’m not sure about using the embedded broker without a password. To be honest I didn’t think you could do that before.

But rather that try and figure it out I suggest you just install mosquitto. By default, clients don’t need a password, so the only thing you would have to change is

mqttt:
  broker: localhost

I’m in the same position - I have two esp8266 based devices that I’d need to be adjust. One of them is neatly hidden away to manage the garage door opener, the other one is located under the house for my drip system - what a pain.
That’s the main reason why I’m still on V. 0.75.3 for my production system.

I was able to do it in 0.57.1.

Switching to mosquitto while I’m migrating is probably the best idea, it would give me a bit more control over the MQTT part. I did however just figure out that I’m using the same clientId for all my devices, which is obviously wrong, but apparently the old build-in broker didn’t care. Mosquito does care and disconnects the previous client that was using the same id, resulting in a constant battle for a connection from all my mqtt clients :confounded:

Seems like I do have to grab all devices and reprogram them after all, but at least I’ll end up with a bit better configuration

1 Like