openhab-addons icon indicating copy to clipboard operation
openhab-addons copied to clipboard

[mqtt] Homie auto-discovery of changes does not always work

Open leifclaesson opened this issue 3 years ago • 5 comments

[org.openhab.binding.mqtt.homie] I have large expandable Relay controller boards which present themselves as Homie devices, and thus those Homie devices are not static, if I add another relay output, the Homie device gets a new node or property which it did not have before.

My issue is: When a Homie device gets a new Node or Property, openhab only sometimes gets a new channel. When a Homie device loses a property, openhab never removes the channel, it keeps showing the channel that no longer exists.

I do not know how to determine if the issue is in the binding or in the core.

Expected Behavior

When the topology of a Homie device changes, these changes are published in the $nodes and $properties topic of said device. I think openHAB should automatically respond to these changes and add/remove channels to match the Homie device.

Current Behavior

Zombie channels are left in their place in OH.

Possible Solution

If automatically adding/removing channels is not desirable/feasible, it would be great to have a "Refresh" button on the Homie thing to force re-building it from the current reported topology of the Homie device.

Steps to Reproduce (for Bugs)

I would be happy to -- but what do you need? The developers of the MQTT / Homie binding certainly already have their own homie devices.

Should I provide an ESP8266 Arduino sketch which reproduces the issue? I would be happy to code one up if that would be useful.

Context

I'm building a smart home with entirely my own hardware. I've designed and built my own ESP32 and ESP8266-based relay-boards that control all the lights in the house, and communicate via MQTT/Homie, and want to control them with openHAB.

This is directly related to the following openhab community topic

Your Environment

Docker openhab/openhab:3.1.0 on raspios-bullseye-arm64 accessed from Firefox 94.0.2 on Windows 10

leifclaesson avatar Dec 05 '21 04:12 leifclaesson

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/oh3-1-mqtt-homie-support/129597/6

openhab-bot avatar Dec 05 '21 04:12 openhab-bot

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/habapp-easy-automation-with-openhab/59669/542

openhab-bot avatar Dec 21 '21 11:12 openhab-bot

I'm facing the same issue. A node got a new property, but it is not showing up as a channel in OH. When I create a new thing, a Homie MQTT Device, all the properties are visible as channels.

Is there any work-around to refresh my existing thing to get a channel for the new property?

I'm running a very recent docker image with OH 3.2.0

mbbert avatar Feb 15 '22 11:02 mbbert

Is there any work-around to refresh my existing thing to get a channel for the new property?

@mbbert The only workaround I've found is to delete the Thing, reconnect the homie device to MQTT (so it shows up in the inbox again), and add the Thing again.

Existing Items do remain, and are automatically connected to the same Channels when you re-add the Thing again.

leifclaesson avatar May 12 '22 07:05 leifclaesson

Is there any work-around to refresh my existing thing to get a channel for the new property?

@mbbert The only workaround I've found is to delete the Thing, reconnect the homie device to MQTT (so it shows up in the inbox again), and add the Thing again.

Existing Items do remain, and are automatically connected to the same Channels when you re-add the Thing again.

Oh man, did that cause me a bit of grief. It worked in the end, but it'd be sweet if there was a "scan for channels" or something.

xanderificnl avatar Oct 11 '22 07:10 xanderificnl

I've found the root cause here. If the Thing is restored from JSON, the subscription to the metadata topics for nodes and properties never happens. If it was created without being restored, it should work. I'm working on a fix right now.

ccutrer avatar Jan 20 '23 22:01 ccutrer

@ccutrer did you manage to fix this, can i link a PR to this issue?

lsiepel avatar Jan 02 '24 11:01 lsiepel