Embedded MQTT stopped working on ver 112

Upgraded to HA 112 and now receiving the following error in the log file:

2020-07-04 14:32:52 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry configuration.yaml for mqtt
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/config_entries.py", line 220, in async_setup
    hass, self
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/mqtt/__init__.py", line 489, in async_setup_entry
    await hass.data[DATA_MQTT].async_connect()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/mqtt/__init__.py", line 703, in async_connect
    self.conf[CONF_BROKER],
KeyError: 'broker'

My configuration.yaml has:

mqtt:
    discovery: true
    password: hello

Noticed that they’re are now warnings saying that the embedded MQTT broker marked as deprecated from release .92, hence does that mean its no longer supported or will load? And if so what’s the suggested replacement solution for the internal, Just got a few switches around the house and just looking for something simple to install and setup

THanks,

Rob.

Correct, it’s been deprecated for several releases in order to provide users with time to switch to another broker. The release notes for 0.112 indicate the embedded MQTT Broker has been removed.

If you have installed Home Assistant OS or Home Assistant Supervised, you can install the Mosquitto MQTT Broker Add-on.

1 Like

Thanks for that.

Hoping you could provide some guidance…

I’ve installed the mosquitto broker using:


Added the intergration within HA and pointed it 127.0.0.1

Console of a tasmota device showing:

