Go to the documentation of this file.
54 auto it =
leaks.find(type);
55 if (it ==
leaks.end())
101 #ifdef EMAIL_NOTIFICATION
103 String state = stateOfHomeAlarmTmp ?
"ACTIVE" :
"NOT ACTIVE";
107 "Home alarm is now " + state +
"\r\n"
121 int isAnyLeakActive = 0;
122 for (
const auto leak :
leaks) {
125 #ifdef HOME_ALARM_SETTINGS
129 leak.second->update();
130 if (leak.second->isActive())
143 for (
const auto leak :
leaks)
144 leak.second->reset();
152 #ifdef EMAIL_NOTIFICATION
155 "Reset of the device",
156 "All the detection algorithms have been reset");
163 #ifdef EMAIL_NOTIFICATION
170 msg =
"open to closed";
173 msg =
"closed to open";
177 "Valve is now " + state,
178 "The state of the valve has been changed from " + msg);
184 const String LeaksController::getLogID()
const {
return "[LEAKS_CONTROLLER]"; }
186 const String LeaksController::getLogDescription()
const {
188 String(
"VALVE_STATE=") + String(
valveState) +
" | " +
200 return String(
"Overview (1)");
203 return String(
"VALVE STATE=") + String(
valveState);
223 return fce->second(*
this);
228 return String(
"OFF");
235 return String(
"OFF");
241 return String(
"OFF");
249 String HTML_monthlyConsumption(
const LeaksController& leaksController) {
@ Total
total water leak detection algorithm
friend String HTML_monthlyConsumption(const LeaksController &leaksController)
Associated function for returing the monthly water consumption in liters.
void addLeakDetection(ALeakDetectable::Type type, ALeakDetectable *leak)
Adds another water leak detection algorithm to the collection.
std::map< ALeakDetectable::Type, ALeakDetectable * > leaks
collection (map) of water leak detection algorithms
int valveState
state of the main valve
Consumption * monthlyConsumptionCounter
monthly water consumption
#define HOME_ALARM_PIN
home alarm
PulseCounter pulseCounter(SENSOR_PIN)
@ Low
low water leak detection algorithm
LeaksController()
Constructor of the class.
int manualValveClose
state of the "manual close" button
int getNumberOfLeakDetections() const
Return the number of water leak detection algorithm.
time_t limitResetTime
limit reset time e.g. 5 mins, 24h, ....
friend String HTML_valve(const LeaksController &leaksController)
Associated function for returing the current state of the main valve.
int limitPulseAction
limit action in pulses
void setMonthlyConsumptionCounter(Consumption *monthlyConsumptionCounter)
Sets an instance of Consumption (monthly water consumption)
int stateOfHomeAlarm
state of the home alarm
void update()
Updates the class.
int getConsumptionCount() const
Returns the current number of pulses detected so far within the monitoring period.
void updateAlarmConfig(LeakDetectionConfig_t newAlarmConfig)
Updates the alarm settings.
std::map< int, String(*)(const LeaksController &leaksController)> htmlData
A map of different values (keys) and their associated functions which returns the appropriate values.
@ High
high water leak detection algorithm
#define VALVE_MANUAL_CLOSE_PIN
"manual close" button
friend String HTML_manualClose(const LeaksController &leaksController)
Associated function for returing the current state of the "manual close" button.
void update()
Updates the variables.
void updateNormalConfig(LeakDetectionConfig_t newNormalConfig)
Updates the normal settings.
static DateTime * getInstance()
Returns the instance of the class.
static const String UNDEFINED_DATA
string "UNDEFINED"
time_t limitActionTime
limit action time (leak has been detected)
#define VALVE_PIN
main valve
#define VALVE_LED_PIN
main valve LED
void setDailyConsumptionCounter(Consumption *dailyConsumptionCounter)
Sets an instance of Consumption (daily water consumption)
#define PULSE_TO_LITER(p)
Converts pulses to liters.
static LeaksController * instance
the instance of the class
void update() override
Updates the class.
LeakDetectionConfig_t getAlarmConfig()
Returns the current alarm config.
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...
Type
The type of the water leak detection algorithm.
byte sendEmail(String subject, String data)
Sends an e-mail off to the smtp2go server.
void setPulseCounter(PulseCounter *pulseCounter)
Sets an instance of PulseCounter.
@ VALVE_STATE
when the state of the valve has changed
@ RESET
when the device resets
friend String HTML_alarm(const LeaksController &leaksController)
Associated function for returing the current state of the home alarm.
Consumption * dailyConsumptionCounter
daily water consumption
Button manualResetButton
instance of Button (the reset buttton)
String getFormatOfSettingsToSave()
Returns all settings.
const String getRow(int row) const override
Returns the content of the row given as a parameter.
friend String HTML_dailyConsumption(const LeaksController &leaksController)
Associated function for returing the daily water consumption in liters.
LeakDetectionConfig_t getNormalConfig()
Returns the current normal config.
static LeaksController * getInstance()
Returns the instance of the class.
@ ALARM
when the state of the home alarm changes
void changeSettings(ALeakDetectable::Type type, unsigned long detected, unsigned long reset, bool alarm)
Changes settings of a water leak detection algorithm.
PulseCounter * pulseCounter
instance of PulseCounter (output from the sensor)
static EmailSender * getInstance()
Returns the instance of the class.