Compare commits
No commits in common. "master" and "v1.2.0" have entirely different histories.
@ -6,7 +6,6 @@ stages:
|
||||
cache:
|
||||
paths:
|
||||
- "~/.platformio"
|
||||
- ./interface/node_modules
|
||||
|
||||
before_script:
|
||||
- "pip install -U platformio"
|
||||
@ -14,10 +13,7 @@ before_script:
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- "platformio run -e esp12e"
|
||||
- vers=$(grep -Po '[0-9]+\.[0-9]+\.[0-9]+[-0-9A-Za-z]*(?=\")' ./src/Pins.h)
|
||||
- mv .pio/build/esp12e/*.bin Pumpensteuerung-${vers}.bin
|
||||
script: "platformio run -e esp12e"
|
||||
artifacts:
|
||||
paths:
|
||||
- ./*.bin
|
||||
- .pio/build/esp12e/*.bin
|
@ -13,7 +13,6 @@ build_flags =
|
||||
-D FACTORY_AP_LOCAL_IP=\"192.168.4.1\"
|
||||
-D FACTORY_AP_GATEWAY_IP=\"192.168.4.1\"
|
||||
-D FACTORY_AP_SUBNET_MASK=\"255.255.255.0\"
|
||||
-D FACTORY_AP_VISIBLE=true
|
||||
|
||||
; User credentials for admin and guest user
|
||||
-D FACTORY_ADMIN_USERNAME=\"admin\"
|
||||
|
BIN
interface/build/app/icon.png
Normal file
BIN
interface/build/app/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
12
interface/build/app/manifest.json
Normal file
12
interface/build/app/manifest.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name":"ESP8266 React",
|
||||
"icons":[
|
||||
{
|
||||
"src":"/app/icon.png",
|
||||
"sizes":"48x48 72x72 96x96 128x128 256x256"
|
||||
}
|
||||
],
|
||||
"start_url":"/",
|
||||
"display":"fullscreen",
|
||||
"orientation":"any"
|
||||
}
|
22
interface/build/css/roboto.css
Normal file
22
interface/build/css/roboto.css
Normal file
@ -0,0 +1,22 @@
|
||||
/* Just supporting latin due to size constrains on the esp chip */
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
src: local('Roboto Light'), local('Roboto-Light'), url(../fonts/li.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+2215;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Roboto'), local('Roboto-Regular'), url(../fonts/re.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+2215;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
src: local('Roboto Medium'), local('Roboto-Medium'), url(../fonts/me.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+2215;
|
||||
}
|
BIN
interface/build/favicon.ico
Normal file
BIN
interface/build/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
interface/build/fonts/li.woff2
Normal file
BIN
interface/build/fonts/li.woff2
Normal file
Binary file not shown.
BIN
interface/build/fonts/me.woff2
Normal file
BIN
interface/build/fonts/me.woff2
Normal file
Binary file not shown.
BIN
interface/build/fonts/re.woff2
Normal file
BIN
interface/build/fonts/re.woff2
Normal file
Binary file not shown.
BIN
interface/build/js/1.b30b.js.gz
Normal file
BIN
interface/build/js/1.b30b.js.gz
Normal file
Binary file not shown.
@ -3,9 +3,8 @@ import { TextValidator, ValidatorForm, SelectValidator } from 'react-material-ui
|
||||
|
||||
import MenuItem from '@material-ui/core/MenuItem';
|
||||
import SaveIcon from '@material-ui/icons/Save';
|
||||
import Checkbox from '@material-ui/core/Checkbox';
|
||||
|
||||
import {PasswordValidator, RestFormProps, FormActions, FormButton, BlockFormControlLabel} from '../components';
|
||||
import { PasswordValidator, RestFormProps, FormActions, FormButton } from '../components';
|
||||
|
||||
import { isAPEnabled } from './APModes';
|
||||
import { APSettings, APProvisionMode } from './types';
|
||||
@ -92,16 +91,6 @@ class APSettingsForm extends React.Component<APSettingsFormProps> {
|
||||
onChange={handleValueChange('subnet_mask')}
|
||||
margin="normal"
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
value="network_visible"
|
||||
checked={data.network_visible}
|
||||
onChange={handleValueChange("network_visible")}
|
||||
/>
|
||||
}
|
||||
label="Network visible?"
|
||||
/>
|
||||
</Fragment>
|
||||
}
|
||||
<FormActions>
|
||||
|
@ -24,5 +24,4 @@ export interface APSettings {
|
||||
local_ip: string;
|
||||
gateway_ip: string;
|
||||
subnet_mask: string;
|
||||
network_visible: boolean;
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
import React, {Component} from 'react';
|
||||
import {Box, List, ListItem, ListItemText} from '@material-ui/core';
|
||||
import {FormButton, restController, RestControllerProps, RestFormLoader, SectionContent} from '../components';
|
||||
import {
|
||||
FormButton,
|
||||
restController,
|
||||
RestControllerProps,
|
||||
RestFormLoader,
|
||||
SectionContent
|
||||
} from '../components';
|
||||
import {ENDPOINT_ROOT} from "../api";
|
||||
import {GeneralInformaitonState} from "./types";
|
||||
import RefreshIcon from "@material-ui/icons/Refresh";
|
||||
import {getRealTimeString, stringifyTime} from "./Time";
|
||||
|
||||
// define api endpoint
|
||||
export const GENERALINFORMATION_SETTINGS_ENDPOINT = ENDPOINT_ROOT + "generalinfo";
|
||||
@ -12,8 +17,20 @@ export const GENERALINFORMATION_SETTINGS_ENDPOINT = ENDPOINT_ROOT + "generalinfo
|
||||
type GeneralInformationRestControllerProps = RestControllerProps<GeneralInformaitonState>;
|
||||
|
||||
class GeneralInformation extends Component<GeneralInformationRestControllerProps> {
|
||||
intervalhandler: number | undefined;
|
||||
|
||||
componentDidMount() {
|
||||
this.props.loadData();
|
||||
|
||||
// this.intervalhandler = window.setInterval(() => {
|
||||
// this.props.loadData();
|
||||
// console.log("refreshing data");
|
||||
// console.log(this.props.data)
|
||||
// }, 10000);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.intervalhandler);
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -22,71 +39,82 @@ class GeneralInformation extends Component<GeneralInformationRestControllerProps
|
||||
<RestFormLoader
|
||||
{...this.props}
|
||||
render={props => (
|
||||
<>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Chip läuft seit:"
|
||||
secondary={<>{stringifyTime(props.data.runtime)}
|
||||
<br/> {getRealTimeString(props.data.runtime)}</>}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Zuletzt zu wenig Wasser:"
|
||||
secondary={props.data.lastWaterOutage !== 0 ?
|
||||
<>
|
||||
vor {stringifyTime(props.data.lastWaterOutage)}<br/>
|
||||
{getRealTimeString(props.data.lastWaterOutage)}
|
||||
</> : "noch nie!"}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Letzer Pumpenzyklus"
|
||||
secondary={props.data.lastpumptime !== 0 ?
|
||||
<>
|
||||
vor {stringifyTime(props.data.lastpumptime)}<br/>
|
||||
{getRealTimeString(props.data.lastpumptime)}
|
||||
</> : "noch nie!"}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Letze Pumpdauer:"
|
||||
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"
|
||||
secondary={(props.data.watersensor ? "EIN" : "AUS!") + " / " + (props.data.pressuresensor ? "EIN" : "AUS")}
|
||||
/>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Box display="flex" flexWrap="wrap">
|
||||
<Box flexGrow={1} padding={1}>
|
||||
<FormButton startIcon={<RefreshIcon/>} variant="contained" color="secondary"
|
||||
onClick={this.props.loadData}>
|
||||
Refresh
|
||||
</FormButton>
|
||||
<>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Chip läuft seit:"
|
||||
secondary={this.stringifyTime(props.data.runtime)}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Zuletzt zu wenig Wasser:"
|
||||
secondary={props.data.lastWaterOutage !== 0 ? "vor " + this.stringifyTime(props.data.lastWaterOutage) : "noch nie!"}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Letzer Pumpenzyklus"
|
||||
secondary={props.data.lastpumptime !== 0 ? "vor " + this.stringifyTime(props.data.lastpumptime) : "noch nie!"}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Letze Pumpdauer:"
|
||||
secondary={props.data.lastPumpDuration !== 0 ? this.stringifyTime(props.data.lastPumpDuration) : "-"}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Temperatur/Luftfeuchtigkeit:"
|
||||
secondary={(props.data.temp !== -1 ? props.data.temp + "C" : "Auslesefehler!") + " / " + (props.data.hum !== -1 ? props.data.hum + "%" : "Auslesefehler!")}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="WasserSensor / DruckSensor"
|
||||
secondary={(props.data.watersensor ? "EIN" : "AUS!") + " / " + (props.data.pressuresensor ? "EIN" : "AUS")}
|
||||
/>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Box display="flex" flexWrap="wrap">
|
||||
<Box flexGrow={1} padding={1}>
|
||||
<FormButton startIcon={<RefreshIcon/>} variant="contained" color="secondary"
|
||||
onClick={this.props.loadData}>
|
||||
Refresh
|
||||
</FormButton>
|
||||
</Box>
|
||||
<Box flexWrap="none" padding={1} whiteSpace="nowrap">
|
||||
Version: {props.data.version}
|
||||
</Box>
|
||||
</Box>
|
||||
<Box flexWrap="none" padding={1} whiteSpace="nowrap">
|
||||
Version: {props.data.version}
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</SectionContent>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* stringify seconds to a pretty format
|
||||
* @param sec number of seconds
|
||||
*/
|
||||
stringifyTime(sec: number): string {
|
||||
if (sec >= 86400) {
|
||||
// display days
|
||||
return (Math.trunc(sec / 86400) + "d " + Math.trunc((sec % 86400) / 3600) + "h " + Math.trunc((sec % 3600) / 60) + "min " + sec % 60 + "sec");
|
||||
} else if (sec >= 3600) {
|
||||
// display hours
|
||||
return (Math.trunc(sec / 3600) + "h " + Math.trunc((sec % 3600) / 60) + "min " + sec % 60 + "sec");
|
||||
} else if (sec >= 60) {
|
||||
// only seconds and minutes
|
||||
return (Math.trunc(sec / 60) + "min " + sec % 60 + "sec");
|
||||
} else {
|
||||
// only seconds
|
||||
return (sec + "sec");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default restController(GENERALINFORMATION_SETTINGS_ENDPOINT, GeneralInformation);
|
||||
|
@ -1,70 +0,0 @@
|
||||
import React from "react";
|
||||
import {FormButton, restController, RestControllerProps, RestFormLoader, SectionContent} from "../components";
|
||||
import {ENDPOINT_ROOT} from "../api";
|
||||
import {Box, List, ListItem, ListItemText} from "@material-ui/core";
|
||||
import RefreshIcon from "@material-ui/icons/Refresh";
|
||||
import {getRealTimeString, stringifyTime} from "./Time";
|
||||
import {HeatingInformationState} from "./types";
|
||||
|
||||
// define api endpoint
|
||||
export const HEATING_ENDPOINT = ENDPOINT_ROOT + "heatinginfo";
|
||||
|
||||
type HeatingRestcontollerprops = RestControllerProps<HeatingInformationState>;
|
||||
|
||||
class HeatingInformation extends React.Component<HeatingRestcontollerprops> {
|
||||
componentDidMount() {
|
||||
this.props.loadData();
|
||||
}
|
||||
|
||||
render = () => (
|
||||
<SectionContent title='Heizung Information' titleGutter>
|
||||
<RestFormLoader
|
||||
{...this.props}
|
||||
render={props => (
|
||||
<>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Heizung lief zuletzt:"
|
||||
secondary={props.data.lastheating !== 0 ?
|
||||
<>
|
||||
vor {stringifyTime(props.data.lastheating)}<br/>
|
||||
{getRealTimeString(props.data.lastheating)}
|
||||
</> : "noch nie!"}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Letze Heizdauer:"
|
||||
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:"
|
||||
secondary={(props.data.temp !== -1 ? props.data.temp + "C" : "Auslesefehler!") + " / " + (props.data.hum !== -1 ? props.data.hum + "%" : "Auslesefehler!")}
|
||||
/>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Box display="flex" flexWrap="wrap">
|
||||
<Box flexGrow={1} padding={1}>
|
||||
<FormButton startIcon={<RefreshIcon/>} variant="contained" color="secondary"
|
||||
onClick={this.props.loadData}>
|
||||
Refresh
|
||||
</FormButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</SectionContent>
|
||||
);
|
||||
}
|
||||
|
||||
export default restController(HEATING_ENDPOINT, HeatingInformation);
|
@ -9,7 +9,6 @@ import { AuthenticatedRoute } from '../authentication';
|
||||
|
||||
import GeneralInformation from './GeneralInformation';
|
||||
import SettingsController from "./SettingsController";
|
||||
import HeatingInformation from "./HeatingInformation";
|
||||
|
||||
class PumpControl extends Component<RouteComponentProps> {
|
||||
|
||||
@ -22,12 +21,10 @@ class PumpControl extends Component<RouteComponentProps> {
|
||||
<MenuAppBar sectionTitle="Wasserpumpensteuerung">
|
||||
<Tabs value={this.props.match.url} onChange={this.handleTabChange} variant="fullWidth">
|
||||
<Tab value={`/${PROJECT_PATH}/pumpe/information`} label="Information" />
|
||||
<Tab value={`/${PROJECT_PATH}/pumpe/heizung`} label="Heizung" />
|
||||
<Tab value={`/${PROJECT_PATH}/pumpe/settings`} label="Einstellungen" />
|
||||
</Tabs>
|
||||
<Switch>
|
||||
<AuthenticatedRoute exact path={`/${PROJECT_PATH}/pumpe/information`} component={GeneralInformation} />
|
||||
<AuthenticatedRoute exact path={`/${PROJECT_PATH}/pumpe/heizung`} component={HeatingInformation} />
|
||||
<AuthenticatedRoute exact path={`/${PROJECT_PATH}/pumpe/settings`} component={SettingsController} />
|
||||
<Redirect to={`/${PROJECT_PATH}/pumpe/information`} />
|
||||
</Switch>
|
||||
|
@ -1,33 +0,0 @@
|
||||
/**
|
||||
* stringify seconds to a pretty format
|
||||
* @param sec number of seconds
|
||||
*/
|
||||
export function stringifyTime(sec: number): string {
|
||||
if (sec >= 86400) {
|
||||
// display days
|
||||
return (Math.trunc(sec / 86400) + "d " + Math.trunc((sec % 86400) / 3600) + "h " + Math.trunc((sec % 3600) / 60) + "min " + sec % 60 + "sec");
|
||||
} else if (sec >= 3600) {
|
||||
// display hours
|
||||
return (Math.trunc(sec / 3600) + "h " + Math.trunc((sec % 3600) / 60) + "min " + sec % 60 + "sec");
|
||||
} else if (sec >= 60) {
|
||||
// only seconds and minutes
|
||||
return (Math.trunc(sec / 60) + "min " + sec % 60 + "sec");
|
||||
} else {
|
||||
// only seconds
|
||||
return (sec + "sec");
|
||||
}
|
||||
}
|
||||
|
||||
export function getRealTimeString(runtime: number): string {
|
||||
const timestamp = Date.now();
|
||||
|
||||
const a = new Date(timestamp - (runtime * 1000));
|
||||
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
const year = a.getFullYear();
|
||||
const month = months[a.getMonth()];
|
||||
const date = a.getDate();
|
||||
const hour = a.getHours();
|
||||
const min = "0" + a.getMinutes();
|
||||
const sec = "0" + a.getSeconds();
|
||||
return '[' + date + ' ' + month + ' ' + year + ' ' + hour + ':' + min.substr(-2) + ':' + sec.substr(-2) + ']';
|
||||
}
|
@ -7,6 +7,8 @@ export interface SettingsState {
|
||||
}
|
||||
|
||||
export interface GeneralInformaitonState {
|
||||
hum: number;
|
||||
temp: number;
|
||||
lastpumptime: number;
|
||||
lastWaterOutage: number;
|
||||
lastPumpDuration: number;
|
||||
@ -14,14 +16,4 @@ export interface GeneralInformaitonState {
|
||||
watersensor: boolean;
|
||||
pressuresensor: boolean;
|
||||
version: string;
|
||||
pumpcycles: number;
|
||||
}
|
||||
|
||||
export interface HeatingInformationState {
|
||||
lastheating: number;
|
||||
lastheatduration: number;
|
||||
hum: number;
|
||||
temp: number;
|
||||
totalheattime: number;
|
||||
heattimepercent: number;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void APSettingsService::manageAP() {
|
||||
void APSettingsService::startAP() {
|
||||
Serial.println(F("Starting software access point"));
|
||||
WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
|
||||
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), 1, !_state.networkVisible);
|
||||
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str());
|
||||
if (!_dnsServer) {
|
||||
IPAddress apIp = WiFi.softAPIP();
|
||||
Serial.print(F("Starting captive portal on "));
|
||||
|
@ -28,10 +28,6 @@
|
||||
#define FACTORY_AP_PASSWORD "esp-react"
|
||||
#endif
|
||||
|
||||
#ifndef FACTORY_AP_VISIBLE
|
||||
#define FACTORY_AP_VISIBLE true
|
||||
#endif
|
||||
|
||||
#ifndef FACTORY_AP_LOCAL_IP
|
||||
#define FACTORY_AP_LOCAL_IP "192.168.4.1"
|
||||
#endif
|
||||
@ -57,11 +53,10 @@ class APSettings {
|
||||
IPAddress localIP;
|
||||
IPAddress gatewayIP;
|
||||
IPAddress subnetMask;
|
||||
bool networkVisible;
|
||||
|
||||
bool operator==(const APSettings& settings) const {
|
||||
return provisionMode == settings.provisionMode && ssid == settings.ssid && password == settings.password &&
|
||||
localIP == settings.localIP && gatewayIP == settings.gatewayIP && subnetMask == settings.subnetMask && networkVisible == settings.networkVisible;
|
||||
localIP == settings.localIP && gatewayIP == settings.gatewayIP && subnetMask == settings.subnetMask;
|
||||
}
|
||||
|
||||
static void read(APSettings& settings, JsonObject& root) {
|
||||
@ -71,7 +66,6 @@ class APSettings {
|
||||
root["local_ip"] = settings.localIP.toString();
|
||||
root["gateway_ip"] = settings.gatewayIP.toString();
|
||||
root["subnet_mask"] = settings.subnetMask.toString();
|
||||
root["network_visible"] = settings.networkVisible;
|
||||
}
|
||||
|
||||
static StateUpdateResult update(JsonObject& root, APSettings& settings) {
|
||||
@ -87,7 +81,6 @@ class APSettings {
|
||||
}
|
||||
newSettings.ssid = root["ssid"] | FACTORY_AP_SSID;
|
||||
newSettings.password = root["password"] | FACTORY_AP_PASSWORD;
|
||||
newSettings.networkVisible = root["network_visible"] | FACTORY_AP_VISIBLE;
|
||||
|
||||
JsonUtils::readIP(root, "local_ip", newSettings.localIP, FACTORY_AP_LOCAL_IP);
|
||||
JsonUtils::readIP(root, "gateway_ip", newSettings.gatewayIP, FACTORY_AP_GATEWAY_IP);
|
||||
|
@ -20,12 +20,11 @@ build_flags=
|
||||
lib_compat_mode = strict
|
||||
|
||||
; Uncomment & modify the lines below in order to configure OTA updates
|
||||
;upload_flags =
|
||||
; --port=8266
|
||||
; --auth=esp-react
|
||||
; --host_port=14515
|
||||
;upload_port = 192.168.0.230
|
||||
;upload_protocol = espota
|
||||
upload_flags =
|
||||
--port=8266
|
||||
--auth=esp-react
|
||||
--host_port=14515
|
||||
upload_port = 192.168.0.230
|
||||
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
#include "GeneralInfoService.h"
|
||||
#include "Pins.h"
|
||||
#include "Timer.h"
|
||||
|
||||
GeneralInfoService::GeneralInfoService(AsyncWebServer *server) :
|
||||
GeneralInfoService::GeneralInfoService(AsyncWebServer *server, float *lasthum, float *lasttemp) :
|
||||
hum(lasthum),
|
||||
temp(lasttemp),
|
||||
lastPumpTime(0),
|
||||
lastWaterOutage(0),
|
||||
lastPumpDuration(0),
|
||||
pumpCycles(0) {
|
||||
lastPumpDuration(0) {
|
||||
server->on(GENERALINFO_SERVICE_PATH, HTTP_GET, std::bind(&GeneralInfoService::reply, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
@ -18,36 +18,31 @@ void GeneralInfoService::reply(AsyncWebServerRequest *request) {
|
||||
AsyncJsonResponse *response = new AsyncJsonResponse(false, MAX_FEATURES_SIZE);
|
||||
JsonObject root = response->getRoot();
|
||||
|
||||
const uint32_t systime = Timer::getSystemSeconds();
|
||||
root["temp"] = *temp;
|
||||
root["hum"] = *hum;
|
||||
|
||||
root["lastpumptime"] = lastPumpTime != 0 ? systime - lastPumpTime : 0;
|
||||
root["lastWaterOutage"] = lastWaterOutage != 0 ? systime - lastWaterOutage : 0;
|
||||
root["lastPumpDuration"] = lastPumpDuration != 0 ? lastPumpDuration : 0;
|
||||
root["runtime"] = systime;
|
||||
root["lastpumptime"] = lastPumpTime != 0 ? (millis() - lastPumpTime) / 1000 : 0;
|
||||
root["lastWaterOutage"] = lastWaterOutage != 0 ? (millis() - lastWaterOutage) / 1000 : 0;
|
||||
root["lastPumpDuration"] = lastPumpDuration != 0 ? lastPumpDuration / 1000 : 0;
|
||||
root["runtime"] = millis() / 1000;
|
||||
|
||||
root["watersensor"] = digitalRead(WasserSensorPin) ? true : false;
|
||||
root["pressuresensor"] = digitalRead(DruckSensorPin) ? true : false;
|
||||
|
||||
root["pumpcycles"] = pumpCycles;
|
||||
|
||||
root["version"] = VERSION;
|
||||
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
void GeneralInfoService::setlastPumpTime(uint32_t lastPumpTime) {
|
||||
void GeneralInfoService::setlastPumpTime(unsigned long lastPumpTime) {
|
||||
this->lastPumpTime = lastPumpTime;
|
||||
}
|
||||
|
||||
void GeneralInfoService::setlastWaterOutage(uint32_t lastWaterOutage) {
|
||||
void GeneralInfoService::setlastWaterOutage(unsigned long lastWaterOutage) {
|
||||
this->lastWaterOutage = lastWaterOutage;
|
||||
}
|
||||
|
||||
void GeneralInfoService::setPumpDuration(uint32_t lastPumpDuration) {
|
||||
void GeneralInfoService::setPumpDuration(unsigned long lastPumpDuration) {
|
||||
this->lastPumpDuration = lastPumpDuration;
|
||||
}
|
||||
|
||||
void GeneralInfoService::setPumpCycles(uint32_t cycles) {
|
||||
this->pumpCycles = cycles;
|
||||
}
|
||||
|
@ -17,34 +17,34 @@
|
||||
|
||||
class GeneralInfoService {
|
||||
public:
|
||||
GeneralInfoService(AsyncWebServer* server);
|
||||
GeneralInfoService(AsyncWebServer* server, float* lasthum, float* lasttemp);
|
||||
|
||||
/**
|
||||
* sets the last time when the pump was on
|
||||
* @param lastPumpTime pump time in ms
|
||||
*/
|
||||
void setlastPumpTime(uint32_t lastPumpTime);
|
||||
void setlastPumpTime(unsigned long lastPumpTime);
|
||||
|
||||
/**
|
||||
* sets the last time of a water outage
|
||||
* @param lastWaterOutage last wateroutage time in ms
|
||||
*/
|
||||
void setlastWaterOutage(uint32_t lastWaterOutage);
|
||||
void setlastWaterOutage(unsigned long lastWaterOutage);
|
||||
|
||||
/**
|
||||
* sets the duration of the last pump cycle
|
||||
* @param lastPumpDuration duration in ms
|
||||
*/
|
||||
void setPumpDuration(uint32_t lastPumpDuration);
|
||||
|
||||
void setPumpCycles(uint32_t i);
|
||||
void setPumpDuration(unsigned long lastPumpDuration);
|
||||
|
||||
private:
|
||||
void reply(AsyncWebServerRequest* request);
|
||||
|
||||
float * hum;
|
||||
float * temp;
|
||||
|
||||
unsigned long lastPumpTime, lastWaterOutage, lastPumpDuration;
|
||||
|
||||
uint32_t pumpCycles;
|
||||
};
|
||||
|
||||
|
||||
|
160
src/Heating.cpp
160
src/Heating.cpp
@ -4,25 +4,38 @@
|
||||
|
||||
#include "Heating.h"
|
||||
#include "Pins.h"
|
||||
#include "Timer.h"
|
||||
|
||||
Heating::Heating() : mHeizungTicker(),
|
||||
mLuefterTicker(),
|
||||
mTurnOffTicker(),
|
||||
msettings(nullptr),
|
||||
mheatingservice(nullptr),
|
||||
mHeatingStatus(false),
|
||||
lasttemp(0),
|
||||
lasthum(0),
|
||||
sensor() {}
|
||||
|
||||
void Heating::init(unsigned mode, const SettingState *settings, HeatingInfoService *heatingservice) {
|
||||
msettings = settings;
|
||||
mheatingservice = heatingservice;
|
||||
|
||||
void Heating::init(unsigned mode, const SettingState* settings) {
|
||||
switch (mode) {
|
||||
case TIME: {
|
||||
this->handleTimeHeater();
|
||||
const unsigned percentOn = 20;
|
||||
const unsigned refreshperiod = 900;
|
||||
|
||||
const auto func = [this]() {
|
||||
mLuefterTicker.detach();
|
||||
|
||||
// every minute turn on the heating
|
||||
digitalWrite(LuefterPin, HIGH);
|
||||
digitalWrite(HeizungPin, HIGH);
|
||||
|
||||
Serial.println("Turning on heating");
|
||||
|
||||
mTurnOffTicker.once((int) ((float) refreshperiod * (float) percentOn / 100.0), []() {
|
||||
digitalWrite(HeizungPin, LOW);
|
||||
|
||||
Serial.println("Turned off heating!");
|
||||
});
|
||||
|
||||
mLuefterTicker.once((int) (((float) refreshperiod * (float) percentOn / 100.0) + 30.0), []() {
|
||||
digitalWrite(LuefterPin, LOW);
|
||||
|
||||
Serial.println("Turned off fan!");
|
||||
});
|
||||
};
|
||||
|
||||
func();
|
||||
mHeizungTicker.attach(refreshperiod, func);
|
||||
break;
|
||||
}
|
||||
case HUMIDITY:
|
||||
@ -30,17 +43,39 @@ void Heating::init(unsigned mode, const SettingState *settings, HeatingInfoServi
|
||||
|
||||
sensor.setPin(TempSensorPin);
|
||||
|
||||
sensor.onData([this](float hum, float temp) {
|
||||
schedule_function([hum, temp, this]() {
|
||||
sensor.onData([this, settings](float hum, float temp) {
|
||||
schedule_function([hum, temp, settings, this]() {
|
||||
Serial.printf("Temp: %gdegC\n", temp);
|
||||
Serial.printf("Humid: %g%%\n", hum);
|
||||
|
||||
mheatingservice->setSensorData(hum, temp);
|
||||
|
||||
this->lasttemp = temp;
|
||||
this->lasthum = hum;
|
||||
|
||||
this->handleHeatingEvents();
|
||||
if (hum > (float)settings->heatUp) {
|
||||
// turn off active turnoff timers
|
||||
mLuefterTicker.detach();
|
||||
Serial.println("heating should run now!");
|
||||
// turn on heating and fan
|
||||
digitalWrite(LuefterPin, HIGH);
|
||||
digitalWrite(HeizungPin, HIGH);
|
||||
mHeatingStatus = true;
|
||||
} else if (hum < (float)settings->heatLow) {
|
||||
// if humidity too low turn off heating and fan after 60secs
|
||||
digitalWrite(HeizungPin, LOW);
|
||||
Serial.println("heating should NOT run now!");
|
||||
|
||||
// if heating status in on set ticker to turn of fan in 60sec
|
||||
if (mHeatingStatus) {
|
||||
mLuefterTicker.once((float)settings->fanRuntime, []() {
|
||||
// turn off fan
|
||||
digitalWrite(LuefterPin, LOW);
|
||||
schedule_function([]() {
|
||||
Serial.println("turning off fan");
|
||||
});
|
||||
});
|
||||
}
|
||||
mHeatingStatus = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -48,13 +83,6 @@ void Heating::init(unsigned mode, const SettingState *settings, HeatingInfoServi
|
||||
this->lasttemp = -1.0;
|
||||
this->lasthum = -1.0;
|
||||
|
||||
mheatingservice->setSensorData(-1.0, -1.0);
|
||||
|
||||
// emergency turnoff of heating
|
||||
if (mHeatingStatus) {
|
||||
digitalWrite(HeizungPin, LOW);
|
||||
}
|
||||
|
||||
schedule_function([e]() {
|
||||
Serial.printf("Error: %d\n", e);
|
||||
});
|
||||
@ -70,72 +98,18 @@ void Heating::init(unsigned mode, const SettingState *settings, HeatingInfoServi
|
||||
}
|
||||
}
|
||||
|
||||
void Heating::handleHeatingEvents() {
|
||||
if (this->lasthum > (float) msettings->heatUp) {
|
||||
// only turn on if turned off
|
||||
if (mHeatingStatus == false) {
|
||||
// turn off active turnoff timers
|
||||
mLuefterTicker.detach();
|
||||
Serial.println("heating should run now!");
|
||||
// turn on heating and fan
|
||||
digitalWrite(LuefterPin, HIGH);
|
||||
digitalWrite(HeizungPin, HIGH);
|
||||
|
||||
mHeatingStatus = true;
|
||||
mheatingservice->setLastHeatingStarttime(Timer::getSystemSeconds());
|
||||
|
||||
mheatingservice->setLastHetingEndtime(0);
|
||||
}
|
||||
} else if (this->lasthum < (float) msettings->heatLow) {
|
||||
// if humidity too low turn off heating and fan after 60secs
|
||||
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) {
|
||||
mLuefterTicker.once((float) msettings->fanRuntime, []() {
|
||||
// turn off fan
|
||||
digitalWrite(LuefterPin, LOW);
|
||||
schedule_function([]() {
|
||||
Serial.println("turning off fan");
|
||||
});
|
||||
});
|
||||
}
|
||||
mheatingservice->setLastHetingEndtime(Timer::getSystemSeconds());
|
||||
mHeatingStatus = false;
|
||||
}
|
||||
}
|
||||
float *Heating::getLastTemp() {
|
||||
return &lasttemp;
|
||||
}
|
||||
|
||||
void Heating::handleTimeHeater() {
|
||||
const unsigned percentOn = 20;
|
||||
const unsigned refreshperiod = 900;
|
||||
|
||||
const auto func = [this]() {
|
||||
mLuefterTicker.detach();
|
||||
|
||||
// every minute turn on the heating
|
||||
digitalWrite(LuefterPin, HIGH);
|
||||
digitalWrite(HeizungPin, HIGH);
|
||||
|
||||
Serial.println("Turning on heating");
|
||||
|
||||
mTurnOffTicker.once((int) ((float) refreshperiod * (float) percentOn / 100.0), []() {
|
||||
digitalWrite(HeizungPin, LOW);
|
||||
|
||||
Serial.println("Turned off heating!");
|
||||
});
|
||||
|
||||
mLuefterTicker.once((int) (((float) refreshperiod * (float) percentOn / 100.0) + 30.0), []() {
|
||||
digitalWrite(LuefterPin, LOW);
|
||||
|
||||
Serial.println("Turned off fan!");
|
||||
});
|
||||
};
|
||||
|
||||
func();
|
||||
mHeizungTicker.attach(refreshperiod, func);
|
||||
float *Heating::getLastHum() {
|
||||
return &lasthum;
|
||||
}
|
||||
|
||||
Heating::Heating() : mHeizungTicker(),
|
||||
mLuefterTicker(),
|
||||
mTurnOffTicker(),
|
||||
mHeatingStatus(),
|
||||
lasttemp(0),
|
||||
lasthum(0),
|
||||
sensor() {}
|
||||
|
@ -8,18 +8,15 @@
|
||||
#include <DHT.h>
|
||||
#include "Pins.h"
|
||||
#include "SettingsService.h"
|
||||
#include "HeatingInfoService.h"
|
||||
|
||||
class Heating {
|
||||
public:
|
||||
Heating();
|
||||
|
||||
/**
|
||||
* initialize the heater
|
||||
* @param mode select the operating mode
|
||||
* @param settings a settings object is needed for HUMIDITY mode to get percent values set by user
|
||||
*/
|
||||
void init(unsigned mode, const SettingState* settings, HeatingInfoService *heatingservice);
|
||||
void init(unsigned mode, const SettingState* settings);
|
||||
|
||||
float* getLastHum();
|
||||
float* getLastTemp();
|
||||
|
||||
enum MODES {TIME, HUMIDITY};
|
||||
private:
|
||||
@ -27,26 +24,10 @@ private:
|
||||
Ticker mLuefterTicker;
|
||||
Ticker mTurnOffTicker;
|
||||
|
||||
const SettingState* msettings;
|
||||
HeatingInfoService *mheatingservice;
|
||||
|
||||
bool mHeatingStatus;
|
||||
|
||||
float lasttemp;
|
||||
float lasthum;
|
||||
|
||||
DHT22 sensor;
|
||||
|
||||
/**
|
||||
* handle events after successfully received a humidity value
|
||||
* - turn on/off of heating
|
||||
* - afterrun of fan
|
||||
*/
|
||||
void handleHeatingEvents();
|
||||
|
||||
/**
|
||||
* handle events for time-heating mode
|
||||
* when to turn on/off heating + fan
|
||||
*/
|
||||
void handleTimeHeater();
|
||||
};
|
||||
|
@ -1,58 +0,0 @@
|
||||
//
|
||||
// Created by lukas on 19.12.20.
|
||||
//
|
||||
|
||||
#include <AsyncJson.h>
|
||||
#include "HeatingInfoService.h"
|
||||
#include "Timer.h"
|
||||
|
||||
HeatingInfoService::HeatingInfoService(AsyncWebServer *server) :
|
||||
hum(-1),
|
||||
temp(-1),
|
||||
lastheating(0),
|
||||
lastheatend(0),
|
||||
totalHeatTime(0) {
|
||||
server->on(HEATINGINFO_SERVICE_PATH, HTTP_GET, std::bind(&HeatingInfoService::reply, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
void HeatingInfoService::reply(AsyncWebServerRequest *request) {
|
||||
AsyncJsonResponse *response = new AsyncJsonResponse(false, MAX_FEATURES_SIZE);
|
||||
JsonObject root = response->getRoot();
|
||||
|
||||
root["temp"] = temp;
|
||||
root["hum"] = hum;
|
||||
|
||||
const uint32_t systime = Timer::getSystemSeconds();
|
||||
|
||||
root["lastheating"] = lastheating != 0 ? systime - lastheating : 0;
|
||||
// if lastheating == 0 => there was no cycle upon now
|
||||
// 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);
|
||||
}
|
||||
|
||||
void HeatingInfoService::setSensorData(float hum, float temp) {
|
||||
this->hum = hum;
|
||||
this->temp = temp;
|
||||
}
|
||||
|
||||
void HeatingInfoService::setLastHeatingStarttime(unsigned long time) {
|
||||
this->lastheating = 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;
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
//
|
||||
// Created by lukas on 19.12.20.
|
||||
//
|
||||
|
||||
#ifndef PUMPENSTEUERUNG_HEATINGINFOSERVICE_H
|
||||
#define PUMPENSTEUERUNG_HEATINGINFOSERVICE_H
|
||||
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
#define MAX_FEATURES_SIZE 256
|
||||
#define HEATINGINFO_SERVICE_PATH "/rest/heatinginfo" // set the api backend path
|
||||
|
||||
|
||||
class HeatingInfoService {
|
||||
public:
|
||||
HeatingInfoService(AsyncWebServer* server);
|
||||
|
||||
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);
|
||||
|
||||
float hum;
|
||||
float temp;
|
||||
|
||||
unsigned long lastheating;
|
||||
unsigned long lastheatend;
|
||||
|
||||
uint32_t totalHeatTime;
|
||||
};
|
||||
|
||||
|
||||
#endif //PUMPENSTEUERUNG_HEATINGINFOSERVICE_H
|
@ -16,6 +16,6 @@
|
||||
#define TempSensorPin D4
|
||||
|
||||
// version info
|
||||
#define VERSION "v1.2.4-Alpha2"
|
||||
#define VERSION "v1.2.0"
|
||||
|
||||
#endif //PUMPENSTEUERUNG_PINS_H
|
||||
|
@ -1,10 +0,0 @@
|
||||
//
|
||||
// Created by lukas on 09.12.20.
|
||||
//
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Timer.h"
|
||||
|
||||
uint32_t Timer::getSystemSeconds() {
|
||||
return (uint32_t)(micros64() / 1000000);
|
||||
}
|
18
src/Timer.h
18
src/Timer.h
@ -1,18 +0,0 @@
|
||||
//
|
||||
// Created by lukas on 09.12.20.
|
||||
//
|
||||
|
||||
#ifndef PUMPENSTEUERUNG_TIMER_H
|
||||
#define PUMPENSTEUERUNG_TIMER_H
|
||||
|
||||
class Timer {
|
||||
public:
|
||||
/**
|
||||
* get system time in seconds
|
||||
* @return system time in seconds
|
||||
*/
|
||||
static uint32_t getSystemSeconds();
|
||||
};
|
||||
|
||||
|
||||
#endif //PUMPENSTEUERUNG_TIMER_H
|
92
src/main.cpp
92
src/main.cpp
@ -5,8 +5,6 @@
|
||||
#include "Pins.h"
|
||||
#include "GeneralInfoService.h"
|
||||
#include "SettingsService.h"
|
||||
#include "Timer.h"
|
||||
#include "HeatingInfoService.h"
|
||||
|
||||
bool allow;
|
||||
bool error = false;
|
||||
@ -15,19 +13,17 @@ bool error = false;
|
||||
Ticker status;
|
||||
|
||||
//pumpendauer maximum ticker
|
||||
Ticker pumpendauer, wasserSensorDoubleCheck;
|
||||
Ticker pumpendauer;
|
||||
|
||||
//WifiManager mang;
|
||||
Heating mHeat;
|
||||
|
||||
uint32_t turnontime = 0;
|
||||
uint32_t pumpcycles = 0;
|
||||
unsigned long turnontime = 0;
|
||||
|
||||
AsyncWebServer server(80);
|
||||
ESP8266React esp8266React(&server);
|
||||
|
||||
GeneralInfoService generalinfo = GeneralInfoService(&server);
|
||||
HeatingInfoService heatinginfo = HeatingInfoService(&server);
|
||||
GeneralInfoService generalinfo = GeneralInfoService(&server, mHeat.getLastHum(), mHeat.getLastTemp());
|
||||
SettingsService settingsservice = SettingsService(&server, esp8266React.getSecurityManager());
|
||||
|
||||
void pumpeSchalten(bool on) {
|
||||
@ -35,20 +31,16 @@ void pumpeSchalten(bool on) {
|
||||
if (on) {
|
||||
Serial.println("versuche Pumpe EIN zuschalten");
|
||||
// refresh last pump counter
|
||||
generalinfo.setlastPumpTime(Timer::getSystemSeconds());
|
||||
generalinfo.setlastPumpTime(millis());
|
||||
} else {
|
||||
Serial.println("versuche Pumpe AUS zuschalten");
|
||||
}
|
||||
|
||||
if (allow && !error) {
|
||||
if (on) {
|
||||
pumpcycles++;
|
||||
generalinfo.setPumpCycles(pumpcycles);
|
||||
|
||||
pumpendauer.once((float) settingsservice.getSettings()->maxpumpduration + 1, []() {
|
||||
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 (millis() - turnontime >= (unsigned)settingsservice.getSettings()->maxpumpduration * 1000 && turnontime != 0) {
|
||||
//error zu lange
|
||||
Serial.println("\n\npumpe lief mehr als 10 Minuten durchgaengig");
|
||||
pumpeSchalten(false);
|
||||
@ -56,17 +48,16 @@ void pumpeSchalten(bool on) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
generalinfo.setPumpDuration(Timer::getSystemSeconds() - turnontime);
|
||||
generalinfo.setPumpDuration(millis() - turnontime);
|
||||
}
|
||||
|
||||
// save pump start time
|
||||
turnontime = Timer::getSystemSeconds();
|
||||
turnontime = millis();
|
||||
|
||||
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);
|
||||
}
|
||||
@ -95,46 +86,39 @@ int wateroutagewaitduration;
|
||||
|
||||
void WasserSensorCheck() {
|
||||
if (digitalRead(WasserSensorPin) == LOW) {
|
||||
// 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
|
||||
Serial.println("Wasser Sensor AUS");
|
||||
//kein Wasser dh timer auf 10min stellen
|
||||
|
||||
// refresh wateroutage counter
|
||||
generalinfo.setlastWaterOutage(Timer::getSystemSeconds());
|
||||
// refresh wateroutage counter
|
||||
generalinfo.setlastWaterOutage(millis());
|
||||
|
||||
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 {
|
||||
@ -195,7 +179,7 @@ void setup() {
|
||||
|
||||
// initialize heating control
|
||||
Serial.println("initializing heating service");
|
||||
mHeat.init(Heating::HUMIDITY, settingsservice.getSettings(), &heatinginfo);
|
||||
mHeat.init(Heating::HUMIDITY, settingsservice.getSettings());
|
||||
|
||||
Serial.println("startup sequence complete!\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user