Problem with duplicate messages using Zigbee2MQTT

I’m new to Node Red, so maybe this problem is solved easily…

I use Xiaomi Aqara Wall Switches and have set up this flow:

grafik

the problem is, that for some reason, Node Red detects every click twice (even though the MQTT message is only sent once…)

grafik
this is from pressing the switch only once
and these are the MQTT messages:

  zigbee2mqtt:info 6/21/2019, 10:18:29 AM MQTT publish: topic 'zigbee2mqtt/0x00158d00012345ab', payload '{"linkquality":31,"battery":100,"voltage":3065,"click":"right"}'
  zigbee2mqtt:info 6/21/2019, 10:18:29 AM MQTT publish: topic 'zigbee2mqtt/0x00158d00012345ab', payload '{"linkquality":31,"battery":100,"voltage":3065,"click":""}'

nothing else is sent from clicking the wallswitch

So, why is Node Red detecting everything twice?!

I already tried using the “delay” function and only let one message through every second, but firstly, this is kind of complicated to set up correctly, and more importantly, introduces a 1sec delay…

If I debug after the switch, I only get the two “right” messageswithout the “” :
grafik

What could cause this issue?

I haven’t figured out what causes this problem, but I’ve found a workaround…

Within the “trigger: state” node, I have added a constraint saying, it only triggers if the previous message is empty:
grafik

this does work, but is probably not the correct way to do it :thinking:

I don’t know where your problem comes from. But here are some suggestions which may help:

  1. Why don’t you use the MQTT node and subscribe to zigbee2mqtt/0x00158d00012345ab directly from node red? This would also make your flow party independent of HA.
  2. You can change the delay node to limit the number of messages per interval then your delay should be avoided as long as you don’t use your switch very fast
  3. As another workaround, you can also add a switch node which lets only msg pass through that’s payload is different from the previous one

Edit: I think I have an idea where it comes from. The trigger in HA fires at every state change. So if you push you button your state changes from “” to “right” and if you release it, it changes back from “right” to “”, which makes 4 messages.

That does sound plausible :thinking:

Thanks - I have set it up this way now - was hoping this would also speed up the response time, but it makes no difference