Problem with sending fast on/off RF commands via OMG

I noticed very interesting problem and would like to find out why it happens.

I have a RF wall switch I control from HA via OMG v 0.9.1beta.
My automation sends 2 mqtt commands to OMG with a very small interval between them.

  1. Turn on the switch
    home/OpenMQTTGateway/commands/MQTTto433 {"value":12001361}
  2. Turn off the switch
    home/OpenMQTTGateway/commands/MQTTto433 {"value":12001360}

The wall switch turns on and remains on.

In mqtt log I have this

home/OpenMQTTGateway/commands/MQTTto433 {β€œvalue”:12001361}
home/OpenMQTTGateway/commands/MQTTto433 {β€œvalue”:12001360}
home/OpenMQTTGateway/433toMQTT {β€œvalue”:12001361}
home/OpenMQTTGateway/433toMQTT {β€œvalue”:12001360}

and in Serial Monitor

Hey I got a callback
11:57:34.324 β†’ MQTTtoRF json
MQTTtoRF OK
11:57:35.193 β†’ Pub json into:
11:57:35.193 β†’ home/OpenMQTTGateway/433toMQTT
11:57:35.193 β†’ {β€œvalue”:12001361}
11:57:35.193 β†’ Hey I got a callback
11:57:35.193 β†’ MQTTtoRF json
MQTTtoRF OK
11:57:36.104 β†’ Pub json into:
11:57:36.104 β†’ home/OpenMQTTGateway/433toMQTT
11:57:36.104 β†’ {β€œvalue”:12001360}
11:57:36.104 β†’ Hey I got a callback
11:57:36.104 β†’ Store signal
11:57:36.104 β†’ Json buf.
11:57:36.104 β†’ Min ind:
11:57:36.104 β†’ 0
11:57:36.104 β†’ store code :
11:57:36.104 β†’ 12001361/76872
11:57:36.104 β†’ Col: val/timestamp
11:57:36.104 β†’ 0:12001361/76872
11:57:36.104 β†’ 1:13916622/64536
11:57:36.104 β†’ 2:75/74694
11:57:36.104 β†’ 3:75/74710
11:57:36.104 β†’ Data JSON stored
11:57:36.104 β†’ Hey I got a callback
11:57:36.208 β†’ Store signal
11:57:36.208 β†’ Json buf.
11:57:36.208 β†’ Min ind:
11:57:36.208 β†’ 0
11:57:36.208 β†’ store code :
11:57:36.208 β†’ 12001360/76892
11:57:36.208 β†’ Col: val/timestamp
11:57:36.208 β†’ 0:12001360/76892
11:57:36.208 β†’ 1:13916622/64536
11:57:36.208 β†’ 2:75/74694
11:57:36.208 β†’ 3:75/74710
11:57:36.208 β†’ Data JSON stored

I wonder why the switch turns on but then does not turn off?
And what is the right way to get it work properly?
Apparently I have the same problem as this person…

