Go to the documentation of this file.
84 #ifdef EMAIL_NOTIFICATION
87 String state =
bypass ?
"on" :
"off";
90 getType() +
" leak detection BYPASS",
91 "bypass is now " + state
115 time_t currentTime = millis();
126 time_t currentTime = millis();
138 #ifdef EMAIL_NOTIFICATION
139 sendEmailLeakDetected();
148 #ifdef EMAIL_NOTIFICATION
149 void LowLeakDetection::sendEmailLeakDetected() {
152 "Low leak detected!",
153 "Low leak was just detected\n\r"
155 "limit for leak to be detected: " +
165 time_t currentTime = millis();
171 return min(100, percentReset);
178 time_t currentTime = millis();
181 percentDetected *= 100;
182 return min(100, percentDetected);
186 const String LowLeakDetection::getLogID()
const {
return "[LOW LEAK]"; }
188 const String LowLeakDetection::getLogDescription()
const {
190 String(
"BYPASS=") + String(
bypass) +
" | " +
191 String(
"ACTIVE=") + String(
active) +
" | " +
194 String(
"FLIP_FLOP=") + String(
flipFlop) +
" | " +
196 String(
"CONFIG=") + ((
config == &
alarmConfig) ? String(
"ALARM") : String(
"NORMAL")) +
206 return getType() +
" water leak";
210 return String(
"BYPASS=") + String(
bypass) + String(
" | ") + String(
"ACTIVE=") + String(
active);
231 return fce->second(*
this);
236 return String(
"Undetected");
237 return String(
"Detected");
242 return String(
"OFF");
249 return String(
"OFF");
264 if (percentage < 60)
return "rgba(44, 62, 80, 0.301)";
265 if (percentage >= 60 && percentage < 75)
return "#ffdc52";
266 if (percentage >= 75 && percentage < 85)
return "#fca758";
LeakDetectionConfig_t alarmConfig
alarm configuration for when there's nobody in the house
LowLeakDetection(PulseCounter *pulseCounter, Type type, LeakDetectionConfig_t normalConfig, LeakDetectionConfig_t alarmConfig)
Constructor of the class.
int flipFlop
state of the flip-flop (1/0)
friend String HTML_resetLimitDaysAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (days) in the alarm configuration.
String timeOfDetection
time when the leak has been detected
String getFormatOfSettingsToSave() override
Returns the current settings of the algorithm.
LowLeakDetection * lowLeakDetection
#define LOW_ILOCK_LED_PIN
low-water leak LED (detected = on)
friend String HTML_detectedLimitDays(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (days) in terms of the normal configuration.
std::map< int, String(*)(const LowLeakDetection &highLeakDetection)> htmlData
A map of different values (keys) and their associated functions which returns the appropriate values.
#define FORMAT_TIME(time)
Converts a time in milliseconds into a formatted string.
@ BYPASS
when a bypass changes
friend String HTML_resetPercentage(const LowLeakDetection &lowLeakDetection)
Associated function for returing the [%] information about how close the algorithm is from being rese...
String getType() const
Returns the type of the water leak detection algorithm.
PulseCounter pulseCounter(SENSOR_PIN)
time_t getLastPulseTime() const
Return the time when the last pulse was detected.
void reset() override
Resets the algorithm.
friend String HTML_detectedLimitSecsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (secs) in terms of the alarm configuration.
time_t flipFlopSetTime
time when the flip-flop has been set to 1
time_t limitResetTime
limit reset time e.g. 5 mins, 24h, ....
friend String HTML_resetLimitSecsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (secs) in the alarm configuration.
int resetWhenDetected
the reset value (%) when a leak was detected
friend String HTML_resetLimitHours(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (hours) in the normal configuration.
LeakDetectionConfig_t * config
pointer to the current configuration
bool detected
indication if a leak has been detected
friend String HTML_detectedLimitSecs(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (secs) in terms of the normal configuration.
friend String HTML_detectedLimitMinsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (mins) in terms of the alarm configuration.
friend String HTML_resetLimitDays(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (days) in the normal configuration.
friend String HTML_activePercentageColor(const LowLeakDetection &lowLeakDetection)
Associated function for returing a color according to [%] information about how close a leak is from ...
friend String HTML_detected(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about a low-water leak being detected (1)
#define DAYS(time)
Calculates the number of days when formatting the time given in milliseconds.
friend String HTML_resetLimitMins(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (mins) in the normal configuration.
int bypassPin
number of the bypass pin
float getPercentLeakDetectionReset() const
Returns percentage information about how close a low-water leak is from being detected.
const String getRow(int row) const override
Returns the content of the row given as a parameter.
void applyNewConfig()
Applies the new config 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"
void update() override
Updates the algorithm.
friend String HTML_detectedLimitHoursAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (hours) in terms of the alarm configuration.
time_t limitActionTime
limit action time (leak has been detected)
LeakDetectionConfig_t newNormalConfig
new parameters of the normal config when the user changes them
unsigned long time_t
Referring to the data type unsigned long as time_t.
friend String HTML_detectedLimitDaysAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (days) in terms of the alarm configuration.
float getPercentLeakDetected() const
Returns percentage information about how close the algorithm is from being reset.
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_resetLimitHoursAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (hours) in the alarm configuration.
Type
The type of the water leak detection algorithm.
friend String HTML_bypass(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about the state of the bypass.
byte sendEmail(String subject, String data)
Sends an e-mail off to the smtp2go server.
void testActiveLeak() override
Tests if a low-water leak has occurred, and if so, it will set the appropriate variables and flags.
friend String HTML_resetLimitMinsAlarm(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (mins) in the alarm configuration.
String getDateTimeStr() const
Returns the current datatime in a string format.
#define SECS(time)
Calculates the number of seconds when formatting the time given in milliseconds.
int active
indication if a leak has been detected + bypass is off
friend String HTML_detectedLimitHours(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (hours) in terms of the normal configuration.
LeakDetectionConfig_t newAlarmConfig
new parameters of the alarm config when the user changes them
void testResetLeak() override
Tests if the low-water the algorithm should be reset based on inactivity of pulse on the input pin.
int isActive() const
Returns information if a pulse has been detected.
int oldBypassValue
old bypass value (used for sending e-mails)
friend String HTML_detectedTime(const LowLeakDetection &lowLeakDetection)
Associated function for returing the detection time of a low-water leak.
#define DELTA_TIME(time1, time2)
Calculates the time difference between two times given as parameters.
PulseCounter * pulseCounter
instance of a pulse counter (input of the system)
friend String HTML_detectedText(const LowLeakDetection &lowLeakDetection)
Associated function for returing information about a low-water leak being detected (2)
#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_detectedLimitMins(const LowLeakDetection &lowLeakDetection)
Associated function for returing the limit action time (mins) in terms of the normal configuration.
LeakDetectionConfig_t normalConfig
normal configuarion for when the house is occupied
friend String HTML_activePercentage(const LowLeakDetection &lowLeakDetection)
Associated function for returing the [%] information about how close a leak is from being detected.
friend String HTML_resetLimitSecs(const LowLeakDetection &lowLeakDetection)
Associated function for returing the reset time (secs) in the normal configuration.
static EmailSender * getInstance()
Returns the instance of the class.