Checking MQTT is working on Hass.IO version 0.99.3

Hi All,
I have been using hassbian a while back and it was simple installation - since i was not involve in home Automation and it did the simple tasks that i needed, So I was satisfied with it. Had not have MQTT on it - so I am not experienced with Message Queuing.

Now that I am REALLY interested in making Home Automation works - i have already got a couple of Raspberry Pi’s 3 Model B and I have decided to plunge into the HassIO as it was suggested to me.

So that exactly what I did, and realized that IT HAD CHANGED A LOT since I worked with it.
Now I have version 0.99.3 (latest) installed using the image provided for RPI3 and RPI3B.

I have unstalled configurator and Node Red and also ESPHome and also made it to work with DuckDNS remotely.
Now that I want to start making it the main MQTT Hub I have difficulties to understand How to do it?

I have Installed the MQTT Broker from Hass.IO add-on page. Mosquitto broker page
Added a dedicated user with password.
and set it up as follwed:

{
  "logins": [
    {
      "username": "mymqttuser",
      "password": "mymqttupass"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": true,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

I also made the change to ACL mentioned in the MQTT Broker page since I installed version > 4.1 of the MQTT Broker.

 "active": true,

and created the mosquitto folder under

/usr/share/hassio/share

and created the files needed including information required.
I have created the files:

/usr/share/hassio/share/mosquitto/accesscontrollist
/usr/share/hassio/share/mosquitto/acl.conf

and edit the MQTT credentials in them.
After making the above changes I started the MQTT Broker.
Not sure what exactly it is doing in the background.
Q: Do I need to manually install mosquitto?
After Clicking START and made the integration to the MQTT and enabled Discovery I have the following in my log:

[21:18:05] INFO: Setup mosquitto configuration
[21:18:05] INFO: Found local users inside config
[21:18:06] INFO: Initialize Hass.io Add-on services
[21:18:06] INFO: Initialize Home Assistant discovery
[21:18:06] INFO: Start Mosquitto daemon
1570385886: Loading config file /share/mosquitto/acl.conf
1570385886: mosquitto version 1.6.3 starting
1570385886: Config loaded from /etc/mosquitto.conf.
1570385886: Loading plugin: /usr/share/mosquitto/auth-plug.so
1570385886: |-- *** auth-plug: startup
1570385886:  ├── Username/password checking enabled.
1570385886:  ├── TLS-PSK checking enabled.
1570385886:  └── Extended authentication not enabled.
1570385886: Opening ipv4 listen socket on port 1883.
1570385886: Opening ipv6 listen socket on port 1883.
1570385886: Opening websockets listen socket on port 1884.
1570385886: Opening ipv4 listen socket on port 8883.
1570385886: Opening ipv6 listen socket on port 8883.
1570385886: Opening websockets listen socket on port 8884.
1570385886: Warning: Mosquitto should not be run as root/administrator.
1570385923: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database

It seems like Everything is Workimg… But I am Confused since I don’t EVEN know how to test if MQTT is working or not?
Q: Why does it say 172.30.32.1 When my RPI IP is 192.168.1.XX?
1570385923: New connection from 172.30.32.1 on port 1883.

I also added the following to my configuration.yaml

mqtt:
  discovery: true
  broker: 192.168.1.XX # My RPI IP
  port: 1883
  username: mymqttuser
  password: mymqttupass

I am not sure I understand what I am doing wrong?
I would be happy to get help on testing the MQTT since when I tried testing the example provided I got Error about double payload or something like that.
using the

mqtt.publish

with the payload:

{
  "topic": "/homeassistant/hello",
  "payload": "This is great",
  "payload_template": "{{ states('sensor.temperature') }}",
  "qos": 2,
  "retain": true
}

And it failed to call service.
I tried deleting one of the payloads and the error message was gone. But no indication if the Service was succeeded at all. So I do NOT even know if I have an MQTT server running at all.

I want to be sure that my MQTT server is UP and running as it should before I am starting adding devices - Since i will not be able to figure out the cause if nothing works. Is it the Server or the device?

I am VERY sorry for the VERY long Question;
I am New with Hass.IO and HA in general. and I would be happy to start Automating my home.
Please assist my with understanding what i was doing wrong? and I would be happy if someone can answer my two questions above as well.

I have so many things I want to implement using HassIO and Node RED and MQTT, I have been watching so many tutorials that I am so eager to Start.

Thank you so much
Aryeduino

1 Like

Did you add a home assistant user?

My access control list:

user mqtt_user <--- your user will be different
topic #
user homeassistant
topic #

172.30.32.1 is the docker container IP address.

Do not add any mqtt configuration yaml. It is a discovered integration and not needed. Delete it. Restart. Then go to the Configuration / Integrations panel and set up the mqtt integration.

Thanks Tom,
Since i am new I would be happy to know where should i add the control list?

BTW, When I do the integration it does NOT ask me to setup any configuration of my MQTT server. Only gives me a check box for discovery and I check it. and when I click on the MQTT again I am getting EMPTY page.

Where should I set the MQTT information?

I am getting this Error While trying the example MQTT:

Log Details (ERROR)
Mon Oct 07 2019 12:42:56 GMT+0300 (Israel Daylight Time)
two or more values in the same group of exclusion 'payload' @ data[<payload>]
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1212, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 576, in validate_dict
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: two or more values in the same group of exclusion 'payload' @ data[<payload>]
Failed to call service mqtt/publish. two or more values in the same group of exclusion 'payload' @ data[<payload>]

Thanks

I have only the mqttuser setup

user mymqttuser
topic readwrite #

Isn’t that enough? thanks

Tom You did it.
I have edited my access control list EXACTLY the same as yours (using my mqtt user name) and It works.
I went to the MQTT tab and
start listening to:
home-assistant/light/1/
and I can see the payload - thank you.

Just would be on the subject and have two questions

  1. QoS and retain? What are these for?

  2. How can I test the MQTT from my LAN? is there a tool that I can use? I still don’t have any devices ready to publish. Can I test it from the LAN and see that the IP is really 192.168.1.XX?

Thank you so much :slightly_smiling_face:

Retained messages are sent to each client as soon as they subscribe to a topic that contains retained messages. This means the client does not have to wait until the broker receives the next message before the client is updated.

It can be a blessing and a curse.

It works well for things like discovery configuration but can cause issues with switch states if not used carefully. See this video about Tasmota and mqtt retain: https://youtu.be/31IyfM1gygo

QoS (Quality of Service) determines how hard the broker or client tries to get a message through.

  • QoS 0: “spray and pray”. Send the message once and hope it gets through. Like the the IP UDP protocol.
  • QoS 1: Looks for acknowledgement of message reception. Messages can be received more than once because of this (due to missed acknowledgements).
  • QoS 2: Two way handshaking to ensure the message is received exactly once. Like the IP TCP protocol.

You can read more about it here (in fact reading all the “mqtt essentials” topicsis a good idea) https://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels/

In practice on a robust local network QoS 0 or 1 is sufficient.

Download MQTT-Explorer or MQTT.Fx. These clients run on your PC and allow you to view and delete retained messages on your broker, see messages arrive in real time, and publish to topics, plus more.

I prefer MQTT-Explorer for subscribing and deleting, MQTT.fx for publishing.

1 Like

Thank you very much Tom!!! :clap::clap::clap: for your help
I have been using the two MQTT clients and learning so much about QoS and Retain.
I have already made a mockup in Node Red and I can see a graph build up using my Randon Number generation function that I am using with injecting by interal and having the MQTT server Works like it should.
Works with localhost and also with it’s LAN IP.
I wonder if I can use gafana to show the graph from the MQTT server since I already have the MQTT Explorer show me a graph as well. I am sure that It can be added to grafana as a datasource.
Just wonder if I need to connect it using 192.168.1.xx:1883 using the Credentials I gave to the MQTT user.
Maybe i will need to understand how to get a feed from a topic into a graph.
That might be the next step after i will install REAL sensors and understand how to connect them to the MQTT.

Thank you Tom!!!

Thanks for Everything - you have motivate me so much and now I have already have the MQTT running as it should and testing it.
I have read about Keeper - Is it any good? can I install it now to my Hass.IO 0.99.3?
Keeper Github
I have read that it monitor the HA and the MQTT so it might be good for what i am looking for.

Any suggestions?
Should I go this path or not?
Anyone has an experience with Keeper on the latest Hass.IO?

Thank you!
Aryeduino

It’s not necessary.