Community Hass.io Add-on: MQTT Server & Web client

hassio-repository
hassio-addon
Tags: #<Tag:0x00007f1b9a70aa00> #<Tag:0x00007f1b9a70b3b0>

#102

Getting very frustrated beating my head against this (see linked thread). Is anyone using this plug-in with OwnTracks? If so, would you share your configuration? I need the plug in config and the “mqtt” and “device_tracker” blocks from configuration.yaml

Much appreciated.


#103

Does anybody know if it’s possible to add the customize folder to this addon?

I tried just adding to the addon config:

 "customize": {
   "active": true,
   "folder": "mosquitto"
   },

But it gets removed when I start the addon


#104

That is not supported.


#105

Ah ok, that explains why it wasn’t working haha

Thanks!


#106

Has anyone managed to make web interface work with external NGINX proxy?


#107

Yes.
I have it exposed behind a NGINX proxy.


#108

@ludeeus, would it be possible to include the plugin that allows recursively removing retained messages?

Great plugin BTW :smile:


#109

I looks like that plugin are ment to only run once (on demand) that is not great for an addon that are designed to allways run, or did I miss something?


#110

TBH I don’t know anything about the addon, it was just part of the same base system (HiveMQ) and I’d like some mechanism for removing retained messages recursively on the broker. If it isn’t a suitable addition then that is no bother.

[edit] - Is it possible to drop it into the plugins folder of the HiveMQ install? Where would I find that folder if it is? I realised this addon is using the HiveMQ client not the broker - apologies.

Cheers


#111

Does anyone know where this error is coming from?

HA can never connect to the broker while nodered can.

2018-10-30 14:21:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 354, in _async_add_entity
    await entity.async_added_to_hass()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/mqtt.py", line 177, in async_added_to_hass
    message_received, self._qos)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 306, in async_subscribe
    topic, msg_callback, qos, encoding)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 688, in async_subscribe
    await self._async_perform_subscription(topic, qos)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 723, in _async_perform_subscription
    _raise_on_error(result)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 808, 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.

Addon config:

mqtt:
  broker: hassio.local
  port: 1883
  client_id: ha_mqtt
  username: !secret mqtt_broker_username2
  password: !secret mqtt_broker_password2

Think i got at least part of the issue… ssl does not seem to be working for HA while it is for the nodered addon. Activating the non ssl part of the addon and using the config above “solves it”.
And i guess the error message above is not related…

But i am still wondering if HA should be able to use a selfsigned cert for ssl with this addon.
My cert is at the default location /ssl/…


#112

You may need to set tls_insecure and/or tls_version :man_shrugging:


#113

Hm i will try that :slight_smile: Thanks for the hint!


#114

Hi all
I am unable to connect to the broker from paho, my notebook is here, and I am using the default config with a single user robin (also used to the web UI).
In the addon logs I see:

1541484333: New client connected from 192.168.1.107 as hassio-mqtt-client (c1, k60, u'robin').
1541484336: Socket error on client hassio-mqtt-client, disconnecting.

I have enable_mqtt : false perhaps this is wrong. Set to true and try port 1883, now error is:

1541485174: New connection from 192.168.1.107 on port 1883.
1541485174: Socket error on client <unknown>, disconnecting.
1541485179: New client connected from 192.168.1.107 as hassio-mqtt-client (c1, k60, u'robin').

UPDATE: using port 1883 this is now working. I’ve updated my notebook. I don’t understand what the difference between using ports 1883 & 1884 is


#115

1883 are for non-ssl MQTT and 1884 are for non-ssl WS


#116

I’m only able to publish around 2 packets from my micropython board before I receive the error:

[Errno 104] ECONNRESET

Source code here. Any ideas?

UPDATE: I’m also seeing this in my HA logs (configured to use the broker):

2018-11-07 07:44:26 WARNING (Thread-2) [homeassistant.components.mqtt] Disconnected from MQTT (1). Trying to reconnect in 64 s

UPDATE 2:
OK I think I’ve identified that this error occurs when I am using the same client_id on both my homeassistant and my micropython board. Appears to require a reset of the broker to clear the error.


#117

This is a great add-on but I am still struggling to get it to work. I have used the Mosquitto broker before but want to move to MQTT Server & Web Client, so I deactivated the former.

However, I cannot call up the Web UI (“Safari can’t connect to myhome.duckdns.org:5713”)

