I'm trying to integrate a Xiaomi Gateway into my NodeRed, but I'm having a weird issue, and it is that I'm getting all the messages twice. So if I want to toggle a light on motion detected, it will turn on and off at the same second.
Each message should have a unique token, and I receive that token twice in NodeRed. I'm listening to the same Gateway in a node.js script using the "dgram" module, and there I get the messages only once, as it should be, with a unique token per message. Please see the following screenshot for more details:
Yes, I have restarted it several times. I have NodeRed working on a docker container on a Synology NAS. I have restarted the container, changed the port settings, restarted the whole NAS and lastly updated the NodeRed container to the last version, I had NodeRed 1.1.3 and now I'm using 3.0.2; the problem is the same on both.
I'm thinking about resolving it by just using a variable, everytime a UDP message is sent I will change the variable from 0 to 1 and vice-versa, and I will only let the message continue if the variable is 1. Example:
UDP message received: Var null or 0 -> stop message -> Set to 1
UDP message received: Var 1 -> continue message -> Set to 0
UDP message received: Var 0 -> stop message -> Set to 1
UDP message received: Var 1 -> continue message -> Set to 0
It is not the best or fancy solution but I'm a software developer so for me this is much easier than solving a problem related to the network. Anyways I will appreciate if anybody knows how to solve it.