Go to the documentation of this file.
59 time_t currentTime = millis();
80 #ifdef EMAIL_NOTIFICATION
81 sendEmailLeakDetected();
90 #ifdef EMAIL_NOTIFICATION
91 void TotalLeakDetection::sendEmailLeakDetected() {
94 "Total leak detected!",
95 "Total leak was just detected\n\r"
97 "limit for leak to be detected: " +
104 if (this->
active == HIGH)
return 0;
106 time_t currentTime = millis();
110 percentDetected *= 100;
111 return min(100, percentDetected);
115 const String TotalLeakDetection::getLogID()
const {
116 return "[TOTAL LEAK]";
125 return getType() +
" water leak";
129 return String(
"BYPASS=") + String(
bypass) + String(
" | ") + String(
"ACTIVE=") + String(
active);
150 return fce->second(*
this);
155 return String(
"Undetected");
156 return String(
"Detected");
161 return String(
"OFF");
168 return String(
"OFF");
183 if (percentage < 60)
return "rgba(44, 62, 80, 0.301)";
184 if (percentage >= 60 && percentage < 75)
return "#ffdc52";
185 if (percentage >= 75 && percentage < 85)
return "#fca758";
LeakDetectionConfig_t alarmConfig
alarm configuration for when there's nobody in the house
const String getRow(int row) const override
Returns the content of the row given as a parameter.
String timeOfDetection
time when the leak has been detected
TotalLeakDetection(PulseCounter *pulseCounter, Type type, LeakDetectionConfig_t normalConfig, LeakDetectionConfig_t alarmConfig)
Constructor of the class.
friend String HTML_resetLimitMinsAlarm(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the reset time (mins) in the alarm configuration.
String getType() const
Returns the type of the water leak detection algorithm.
PulseCounter pulseCounter(SENSOR_PIN)
friend String HTML_detectedTime(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the detection time of a total-water leak.
friend String HTML_detectionLimitAlarm(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the limit (detection) in terms of the alarm configuration.
friend String HTML_resetLimitSecs(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the reset time (secs) in the normal configuration.
friend String HTML_resetLimitHoursAlarm(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the reset time (hours) in the alarm configuration.
time_t limitResetTime
limit reset time e.g. 5 mins, 24h, ....
friend String HTML_detected(const TotalLeakDetection &totalLeakDetection)
Associated function for returing information about a total-water leak being detected (1)
int limitPulseAction
limit action in pulses
friend String HTML_activePercentage(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the [%] information about how close a leak is from being detected.
#define TOTAL_ILOCK_LED_PIN
total-water leak bypass button
int resetWhenDetected
the reset value (%) when a leak was detected
LeakDetectionConfig_t * config
pointer to the current configuration
bool detected
indication if a leak has been detected
#define DAYS(time)
Calculates the number of days when formatting the time given in milliseconds.
void reset() override
Resets the algorithm.
void applyNewConfig()
Applies the new config configuration.
int pulseCount
number of pulses detected so far
friend String HTML_resetLimitDaysAlarm(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the reset time (days) in the alarm configuration.
static DateTime * getInstance()
Returns the instance of the class.
@ LEAK_DETECTED
when a leak has been detected
static const String UNDEFINED_DATA
string "UNDEFINED"
TotalLeakDetection * totalLeakDetection
const String getHTMLData(const int id) const override
Since this class is registered as a source of data for the HTML content, it needs return the appropri...
friend String HTML_detectedText(const TotalLeakDetection &totalLeakDetection)
Associated function for returing information about a total-water leak being detected (2)
unsigned long time_t
Referring to the data type unsigned long as time_t.
#define PULSE_TO_LITER(p)
Converts pulses to liters.
time_t startDayPulseTime
the start of the monoring period
friend String HTML_detectionLimit(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the limit (detection) in terms of the normal configuration.
friend String HTML_resetLimitMins(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the reset time (mins) in the normal configuration.
float getPercentLeakDetectionReset() const
Returns percentage information about how close a total-water leak is from being detected.
friend String HTML_resetLimitSecsAlarm(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the reset time (secs) in the alarm configuration.
Type
The type of the water leak detection algorithm.
byte sendEmail(String subject, String data)
Sends an e-mail off to the smtp2go server.
friend String HTML_bypass(const TotalLeakDetection &totalLeakDetection)
Associated function for returing information about the state of the bypass.
String getDateTimeStr() const
Returns the current datatime in a string format.
friend String HTML_resetLimitHours(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the reset time (hours) in the normal configuration.
friend String HTML_resetLimitDays(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the reset time (days) in the normal configuration.
#define SECS(time)
Calculates the number of seconds when formatting the time given in milliseconds.
void reset() override
Resets the algorithm.
int active
indication if a leak has been detected + bypass is off
void testActiveLeak() override
Tests if the total-water the algorithm should be reset if the current monitoring period is over.
void testResetLeak() override
Tests if a total-water leak has occurred, and if so, it will set the appropriate variables and flags.
friend String HTML_activePercentageColor(const TotalLeakDetection &totalLeakDetection)
Associated function for returing a color according to [%] information about how close a leak is from ...
#define DELTA_TIME(time1, time2)
Calculates the time difference between two times given as parameters.
float getPercentLeakDetected() const
Returns percentage information about how close the algorithm is from being reset.
#define MINS(time)
Calculates the number of minutes when formatting the time given in milliseconds.
#define HOURS(time)
Calculates the number of hours when formatting the time given in milliseconds.
friend String HTML_resetPercentage(const TotalLeakDetection &totalLeakDetection)
Associated function for returing the [%] information about how close the algorithm is from being rese...
LeakDetectionConfig_t normalConfig
normal configuarion for when the house is occupied
std::map< int, String(*)(const TotalLeakDetection &highLeakDetection)> htmlData
A map of different values (keys) and their associated functions which returns the appropriate values.
static EmailSender * getInstance()
Returns the instance of the class.