[TUTORIAL] Setting up MQTT on Homey for configuring Home Assistant for dashboard purposes

Nope nothing happens, also checked the client.
So is the client the problem?

Just out of interest is the MQTT broker on your Synology currently or the internal Scanno one on Homey ?

The broker in Homey never workt for meā€¦ Currently iā€™m using the broker from Hass.io.
Before on my Synology.

The MQTT broker as installed via an addin in Hass.io ? So running in a Docker container. I just wonder if thereā€™s any security issue imposed with that - but then MQTT Hub > MQTT Client from Homey is updating the homie topic correctly so seems OK. You can see it update yes ??.. not just retained old values. I run Mosquitto on the same machine as hass but currently not in a Docker.

@David_Maas can you PM me the full MQTT Hub debug log, with only one device enabled?

I expect the MQTT client is not correctly subscribed to the required topic(s), because messages are not being received.

The reason can be multiple: the hub failed to subscribe (e.g. socket error), MQTT client failed to subscribe (e.g. thinks itā€™s already subscribed), connection failure between mqtt client & broker (security?), something else (an unknown bug?)ā€¦

Iā€™m following this with great interest as my issue is approx the same. Hopefully the solution to Davidā€™s problem also solves my issue.
One thing I find strange on my hass.io installation on Rpi (image from hass.io for Pi2) is I canā€™t see the configuration.yaml file. I canā€™t ssh to it (connection refused) and through Windows SAMBA the Piā€™s IP also is not accessible. I donā€™t have any experience with programming, so donā€™t know how to set-up hass.io or the MQTT broker in hass.io.
When I install the add-on package for configuration it should appear in the left menu bar of hass.io. But this is not happeningā€¦ Iā€™m kinda lost

Thats more of a HASS.IO issue that the purpose of this topicā€¦

However, dont fear your lack of experienceā€¦
Follow this guide and you will have SSH. Hardest part, depending on your set up is getting your pi hooked up to a monitor/keyboard/mouse

I pulled out the SD card of the Pi2 and inserted it in a Linux Mint installation. Under 1 of the 4 partitions on the SD-card I found the configuration.yaml file. It looks like a virginā€¦ brand new :wink:

Blockquotehomeassistant:
#Name of the location where Home Assistant is running
name: Home
#Location required to calculate the time the sun rises and sets
latitude: 52.4592
longitude: 4.6119
#Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 0
#metric for Metric, imperial for Imperial
unit_system: metric
#Pick yours from here: List of tz database time zones - Wikipedia
time_zone: Europe/Amsterdam
#Customization file
customize: !include customize.yaml
#Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
#Show the introduction message on startup.
introduction:
#Uncomment this if you are using SSL/TLS, running in Docker container, etc.
#http:
#base_url: example.duckdns.org:8123
#Discover some devices automatically
discovery:
#Sensors
sensor:
weather prediction
-platform: yr
#Text to speech
tts:
-platform: google
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

It looks like it is write protected :thinking:

when I go to : https://www.home-assistant.io/docs/installation/synology/ I see an error about pyhton. but I donā€™t quie get whether when I use docker whetehr it works then with the newest home automation version? I reallyā€™d like a dashboard function in my homeyā€¦so yeah :slight_smile:

Iā€™m one step further in configuring the hass.io, the configuration.yaml and the broker.

I only need to know how to configure the broker (what to add to configuration.yaml).

I have the embedded mqtt broker in hass.io.
So I donā€™t need to add an IP address to the configuration file (I assume).
What about username and password? Is this still the same as in Homey mqtt client?

It works! After days of stuggling, i decided to remove all apps on the homey - restarted homey, reinstalled the client (make sure you uncheck both checkmarks) and hub. Iā€™m using the broker on my rassberry hassio installation. And it is working!

@NoClaim You can still enter the web gui - Go to addons- configure addon - open it and you will see Use Web Gui.

Thank everyone for your patience.

Edit: And special thanks to Harrie, helped me a lot in private. Bought you a beer for your help and great app!

3 Likes

Okā€¦ this keeps me motivated :slight_smile: I just removed everything from homey (client and hub) and turned off the RPI. Now I will start trying again.
Anything special I need to look at? Iā€™m guessing I all has to do with how I setup the Broker under hass.io and the configuration.yaml

And I managed (with a little bit of reading on hass.io) to add the configurator to the left panel in hass.io. And during this exercise I also noticed I could use the Web GUI link in the add onā€¦ sometime a little bit of reading (and patience) will help :slight_smile:

