1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.58k stars 788 forks source link

Duplicate #1

Closed prahjister closed 7 years ago

prahjister commented 7 years ago

Hey fantastic job on this but I was wondering if you could implement a simple change to remove duplicates. My sensors send duplicate codes to ensure that it is received. Can you implement duplicate removal code? I have changed the code to basically do this but only checks the last code that was sent. This fails if one of the codes sent is not read properly or if 2 sensors fire at the same time. I am using a toggle feature in home assistant so makes it difficult and i will sometimes get 2 toggles.

I used the time feature now() and imported.

1technophile commented 7 years ago

Thanks, I added the modification into this test program: https://github.com/1technophile/433toMQTTto433_ESP8266/blob/1technophile-patch-1/_433toMQTTto433_ESP8266.ino

Feel free to test it and comment, if it is ok I will modify also the one with IR.

prahjister commented 7 years ago

ill test this evening but looking at the code it looks almost exactly like what I implemented. The issue is that it assumes only 1 sensor is transmitting at the same time and that rf is always deciphered correctly. It would be better to log the last 20-30 maybe more in a (vector or array not sure....limited programming experience) and test against all of them. Maybe push each in and the last starts going away after reaches predefined limit.

1technophile commented 7 years ago

ok, can we sumup your problem like this: sensor A send 123456 at 14h23m56s12 sensor A send 123456 at 14h23m56s23 sensor B send 654321 at 14h23m56s33 sensor A send 123456 at 14h23m56s35 sensor B send 654321 at 14h23m56s43

currently you are seeing by mqtt: 123456 123456 654321 123456 654321

with the last modification you will see by mqtt: 123456 654321 123456 654321

and you want to see by mqtt: 123456 654321

is it correct?

prahjister commented 7 years ago

yes exactly if the last time is milliseconds

For clarification i get between 6 and 8 duplicate mqtt requests per trigger within about 2 seconds with an occasional wrong decipher

1technophile commented 7 years ago

Downloadable for test purposes here: https://github.com/1technophile/433toMQTTto433_ESP8266/blob/1technophile-patch-1/_433toMQTTto433_ESP8266.ino

prahjister commented 7 years ago

looks good...will test out tonight....if i wanted to make bigger buffer can I just make a bigger array?

1technophile commented 7 years ago

you need to change also the number of iteration 10 when this line appears: for (int i = 0; i < 10; i++)

prahjister commented 7 years ago

I didn't end up changing more than 10. What you have worked perfectly. I did test 2 simultaneous and neither one works. They interfere with each other.