diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d79f142..06afd51 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/interface/src/project/GeneralInformation.tsx b/interface/src/project/GeneralInformation.tsx index c161693..74eae82 100644 --- a/interface/src/project/GeneralInformation.tsx +++ b/interface/src/project/GeneralInformation.tsx @@ -57,6 +57,12 @@ class GeneralInformation extends Component + + + { secondary={props.data.lastheatduration === 0 ? "-" : props.data.lastheatduration === -1 ? "läuft gerade!" : stringifyTime(props.data.lastheatduration)} /> + + + 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; +} diff --git a/src/GeneralInfoService.h b/src/GeneralInfoService.h index 371234f..a8e6a3d 100644 --- a/src/GeneralInfoService.h +++ b/src/GeneralInfoService.h @@ -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; }; diff --git a/src/Heating.cpp b/src/Heating.cpp index 9d8e300..509b86a 100644 --- a/src/Heating.cpp +++ b/src/Heating.cpp @@ -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) { diff --git a/src/HeatingInfoService.cpp b/src/HeatingInfoService.cpp index 35780be..ab072de 100644 --- a/src/HeatingInfoService.cpp +++ b/src/HeatingInfoService.cpp @@ -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; +} diff --git a/src/HeatingInfoService.h b/src/HeatingInfoService.h index 76f1be9..21a0121 100644 --- a/src/HeatingInfoService.h +++ b/src/HeatingInfoService.h @@ -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; }; diff --git a/src/Pins.h b/src/Pins.h index a2caefd..dd005cf 100644 --- a/src/Pins.h +++ b/src/Pins.h @@ -16,6 +16,6 @@ #define TempSensorPin D4 // version info -#define VERSION "v1.2.4" +#define VERSION "v1.2.4-Alpa1" #endif //PUMPENSTEUERUNG_PINS_H diff --git a/src/main.cpp b/src/main.cpp index eb23aaf..e3dffb3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ Ticker pumpendauer; Heating mHeat; uint32_t turnontime = 0; +uint32_t pumpcycles = 0; AsyncWebServer server(80); ESP8266React esp8266React(&server); @@ -41,6 +42,9 @@ void pumpeSchalten(bool on) { if (allow && !error) { if (on) { + 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) {