NTP server is used from configuration setting

This commit is contained in:
Ollo 2020-11-01 20:29:24 +01:00
parent e0de8dabe8
commit 89070806f7

View File

@ -399,9 +399,11 @@ void onHomieEvent(const HomieEvent& event) {
Homie.getLogger() << "My statistics" << endl; Homie.getLogger() << "My statistics" << endl;
break; break;
case HomieEventType::MQTT_READY: case HomieEventType::MQTT_READY:
Serial.printf("NTP Setup with server %s\r\n", ntpServer.get());
configTime(0, 0, ntpServer.get());
//wait for rtc sync? //wait for rtc sync?
rtcDeepSleepTime = deepSleepTime.get(); rtcDeepSleepTime = deepSleepTime.get();
Serial << "MQTT ready " << endl; Serial << "Setup plants" << endl;
for(int i=0; i < MAX_PLANTS; i++) { for(int i=0; i < MAX_PLANTS; i++) {
mPlants[i].postMQTTconnection(); mPlants[i].postMQTTconnection();
} }
@ -484,7 +486,7 @@ bool aliveHandler(const HomieRange& range, const String& value) {
} }
void homieLoop(){ void homieLoop(){
} }
void systemInit(){ void systemInit(){
@ -510,8 +512,6 @@ 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++) {