Home Assistant Community Add-on: MQTT Server & Web client

I’m not sure about anything but you seem to enjoy drip feeding information.
So here it’s connecting to the local IP address

Up above I posted a connection to the web interface on https://subdomain.domain.duckdns.org

so the subdomain has a certificate…

In the broker I have:

{
  "plain": true,
  "plain_websockets": true,
  "ssl": false,
  "ssl_websockets": false,
  "anonymous": false,
  "logins": [

If I set ssl_websockets: true it doesn’t start. I’m not sure how caddy stores the certificates. in the ssl folder I don’t see anything looking like the standard certificates.

You are telling me this:

And I’m replying that a ssl port require a certificate. (Confirming that this will not work)

Then you are mixing in your webbrowser:

Note that I do this on my limited free time, and therefore I will not write more then I see nessesarry, and I will not teach you about basics of networking, there are far better resources out there for that.

Short: the enpoint/server/site/broker (whatever really) that you are trying to connect to with SSL needs a valid SSL certificate.

If you look in the add-on log I guess you will see “FATAL: certfile not found”, this will block it from starting.

I have not used that, try looking at the docs for it, or ask the developer of it.

and I appreciate your time.
I can use via local IP address:5713 so I can just delete the iFrame and be happy. It’s not like I need to look at my MQTT messages all the time anyway. I will probably only start the addon when I need to use it.

Thanks for your help.

Ah top man!

Glad it was something so simple, I think I saw ‘Mosquitto’ and assumptions kicked in!

Ill change that tonight and swap back over.

Many thanks and much appreciated :smiley:

1 Like

Could someone post an example of how to add multiple mqttusers? the old logins format doesn’t seem to work

Hav no idea what that means, but this works:

  "mqttusers": [
    {
      "username": "user1",
      "password": "user1",
      "readonly": false,
      "topics": [
        "#"
      ]
    },
    {
      "username": "user2",
      "password": "user2",
      "readonly": true,
      "topics": [
        "homeassistant/states"
      ]
    }
  ]

Tried that and when I restart it erases everything but the last user

Cancel that, I forgot the top “{” it works now thank you!

So I have a basically default configuration, including the user topic set to “#”

I can connect via webclient, but when I try to publish a test message, I get nothing, and the log shows:

1540012366: Received SUBSCRIBE from hassio-mqtt-client
1540012366: 	test_topic/ (QoS 2)
1540012366: hassio-mqtt-client 2 test_topic/
1540012366: Sending SUBACK to hassio-mqtt-client
1540012370: Denied PUBLISH from hassio-mqtt-client (d0, q0, r0, m0, 'test_topic/', ... (4 bytes))
1540012371: Denied PUBLISH from hassio-mqtt-client (d0, q0, r0, m0, 'test_topic/', ... (4 bytes))
1540012371: Denied PUBLISH from hassio-mqtt-client (d0, q0, r0, m0, 'test_topic/', ... (4 bytes))

Any ideas?

Own tracks seems to be sending location notices correctly, but I can’t see them in the app, only in the log.

Did you change this "readonly": true, to false for that user?

:tada: Release MQTT v0.1.1

  • Fixes a startup issue where allow_anonymous was true and no users were defined.

Changelog: https://github.com/hassio-addons/addon-mqtt/compare/v0.1.0...v0.1.1

I always get the following error when HA (hassos) starts up:

'Error talking to MQTT: {}'.format(mqtt.error_string(result_code)))
homeassistant.exceptions.HomeAssistantError: Error talking to MQTT: The client is not currently connected.

And my mqtt sensor do not show up anymore. I cant even see them as sensors anymore.
I am wondering why this happens as norered and the webclient can connect without any issues, sending and reading messages is working as well. Just HA itself cannot connect.
I guess this message is appearing as HA tries to connect to the MQTT broker while its not yet started but i am not sure.

My config is as follows:

mqtt:
  broker: hassio.local
  port: 4883
  client_id: ha_mqtt
  username: !secret mqtt_broker_username2
  password: !secret mqtt_broker_password2
  certificate: /ssl/certificate.pem

A sensor for example:

  - platform: mqtt
    name: floortemp
    unit_of_measurement: '°C'
    state_topic: "home/floor/floortemp"

I have had another MQTT broker running on another server and the sensors were working fine…
Another error i can see in the addons log is:

1540029951: OpenSSL Error: error:14037418:SSL routines:ACCEPT_SR_KEY_EXCH:tlsv1 alert unknown ca
1540029951: OpenSSL Error: error:140370E5:SSL routines:ACCEPT_SR_KEY_EXCH:ssl handshake failure

Any ideas?

Greetings

If you use SSL I think you need to use the domainname that the certificate is issued to.
That is probably not hassio.local since AFAIK you can not get a cert for a .local domain.

Its a self signed certificate for the local domain :slight_smile:

Thats why…

Yes.

But I’ve figured it out. The way I set it up, the web user name was different from the broker username. So the web user name let me log into the webclient, but not publish. Making the two identical resolved the issue.

I don’t recall seeing this in the documentation. I might have missed it, but if not, perhaps it should be explicitly stated.

If i remove the line for the certificate the sensors show up but they wont be updated with the actual data… they stay at unknown state.

So it looks like I got MQTT running, and using the web interface can publish test packets and see packets pushed by OwnTracks. Great.

I installed MQTT mostly for OwnTracks. I set up OwnTracks with the following code:

device_tracker:
  - platform: owntracks
    max_gps_accuracy: 200
    waypoints: true
    mqtt_topic: "owntracks/#"

But when I restart, I get the following errors in the HA log:

Timer got out of sync. Resetting
2:39 PM core.py (ERROR)

Error setting up platform owntracks
2:39 PM components/mqtt/__init__.py (ERROR)

Unable to load /config/known_devices.yaml: Config file not found: /config/known_devices.yaml
2:39 PM components/device_tracker/__init__.py (ERROR)

Expanding the middle one shows:

Error setting up platform owntracks

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 180, in async_setup_platform
    hass, p_config, tracker.async_see, disc_info)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/owntracks.py", line 93, in async_setup_scanner
    hass, context.mqtt_topic, async_handle_mqtt_message, 1)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 280, in async_subscribe
    topic, msg_callback, qos, encoding)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 662, in async_subscribe
    await self._async_perform_subscription(topic, qos)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 697, in _async_perform_subscription
    _raise_on_error(result)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 782, 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’m wondering if this is a timing issue. When I restart MQTT (using the plugin controls), it takes quite a while for it to come all the way up - on the order of minutes. Could it be that HA is expecting MQTT to be up before it is ready?

Any advice appreciated.

First error are missing a file. Create that file.

The addon should start before HA, so it should not be an issue.

I use this to connect and do not have any issues:

mqtt:
  broker: a0d7b954-mqtt
  port: 1883

Well, creating that file did clear the error. But not the main one.

I tried using that line for broker, though with port 4883, since I’m using SSL. I have plain MQTT turned off. No joy. I think I’ll try enabling plain, next.

So, some progress. I think there were permission issues. After fiddling with usernames, passwords, and such, the error has gone away. But now I’ve got a different problem - there’s no error, but no sign that the device tracker is there. I think I’ll start a new thread, this seems outside the scope of this one.

Thank you for your help!

Still having issues. I posted a separate thread, but no response so far. The thread is here, in case anyone can help: