Adding NTP hostname setting to webui
This commit is contained in:
parent
dbeddfb74a
commit
e69e1fea7d
|
@ -40,7 +40,8 @@ void setLed(int8_t, uint8_t);
|
|||
//Defaults and macro definitions
|
||||
#define _HOSTNAME "OTGW"
|
||||
#define SETTINGS_FILE "/settings.ini"
|
||||
#define DEFAULT_TIMEZONE "Europe/Amsterdam"
|
||||
#define NTP_DEFAULT_TIMEZONE "Europe/Amsterdam"
|
||||
#define NTP_HOST_DEFAULT "time.google.com"
|
||||
|
||||
#define HOME_ASSISTANT_DISCOVERY_PREFIX "homeassistant" // Home Assistant discovery prefix
|
||||
|
||||
|
@ -93,7 +94,8 @@ String settingMQTTtopTopic = "otgw";
|
|||
String settingMQTTuniqueid = ""; // Intialized in readsettings
|
||||
bool settingMQTTOTmessage = false;
|
||||
bool settingNTPenable = true;
|
||||
String settingNTPtimezone = DEFAULT_TIMEZONE;
|
||||
String settingNTPtimezone = NTP_DEFAULT_TIMEZONE;
|
||||
String settingNTPhostname = NTP_HOST_DEFAULT;
|
||||
bool settingLEDblink = true;
|
||||
|
||||
// GPIO Sensor Settings
|
||||
|
|
|
@ -131,14 +131,12 @@ void restartWifi(){
|
|||
//====[ startNTP ]===
|
||||
void startNTP(){
|
||||
// Initialisation ezTime
|
||||
#define NTP_HOST "time.google.com"
|
||||
|
||||
if (!settingNTPenable) return;
|
||||
|
||||
setDebug(NONE);
|
||||
setServer(NTP_HOST);
|
||||
setServer(CSTR(settingNTPhostname));
|
||||
|
||||
if (settingNTPtimezone.length()==0) settingNTPtimezone = DEFAULT_TIMEZONE; //set back to default timezone
|
||||
if (settingNTPtimezone.length()==0) settingNTPtimezone = NTP_DEFAULT_TIMEZONE; //set back to default timezone
|
||||
|
||||
if (myTZ.setLocation(settingNTPtimezone)){
|
||||
DebugTf("Timezone set to: %s\r\n", CSTR(settingNTPtimezone));
|
||||
|
@ -149,7 +147,7 @@ void startNTP(){
|
|||
DebugTf("DST : %d\r\n", myTZ.isDST());
|
||||
} else {
|
||||
DebugTf("Error setting Timezone: %s\r\n", CSTR(errorString()));
|
||||
settingNTPtimezone = DEFAULT_TIMEZONE;
|
||||
settingNTPtimezone = NTP_DEFAULT_TIMEZONE;
|
||||
}
|
||||
|
||||
myTZ.setDefault();
|
||||
|
|
|
@ -710,6 +710,7 @@
|
|||
,[ "mqtthaprefix", "MQTT Home Assistant prefix"]
|
||||
,[ "ntpenable", "NTP Enable"]
|
||||
,[ "ntptimezone", "NTP Timezone"]
|
||||
,[ "ntphostname", "NTP hostname"]
|
||||
,[ "uptime", "Uptime since boot"]
|
||||
,[ "bootcount", "Nr. Reboots"]
|
||||
,[ "ledblink", "Heartbeat LED (on/off)"]
|
||||
|
|
|
@ -106,7 +106,9 @@ void readSettings(bool show)
|
|||
settingMQTTOTmessage = doc["MQTTOTmessage"]|settingMQTTOTmessage;
|
||||
settingNTPenable = doc["NTPenable"];
|
||||
settingNTPtimezone = doc["NTPtimezone"].as<String>();
|
||||
if (settingNTPtimezone=="null") settingNTPtimezone = "Europe/Amsterdam"; //default to amsterdam timezone
|
||||
if (settingNTPtimezone=="null") settingNTPtimezone = NTP_DEFAULT_TIMEZONE; //"Europe/Amsterdam"; //default to amsterdam timezone
|
||||
settingNTPhostname = doc["NTPhostname"].as<String>();
|
||||
if (settingNTPhostname=="null") settingNTPhostname = NTP_HOST_DEFAULT;
|
||||
settingLEDblink = doc["LEDblink"]|settingLEDblink;
|
||||
settingGPIOSENSORSenabled = doc["GPIOSENSORSenabled"] | settingGPIOSENSORSenabled;
|
||||
settingGPIOSENSORSpin = doc["GPIOSENSORSpin"] | settingGPIOSENSORSpin;
|
||||
|
@ -137,6 +139,7 @@ void readSettings(bool show)
|
|||
Debugf("HA prefix : %s\r\n", CSTR(settingMQTThaprefix));
|
||||
Debugf("NTP enabled : %s\r\n", CBOOLEAN(settingNTPenable));
|
||||
Debugf("NPT timezone : %s\r\n", CSTR(settingNTPtimezone));
|
||||
Debugf("NPT hostname : %s\r\n", CSTR(settingNTPhostname));
|
||||
Debugf("Led Blink : %s\r\n", CBOOLEAN(settingLEDblink));
|
||||
Debugf("GPIO Sensors : %s\r\n", CBOOLEAN(settingGPIOSENSORSenabled));
|
||||
Debugf("GPIO Sen. Pin : %d\r\n", settingGPIOSENSORSpin);
|
||||
|
@ -201,6 +204,7 @@ void updateSetting(const char *field, const char *newValue)
|
|||
if (strstr(field, "mqtt") != NULL) startMQTT();//restart MQTT on change of any setting
|
||||
|
||||
if (stricmp(field, "NTPenable")==0) settingNTPenable = EVALBOOLEAN(newValue);
|
||||
if (stricmp(field, "NTPhostname")==0) settingNTPhostname = String(newValue);
|
||||
if (stricmp(field, "NTPtimezone")==0) {
|
||||
settingNTPtimezone = String(newValue);
|
||||
startNTP(); // update timezone if changed
|
||||
|
|
14
version.h
14
version.h
|
@ -2,15 +2,15 @@
|
|||
#define _VERSION_MAJOR 0
|
||||
#define _VERSION_MINOR 8
|
||||
#define _VERSION_PATCH 7
|
||||
#define _VERSION_BUILD 1064
|
||||
#define _VERSION_GITHASH "13191a2"
|
||||
#define _VERSION_BUILD 1067
|
||||
#define _VERSION_GITHASH "dbeddfb"
|
||||
#define _VERSION_PRERELEASE beta
|
||||
#define _VERSION_DATE "15-09-2021"
|
||||
#define _VERSION_TIME "20:31:41"
|
||||
#define _VERSION_TIME "21:34:07"
|
||||
#define _SEMVER_CORE "0.8.7"
|
||||
#define _SEMVER_BUILD "0.8.7+1064"
|
||||
#define _SEMVER_GITHASH "0.8.7+13191a2"
|
||||
#define _SEMVER_FULL "0.8.7-beta+13191a2"
|
||||
#define _SEMVER_BUILD "0.8.7+1067"
|
||||
#define _SEMVER_GITHASH "0.8.7+dbeddfb"
|
||||
#define _SEMVER_FULL "0.8.7-beta+dbeddfb"
|
||||
#define _SEMVER_NOBUILD "0.8.7-beta (15-09-2021)"
|
||||
#define _VERSION "0.8.7-beta+13191a2 (15-09-2021)"
|
||||
#define _VERSION "0.8.7-beta+dbeddfb (15-09-2021)"
|
||||
//The version information is created automatically, more information here: https://github.com/rvdbreemen/autoinc-semver
|
||||
|
|
Loading…
Reference in New Issue