My first steps discovering Home Assistant, setting up a HA client to an existing MQTT Broker

Hi to you all!

First of all, let me summarize my current setup, in short:

  • Hardware: Raspberry Pi 3+ with Raspbian Stretch with desktop.
  • Configured: Node-Red with encrypted login using a self-signed certificate.
  • Configured: MQTT broker, encrypted communications using self-signed certificate and using user/password authentication.
  • Configured: Home Assistant 0.73.2 setup with encrypted user/password login using self signed certificates.

I don’t know anything about Home Assistant, so please be patient with me… :cold_sweat:

The reason to try this because I’m fed up with Fibaro, manufacturer of my current HC2 Z-Wave controller. In short, I do not like their closed source approach…

The best way to learn a new system, IMHO, is to set a goal and try to achieve it. That’s why I need you guys…:wink:

My first goal is to setup an working Home Assistant MQTT client <—> MQTT broker (localhost). I do not want to use the Home Assistant MQTT broker solution.

The current MQTT broker is already communicating with several other IoT devices, like an Athom Homey/Tablet/HC2-controller, managed by Node-Red.

To get the Home Assistant MQTT client to communicate with the MQTT broker it will need to accept a self-signed SSL certificate and it would need an option to use a user/password.

So, where can I start with accomplishing this? :crazy_face:

Thank you in advance, it’s highly appreciated!

Start by reading the documents

1 Like

I did @gpbenton. It’s about broker configuration. I want to create an client setup.

Because I’m completely new to Home Assistant I need some guidance here…

Thanks for the quick respond, though!

No, that page is about setting up HA as client to your broker.

OK. Will read it first. If I have questions I will come back. Thanx.

Ok, looks like I could use that.

so my setup looks something like:
# Example configuration.yaml entry
broker: localhost
port: 8883
username: <MY_USER_NAME>
password: <MY_PASSWORD>
tls_insecure: true

If I use the tls_insecure-option will this mean my MQTT-broker self-signed certificate will not be verified and the certificate-option has not to be used?

I have never used a certificate (I only use mqtt on my network), but my understanding is that you need to specify the certificate, but it doesn’t check the certificate against a trusted authority, allowing you to use a self-signed certificate.

Thank you @gpbenton, then I have to use the MQTT-broker certificate. Maybe I should do some testing.

Because I’m completly noob on HA, just some questions to see whether I understand some basic HA principles:
1 - I must add the above rules to configuration.yaml right? Do have to reboot HA or something like that to get the changes activated?
2 - Is there a (proper) way to get configuration.yaml edited from within the HA frontend-UI?
3 - Also, is there an easy way to backup HA in case something goes wrong?


Okay, so far so good. This is what I did so far…

1 - Made a new file, in same directory as configuration.yaml, called mqtt.yaml
2 - Edit the file and add:

# 20180721
# Include in configuration file configuration.yaml
# mqtt: !include mqtt.yaml
broker: localhost
port: 8883
username: <MQTT_USERNAME>
password: <MQTT_PASSWORD>
tls_insecure: true

3 - Included in configuration.yaml:

mqtt: !include mqtt.yaml

4 - Went to the frontend-UI and validated the changes which were OK (yes!)
5 - Reloaded the core, and checked logs and info pages for errors, looking good!

Now I have to find a way to check if the mqtt is really working. Probably I have to make a device of some kind.

Need to some reading to do I guess…:thinking:

you should be able to SSH into your Pi and subscribe to one of your existing topics and see the traffic being sent. then you could publish to a topic and check the topics on your broker to see if the broker saw the message.

I use MQTTFx on a windows PC to subscribe/publish messages to check the operation of the network. It’s pretty straight forward to use.

I know that my MQTT is working, I’m already using it (Homey/Tablet/Telegram etc) configured by Node-Red.

Now I have to check if HA is listening. Probably I have to set device configuration in mqtt.yaml which contains the topic were it has to listen to, right?

As I said, HA is very new to me… Call me an absolute noob. :roll_eyes:

Right. read the first sentence in my post… You can go into your Pi via SSH and subscribe to an existing topic and see if the PI receives the message. That way you know if HA has been successfully added to your MQTT network and is listening.

Then just a double check you can publish to a topic and see if your broker receives it.

Another question is did you install the MQTT client software to the Pi running Home Assistant?

Sorry @finity, I don’t understand what you mean… :flushed:

For example, I want to monitor an already configure MQTT device on a topic HC2/devices/status/619, which is a temperature Zwave device connected to my Fibaro HC2 gateway and sending it’s value to this topic (on change).

I can see this value is transmitted because I can monitor it with Node-Red.

The question is, how do can I monitor this with HA?

BTW, I use a MQTT broker installed in RasPi, not one initiated by HA.
EDIT: I’m not using

OK. your broker is on a different RPi than the one you have HA installed on or on the same one?

On the same one.

do you have a way set up to monitor the MQTT traffic on your network?

I use MQTTFx on my windows PC, connect to my broker and subscribe to # (all topics). That way I will see all messages that are transmitted across the network.

I can, using Node-Red. I don’t use Windows, I’m one of this weird Linux users…:scream:

OK good enough. :grinning:

Now go to the services panel in HA (it’s in the hamburger menu on the left at the bottom and looks like a “remote” icon). Once there drop down the menu where it says service and look for mqtt.publish. in the service data area put (as the example in the docs shows)

  "topic": "home-assistant/light/1/command",
  "payload": "on"

fire up you MQTT monitor, subscribe to all topics and then click “call service” and you should see the topic and payload above pop up on the monitor.

1 Like

I don’t think these were answered in the previous posts, but apologies if you know already

You have to restart home assistant to get the changes to any yaml file. There is a an option to do this from the services tab. Note that this is homeassistant/restart not the option you mentioned above. But I don’t normally have the front end open, so I normally just restart the service

I have heard there is, but I have never used it. I am a terminal/vim user.

All the configuration files are in the yaml, which is all you need to back up your HA configuration. I have these in a git repository offsite, which I update from my test virtual machine and pull it to my Pi from there.

Of course, it is generally a good idea to take a dump of your SD card periodically. I will get around to that again eventually.

1 Like