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

Do you still need :

  • Mosquitto (Synology package)

when you sue teh rboker and client and hub on homey?

more important question. Why would I want to sue home assistant? and would I run it on a pi then I presume? Soemthing new for em it seems ^^

Wrote some logic to retry topic subscription on failure. If a subscription fails, Homey does not listen to triggers from outside apps. Maybe this helps addressing the above problems.

If you use the MQTT broker on Homey then you don’t need to run Mosquitto on Synology.

Concerning your other question; i obviously cannot answer this since you are asking yourself a question and i think you are the only one who will know the answer :man_shrugging:t4:

  1. Yes restarted everything several times in different orders.
  2. Yes, no luck.

  1. Seeing the incoming message on the broker-homie-homey directory in the Mqtt Explorer
  2. See a lot coming in at the client, but not the task i trieing to execute.
  3. Messages are incomming.

Only i dont see a Client tab in the Mqtt explorer, is this correct?

MQTT Explorer is a great little tool for us to sort out what isn’t working…
At the top of the topic tree you should show that you have two clients connected (Homey and Home Assistant)
image

Double check you are using the latest version of MQTT Hub, 2.1.7 or higher and $state should show ‘ready’.
image

In the Homie.Homey fork expand it so you can see a specific simple device that you know works in Homey and is also auto created in HA and updates OK (from Homey) - like a switch or a light. You should see something like this for my non dimmable light device ‘test’.

image

Watch the tree whilst you toggle on and off the device from Homey and you will see that the onoff topic updates with the current value as it turns on and off. Now try and control it from HomeAssistant - did a ‘set’ subtopic appear and if so is it updated as you alter it in the HA interface?

image

If it is created does the onoff topic update too ? You’ll see mine has switched to true.

If it is not created then this points towards where the problem lies and I’ll see if I can help you fix that.

You can try manually publishing the topic and updating its value in MQTT explorer between true and false . You need to enter the Topic, select ‘raw’ add false or true and click publish .The real light should follow each state update. This would show that MQTT-Hub is working.
Here is my topic - (note my Homey is called louey - yours is homey)

image

Just for completeness what is happening here is that a homeassistant tree is being added to the MQTT broker (by MQTT Hub) and that tells Home Assistant what type of devices you have available and how to control them and track their status. So in my example I had a non dimmable light called test.

Here is the expanded content of that ‘config’ topic as shown in MQTT Explorer.

image

You will notice within that that it points HomeAssistant to two topics that provide the state and can control the device. This sets up the two way working linkage between HomeAssistant and Homey.

“state_topic”: “homie/louey/test/onoff”
“command_topic”: “homie/louey/test/onoff/set”

I have installed MQTT explorer. And I can’t see anything change when trying to control a switch from HA. Pushing a button (controlled in Homey) I can see the value change from true to false and the other way around.

I assume I installed everything correctly (I know… assumptions :smile:)
Can it be something with user credentials?

So the ‘set’ topic does not get created within the device (in the homie tree) ? That would indicate HA is not accessing the MQTT broker (but yet contradictorily it has discovered the devices).

Does you MQTT server have a username/password setup and if so did you add that in your configuration.yaml ?

Can you post the section in HA’s configuration.yaml headed mqtt: (obscuring any passwords). Like this…

mqtt:
  broker: 192.168.1.78
  username: kevin
  password: redacted
  discovery: true
  discovery_prefix: homeassistant

Also - in the post just above yours I showed what a ‘config’ topic should look like when expanded in MQTT Explorer. Can you post yours for this device.

1 Like

:worried: … I have installed hass.io image directly to the pi. I’m a gui kinda guy… no real cl experience

Where can I find the configation.yaml file and how can I change the file?

this is the config file for the broker running on hass.io

Blockquote
{
“logins”: [
{
“username”: “username”,
“password”: “password”
}
],
“anonymous”: false,
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

NB: This is for a hass.io image - it is slightly different if you installed a Docker container or use HomeAssistant rather than hass.io.

Three things you could do - log in via SSH and edit the file directly or install the SAMBA addin and then the configuration folder for homeassistant will be accessible as a share. In the config folder is configuration.yaml.

image

Or add the Configurator addin which will provide an editor within Hass.io You’ll probably prefer this as it’s more GUI based.

In configuration.yaml you should have, or add an MQTT section as above (just the mqtt: part not mqtt_eventstream or mqtt_statestream). If you broker does not have a username or password just omit those lines. Be very careful with editing configuration.yaml particularly preserving whitespace. It’s very tetchy on this. Save the new version and then click ‘Configuration > General > Check Config’ button and confirm it says ‘Configuration Valid’ before then restarting HA by clicking ‘restart’ in red at the bottom of that same page.

(You can I think also do this via Configuration > Integrations > MQTT but I have not tried it that way)

1 Like

I noticed in my installation my tv is popping up all of the time.
It seems this one issn’t controlled by homey but directly.

I can control this device in HA, set it louder, quiet, off.
Now i i’m confused, what works and what not.

This is perhaps an Apple TV ? Some things are discovered by Home Assistant directly - you can limit this within the discovery component in HA. Don’t worry about those at the moment, they are not being discovered by MQTT.

Sorry was mixing yourself and NoClaim up… You still have this problem ? You are using MQTT Hub v2.1.7 or later aren’t you ? This was a problem in earlier versions.

K

This is not happening, the set is changing but the onoff stays the same, i tried the raw version, but it issn’t working.

edit: using Hub 2.1.8.

Ahh - well that points to maybe an MQTT Hub issue,
Changing set between true and false should update the state reported in the onoff topic
(assuming $settable = true)

What is the physical device in Homey ?
Is it just on/off or does it have other capabilities ?
Is this the same for all devices ?

The physical device in Homey is a Fibaro wallplug.
So i this case just on off.

But i tried several devices and it is all the same.

When you switch the value manually using the MQTT explorer (payload true/false on the set topic), do you see it coming in in the MQTT Client log?

Nope

Do you see a message like: “successfully subscribed to topic …” in the MQTT hub log?

No nothing happens, i have looked in debug and information.
I only see a lot of updates of my signal measure of my telephone

Try turning off all devices except one light to get a clean log.