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> waterLevelMin("waterminlevel", "distance (mm) at minimum water level (pumps still covered)");
HomieSetting<long> waterLevelWarn("waterlevelwarn", "warn (mm) if below this water level %"); HomieSetting<long> waterLevelWarn("waterlevelwarn", "warn (mm) if below this water level %");
HomieSetting<long> waterLevelVol("waterVolume", "(ml) between minimum and maximum"); HomieSetting<long> waterLevelVol("waterVolume", "(ml) between minimum and maximum");
HomieSetting<const char *>ntpServer("ntpServer", "NTP server (pool.ntp.org as default)");
/** Plant specific ones */ /** 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 int lastPumpRunning = 0;
RTC_DATA_ATTR long lastWaterValue = 0; RTC_DATA_ATTR long lastWaterValue = 0;
const char* ntpServer = "pool.ntp.org";
bool warmBoot = true; bool warmBoot = true;
bool volatile mode3Active = false; /**< Controller must not sleep */ bool volatile mode3Active = false; /**< Controller must not sleep */
bool volatile mDeepsleep = false; bool volatile mDeepsleep = false;
@ -180,8 +178,6 @@ void espDeepSleepFor(long seconds, bool activatePump = false){
void mode2MQTT(){ void mode2MQTT(){
readSystemSensors(); readSystemSensors();
configTime(0, 0, ntpServer);
digitalWrite(OUTPUT_PUMP, LOW); digitalWrite(OUTPUT_PUMP, LOW);
for (int i=0; i < MAX_PLANTS; i++) { for (int i=0; i < MAX_PLANTS; i++) {
mPlants[i].deactivatePump(); mPlants[i].deactivatePump();
@ -488,7 +484,7 @@ bool aliveHandler(const HomieRange& range, const String& value) {
} }
void homieLoop(){ void homieLoop(){
} }
void systemInit(){ void systemInit(){
@ -502,6 +498,7 @@ void systemInit(){
deepSleepTime.setDefaultValue(60); deepSleepTime.setDefaultValue(60);
deepSleepNightTime.setDefaultValue(600); deepSleepNightTime.setDefaultValue(600);
wateringDeepSleep.setDefaultValue(5); wateringDeepSleep.setDefaultValue(5);
ntpServer.setDefaultValue("pool.ntp.org");
/* waterLevelMax 1000 */ /* 100cm in mm */ /* waterLevelMax 1000 */ /* 100cm in mm */
waterLevelMin.setDefaultValue(50); /* 5cm in mm */ waterLevelMin.setDefaultValue(50); /* 5cm in mm */
@ -513,6 +510,8 @@ void systemInit(){
//Homie.disableLogging(); //Homie.disableLogging();
Homie.setup(); Homie.setup();
configTime(0, 0, ntpServer.get());
mConfigured = Homie.isConfigured(); mConfigured = Homie.isConfigured();
if (mConfigured) { if (mConfigured) {
for(int i=0; i < MAX_PLANTS; i++) { for(int i=0; i < MAX_PLANTS; i++) {