3:15:18 MQT: sonoff5/cmnd/POWER = 
13:16:14 MQT: sonoff5/tele/STATE = {"Time":"2020-07-04T13:16:14","Uptime":"53T23:56:16","UptimeSec":4665376,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":189,"POWER":"OFF","Wifi":{"AP":1,"SSId":"wifi","BSSId":"D8:47:32:AE:97:D9","Channel":2,"RSSI":58,"Signal":-71,"LinkCount":6,"Downtime":"0T00:08:34"}}
13:16:31 MQT: sonoff5/tele/HASS_STATE = {"Version":"7.2.0(tasmota)","BuildDateTime":"2019-12-21T19:02:32","Core":"2_6_1","SDK":"2.2.2-dev(38a443e)","Module":"Sonoff Basic","RestartReason":"Software/System restart","Uptime":"53T23:56:33","WiFi LinkCount":6,"WiFi Downtime":"0T00:08:34","MqttCount":189,"BootCount":23,"SaveCount":6961,"IPAddress":"192.168.0.5","RSSI":"60","LoadAvg":19}

HA is showing this??

2020-07-04 22:30:20 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities switch.sonoff_4
2020-07-04 22:30:21 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities switch.sonoff_2
2020-07-04 22:30:21 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities switch.sonoff
2020-07-04 22:30:21 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities switch.sonoff2
2020-07-04 22:30:21 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities switch.sonoff3
2020-07-04 22:30:21 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities switch.sonoff4

No devices being discovered in HA or the previously devices working in earliver versions of HA are still reporting not available.

Any help would be great.

THanks,

Rob.

Are you saying this worked when you used the embedded MQTT broker but no longer works with the broker you just installed?

You probably need to issue

setoption19 1

again in the tasmota console.

Yes correct thanks,

Was working with prior versions fo HA with the integrated broker now it doesn’t with the mosquitto broker installed.
Have set the SetOption19 1 as well.
Not sure if this make any differene but not running in a Hassbian environment but under a Noobs O/S on a RP3.

I assume the broker’s IP address hasn’t changed (i.e. it’s the same as the server hosting Home Assistant) so it’s probably an authentication issue.

What is the account that the Tasmota devices are using to login to the Mosquitto MQTT Broker? Or have you configured the broker to accept anonymous logins?

Thank you,
I’ve not touched any of the tasmota devices configuration as they appear to be logging into HA. In fact I did play with the username/password and it didn’t seem to make any difference.
Stopping the mosquito you can see the tasmota trying to connect so again it seems to be taling to Mosquito broker. COnversly can see HA error via the log if the Mosq. broker is stopped.

23:24:18 MQT: homeassistant/binary_sensor/A34134_SW_2/config =  (retained)
23:24:18 MQT: homeassistant/binary_sensor/A34134_SW_3/config =  (retained)
23:24:18 MQT: homeassistant/binary_sensor/A34134_SW_4/config =  (retained)
23:24:18 MQT: homeassistant/binary_sensor/A34134_SW_5/config =  (retained)
23:24:18 MQT: homeassistant/binary_sensor/A34134_SW_6/config =  (retained)
23:24:18 MQT: homeassistant/binary_sensor/A34134_SW_7/config =  (retained)
23:24:18 MQT: homeassistant/binary_sensor/A34134_SW_8/config =  (retained)
23:24:18 MQT: homeassistant/sensor/A34134_status/config = {"name":"Sonoff status","stat_t":"~HASS_STATE","avty_t":"~LWT","frc_upd":true,"pl_avail":"Online","pl_not_avail":"Offline","json_attributes_topic":"~HASS_STATE","unit_of_meas":" ","val_tpl":"{{value_json['RSSI']}}","ic":"mdi:information-outline","uniq_id":"A34134_status","device":{"identifiers":["A34134"],"connections":[["mac","68:C6:3A:A3:41:34"]],"name":"Sonoff","model":"Sonoff Basic","sw_version":"7.2.0(tasmota)","manufacturer":"Tasmota"},"~":"sonoff5/tele/"} (retained)
23:24:22 MQT: sonoff5/tele/STATE = {"Time":"2020-07-04T23:24:22","Uptime":"0T00:08:15","UptimeSec":495,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":2,"POWER":"OFF","Wifi":{"AP":1,"SSId":"wifi","BSSId":"D8:47:32:55:68:57","Channel":2,"RSSI":66,"Signal":-67,"LinkCount":1,"Downtime":"0T00:00:06"}}
23:24:22 MQT: sonoff5/tele/HASS_STATE = {"Version":"7.2.0(tasmota)","BuildDateTime":"2019-12-21T19:02:32","Core":"2_6_1","SDK":"2.2.2-dev(38a443e)","Module":"Sonoff Basic","RestartReason":"Software/System restart","Uptime":"0T00:08:15","WiFi LinkCount":1,"WiFi Downtime":"0T00:00:06","MqttCount":2,"BootCount":25,"SaveCount":6965,"IPAddress":"192.168.0.5","RSSI":"64","LoadAvg":19}
23:24:22 MQT: sonoff5/stat/RESULT = {"Version":"7.2.0(tasmota)","BuildDateTime":"2019-12-21T19:02:32","Core":"2_6_1","SDK":"2.2.2-dev(38a443e)","Module":"Sonoff Basic","RestartReason":"Software/System restart","Uptime":"0T00:08:15","WiFi LinkCount":1,"WiFi Downtime":"0T00:00:06","MqttCount":2,"BootCount":25,"SaveCount":6965,"IPAddress":"192.168.0.5","RSSI":"64","LoadAvg":19}
23:26:07 APP: Serial logging disabled
23:26:10 MQT: sonoff5/tele/HASS_STATE = {"Version":"7.2.0(tasmota)","BuildDateTime":"2019-12-21T19:02:32","Core":"2_6_1","SDK":"2.2.2-dev(38a443e)","Module":"Sonoff Basic","RestartReason":"Software/System restart","Uptime":"0T00:10:03","WiFi LinkCount":1,"WiFi Downtime":"0T00:00:06","MqttCount":2,"BootCount":25,"SaveCount":6965,"IPAddress":"192.168.0.5","RSSI":"64","LoadAvg":19}
23:26:19 MQT: sonoff5/tele/STATE = {"Time":"2020-07-04T23:26:19","Uptime":"0T00:10:12","UptimeSec":612,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":25,"MqttCount":2,"POWER":"OFF","Wifi":{"AP":1,"SSId":"wifi","BSSId":"D8:47:32:55:68:57","Channel":2,"RSSI":62,"Signal":-69,"LinkCount":1,"Downtime":"0T00:00:06"}}

Let’s confirm that as opposed to relying on appearances.

Go here and review the broker’s log (replace your_address with either the hostname or IP address of your Home Assistant server):

http://your_address:8123/hassio/addon/core_mosquitto/logs

You should see a record of the accounts used by Home Assistant and the Tasmota devices connecting to the Mosquitto MQTT broker.

Once you have confirmed the logs show evidence of their connection, use an MQTT client to subscribe to the same topic used by the Tasmota devices and observe what is being published. You can use MQTT Explorer or the one built into Home Assistant (in version 0.112 it’s now located in Configuration > Integrations > MQTT > Configure > Listen to a topic)

Sure, just keep in mind I’m not running in a hassio environment but here’s the logs from mosquito from /var/log/mosquitto/mosquitto.log:

1593862255: Opening ipv6 listen socket on port 1883.
1593862262: New connection from 192.168.0.5 on port 1883.
1593862262: New client connected from 192.168.0.5 as sonoff5 (c1, k30, u'homeassistant').
1593862262: New connection from 192.168.0.9 on port 1883.
1593862262: New client connected from 192.168.0.9 as sonoff1 (c1, k30, u'homeassistant').
1593862263: New connection from 192.168.0.12 on port 1883.
1593862263: New client connected from 192.168.0.12 as sonoff_4ch2 (c1, k30, u'homeassistant').
1593862263: New connection from 192.168.0.11 on port 1883.
1593862263: New client connected from 192.168.0.11 as sonoff_4ch1 (c1, k30, u'homeassistant').
1593862298: New connection from 192.168.0.111 on port 1883.
1593862298: New client connected from 192.168.0.111 as 35Vw0TZ5jk7zijyiMldcOt (c1, k60).
1593862298: Client 35Vw0TZ5jk7zijyiMldcOt disconnected.
1593862298: New connection from 192.168.0.111 on port 1883.
1593862298: New client connected from 192.168.0.111 as 2173cae9-57f4-4fca-91ab-1cec06f8c258 (c1, k60).
1593862364: Client 2173cae9-57f4-4fca-91ab-1cec06f8c258 disconnected.
1593862364: New connection from 192.168.0.111 on port 1883.
1593862364: New client connected from 192.168.0.111 as 01f86364-373d-48ac-9fde-b03de2430b15 (c1, k60).
1593863130: Client 01f86364-373d-48ac-9fde-b03de2430b15 disconnected.
1593863154: New connection from 192.168.0.111 on port 1883.
1593863154: New client connected from 192.168.0.111 as 14bf9c6e-34a2-49d3-8376-83f9456e1028 (c1, k60).
1593863908: Client 14bf9c6e-34a2-49d3-8376-83f9456e1028 disconnected.
1593863932: New connection from 192.168.0.111 on port 1883.
1593863932: New client connected from 192.168.0.111 as fb887b05-e8b3-4374-8bd0-1ba8ff4b118c (c1, k60).
1593864055: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1593864474: New connection from ::1 on port 1883.
1593864474: New client connected from ::1 as mosqsub|31317-raspberry (c1, k60).
1593864490: Socket error on client mosqsub|31317-raspberry, disconnecting.
1593864491: New connection from ::1 on port 1883.
1593864491: New client connected from ::1 as mosqpub|31336-raspberry (c1, k60).
1593864491: Client mosqpub|31336-raspberry disconnected.
1593864585: mosquitto version 1.5.7 terminating
1593864585: mosquitto version 1.5.7 starting
1593864585: Config loaded from /etc/mosquitto/mosquitto.conf.
1593864585: Opening ipv4 listen socket on port 1883.
1593864585: Opening ipv6 listen socket on port 1883.

Now interestingly I do wonder if the HA is talking to mosquito as after restarting HA and playing with removing and then adding the HA MQTT integration, the logs haven’t updated.

Okay stop, it’s fixed.
Have no idea why. All I simply did was remove/add the MQTT integration within HA and restart HA…which I’d previously had done prior to raising this issue.

Hmmm next test is to reboot the system from scratch and see what happens might leave it for today. But for now, big thanks to all the suggestions, Would be good to get some feedback on what I might have done wrong.
As a note lookign at the Mosquito logs nothing has been added pas the “1593864585: Opening ipv6 listen socket on port 1883”. So the log doesn’t seem to give any insight as to what the broker is doing…or not.

Rob.

Even if you are running Home Assistant Supervised, that URL will still work. If you are running neither Home Assistant OS or Home Assistant Supervised, that means you cannot install the Mosquitto MQTT Add-On because neither Home Assistant Container or Home Assistant Core support Add-Ons.

So how did you install the Mosquitto broker? If it’s not as an Add-On then it doesn’t share Home Assistant’s user accounts and you must create them separately.

Installed the mosquitto broker using this link:

Process was:
sudo apt install mosquitto mosquitto-clients
sudo systemctl enable mosquito
sudo systemctl status mosquitto
Removed all MQTT reference in configuration.yaml
Then added the integration withing HA. configure the integration to point to 127.0.0.1
And that’s, left the PWD/username on my tasmota devices as default.
…and remove and added MQTT intergation with HA and rebooted HA several times.
BTW the link didn’t work for checking the logs returned 404: Not Found

That’s a “bare metal” installation and probably the default where no authentication is required (i.e any MQTT client can login to the broker without supplying a username/password; minimally just a session identifier). Should you ever wish to improve security and add authentication, Steve’s Internet Guide has a concise article explaining how to do that.

You would definitely need to revise the configuration of the MQTT integration so that it no longer attempts to use the old embedded MQTT broker.

Because you’re not running the Mosquitto MQTT Broker Add-on.

Look through my posts and you’ll see I’ve referred to it several times, with the assumption that is what you chose to install. You only clarified that you were NOT running it in your most recent post.

Thanks again,

Yes it is bare metal, but now that it’s working can play with the security aspect.

“You would definitely need to revise the configuration of the MQTT integration so that it no longer attempts to use the old embedded MQTT broker.”
If you’re referring to the MQTT integration with HA yes the original embedded was removed and then created a new MQTT that pointed to 127.0.0.But in saying that I didn’t remove the Embedded MQTT until I realised sometime later some of the switches wern’t working.

That implies you temporarily had two MQTT brokers installed on the same machine, the old embedded one and the new one you just installed. Under no circumstances would that have worked correctly because both would be vying to use the same default port number (1883).

Sorry was referring to your statement:
If you have installed Home Assistant OS or Home Assistant Supervised, you can install the Mosquitto MQTT Broker Add-on.
I then intepreted MQTT broker Add-on and integration meaning the same thing.

Ouch! Negative. The two are very different.

Add-Ons are curated applications (such as Mosquitto, Node-Red, Samba, etc) distributed as custom docker containers. They are designed to work hand-in-glove with Home Assistant.

Integrations are the means by which Home Assistant communicates with devices and services (lighting, weather, etc).

Correct,but that was temporary and resolved before raised the issue on the forum.
But hey no idea here, as it now works and I have no idea why. Possibly maybe it didn’t remove correctly??

FWIW, I’m having the same issue with 112 (I started another thread).

In my case, I’m using the HA mqtt broker, and integration, so there’s no third party stuff in my setup.

Glad your’s is sorted out, a reboot hasn’t resolved my issue.

As a start, have a look at the logs on the tasmota device. See if they’re connecting.
Should see somethign like this: