Any way to automatically fetch data after n seconds?

Skip to first unread message

Mehran Ahmad

Oct 28, 2021, 1:14:17 AM10/28/21
to Routix
I have a couple of switches with retained flags set and as such, they dont republish until a state change.  I also have scripted OnDisplay in conjuction with OnTap so that if the secondsSinceLastActivity > 10 minutes (600 seconds)  prevent publishing.

Why: I have MQTT Dash running on multiple android phones - lets call them device A and B for simplicity.  If I switch the button on A, device B wont receive the payload if it is off network, the app is not running, or android is in deepsleep or switches network from home wifi to cell.  When user wakes up device B and brings MQTT Dash to the foreground, sometimes it might take a couple of seconds for the app to recognize state change and reconnect back to the broker to resubscribe.  Until then it will still show the old value for a couple of seconds.  It it during this period, the user on device B, might inadvertently switch the device back to its previous state because they havent received the update yet and as soon as they do get the update, they have already put a publish in queue which will execute one connected to broker.

As a workaround to being able to publish on stale data, Ive implemented the logic above to prevent publishing after 10 minutes.  This is working fine but the issue now is that if I do keep the app in the foreground, i have to back out (disconnect) and click back on the connection to be able to republish.

I have looked into QOS on MQTT and not sure if it would solve this issue.  Any guidance would be helpful.

On another note, I just want to commend the devs on this powerful app.  The scripting capabilities make it extremely powerful and highly developer-centric .  It hasnt been updated in a while, a blessing in some sense that it allows the app to still function well on old Android platforms - I have it running on a Nook HD w/ LineageOS 14.1. What really caught my attention was the first sentence for the app description: "Warning: This app is for nerds only :)" !!!

Reply all
Reply to author
0 new messages