How to use Node-RED with MQTT device trigger from Zigbee2MQTT 2.0.0 breaking change? #25579
Replies: 11 comments 26 replies
-
After poking around I found out that I need to manually connect to the MQTT Server and listen to a topic using the |
Beta Was this translation helpful? Give feedback.
-
I've enabled the legacy action sensor which solved some of the issues. It seems like some devices just don't work anymore. I've got an Aquara WXKG03LM_rev2 toggle switch which says it exposes the action sensor, but when checking the device as such, it only shows Voltage, Battery and Linkquality. There's no mention of the action sensor. Am I doing something wrong or is this some sort of bug? |
Beta Was this translation helpful? Give feedback.
-
yup.. this is part of my configuration.yaml:
Strange... I assumed I could restart HA to restart the add-on, but I need to do that for the add-on itself.. hmm.. But.. entity is back now.. now have to see if I can get it back to work again :) |
Beta Was this translation helpful? Give feedback.
-
Enabling Before deploying: After deploying and editting: |
Beta Was this translation helpful? Give feedback.
-
Also in the same boat, but I'm not really worried about directly connected NR to the MQTT Broker. That said, struggling to find how to create the actions: single, double and long clicks. Anyone ? |
Beta Was this translation helpful? Give feedback.
-
Ah, there it is... I thought I was the only one with this issue... |
Beta Was this translation helpful? Give feedback.
-
OK, I got it working with a simple test flow but since I enabled legacy actions, I think I am still using those actions... I can't test what happens when I turn legacy actions now as the family is at home and if they can't turn on/off lights I will be in big trouble! |
Beta Was this translation helpful? Give feedback.
-
Thank you for this. I wonder when the legacy actions will be removed. But I
think I would keep them for now as I have loads of flows that use the
actions.
…On Thu, 9 Jan 2025, 19:01 David De Smet, ***@***.***> wrote:
It works without the legacy_action_sensor enabled. I tested that before
going back to the original way.
—
Reply to this email directly, view it on GitHub
<#25579 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AONHCL37KRRGXGIMIJQQNT32J3BRXAVCNFSM6AAAAABUUJYPNKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNZZGAYTGNQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
The really nice thing with subscribing to MQTT topics is that it allows for "generic" topics with wildcards like this:
Read more about that here: https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/ For this to work your devices should follow a name scheme that represents nested levels like Afterwards their actions will be available under the topic In my case I then extract the device data in a following js node and evaluate the logic in a switch node. To find all mqtt messages initially you can simply put a
Extracting the data: Reacting to the subscription in a switch node:
|
Beta Was this translation helpful? Give feedback.
-
I'm using mqtt in node. The strange thing is, I get three identical events by one single press. The settings of the mqtt in node is following Can anybody help? |
Beta Was this translation helpful? Give feedback.
-
[edit 20250118] Per @Koenkk, the recommendation is to rely on Legacy, rather than "Experimental" mode. So the approach below is potentially subject to additional refactoring in the future. After having spent a few hours, I found a way to avoid "Legacy" setting (life is too short to keep coming back and fixing reliance upon legacy stuff) and make it work with node red. Hope someone finds this useful. My setup: In Zigbee2MQTT settings, Home Assistant integration tab, I have enabled experimental features, so that I receive the "new" behavior. (they removed the old behavior with a breaking change, but they didn't introduce any new behavior unless it is explicitly configured): Notice that I did NOT turn on legacy mode here. Then, in Node RED, I am able to read the event state using entities (further reading here), like so:
Obviously, your event types may differ from mine, depending on the zigbee device itself and what it's sending. The above is for an Ikea Tradfri button. Another button (random stuff from Aliexpress) I am testing like this:
With this, I restored by Z2M pre-2.0.0 behavior, and I am not dependent on legacy any more. I hope the "experimental" thing becomes permanent so that I don't have to revisit this... |
Beta Was this translation helpful? Give feedback.
-
With all
sensor.*_click
entities removed from Zigbee2MQTT 2.0.0, it is suggested to use MQTT device trigger, but that article shows how to create an automation through HA.How can I achieve the same with Node-RED?
I've all my automations in Node-RED and would like to keep all of them in there rather than having a couple in HA and having to switch between them.
Beta Was this translation helpful? Give feedback.
All reactions