Hi all. First time working with Webhooks and had a question. My device checks for a value every X minutes. When that happens it then checks a sensor. If the sensor value is higher than expected, it sends a text via SendGrid then an email via MailGun. The text message is always firing twice. Looking at the logs it shows the Webhook firing twice, despite me calling it once. I even changed to code to update the ‘tick’ variable in case it was some code synchronous thing. The code (slightly modified) is below. Anything standing out?
int tick = 0;
void loop() {
// Check every 5 minutes
if((int)Time.now() >= tick+300) {
if(functionName() >= (float)threshold) {
// call webhook for texting
tick = (int)Time.now();
Particle.publish("txt-webhook-name", String(functionName(), 2), PRIVATE);
// call webhook for email
Particle.publish("email-webhook-name", String(functionName(), 2), PRIVATE);
}
tick = (int)Time.now();
}
}