Avoid duplicates


#1

Hi!
I had an issue where the avoidance of duplicates did not work, no matter what value i entered in
#define time_avoid_duplicate 3000

So, i tried to understand what de code does. I think i now understand maybe 10%. :slight_smile:

I discovered that this was what happened (rough sketch):

  1. RF received
  2. Check if duplicate by comparing new value with stored values
  3. Another RF received
  4. Check if duplicate by comparing new value with stored values
  5. Store values (first time)

So, as values are not stored between checks, several duplicates were sent. This could really pile up. I got loads of duplicates.

Then I was able to solve this by adding a short delay:

#ifdef ZgatewayRF
  if(RFtoMQTT()){
  trc(F("RFtoMQTT OK"));
  //GREEN ON
  digitalWrite(led_receive, LOW);
  timer_led_receive = millis();
  delay(100);  //ADDED THIS LINE
  }
#endif

Actually, I stole the idea from the IR part.

Hope this might help anyone encountering the same issue. I leave it up to you real developers to decide if this is something to add to the distributed code base. :slight_smile:

Hardware: D1 mini + MX-RM-5V


#2

…found out this does not alway work…