A device reports its temperature to Losant. Our users have a smartphone app that displays a plot of the temperature curve.
Additionally, a workflow is triggered and checks if the temperature of the device is still within an acceptable range. If this is not the case, the smartphone app should immediately display a warning message.
Of course I do not want the app to permanently poll Losant to check its temperature. Instead, I want Losant to notify my app about this event.
How can this be done? My aproach is to have the app subcribe to the Losant MQTT broker and check for a specific topic. The workflow would post a message to this topic, which the client (my app) received immediately and displayed a warning.
So I set up the following test workflow:
The configuration of the MQTT node:
This is the reception string for the MQTT subscriber:
“C:\Program Files\mosquitto\mosquitto_sub” -h broker.losant.com -p 1883 -i DEVICE_ID -u APP_ACCESS_KEY -P APP_ACCESS_SECRET -V mqttv311 -v -t DEVICE_ID/#
So I am subscribing to all topics published for that device. Indeed, sometimes I receive the published message. But very unreliablely, maybe one in ten times.
What is going on? Why don’t I get all of these MQTT messages?
And, more generally speaking, is this a proper way of doing what I want?