So, somewhere along the way, I have not configured something correctly.

My Config is:

{
  "log_level": "info",
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "web": {
    "enabled": true,
    "username": "xx",
    "password": "xxx",
    "ssl": true
  },
  "broker": {
    "enabled": true,
    "enable_ws": true,
    "enable_mqtt": true,
    "enable_ws_ssl": true,
    "enable_mqtt_ssl": true,
    "allow_anonymous": false
  },
  "mqttusers": [
    {
      "username": "xx",
      "password": "xxx",
      "readonly": true,
      "topics": [
        "#"
      ]
    }
  ]
}

and I am using the default ports.

The log upon restart says:

**[s6-init] making user provided files available at /var/run/s6/etc…exited 0.
**[s6-init] ensuring user provided files have correct perms…exited 0.
**[fix-attrs.d] applying ownership & permissions fixes…
**[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts…
[cont-init.d] 00-banner.sh: executing… **
-----------------------------------------------------------
**** Hass.io Add-on: MQTT Server & Web client v0.1.1

**** Mosquitto MQTT Server bundled with Hivemq’s web client

**** From: Community Hass.io Add-ons

**** By: Franck Nijhof [email protected]

-----------------------------------------------------------
**** aarch64 / HassOS 1.10 / HA 0.81.6 / SU 139 / stable

**-----------------------------------------------------------
**[cont-init.d] 00-banner.sh: exited 0.
****[cont-init.d] 01-log-level.sh: executing… **
**Log level is set to INFO
**[cont-init.d] 01-log-level.sh: exited 0.
****[cont-init.d] 02-updates.sh: executing… **
**INFO: You are running the latest version of this add-on
**[cont-init.d] 02-updates.sh: exited 0.
****[cont-init.d] 10-requirements.sh: executing… **
**INFO: Password is NOT in the Have I Been Pwned database! Nice!
**[cont-init.d] 10-requirements.sh: exited 0.
****[cont-init.d] 11-patches.sh: executing… **
**patching file /app/index.html
**[cont-init.d] 11-patches.sh: exited 0.
****[cont-init.d] 20-mqtt_broker.sh: executing… **
**INFO: Adding configuration for MQTT Server…
**INFO: Setting configuration for websockets…
**INFO: Setting configuration for mqtt…
**[cont-init.d] 20-mqtt_broker.sh: exited 0.
****[cont-init.d] 21-mqtt_web.sh: executing… **
**[cont-init.d] 21-mqtt_web.sh: exited 0.
****[cont-init.d] 40-nginx.sh: executing… **
**Adding password for user pi
**[cont-init.d] 40-nginx.sh: exited 0.
**[cont-init.d] done.
**[services.d] starting services
**[services.d] done.
**INFO: Starting NGINX for the MQTT client…
**INFO: Starting mosquitto MQTT Server…
**1541817426: mosquitto version 1.4.15 (build date 2018-03-04 15:36:00+0000) starting
**1541817426: Config loaded from /opt/mosquitto.conf.
**1541817426: Opening websockets listen socket on port 1884.
**1541817427: Opening websockets listen socket on port 4884.
**1541817427: Opening ipv4 listen socket on port 1883.
**1541817427: Opening ipv6 listen socket on port 1883.
**1541817427: Opening ipv4 listen socket on port 4883.
**1541817427: Opening ipv6 listen socket on port 4883.

  1. Is there anything that needs to be defined in configurations.yaml?
  2. What determines the port numbers?

#118

Try using https://IPADDRESS:5713

If you want to connect HA to the broker, then yes it will need to be defined.
https://www.home-assistant.io/docs/mqtt/broker#run-your-own

There are 5 ports mapped to to addon.
1883 non-ssl MQTT port
1884 non-ssl WS port
4883 ssl MQTT port
4884 ssl WS port
5715 WebUI port


#119

Thanks much @ludeeus, that seemed to have done the trick! I have access to the webclient and I can connect to the broker.

Just to check: is there anything else that I should have to enter in configurations.yaml besides this:

#Mosquitto broker
mqtt:
    broker: 192.168.xxx.xx
    username: !secret mqtt_my_username
    password: !secret mqtt_my_password

#120

That should work, but your mqtt user has “readonly”: true,


#121

With the latest update to mosquitto add-on the bridge between cloudmqtt and mosquitto, for my devices using owntracks stop working, with this add-on can do it?and how?