How to get back-to-back push notifications (from MQTT) to work

Hi guys,
I have an Arduino that sends out MQTT messages to the topic “gate/alerts/state”. I would like Home Assistant to forward these messages as push notifications to the HA App.

I have this fully working except for one thing: If my Arduino device sends more than 2 or more messages immediately after each other, then only the first one makes it through to the App notification.
I have found that all the MQTT messages make it from the Arduino to HA successfully (they show up in MQTT “Listen to a Topic”), but only the first message makes it from HA to the app.
If I make the Arduino insert a 500mS delay between each MQTT message, then everything works. But that’s causing problems on the Arduino side so it would be much better if HA wouldn’t drop them.

Here’s the automation:

alias: "Notify: Forward MQTT Alerts to notification"
description: ""
trigger:
  - platform: mqtt
    topic: gate/alerts/state
condition: []
action:
  - service: notify.mobile_app_test_iphone
    data:
      message: "{{ trigger.payload_json['Msg'] }}"
      title: "{{ trigger.payload_json['Title'] }}"
mode: single

Here’s what the MQTT JSON Payload looks like:

{
    "Title": "Sample title here.",
    "Msg": "Message A.",
    "Critical": 0,
    "MsgNum": 52
}

Any Ideas on what’s going on here or how to fix it?

First question: Does your data change with each MQTT packet?

Second: Have you tried actually creating a sensor and triggering when updated, rather than using the MQTT trigger?

1 Like

The sensor would be the best way, otherwise try changing

mode: single

to:

mode: parallel

You guys are awesome!! The following worked: As tom_I suggested, I simply changed
mode: single
to:
mode: parallel

Now it works great and does not seem to drop any messages, no matter how quickly I send them!
And to answer the other questions, yes I had tried creating a sensor and triggering when the sensor updated. To guarantee that the state changed, I had “MsgNum” as the state and the Arduino incremented MsgNum with each packet (Then Title and msg were attributes). That was giving me identical results, where it would drop back to back messages. I’m guessing that method would also be fixed by setting the mode to parallel.
Thank you!