NTP Server can be set via configuration item

This commit is contained in:
Ollo 2020-11-01 20:17:21 +01:00
parent b85b2e6952
commit e0de8dabe8
2 changed files with 5 additions and 5 deletions

View File

@ -45,6 +45,7 @@ HomieSetting<long> waterLevelMax("watermaxlevel", "distance (mm) at maximum wate
HomieSetting<long> waterLevelMin("waterminlevel", "distance (mm) at minimum water level (pumps still covered)");
HomieSetting<long> waterLevelWarn("waterlevelwarn", "warn (mm) if below this water level %");
HomieSetting<long> waterLevelVol("waterVolume", "(ml) between minimum and maximum");
HomieSetting<const char *>ntpServer("ntpServer", "NTP server (pool.ntp.org as default)");
/** Plant specific ones */

View File

@ -49,8 +49,6 @@ RTC_DATA_ATTR long rtcMoistureTrigger6 = 0; /**<Level for the moisture sensor
RTC_DATA_ATTR int lastPumpRunning = 0;
RTC_DATA_ATTR long lastWaterValue = 0;
const char* ntpServer = "pool.ntp.org";
bool warmBoot = true;
bool volatile mode3Active = false; /**< Controller must not sleep */
bool volatile mDeepsleep = false;
@ -180,8 +178,6 @@ void espDeepSleepFor(long seconds, bool activatePump = false){
void mode2MQTT(){
readSystemSensors();
configTime(0, 0, ntpServer);
digitalWrite(OUTPUT_PUMP, LOW);
for (int i=0; i < MAX_PLANTS; i++) {
mPlants[i].deactivatePump();
@ -502,6 +498,7 @@ void systemInit(){
deepSleepTime.setDefaultValue(60);
deepSleepNightTime.setDefaultValue(600);
wateringDeepSleep.setDefaultValue(5);
ntpServer.setDefaultValue("pool.ntp.org");
/* waterLevelMax 1000 */ /* 100cm in mm */
waterLevelMin.setDefaultValue(50); /* 5cm in mm */
@ -513,6 +510,8 @@ void systemInit(){
//Homie.disableLogging();
Homie.setup();
configTime(0, 0, ntpServer.get());
mConfigured = Homie.isConfigured();
if (mConfigured) {
for(int i=0; i < MAX_PLANTS; i++) {