Excessive data operations

I have a particle photon 2 monitoring garage doors. My code is fairly straightforward but somehow the device is using hundreds of thousands of operations per day. It has been running for years fine without doing so. I switched out the photon board twice just hoping something was off but had no luck. I can watch the console to monitor and do not see events but Particle's report shows them but of course it doesn't show time of day, etc.

Here's my code:

// Constants for clarity
const int PIN_RIGHT_GARAGE = D0;
const int PIN_LEFT_GARAGE = D4;
const unsigned long ALERT_INTERVAL = 600000; // 10 minutes

// Timing variables (independent for each door)
unsigned long lastAlertRight = 0;
unsigned long lastAlertLeft = 0;

bool state = HIGH;

void setup() {
pinMode(PIN_LEFT_GARAGE, INPUT_PULLUP);
pinMode(PIN_RIGHT_GARAGE, INPUT_PULLUP);


Particle.function("leftstatus", getStatusLeftGarage);
Particle.function("rightstatus", getStatusRightGarage);
Particle.function("getbothgaragestatus", getStatusBothGarage);


//     Particle.function("switch1", getSwitchStatus);
}

int getStatusBothGarage(String args) {
int left = digitalRead(PIN_LEFT_GARAGE);   // 1 if closed, 0 if open
int right = digitalRead(PIN_RIGHT_GARAGE); // 1 if closed, 0 if open


if (left == 0 && right == 0) return 1; // Both open
if (left == 1 && right == 1) return 2; // Both closed
if (left == 0 && right == 1) return 3; // Left open, Right closed
if (left == 1 && right == 0) return 4; // Right open, Left closed
return -1;

}

int getStatusLeftGarage(String args) { return digitalRead(PIN_LEFT_GARAGE); }
int getStatusRightGarage(String args) { return digitalRead(PIN_RIGHT_GARAGE); }
//int getSwitchStatus(String args) { return state; }

void indicateActivity() {
RGB.control(true);
RGB.color(243, 136, 14); // Orange
delay(100);              // Short blink to show it processed
RGB.color(47, 124, 27);  // Green
RGB.control(false);
}

void loop() {
unsigned long now = millis();
// Check once per hour or similar to see if it's our "Reset Day"
// Time.weekday() returns 1 (Sun) through 7 (Sat)
// We can reset every Wednesday (4) at 3:00 AM
if (Time.weekday() == 4 && Time.hour() == 3 && Time.minute() == 0) {
System.reset();
}


// Right Garage Logic
if (digitalRead(PIN_RIGHT_GARAGE) == LOW) {
    if (now - lastAlertRight >= ALERT_INTERVAL) {
        lastAlertRight = now;
        indicateActivity();
        Particle.publish("garage_alert", "RightGarage", PRIVATE);
    }
}
// Left Garage Logic
if (digitalRead(PIN_LEFT_GARAGE) == LOW) {
    if (now - lastAlertLeft >= ALERT_INTERVAL) {
        lastAlertLeft = now;
        indicateActivity();
        Particle.publish("garage_alert", "LeftGarage", PRIVATE);
    }
}


}

I would add

SerialLogHandler logHandler(LOG_LEVEL_TRACE);

and monitor the USB serial debug with a laptop. It may help.

Also, how often are you calling the functions? Each function call uses a data operation so if you're polling those values with any frequency that will add up quickly. Variables requests do as well. Getting the data operations report from the Billing page in the console may help determine the cause.

I will add the logging. those functions would only be called when I hit a web app on my phone. It could be several times per day but shouldn't do over 500,000 data operations like it has been doing recently. I wish there was some detailed logging from Particle that could show times per day or IP the requests come from. It would make it easier to see what (if anything) is calling it that is unknown to me

If you can provide the Device ID that is responsible for the data operations we may be able to find additional information.

Device id is 0a10aced202194944a0432f0 now.
Previously it was device id 35003a000b47353235303037 that was using the same code

On the old device, it’s variable requests and function calls, and mostly on 2026-04-26 and 2026-04-27. For a while, you were making 100,000 requests per hour. I can’t see the IP addresses because there are too many to query and I’m not sure how to get around that because I don't normally use that tool.

I cannot imagine what I'd have that would be making that many requests. So each request is an inbound request to the device's cloud api?
I wish it had more than just the date

If I changed the function names and variables names even if calls were coming in and trying for no longer existing functions/variable would data operations build up?

If you remove the variable/function names from device firmware they'll be rejected at the cloud API level returning an error code (maybe 404?), will not be sent to the device, and will not count as a data operation.

Ok, I will do that just in case there is some other unknown app, etc. that is hitting the variables/functions that I don't know about. Unfortunately my sandbox is paused now so I'm not sure if the expected traffic will show up now.
thanks

Hi, is there an app, script, program of sorts that is reading the status of your garage doors? Maybe an UI, a website, something?

Could it be that there is something querying the device 100k times an hour by mistake?