Sorry, I did not mean to distract. I do not think changing the "rssi" code will "fix" things. Just pointing out to eliminate unnecessary code, wherever it may be. Once a solution is found, you can put the code back in, if you wish.
So, back to "calculating the current second" and changing "handlecloud()".
I have been using checks against the hour and minute, similar to what you are doing. Maybe my code is failing in this regard and I just don't know it. So, I thought it was high time I learned what you and @ScruffR know about calculating cursec
. I took a look in the forum and found this thread:
https://community.particle.io/t/doing-something-at-a-certain-time/40245/5
In an example, there is a variable called oneShotGuard you might be interested in.
Moving on to Particle cloud connection (will leave MQTT to you). I would recommend using PublishQueueAsyncRK library to publish messages asynchronously. This library is a handy tool allowing status messages you might publish get through to your console without blocking even if there is a seconds to minutes disconnect occurring. This might help in monitoring your pump commands while finding a solution.
https://community.particle.io/t/publishqueueasyncrk-and-large-datasets/52733/20