Compare commits

...

5 Commits

Author SHA1 Message Date
aee4725379 Merge branch 'detach' into 'master'
detach before call

See merge request lukas/pumpensteuerung!11
2021-04-10 09:08:52 +00:00
697ed69d95 add new ticker to check after 500ms if water outage is correct. 2021-04-03 17:16:24 +02:00
6adfb3c09e detach before call 2021-04-01 17:33:57 +02:00
9c782879a5 Merge branch 'pumpcounter' into 'master'
Total heating time and pump count

See merge request lukas/pumpensteuerung!9
2021-03-26 22:15:20 +00:00
2f38947ea4 add features to show total heating time and percentage on heating tab
and total pump cycles on homepage
2021-03-26 22:15:20 +00:00
11 changed files with 97 additions and 37 deletions

View File

@ -16,7 +16,7 @@ build:
stage: build
script:
- "platformio run -e esp12e"
- vers=$(grep -Po '[0-9]*\.[0-9]*\.[0-9]*(?=\")' ./src/Pins.h)
- vers=$(grep -Po '[0-9]+\.[0-9]+\.[0-9]+[-0-9A-Za-z]*(?=\")' ./src/Pins.h)
- mv .pio/build/esp12e/*.bin Pumpensteuerung-${vers}.bin
artifacts:
paths:

View File

@ -57,6 +57,12 @@ class GeneralInformation extends Component<GeneralInformationRestControllerProps
secondary={props.data.lastPumpDuration !== 0 ? stringifyTime(props.data.lastPumpDuration) : "-"}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Pumpzyklen seit Programmstart"
secondary={props.data.pumpcycles}
/>
</ListItem>
<ListItem>
<ListItemText
primary="WasserSensor / DruckSensor"

View File

@ -39,6 +39,12 @@ class HeatingInformation extends React.Component<HeatingRestcontollerprops> {
secondary={props.data.lastheatduration === 0 ? "-" : props.data.lastheatduration === -1 ? "läuft gerade!" : stringifyTime(props.data.lastheatduration)}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Gesammte Heizdauer / Prozentuelle Einschaltzeit"
secondary={stringifyTime(props.data.totalheattime) + ' / ' + (props.data.heattimepercent * 100).toFixed(2) + '%'}
/>
</ListItem>
<ListItem>
<ListItemText
primary="Temperatur/Luftfeuchtigkeit:"

View File

@ -14,6 +14,7 @@ export interface GeneralInformaitonState {
watersensor: boolean;
pressuresensor: boolean;
version: string;
pumpcycles: number;
}
export interface HeatingInformationState {
@ -21,5 +22,6 @@ export interface HeatingInformationState {
lastheatduration: number;
hum: number;
temp: number;
totalheattime: number;
heattimepercent: number;
}

View File

@ -9,7 +9,8 @@
GeneralInfoService::GeneralInfoService(AsyncWebServer *server) :
lastPumpTime(0),
lastWaterOutage(0),
lastPumpDuration(0) {
lastPumpDuration(0),
pumpCycles(0) {
server->on(GENERALINFO_SERVICE_PATH, HTTP_GET, std::bind(&GeneralInfoService::reply, this, std::placeholders::_1));
}
@ -27,6 +28,8 @@ void GeneralInfoService::reply(AsyncWebServerRequest *request) {
root["watersensor"] = digitalRead(WasserSensorPin) ? true : false;
root["pressuresensor"] = digitalRead(DruckSensorPin) ? true : false;
root["pumpcycles"] = pumpCycles;
root["version"] = VERSION;
response->setLength();
@ -44,3 +47,7 @@ void GeneralInfoService::setlastWaterOutage(uint32_t lastWaterOutage) {
void GeneralInfoService::setPumpDuration(uint32_t lastPumpDuration) {
this->lastPumpDuration = lastPumpDuration;
}
void GeneralInfoService::setPumpCycles(uint32_t cycles) {
this->pumpCycles = cycles;
}

View File

@ -37,11 +37,14 @@ public:
*/
void setPumpDuration(uint32_t lastPumpDuration);
void setPumpCycles(uint32_t i);
private:
void reply(AsyncWebServerRequest* request);
unsigned long lastPumpTime, lastWaterOutage, lastPumpDuration;
uint32_t pumpCycles;
};

View File

