Yeah, that was it.
This is what you'd want to add...
Code: Select all
// Define Ports to log
const byte numPumps=1;
byte pump[numPumps] = { ATO_Pump };
byte portalMinutes[numPumps] = { 0 };
byte portalPrevMinutes[numPumps] = { 1 };
static unsigned long pumpTimer[numPumps];
static boolean pumpStatus[numPumps];
for (int i=0;i< numPumps;i++) {
if (ReefAngel.Relay.Status(pump[i])) {
if (!pumpStatus[i]) {
pumpTimer[i]=now()-pumpTimer[i]; // Pump was off, timer is now a time
pumpStatus[i]=true;
}
} else {
if (pumpStatus[i]) {
pumpTimer[i]=now()-pumpTimer[i]; // Pump was on, timer is now a timer
pumpStatus[i]=false;
// Normalize and assign to CustomVar for reporting on the portal
ReefAngel.CustomVar[portalMinutes[i]]=pumpTimer[i]/60; // Number of Minutes
}
}
}
static boolean clearTimer;
if (now()%SECS_PER_DAY!=SECS_PER_DAY-1) clearTimer=true;
if ((now()%SECS_PER_DAY==SECS_PER_DAY-1) && clearTimer==true) {
// Backup timers to portal variable
for (int i=0;i<numPumps;i++) {
ReefAngel.CustomVar[portalPrevMinutes[i]] = pumpTimer[i]/60;
pumpTimer[i]=0; // Clear timer for port
}
clearTimer=false;
}
This will log the number of minutes your ATO pump is on through out the day into the Portal Custom Variable C0. At 11:59pm it will back that up to C1. If you want to add more ports to log, you'll need to define them in the first few lines above. You'll need to set the number of pumps, the ports, and the variables to use for the logging and backup..
For instance, to add Port3 and have it save to variables 2 and backup to variable 3..
Code: Select all
const byte numPumps=2;
byte pump[numPumps] = { ATO_Pump, Port3 };
byte portalMinutes[numPumps] = { 0, 2 };
byte portalPrevMinutes[numPumps] = { 1, 3 };