P.S. The only way to get a correct behaviour (i.e the switch is off at the end) is to add small (1-2 seconds) delay between these 2 commands (actually, it’s just adding for: '00:00:01’ to trigger: platform: state), in which case I get

in mqtt log

home/OpenMQTTGateway/commands/MQTTto433 {β€œvalue”:12001361}

home/OpenMQTTGateway/433toMQTT {β€œvalue”:12001361}

home/OpenMQTTGateway/commands/MQTTto433 {β€œvalue”:12001360}

home/OpenMQTTGateway/433toMQTT {β€œvalue”:12001360}

in Serial Monitor

Hey I got a callback
12:15:09.941 β†’ MQTTtoRF json
MQTTtoRF OK
12:15:10.795 β†’ Pub json into:
12:15:10.795 β†’ home/OpenMQTTGateway/433toMQTT
12:15:10.829 β†’ {β€œvalue”:12001361}
12:15:10.829 β†’ Hey I got a callback
12:15:10.829 β†’ Store signal
12:15:10.829 β†’ Json buf.
12:15:10.829 β†’ Min ind:
12:15:10.829 β†’ 0
12:15:10.829 β†’ store code :
12:15:10.829 β†’ 12001361/1125296
12:15:10.829 β†’ Col: val/timestamp
12:15:10.829 β†’ 0:12001361/1125296
12:15:10.829 β†’ 1:13916622/64536
12:15:10.829 β†’ 2:75/74694
12:15:10.829 β†’ 3:75/74710
12:15:10.896 β†’ Data JSON stored
Hey I got a callback
12:15:13.328 β†’ MQTTtoRF json
MQTTtoRF OK
12:15:14.253 β†’ Pub json into:
12:15:14.253 β†’ home/OpenMQTTGateway/433toMQTT
12:15:14.253 β†’ {β€œvalue”:12001360}
12:15:14.253 β†’ Hey I got a callback
12:15:14.253 β†’ Store signal
12:15:14.253 β†’ Json buf.
12:15:14.253 β†’ Min ind:
12:15:14.253 β†’ 0
12:15:14.253 β†’ store code :
12:15:14.253 β†’ 12001360/1128692
12:15:14.253 β†’ Col: val/timestamp
12:15:14.253 β†’ 0:12001360/1128692
12:15:14.253 β†’ 1:13916622/64536
12:15:14.253 β†’ 2:75/74694
12:15:14.253 β†’ 3:75/74710
12:15:14.522 β†’ Data JSON stored

Hi @AhmadK

I know it’s an old topic. I am having the same issue as you describe.

When I go to sleep I want all my switches to turn off. So from a Node Red flow I lookup all switches in Home Assistant. Then I use rate-limiting to send the messages to OMG.
However what I would like to do is call a scene in HA which does not have the rate limiting.

Maybe some other people are reading this topic too.

Whenever OMG is handling a callback main.ino callback would it make sense to temporarily unsubscribe or disable receiving ?
That way messages would just queue in MQTT and handle then sequentially.

Hi,

Did you tried to deactivate the receiving in the code when sending your messages flow to verify that this help ?

Hi Florian,

Not yet. I have the code ready to install but have been busy.
I was thinking somewhere along the line of :

  //launch the function to treat received data if this data concern OpenMQTTGateway
  if ((strstr(topic, subjectMultiGTWKey) != NULL) ||
      (strstr(topic, subjectGTWSendKey) != NULL) ||
      (strstr(topic, subjectFWUpdate) != NULL))

#ifdef ZgatewayRF
      client.unsubscribe(subjectMultiGTWRF); // subject on which other OMG will publish, this OMG will store these msg and by the way don't republish them if they have been already published
#endif
#ifdef ZgatewayIR
      client.unsubscribe(subjectMultiGTWIR); // subject on which other OMG will publish, this OMG will store these msg and by the way don't republish them if they have been already published
#endif

    receivingMQTT(topic, (char*)p);

#ifdef ZgatewayRF
      client.subscribe(subjectMultiGTWRF); // subject on which other OMG will publish, this OMG will store these msg and by the way don't republish them if they have been already published
#endif
#ifdef ZgatewayIR
      client.subscribe(subjectMultiGTWIR); // subject on which other OMG will publish, this OMG will store these msg and by the way don't republish them if they have been already published
#endif

  // Free the memory
  free(p);

I will test and let you know.

Hi @1technophile

I’ve been testing today. I thought i found something but unfortunately it doesn’t seem to be the case. I attached the debugger in VSCode like in RF2 kaku It was quite difficult to get the right breakpoints to see what was going on. When I set qos to 2 in MQTT I can send multiple messages and process each one by stepping through the debugger.

I modified my home assistant config to send qos and verified this by creating a subscriber in Node-red. (MQTT Explorer doesn’t show qos correctly) and verified the right qos value was sent.

However when selecting a scene in HA not all RF commands are received. :frowning:

I’m testing with the latest stable 0.9.8 release or should I use DEV branch?

KR
Bert