I’ve set up MQTT 2.4 bindings with Homie and an ESP8266 which has a single button to control some lights. I’ve linked the button to a switch item using the rawbutton-toggle-switch profile (via Paper UI). The first problem I experienced is that a single press triggered multiple events (which makes my lights go crazy):
When I subscribe to the channel via Mosquitto I only observe a single message (so ESP and transmission seem to work fine). I thought a restart of OpenHab may help. However, now I don’t see any such messages in the log and the item does not toggle. I can still see the messages in Mosquitto and also the device status is updated in OpenHab
2019-01-09 20:33:14.874 [hingStatusInfoChangedEvent] - 'mqtt:homie300:f4feb5ec:b361d0' changed from ONLINE (CONFIGURATION_PENDING) to ONLINE
QoS is at least once, which might explain the first problem but not the recent problem. Any ideas?
As far as I understand a link always has a profile and in case of a button (channel itself is correctly auto-discovered as trigger channel of type system.rawbutton as documented MQTT Things and Channels - Bindings | openHAB) the only profile Paper UI let’s me select is Raw Button Toggle. The docs explicitly mention the switching lights example as a use case for that profile.
Removing and recreating the Thing entirely solves the problem. Now, I have exactly one message per button press. But only until the next reboot. A reboot seems to consistently break the setup. Do I need to save something explicitly?
I think the two issues (no toggle and too many toggles) are related. I can also reproduce the latter. Every time a Homie device goes offline and online again I get an additional log of a press (see above). I suspect that multiple handler run in parallel. And on boot no handler is started.
My setup is OpenHab 2.4.0 on Openhabian (Pi). I’ve created a single switch item and linked the button channel to the item. I’ve noticed in the logs, that on boot all links are recreated (not only mqtt):
2019-01-10 22:59:10.713 [temChannelLinkRemovedEvent] - Link 'Light => mqtt:homie300:f4feb5ec:b361d0:light#on' has been removed.
2019-01-10 22:59:10.716 [temChannelLinkRemovedEvent] - Link 'Light => mqtt:homie300:f4feb5ec:b361d0:button#button' has been removed.
2019-01-10 22:59:10.734 [temChannelLinkRemovedEvent] - Link 'Light => zwave:device:707546a4:node98:switch_binary' has been removed.
2019-01-10 22:59:10.740 [temChannelLinkRemovedEvent] - Link 'Light => mqtt:homie300:66080c3d:button#button' has been removed.
2019-01-10 23:00:37.647 [.ItemChannelLinkAddedEvent] - Link 'Light-mqtt:homie300:f4feb5ec:b361d0:light#on' has been added.
2019-01-10 23:00:37.655 [.ItemChannelLinkAddedEvent] - Link 'Light-zwave:device:707546a4:node98:switch_binary' has been added.
2019-01-10 23:00:37.660 [.ItemChannelLinkAddedEvent] - Link 'Light-mqtt:homie300:f4feb5ec:b361d0:button#button' has been added.
2019-01-10 23:00:37.664 [.ItemChannelLinkAddedEvent] - Link 'Light-mqtt:homie300:66080c3d:button#button' has been added.
Is this on purpose? Is there any other data that might be helpful?
I have the exact same error and it has nothing to do with a button. I have a sensor which is constantly sending messages. When i add the thing, it is working. But if i restart openhab the connection is gone.
I figured it out, it is a bug in the mqtt implementation. It is already fixed. In the current Snapshot version it is already working.
A workaround that was working for me: If you delete all retained messages from the broker (e.g. with mqtt explorer), the devices start working again until the next restart.