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%.
I discovered that this was what happened (rough sketch):
- RF received
- Check if duplicate by comparing new value with stored values
- Another RF received
- Check if duplicate by comparing new value with stored values
- 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.
Hardware: D1 mini + MX-RM-5V