@ -91,6 +91,8 @@ void Heating::handleHeatingEvents() {
if (mHeatingStatus == true) {
digitalWrite(HeizungPin, LOW);
Serial.println("heating should NOT run now!");
// add the heat time it took to the total
mheatingservice->addHeatTime(Timer::getSystemSeconds() - mheatingservice->getLastHeatingStartTime());
// if heating status in on set ticker to turn of fan in 60sec
if (mHeatingStatus) {

View File

@ -10,7 +10,8 @@ HeatingInfoService::HeatingInfoService(AsyncWebServer *server) :
hum(-1),
temp(-1),
lastheating(0),
lastheatend(0) {
lastheatend(0),
totalHeatTime(0) {
server->on(HEATINGINFO_SERVICE_PATH, HTTP_GET, std::bind(&HeatingInfoService::reply, this, std::placeholders::_1));
}
@ -28,6 +29,9 @@ void HeatingInfoService::reply(AsyncWebServerRequest *request) {
// if lastheatend == 0 => heating is currently active
root["lastheatduration"] = lastheating == 0 ? 0 : lastheatend == 0 ? -1 : lastheatend - lastheating;
root["totalheattime"] = this->totalHeatTime;
root["heattimepercent"] = (float)this->totalHeatTime / (float)Timer::getSystemSeconds();
response->setLength();
request->send(response);
}
@ -44,3 +48,11 @@ void HeatingInfoService::setLastHeatingStarttime(unsigned long time) {
void HeatingInfoService::setLastHetingEndtime(unsigned long time) {
this->lastheatend = time;
}
uint32_t HeatingInfoService::getLastHeatingStartTime() {
return this->lastheating;
}
void HeatingInfoService::addHeatTime(uint32_t time) {
totalHeatTime += time;
}

View File

@ -18,9 +18,16 @@ public:
void setSensorData(float hum, float temp);
void setLastHeatingStarttime(unsigned long time);
uint32_t getLastHeatingStartTime();
void setLastHetingEndtime(unsigned long time);
/**
* add time how long the heater heated
* @param time time in seconds
*/
void addHeatTime(uint32_t time);
private:
void reply(AsyncWebServerRequest* request);
@ -29,6 +36,8 @@ private:
unsigned long lastheating;
unsigned long lastheatend;
uint32_t totalHeatTime;
};

View File

@ -16,6 +16,6 @@
#define TempSensorPin D4
// version info
#define VERSION "v1.2.4"
#define VERSION "v1.2.4-Alpha2"
#endif //PUMPENSTEUERUNG_PINS_H

View File

@ -15,12 +15,13 @@ bool error = false;
Ticker status;
//pumpendauer maximum ticker
Ticker pumpendauer;
Ticker pumpendauer, wasserSensorDoubleCheck;
//WifiManager mang;
Heating mHeat;
uint32_t turnontime = 0;
uint32_t pumpcycles = 0;
AsyncWebServer server(80);
ESP8266React esp8266React(&server);
@ -41,9 +42,13 @@ void pumpeSchalten(bool on) {
if (allow && !error) {
if (on) {
pumpendauer.once((float)settingsservice.getSettings()->maxpumpduration + 1, []() {
pumpcycles++;
generalinfo.setPumpCycles(pumpcycles);
pumpendauer.once((float) settingsservice.getSettings()->maxpumpduration + 1, []() {
//erlaube keine einschaltung von mehr als 60 sek
if (Timer::getSystemSeconds() - turnontime >= (unsigned)settingsservice.getSettings()->maxpumpduration && turnontime != 0) {
if (Timer::getSystemSeconds() - turnontime >=
(unsigned) settingsservice.getSettings()->maxpumpduration && turnontime != 0) {
//error zu lange
Serial.println("\n\npumpe lief mehr als 10 Minuten durchgaengig");
pumpeSchalten(false);
@ -60,7 +65,8 @@ void pumpeSchalten(bool on) {
digitalWrite(SchuetzPin, on);
Serial.println("[Erfolg] pumpe wird geschalten");
} else {
Serial.println("[FEHLGESCHLAGEN] Schalten des Schütz gesperrt durch Timeout oder Fehler-- sofortiges ausschalten der pumpe\n");
Serial.println(
"[FEHLGESCHLAGEN] Schalten des Schütz gesperrt durch Timeout oder Fehler-- sofortiges ausschalten der pumpe\n");
turnontime = -1;
digitalWrite(SchuetzPin, LOW);
}
@ -89,39 +95,46 @@ int wateroutagewaitduration;
void WasserSensorCheck() {
if (digitalRead(WasserSensorPin) == LOW) {
Serial.println("Wasser Sensor AUS");
//kein Wasser dh timer auf 10min stellen
// check if water sensor is also low after 500ms and lock it then
wasserSensorDoubleCheck.once_ms(500, []() {
if (digitalRead(WasserSensorPin) == LOW) {
Serial.println("Wasser Sensor AUS");
//kein Wasser dh timer auf 10min stellen
// refresh wateroutage counter
generalinfo.setlastWaterOutage(Timer::getSystemSeconds());
// refresh wateroutage counter
generalinfo.setlastWaterOutage(Timer::getSystemSeconds());
allow = false;
Serial.println("Schalte pumpe aus");
pumpeSchalten(false);
allow = false;
Serial.println("Schalte pumpe aus");
pumpeSchalten(false);
Serial.println("warte 30min");
Serial.println("warte 30min");
status.detach();
wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
status.attach(5, []() {
wateroutagewaitduration -= 5;
Serial.print("noch ");
Serial.print(wateroutagewaitduration);
Serial.println(" Sekunden verbleibend");
if (wateroutagewaitduration <= 0) {
if (digitalRead(WasserSensorPin)) {
allow = true;
Serial.println("Einschalten der Pumpe wieder erlaubt.");
//pruefen ob drucksensor ein
DruckschalterInt();
} else {
Serial.print("wassersensor immer noch kein Wasser --> verlaengern um 120min\n\n");
WasserSensorCheck();
}
status.detach();
wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
status.detach();
status.attach(5, []() {
wateroutagewaitduration -= 5;
Serial.print("noch ");
Serial.print(wateroutagewaitduration);
Serial.println(" Sekunden verbleibend");
if (wateroutagewaitduration <= 0) {
status.detach();
if (digitalRead(WasserSensorPin)) {
allow = true;
Serial.println("Einschalten der Pumpe wieder erlaubt.");
//pruefen ob drucksensor ein
DruckschalterInt();
} else {
Serial.print("wassersensor immer noch kein Wasser --> verlaengern um 120min\n\n");
WasserSensorCheck();
}
}
});
}
});
} else {