MQTT communication between Homey and Home Assistant, after HA has restarted

Hi,
I have configured my Homey to communicate with MQTT to my Home Assistant. The problem is when I have restarted my Home Assistant for configuration changes. Home Assistant losing connection with the Homey. To get things working again, I need to restart my Homey MQTT Client app, and send -broadcast from MQTT Hub on Homey. After this everthing is working normally again.

My setup is like this.
MQTT Hub(v2.1.9) and MQTT Client(v2.2.3) installed on my Homey Pro.
Client is configured to connect Mosquitto Broker(v5.1) running on the Home Assistant.

How can I fix the problem, so I dont need to restart MQTT Client and broadcast every time Home Assistant has been restarted?

Can you please provide some more context? How can this solve his issue?
I am asking because I have a similar issue (see this post)

By setting birth and last will messages, upon restart Home Assistant advertises itā€™s presence to the MQTT broker. This in turn triggers the MQTT hub app of Homey to broadcast all the devices and their state to the broker which Home Assistant uses to repopulate the devicesā€¦ When set successfully, there should be no need to reboot the Homey hub or client app after a Home Assistant reboot, just wait and the devices will turn from unavailable to proper state. You can actually observe this while opening the settings of the MQTT hub app on Homey and restarting Home Assistant: you will see the green bar of broadcast start automatically!

1 Like

I have now added the birth and last will setting in Home Assistant. Needed to restart both Hub/Client after I added them. Tried to restart the Home Assistant now. And it seems to work :slight_smile:

Thanks for your assistance :slight_smile:

1 Like

Although I can see this works around the issue I wonder is this because the MQTT HA Auto Discovery messages are not being sent retained ? I assume the homie topics are retained , except the ā€¦/set ones. It should just work without LWT

Not an expert on retained MQTT messages, but from what I have understood, they are not always the way to go either?

Retained messages on a broker provide the last reported payload value to any new connecting client, useful when clients frequently disconnect/reconnect. The last retained is usually the current value unless the providing source is no longer connected.

For homie configuration values, and indeed for HA Discovery information, as this is not ā€˜changingā€™ data this is ideal. For status values itā€™s more a case of what youā€™re wanting but usually you want this and the homie spec defines it For command topics itā€™s definitely not typical to retain such values.

As you are causing Homey to resend itā€™s last (current) data with LWT it should be the same as Homey is constantly connected (and wouldnā€™t be able to respond to LWT unless it was anyway)

I see, thanks for a clear explanation!

Maybe itā€™s good to also hear @HarriedeGroot opinion as developer of the MQTT hub app?

Just merged a pull request:

2 Likes

Hi, my configuration.yaml looks like this, but I still have to restart the HUB-app on Homey everytime I restart HA.
Screenshot_6

And these are my HUB-settings

Compared your setup with mine, Its very similar. Only different I found was the command is turn ā€œonā€ in my configuration. I need to restart the app sometime. But not often, i restart my HA all the time when Im doing configuration on it.

Iā€™ve fixed itā€¦ eventually it was quit stupid; the quotes Iā€™ve used where copy/pasted from somewhere else, and werenā€™t the right ones. When I retyped them, the string-text from/payload (hass/status, online) ā€˜turned greenā€™ instead of black, and now everything automatically updates when HA restarts.

This is a very annoying error on this forum, single and double quotes are mis-formed:

image

Uless you use this: image Preformatted text (ctr+shift+c )