Compare commits
	
		
			10 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5cfd78f942 | |||
| 3a5f1a3a74 | |||
| 39a8ecde85 | |||
| a9671773f3 | |||
| 9c782879a5 | |||
| 2f38947ea4 | |||
| 5351bcb15d | |||
| 983d2b9ce7 | |||
| 62cea9932e | |||
| 3b502ac434 | 
@@ -16,7 +16,7 @@ build:
 | 
				
			|||||||
  stage: build
 | 
					  stage: build
 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
    - "platformio run -e esp12e"
 | 
					    - "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
 | 
					    - mv .pio/build/esp12e/*.bin Pumpensteuerung-${vers}.bin
 | 
				
			||||||
  artifacts:
 | 
					  artifacts:
 | 
				
			||||||
    paths:
 | 
					    paths:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,6 +57,12 @@ class GeneralInformation extends Component<GeneralInformationRestControllerProps
 | 
				
			|||||||
                                        secondary={props.data.lastPumpDuration !== 0 ? stringifyTime(props.data.lastPumpDuration) : "-"}
 | 
					                                        secondary={props.data.lastPumpDuration !== 0 ? stringifyTime(props.data.lastPumpDuration) : "-"}
 | 
				
			||||||
                                    />
 | 
					                                    />
 | 
				
			||||||
                                </ListItem>
 | 
					                                </ListItem>
 | 
				
			||||||
 | 
					                                <ListItem>
 | 
				
			||||||
 | 
					                                    <ListItemText
 | 
				
			||||||
 | 
					                                        primary="Pumpzyklen seit Programmstart"
 | 
				
			||||||
 | 
					                                        secondary={props.data.pumpcycles}
 | 
				
			||||||
 | 
					                                    />
 | 
				
			||||||
 | 
					                                </ListItem>
 | 
				
			||||||
                                <ListItem>
 | 
					                                <ListItem>
 | 
				
			||||||
                                    <ListItemText
 | 
					                                    <ListItemText
 | 
				
			||||||
                                        primary="WasserSensor / DruckSensor"
 | 
					                                        primary="WasserSensor / DruckSensor"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)}
 | 
					                                    secondary={props.data.lastheatduration === 0 ? "-" : props.data.lastheatduration === -1 ? "läuft gerade!" : stringifyTime(props.data.lastheatduration)}
 | 
				
			||||||
                                />
 | 
					                                />
 | 
				
			||||||
                            </ListItem>
 | 
					                            </ListItem>
 | 
				
			||||||
 | 
					                            <ListItem>
 | 
				
			||||||
 | 
					                                <ListItemText
 | 
				
			||||||
 | 
					                                    primary="Gesammte Heizdauer / Prozentuelle Einschaltzeit"
 | 
				
			||||||
 | 
					                                    secondary={stringifyTime(props.data.totalheattime) + ' / ' + (props.data.heattimepercent * 100).toFixed(2) + '%'}
 | 
				
			||||||
 | 
					                                />
 | 
				
			||||||
 | 
					                            </ListItem>
 | 
				
			||||||
                            <ListItem>
 | 
					                            <ListItem>
 | 
				
			||||||
                                <ListItemText
 | 
					                                <ListItemText
 | 
				
			||||||
                                    primary="Temperatur/Luftfeuchtigkeit:"
 | 
					                                    primary="Temperatur/Luftfeuchtigkeit:"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,7 @@ export interface GeneralInformaitonState {
 | 
				
			|||||||
  watersensor: boolean;
 | 
					  watersensor: boolean;
 | 
				
			||||||
  pressuresensor: boolean;
 | 
					  pressuresensor: boolean;
 | 
				
			||||||
  version: string;
 | 
					  version: string;
 | 
				
			||||||
 | 
					  pumpcycles: number;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface HeatingInformationState {
 | 
					export interface HeatingInformationState {
 | 
				
			||||||
@@ -21,5 +22,6 @@ export interface HeatingInformationState {
 | 
				
			|||||||
  lastheatduration: number;
 | 
					  lastheatduration: number;
 | 
				
			||||||
  hum: number;
 | 
					  hum: number;
 | 
				
			||||||
  temp: number;
 | 
					  temp: number;
 | 
				
			||||||
 | 
					  totalheattime: number;
 | 
				
			||||||
 | 
					  heattimepercent: number;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,8 @@
 | 
				
			|||||||
GeneralInfoService::GeneralInfoService(AsyncWebServer *server) :
 | 
					GeneralInfoService::GeneralInfoService(AsyncWebServer *server) :
 | 
				
			||||||
        lastPumpTime(0),
 | 
					        lastPumpTime(0),
 | 
				
			||||||
        lastWaterOutage(0),
 | 
					        lastWaterOutage(0),
 | 
				
			||||||
        lastPumpDuration(0) {
 | 
					        lastPumpDuration(0),
 | 
				
			||||||
 | 
					        pumpCycles(0) {
 | 
				
			||||||
    server->on(GENERALINFO_SERVICE_PATH, HTTP_GET, std::bind(&GeneralInfoService::reply, this, std::placeholders::_1));
 | 
					    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["watersensor"] = digitalRead(WasserSensorPin) ? true : false;
 | 
				
			||||||
    root["pressuresensor"] = digitalRead(DruckSensorPin) ? true : false;
 | 
					    root["pressuresensor"] = digitalRead(DruckSensorPin) ? true : false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    root["pumpcycles"] = pumpCycles;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    root["version"] = VERSION;
 | 
					    root["version"] = VERSION;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    response->setLength();
 | 
					    response->setLength();
 | 
				
			||||||
@@ -44,3 +47,7 @@ void GeneralInfoService::setlastWaterOutage(uint32_t lastWaterOutage) {
 | 
				
			|||||||
void GeneralInfoService::setPumpDuration(uint32_t lastPumpDuration) {
 | 
					void GeneralInfoService::setPumpDuration(uint32_t lastPumpDuration) {
 | 
				
			||||||
    this->lastPumpDuration = lastPumpDuration;
 | 
					    this->lastPumpDuration = lastPumpDuration;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void GeneralInfoService::setPumpCycles(uint32_t cycles) {
 | 
				
			||||||
 | 
					    this->pumpCycles = cycles;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,11 +37,14 @@ public:
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    void setPumpDuration(uint32_t lastPumpDuration);
 | 
					    void setPumpDuration(uint32_t lastPumpDuration);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void setPumpCycles(uint32_t i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    void reply(AsyncWebServerRequest* request);
 | 
					    void reply(AsyncWebServerRequest* request);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    unsigned long lastPumpTime, lastWaterOutage, lastPumpDuration;
 | 
					    unsigned long lastPumpTime, lastWaterOutage, lastPumpDuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    uint32_t pumpCycles;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ Heating::Heating() : mHeizungTicker(),
 | 
				
			|||||||
                     msettings(nullptr),
 | 
					                     msettings(nullptr),
 | 
				
			||||||
                     mheatingservice(nullptr),
 | 
					                     mheatingservice(nullptr),
 | 
				
			||||||
                     mHeatingStatus(false),
 | 
					                     mHeatingStatus(false),
 | 
				
			||||||
 | 
					                     mPumpCycleActive(false),
 | 
				
			||||||
                     lasttemp(0),
 | 
					                     lasttemp(0),
 | 
				
			||||||
                     lasthum(0),
 | 
					                     lasthum(0),
 | 
				
			||||||
                     sensor() {}
 | 
					                     sensor() {}
 | 
				
			||||||
@@ -32,8 +33,8 @@ void Heating::init(unsigned mode, const SettingState *settings, HeatingInfoServi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            sensor.onData([this](float hum, float temp) {
 | 
					            sensor.onData([this](float hum, float temp) {
 | 
				
			||||||
                schedule_function([hum, temp, this]() {
 | 
					                schedule_function([hum, temp, this]() {
 | 
				
			||||||
                    Serial.printf("Temp: %gdegC\n", temp);
 | 
					//                    Serial.printf("Temp: %gdegC\n", temp);
 | 
				
			||||||
                    Serial.printf("Humid: %g%%\n", hum);
 | 
					//                    Serial.printf("Humid: %g%%\n", hum);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    mheatingservice->setSensorData(hum, temp);
 | 
					                    mheatingservice->setSensorData(hum, temp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,13 +56,16 @@ void Heating::init(unsigned mode, const SettingState *settings, HeatingInfoServi
 | 
				
			|||||||
                    digitalWrite(HeizungPin, LOW);
 | 
					                    digitalWrite(HeizungPin, LOW);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                schedule_function([e]() {
 | 
					//                schedule_function([e]() {
 | 
				
			||||||
                    Serial.printf("Error: %d\n", e);
 | 
					//                    Serial.printf("Error: %d\n", e);
 | 
				
			||||||
                });
 | 
					//                });
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            mHeizungTicker.attach(10, [this]() {
 | 
					            mHeizungTicker.attach(10, [this]() {
 | 
				
			||||||
 | 
					                // only check if no pump cycle is active
 | 
				
			||||||
 | 
					                if (!mPumpCycleActive) {
 | 
				
			||||||
                    sensor.read();
 | 
					                    sensor.read();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
@@ -76,9 +80,10 @@ void Heating::handleHeatingEvents() {
 | 
				
			|||||||
        if (mHeatingStatus == false) {
 | 
					        if (mHeatingStatus == false) {
 | 
				
			||||||
            // turn off active turnoff timers
 | 
					            // turn off active turnoff timers
 | 
				
			||||||
            mLuefterTicker.detach();
 | 
					            mLuefterTicker.detach();
 | 
				
			||||||
            Serial.println("heating should run now!");
 | 
					            //Serial.println("heating should run now!");
 | 
				
			||||||
            // turn on heating and fan
 | 
					
 | 
				
			||||||
            digitalWrite(LuefterPin, HIGH);
 | 
					            digitalWrite(LuefterPin, HIGH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            digitalWrite(HeizungPin, HIGH);
 | 
					            digitalWrite(HeizungPin, HIGH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            mHeatingStatus = true;
 | 
					            mHeatingStatus = true;
 | 
				
			||||||
@@ -90,7 +95,9 @@ void Heating::handleHeatingEvents() {
 | 
				
			|||||||
        // if humidity too low turn off heating and fan after 60secs
 | 
					        // if humidity too low turn off heating and fan after 60secs
 | 
				
			||||||
        if (mHeatingStatus == true) {
 | 
					        if (mHeatingStatus == true) {
 | 
				
			||||||
            digitalWrite(HeizungPin, LOW);
 | 
					            digitalWrite(HeizungPin, LOW);
 | 
				
			||||||
            Serial.println("heating should NOT run now!");
 | 
					            ////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 heating status in on set ticker to turn of fan in 60sec
 | 
				
			||||||
            if (mHeatingStatus) {
 | 
					            if (mHeatingStatus) {
 | 
				
			||||||
@@ -98,7 +105,7 @@ void Heating::handleHeatingEvents() {
 | 
				
			|||||||
                    // turn off fan
 | 
					                    // turn off fan
 | 
				
			||||||
                    digitalWrite(LuefterPin, LOW);
 | 
					                    digitalWrite(LuefterPin, LOW);
 | 
				
			||||||
                    schedule_function([]() {
 | 
					                    schedule_function([]() {
 | 
				
			||||||
                        Serial.println("turning off fan");
 | 
					                        ////Serial.println("turning off fan");
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -119,21 +126,46 @@ void Heating::handleTimeHeater() {
 | 
				
			|||||||
        digitalWrite(LuefterPin, HIGH);
 | 
					        digitalWrite(LuefterPin, HIGH);
 | 
				
			||||||
        digitalWrite(HeizungPin, HIGH);
 | 
					        digitalWrite(HeizungPin, HIGH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Serial.println("Turning on heating");
 | 
					        ////Serial.println("Turning on heating");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        mTurnOffTicker.once((int) ((float) refreshperiod * (float) percentOn / 100.0), []() {
 | 
					        mTurnOffTicker.once((int) ((float) refreshperiod * (float) percentOn / 100.0), []() {
 | 
				
			||||||
            digitalWrite(HeizungPin, LOW);
 | 
					            digitalWrite(HeizungPin, LOW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Serial.println("Turned off heating!");
 | 
					            ////Serial.println("Turned off heating!");
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        mLuefterTicker.once((int) (((float) refreshperiod * (float) percentOn / 100.0) + 30.0), []() {
 | 
					        mLuefterTicker.once((int) (((float) refreshperiod * (float) percentOn / 100.0) + 30.0), []() {
 | 
				
			||||||
            digitalWrite(LuefterPin, LOW);
 | 
					            digitalWrite(LuefterPin, LOW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Serial.println("Turned off fan!");
 | 
					            ////Serial.println("Turned off fan!");
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    func();
 | 
					    func();
 | 
				
			||||||
    mHeizungTicker.attach(refreshperiod, func);
 | 
					    mHeizungTicker.attach(refreshperiod, func);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Heating::setPumCycleActive(bool active) {
 | 
				
			||||||
 | 
					    mPumpCycleActive = active;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // turn off fan if pumpcycleactive
 | 
				
			||||||
 | 
					    if (active) {
 | 
				
			||||||
 | 
					        digitalWrite(LuefterPin, LOW);
 | 
				
			||||||
 | 
					        digitalWrite(HeizungPin, LOW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mHeizungTicker.detach();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (mHeatingStatus) {
 | 
				
			||||||
 | 
					            // to add the correct time to the heat min counter!
 | 
				
			||||||
 | 
					            mheatingservice->addHeatTime(Timer::getSystemSeconds() - mheatingservice->getLastHeatingStartTime());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        mHeizungTicker.detach();
 | 
				
			||||||
 | 
					        mHeizungTicker.attach(10, [this]() {
 | 
				
			||||||
 | 
					            // only check if no pump cycle is active
 | 
				
			||||||
 | 
					            if (!mPumpCycleActive) {
 | 
				
			||||||
 | 
					                sensor.read();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,8 @@ public:
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    void init(unsigned mode, const SettingState* settings, HeatingInfoService *heatingservice);
 | 
					    void init(unsigned mode, const SettingState* settings, HeatingInfoService *heatingservice);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void setPumCycleActive(bool active);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    enum MODES {TIME, HUMIDITY};
 | 
					    enum MODES {TIME, HUMIDITY};
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    Ticker mHeizungTicker;
 | 
					    Ticker mHeizungTicker;
 | 
				
			||||||
@@ -30,7 +32,7 @@ private:
 | 
				
			|||||||
    const SettingState* msettings;
 | 
					    const SettingState* msettings;
 | 
				
			||||||
    HeatingInfoService *mheatingservice;
 | 
					    HeatingInfoService *mheatingservice;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool mHeatingStatus;
 | 
					    bool mHeatingStatus, mPumpCycleActive;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    float lasttemp;
 | 
					    float lasttemp;
 | 
				
			||||||
    float lasthum;
 | 
					    float lasthum;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,8 @@ HeatingInfoService::HeatingInfoService(AsyncWebServer *server) :
 | 
				
			|||||||
        hum(-1),
 | 
					        hum(-1),
 | 
				
			||||||
        temp(-1),
 | 
					        temp(-1),
 | 
				
			||||||
        lastheating(0),
 | 
					        lastheating(0),
 | 
				
			||||||
        lastheatend(0) {
 | 
					        lastheatend(0),
 | 
				
			||||||
 | 
					        totalHeatTime(0) {
 | 
				
			||||||
    server->on(HEATINGINFO_SERVICE_PATH, HTTP_GET, std::bind(&HeatingInfoService::reply, this, std::placeholders::_1));
 | 
					    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
 | 
					    // if lastheatend == 0 => heating is currently active
 | 
				
			||||||
    root["lastheatduration"] = lastheating == 0 ? 0 : lastheatend == 0 ? -1 : lastheatend - lastheating;
 | 
					    root["lastheatduration"] = lastheating == 0 ? 0 : lastheatend == 0 ? -1 : lastheatend - lastheating;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    root["totalheattime"] = this->totalHeatTime;
 | 
				
			||||||
 | 
					    root["heattimepercent"] = (float)this->totalHeatTime / (float)Timer::getSystemSeconds();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    response->setLength();
 | 
					    response->setLength();
 | 
				
			||||||
    request->send(response);
 | 
					    request->send(response);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -44,3 +48,11 @@ void HeatingInfoService::setLastHeatingStarttime(unsigned long time) {
 | 
				
			|||||||
void HeatingInfoService::setLastHetingEndtime(unsigned long time) {
 | 
					void HeatingInfoService::setLastHetingEndtime(unsigned long time) {
 | 
				
			||||||
    this->lastheatend = time;
 | 
					    this->lastheatend = time;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint32_t HeatingInfoService::getLastHeatingStartTime() {
 | 
				
			||||||
 | 
					    return this->lastheating;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void HeatingInfoService::addHeatTime(uint32_t time) {
 | 
				
			||||||
 | 
					    totalHeatTime += time;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,9 +18,16 @@ public:
 | 
				
			|||||||
    void setSensorData(float hum, float temp);
 | 
					    void setSensorData(float hum, float temp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setLastHeatingStarttime(unsigned long time);
 | 
					    void setLastHeatingStarttime(unsigned long time);
 | 
				
			||||||
 | 
					    uint32_t getLastHeatingStartTime();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setLastHetingEndtime(unsigned long time);
 | 
					    void setLastHetingEndtime(unsigned long time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * add time how long the heater heated
 | 
				
			||||||
 | 
					     * @param time time in seconds
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    void addHeatTime(uint32_t time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    void reply(AsyncWebServerRequest* request);
 | 
					    void reply(AsyncWebServerRequest* request);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -29,6 +36,8 @@ private:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    unsigned long lastheating;
 | 
					    unsigned long lastheating;
 | 
				
			||||||
    unsigned long lastheatend;
 | 
					    unsigned long lastheatend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    uint32_t totalHeatTime;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,6 @@
 | 
				
			|||||||
#define TempSensorPin  D4
 | 
					#define TempSensorPin  D4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// version info
 | 
					// version info
 | 
				
			||||||
#define VERSION "v1.2.4"
 | 
					#define VERSION "v1.2.4-Alpa1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif //PUMPENSTEUERUNG_PINS_H
 | 
					#endif //PUMPENSTEUERUNG_PINS_H
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,12 +17,12 @@ SettingsService::SettingsService(AsyncWebServer *server, SecurityManager *securi
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SettingsService::onConfigUpdated() {
 | 
					void SettingsService::onConfigUpdated() {
 | 
				
			||||||
    Serial.println("switching led!");
 | 
					    ////Serial.println("switching led!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    File settingsFile = ESPFS.open("settings.json", "w+");
 | 
					    File settingsFile = ESPFS.open("settings.json", "w+");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (settingsFile) {
 | 
					    if (settingsFile) {
 | 
				
			||||||
        Serial.println("writing config file!");
 | 
					        ////Serial.println("writing config file!");
 | 
				
			||||||
        StaticJsonDocument<256> doc;
 | 
					        StaticJsonDocument<256> doc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        doc["waterOutageWaitDuration"] = _state.waterOutageWaitDuration;
 | 
					        doc["waterOutageWaitDuration"] = _state.waterOutageWaitDuration;
 | 
				
			||||||
@@ -46,7 +46,7 @@ void SettingsService::begin() {
 | 
				
			|||||||
        // Deserialize the JSON document
 | 
					        // Deserialize the JSON document
 | 
				
			||||||
        DeserializationError error = deserializeJson(doc, settingsFile);
 | 
					        DeserializationError error = deserializeJson(doc, settingsFile);
 | 
				
			||||||
        if (error) {
 | 
					        if (error) {
 | 
				
			||||||
            Serial.println(F("Failed to read file, using default configuration"));
 | 
					            ////Serial.println(F("Failed to read file, using default configuration"));
 | 
				
			||||||
            onConfigUpdated();
 | 
					            onConfigUpdated();
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -59,7 +59,7 @@ void SettingsService::begin() {
 | 
				
			|||||||
        _state.heatLow = doc["heatLow"] | 65;
 | 
					        _state.heatLow = doc["heatLow"] | 65;
 | 
				
			||||||
        _state.fanRuntime = doc["fanRuntime"] | 60;
 | 
					        _state.fanRuntime = doc["fanRuntime"] | 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Serial.println("read config file!");
 | 
					        ////Serial.println("read config file!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        settingsFile.close();
 | 
					        settingsFile.close();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										68
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										68
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -21,6 +21,7 @@ Ticker pumpendauer;
 | 
				
			|||||||
Heating mHeat;
 | 
					Heating mHeat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t turnontime = 0;
 | 
					uint32_t turnontime = 0;
 | 
				
			||||||
 | 
					uint32_t pumpcycles = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AsyncWebServer server(80);
 | 
					AsyncWebServer server(80);
 | 
				
			||||||
ESP8266React esp8266React(&server);
 | 
					ESP8266React esp8266React(&server);
 | 
				
			||||||
@@ -32,56 +33,69 @@ SettingsService settingsservice = SettingsService(&server, esp8266React.getSecur
 | 
				
			|||||||
void pumpeSchalten(bool on) {
 | 
					void pumpeSchalten(bool on) {
 | 
				
			||||||
    //    digitalWrite(4,on);
 | 
					    //    digitalWrite(4,on);
 | 
				
			||||||
    if (on) {
 | 
					    if (on) {
 | 
				
			||||||
        Serial.println("versuche Pumpe EIN zuschalten");
 | 
					        //Serial.println("versuche Pumpe EIN zuschalten");
 | 
				
			||||||
        // refresh last pump counter
 | 
					        // refresh last pump counter
 | 
				
			||||||
        generalinfo.setlastPumpTime(Timer::getSystemSeconds());
 | 
					        generalinfo.setlastPumpTime(Timer::getSystemSeconds());
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        Serial.println("versuche Pumpe AUS zuschalten");
 | 
					        //Serial.println("versuche Pumpe AUS zuschalten");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (allow && !error) {
 | 
					    if (allow && !error) {
 | 
				
			||||||
        if (on) {
 | 
					        if (on) {
 | 
				
			||||||
            pumpendauer.once((float)settingsservice.getSettings()->maxpumpduration + 1, []() {
 | 
					            pumpcycles++;
 | 
				
			||||||
 | 
					            generalinfo.setPumpCycles(pumpcycles);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // pump cycle started
 | 
				
			||||||
 | 
					            mHeat.setPumCycleActive(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pumpendauer.once((float) settingsservice.getSettings()->maxpumpduration + 1, []() {
 | 
				
			||||||
                //erlaube keine einschaltung von mehr als 60 sek
 | 
					                //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
 | 
					                    //error zu lange
 | 
				
			||||||
                    Serial.println("\n\npumpe lief mehr als 10 Minuten durchgaengig");
 | 
					                    //Serial.println("\n\npumpe lief mehr als 10 Minuten durchgaengig");
 | 
				
			||||||
                    pumpeSchalten(false);
 | 
					                    pumpeSchalten(false);
 | 
				
			||||||
                    error = true;
 | 
					                    error = true;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            generalinfo.setPumpDuration(Timer::getSystemSeconds() - turnontime);
 | 
					            generalinfo.setPumpDuration(Timer::getSystemSeconds() - turnontime);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // pump cycle stopped...
 | 
				
			||||||
 | 
					            mHeat.setPumCycleActive(false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // save pump start time
 | 
					        // save pump start time
 | 
				
			||||||
        turnontime = Timer::getSystemSeconds();
 | 
					        turnontime = Timer::getSystemSeconds();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        digitalWrite(SchuetzPin, on);
 | 
					        digitalWrite(SchuetzPin, on);
 | 
				
			||||||
        Serial.println("[Erfolg] pumpe wird geschalten");
 | 
					        //Serial.println("[Erfolg] pumpe wird geschalten");
 | 
				
			||||||
    } else {
 | 
					    } 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;
 | 
					        turnontime = -1;
 | 
				
			||||||
        digitalWrite(SchuetzPin, LOW);
 | 
					        digitalWrite(SchuetzPin, LOW);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ICACHE_RAM_ATTR void DruckschalterInt() {
 | 
					ICACHE_RAM_ATTR void DruckschalterInt() {
 | 
				
			||||||
 | 
					    schedule_function([]() {
 | 
				
			||||||
        if (digitalRead(DruckSensorPin) == HIGH) {
 | 
					        if (digitalRead(DruckSensorPin) == HIGH) {
 | 
				
			||||||
            //pumpe einschalten
 | 
					            //pumpe einschalten
 | 
				
			||||||
        Serial.println("\n\nDruck Sensor EIN");
 | 
					            //Serial.println("\n\nDruck Sensor EIN");
 | 
				
			||||||
            if (digitalRead(WasserSensorPin)) {
 | 
					            if (digitalRead(WasserSensorPin)) {
 | 
				
			||||||
            Serial.println("Wasser Sensor EIN");
 | 
					                //Serial.println("Wasser Sensor EIN");
 | 
				
			||||||
                pumpeSchalten(true);
 | 
					                pumpeSchalten(true);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
            Serial.println("Wasser Sensor aus irgent einem Grund doch nicht ein -- sofort abschalten!");
 | 
					                //Serial.println("Wasser Sensor aus irgent einem Grund doch nicht ein -- sofort abschalten!");
 | 
				
			||||||
                pumpeSchalten(false);
 | 
					                pumpeSchalten(false);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            //pumpe ausschalten
 | 
					            //pumpe ausschalten
 | 
				
			||||||
        Serial.println("\n\nDruck Sensor AUS");
 | 
					            //Serial.println("\n\nDruck Sensor AUS");
 | 
				
			||||||
            pumpeSchalten(false);
 | 
					            pumpeSchalten(false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// time counter to wait
 | 
					// time counter to wait
 | 
				
			||||||
@@ -89,48 +103,50 @@ int wateroutagewaitduration;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void WasserSensorCheck() {
 | 
					void WasserSensorCheck() {
 | 
				
			||||||
    if (digitalRead(WasserSensorPin) == LOW) {
 | 
					    if (digitalRead(WasserSensorPin) == LOW) {
 | 
				
			||||||
        Serial.println("Wasser Sensor AUS");
 | 
					        //Serial.println("Wasser Sensor AUS");
 | 
				
			||||||
        //kein Wasser dh timer auf 10min stellen
 | 
					        //kein Wasser dh timer auf 10min stellen
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // refresh wateroutage counter
 | 
					        // refresh wateroutage counter
 | 
				
			||||||
        generalinfo.setlastWaterOutage(Timer::getSystemSeconds());
 | 
					        generalinfo.setlastWaterOutage(Timer::getSystemSeconds());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        allow = false;
 | 
					        allow = false;
 | 
				
			||||||
        Serial.println("Schalte pumpe aus");
 | 
					        //Serial.println("Schalte pumpe aus");
 | 
				
			||||||
        pumpeSchalten(false);
 | 
					        pumpeSchalten(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Serial.println("warte 30min");
 | 
					        //Serial.println("warte 30min");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        status.detach();
 | 
					        status.detach();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
 | 
					        wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
 | 
				
			||||||
        status.attach(5, []() {
 | 
					        status.attach(5, []() {
 | 
				
			||||||
            wateroutagewaitduration -= 5;
 | 
					            wateroutagewaitduration -= 5;
 | 
				
			||||||
            Serial.print("noch ");
 | 
					            //Serial.print("noch ");
 | 
				
			||||||
            Serial.print(wateroutagewaitduration);
 | 
					            //Serial.print(wateroutagewaitduration);
 | 
				
			||||||
            Serial.println(" Sekunden verbleibend");
 | 
					            //Serial.println(" Sekunden verbleibend");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (wateroutagewaitduration <= 0) {
 | 
					            if (wateroutagewaitduration <= 0) {
 | 
				
			||||||
                if (digitalRead(WasserSensorPin)) {
 | 
					                if (digitalRead(WasserSensorPin)) {
 | 
				
			||||||
                    allow = true;
 | 
					                    allow = true;
 | 
				
			||||||
                    Serial.println("Einschalten der Pumpe wieder erlaubt.");
 | 
					                    //Serial.println("Einschalten der Pumpe wieder erlaubt.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    //pruefen ob drucksensor ein
 | 
					                    //pruefen ob drucksensor ein
 | 
				
			||||||
                    DruckschalterInt();
 | 
					                    DruckschalterInt();
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    Serial.print("wassersensor immer noch kein Wasser --> verlaengern um 120min\n\n");
 | 
					                    //Serial.print("wassersensor immer noch kein Wasser --> verlaengern um 120min\n\n");
 | 
				
			||||||
                    WasserSensorCheck();
 | 
					                    WasserSensorCheck();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                status.detach();
 | 
					                status.detach();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        Serial.println("Wasser Sensor EIN");
 | 
					        //Serial.println("Wasser Sensor EIN");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ICACHE_RAM_ATTR void WasserSensorInt() {
 | 
					ICACHE_RAM_ATTR void WasserSensorInt() {
 | 
				
			||||||
 | 
					    schedule_function([]() {
 | 
				
			||||||
        WasserSensorCheck();
 | 
					        WasserSensorCheck();
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setup() {
 | 
					void setup() {
 | 
				
			||||||
@@ -151,9 +167,9 @@ void setup() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // initilize serial connection
 | 
					    // initilize serial connection
 | 
				
			||||||
    Serial.begin(115200);
 | 
					    Serial.begin(115200);
 | 
				
			||||||
    Serial.println("\n\n\n\nstartup of ESP");
 | 
					    //Serial.println("\n\n\n\nstartup of ESP");
 | 
				
			||||||
    Serial.print("Version: ");
 | 
					    //Serial.print("Version: ");
 | 
				
			||||||
    Serial.println(VERSION);
 | 
					    //Serial.println(VERSION);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //initial measurement of water state
 | 
					    //initial measurement of water state
 | 
				
			||||||
@@ -175,16 +191,16 @@ void setup() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // initialize wifi
 | 
					    // initialize wifi
 | 
				
			||||||
    Serial.println("Initializing wifi");
 | 
					    //Serial.println("Initializing wifi");
 | 
				
			||||||
    esp8266React.begin();
 | 
					    esp8266React.begin();
 | 
				
			||||||
    settingsservice.begin();
 | 
					    settingsservice.begin();
 | 
				
			||||||
    server.begin();
 | 
					    server.begin();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // initialize heating control
 | 
					    // initialize heating control
 | 
				
			||||||
    Serial.println("initializing heating service");
 | 
					    //Serial.println("initializing heating service");
 | 
				
			||||||
    mHeat.init(Heating::HUMIDITY, settingsservice.getSettings(), &heatinginfo);
 | 
					    mHeat.init(Heating::HUMIDITY, settingsservice.getSettings(), &heatinginfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Serial.println("startup sequence complete!\n");
 | 
					    //Serial.println("startup sequence complete!\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user