With mqtt client configuration on Homey no checkmarks are checked.So there is nothing to uncheckā€¦ or am I missing something? (except for a few braincells :frowning: )

I have no section mqtt in my configuration.yaml file. This clearly is not automated. Do I need to add something to the configuration file?

I have set a username and password in both mqtt client and broker, is this required?

When I check the mqtt addon log I see for almost every line (where noclaim is the username I use)

mosquitto_auth_acl_check(ā€¦, client id not available, noclaim, homie/homey/essent-stroom/measure-power, MOSQ_ACL_READ)
1553805216: |-- aclcheck(noclaim, homie/homey/essent-stroom/measure-power, 1) CACHEDAUTH: 0

Having some trouble setting all up. Few questions I donā€™t understand yet.

1: Iā€™m using the mqtt client, mqtt hub and mqtt broker on homey. Then I have installed HA on raspberry pi with the add-on mosquitto broker. As stated above the topics will go from: Homey - hub - client - broker - HA. Do I use the broker double now? In other words. Can I delete the broker app from my homey and use the HA mosquitto broker to connect to the client app on Homey?

2: When setting up a dashboard on the HA interface, I have to select the entity (device). Should all Homey devices appear with their name on my entity list in HA or do I have to add them all manually?

  1. Yes. You can remove the Homey broker app. Use Mosquitto on your pi.
  2. Yes. All devices should appear automatically (see MQTT Discovery).
1 Like

Iā€™m currently configuring and learning HA. Iā€™ve set up MQTT stuff as described in tutorial and works fine. While configuring HA, i have to restart it several times. I notice sometimes in MQTT explorer the HA topics are gone. I can fix this by restarting the MQTT hub and client.

How can I make sure I donā€™t have to do this? Like I said this happens sometimes, so itā€™s mostly working when I restart HA.

As Harrie replied you only ever need one MQTT Broker. I too recommend avoiding the Homey inbuilt option. Itā€™s very likely your other hardware that youā€™re using for HomeAssistant, openHAB or whatever is more powerful than Homey and installing Mosquitto there will work better , leaving Homey less encumbered.

When you send data to an MQTT broker you predefine whether that data should be retained (stored on) the broker or not. What this means is that a later connecting client can retrieve the last data and so be kept up to date with the last 'published data. MQTT Explorer is such a client - if previous data was published with ā€˜retainedā€™ flag set then it will be able to read that data, if retained was ā€˜falseā€™ then nothing has been stored on the broker and it will only get an update when new data is sent.

Whether you should publish data ā€˜retainedā€™ or not is important and impacts how the topics work together. MQTT Hub via Homie3 and the HA Discovery protocol use both appropriately. What you are noticing is that the HA topics are correctly published without a ā€˜retainedā€™ flag.

Now - there are a couple of ways around this. You can manually push the ā€˜broadcastā€™ button in MQTT Hub - this will send again the HA topics. You donā€™t need to totally restart it. Obviously this is a manual solution.

The preferred way is to set up the ā€˜last will and testamentā€™ from HA. What this does is send a message when HomeAssistant leaves/joins the MQTT broker. MQTT Hub sees this and will automatically resend the HA topic tree so it is kept bang up to date. Details on how to configure this are in this or one of the related topics. Iā€™m in a bit of a rush currently but Iā€™ll have a search later and update - if you havenā€™t found it before.

I already configured this ā€˜last will and testamentā€™ on HA. This is in my configuration under mqtt:

birth_message:
topic: ā€˜hass/statusā€™
payload: ā€˜onlineā€™
will_message:
topic: ā€˜hass/statusā€™
payload: ā€˜offlineā€™

Not sure if this is correct?

I also had it enabled in MQTT Hub. I didnā€™t change topics and message values there. Is all of this what you mean or do I miss something to fix it?

I already thought so by reading the posts above. Configured all well now. The broker on the pi receives the topics when I change temperature in example. Now need to figure out how to setup the dashboard. I canā€™t seem to find how the entities work on HA dashboard. Entities wonā€™t show automatically.

Edit: switched the discover home assistent off and back on and broadcast devices again and all devices showing up now. Only messages dont seem to go back to homey yet but Will figure out this week.

Let me know if you work this out as mine are only one way (change on Homey reflected in HA but canā€™t change them from HA).