diff --git a/OTGW-firmware.ino b/OTGW-firmware.ino index e488a62..251d6c8 100644 --- a/OTGW-firmware.ino +++ b/OTGW-firmware.ino @@ -60,7 +60,7 @@ void setup() { // Connect to and initialise WiFi network OTGWSerial.println(F("Attempting to connect to WiFi network\r")); setLed(LED1, ON); - startWiFi(_HOSTNAME, 240); // timeout 240 seconds + startWiFi(CSTR(settingHostname), 240); // timeout 240 seconds blinkLED(LED1, 3, 100); setLed(LED1, OFF); @@ -153,7 +153,7 @@ void doTaskEvery60s(){ if (WiFi.status() != WL_CONNECTED) { //disconnected, try to reconnect then... - startWiFi(_HOSTNAME, 240); + startWiFi(CSTR(settingHostname), 240); //check OTGW and telnet startTelnet(); startOTGWstream(); diff --git a/README.md b/README.md index c3c267b..44348a4 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Looking for the documentation, go here (work in progress):
https://github. | Version | Release notes | |-|-| | 0.8.2 | Added: Command Queue to MQTT command topic
Bugfix: Values not updating in WebUI fixed
Added: verbose debug modes
-Added check for littlefs githash
Added: Interval setting for sensor readout
Adding: Send OTGW commands on boot| +Added check for littlefs githash
Added: Interval setting for sensor readout
Adding: Send OTGW commands on boot
Bugfix: Hostname now actually changes if needed.| | 0.8.1 | Improved ot msg processing
MQTT: added `otgw-firmware/version`, `otgw-firmware/reboot_count`, `otgw-firmware/version` and `otgw-firmware/uptime` (seconds)
Bugfix: typoo in topic name `master_low_off_pomp_control_function` -> `master_low_off_pump_control_function`
Bugfix: Home Assistant thermostat operation mode (flame icon) template
Feature: Add support for Dallas temperature sensors, defaults GPIO10, pushes data to `otgw-firmware/sensors/` | | 0.8.0 | **Breaking Change: MQTT topic naming convention has changed from `/` to `/value//` for data publshed and `/set//` for subscriptions**
Update Homeasssistant Discovery: add OTGW as a device and group all exposed entities as childs
Update Homeasssistant Discovery: add climate (thermostat) enity, uses temporary temperature override (OTGW `TT` command) (Home Assistant Core v2021.2.0+)
Bugfix #14: reduce MQTT connect timeout < the watchdog timeout to prevent reboot on a timout
Adding LLMNR responder (http://otgw/ will work now too)
New restapi: Telegraf endpoint (/api/v1/otgw/telegraf)
Fixing bugs in core OTGW msg processor for ASF flas| | 0.7.8 | Update Home Assistant Discovery
Flexible Home Assistant prefix
Bugfix: Removed hardcoded OTGW topic
Bugfix: NTP timezone discovery removed | diff --git a/handleDebug.ino b/handleDebug.ino index 398744b..1a76f8e 100644 --- a/handleDebug.ino +++ b/handleDebug.ino @@ -4,6 +4,10 @@ void handleDebug(){ char c; c = TelnetStream.read(); switch (c){ + case 'q': + DebugTln("Read settings"); + readSettings(true); + break; case 'm': DebugTln("Configure MQTT Discovery"); DebugTf("Enable MQTT: %s", CBOOLEAN(settingMQTTenable)); @@ -13,7 +17,7 @@ void handleDebug(){ if (WiFi.status() != WL_CONNECTED) { DebugTln("Reconnecting to wifi"); - startWiFi(_HOSTNAME, 240); + startWiFi(CSTR(settingHostname), 240); //check OTGW and telnet startTelnet(); startOTGWstream(); diff --git a/settingStuff.ino b/settingStuff.ino index 6ddf549..feee19c 100644 --- a/settingStuff.ino +++ b/settingStuff.ino @@ -27,7 +27,7 @@ void writeSettings(bool show) DebugT(F("Start writing setting data ")); //const size_t capacity = JSON_OBJECT_SIZE(6); // save more setting, grow # of objects accordingly - DynamicJsonDocument doc(512); + DynamicJsonDocument doc(1024); JsonObject root = doc.to(); root["hostname"] = settingHostname; root["MQTTenable"] = settingMQTTenable; @@ -71,7 +71,7 @@ void readSettings(bool show) } // Deserialize the JSON document - StaticJsonDocument<512> doc; + StaticJsonDocument<1024> doc; DeserializationError error = deserializeJson(doc, file); if (error) { @@ -109,12 +109,6 @@ void readSettings(bool show) // Close the file (Curiously, File's destructor doesn't close the file) file.close(); - //Update some settings right now - MDNS.setHostname(CSTR(settingHostname)); // start advertising with new(?) settingHostname - - //Resetart MQTT connection every "save settings" - startMQTT(); - DebugTln(F(" .. done\r\n")); if (show) { @@ -156,6 +150,13 @@ void updateSetting(const char *field, const char *newValue) settingMQTTtopTopic = settingMQTTtopTopic.substring(0, pos-1); } + //Update some settings right now + startMDNS(CSTR(settingHostname)); + startLLMNR(CSTR(settingHostname)); + + //Resetart MQTT connection every "save settings" + startMQTT(); + Debugln(); DebugTf("Need reboot before new %s.local will be available!\r\n\n", CSTR(settingHostname)); } @@ -173,9 +174,10 @@ void updateSetting(const char *field, const char *newValue) } if (stricmp(field, "MQTThaprefix")==0) { settingMQTThaprefix = String(newValue); - if (settingMQTThaprefix.length()==0) settingMQTThaprefix = HOME_ASSISTANT_DISCOVERY_PREFIX; + if (settingMQTThaprefix.length()==0) settingMQTThaprefix = HOME_ASSISTANT_DISCOVERY_PREFIX; } - if (stricmp(field, "MQTTOTmessage")==0) settingMQTTOTmessage = EVALBOOLEAN(newValue); + if (stricmp(field, "MQTTOTmessage")==0) settingMQTTOTmessage = EVALBOOLEAN(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, "NTPtimezone")==0) { @@ -204,6 +206,10 @@ void updateSetting(const char *field, const char *newValue) //finally update write settings writeSettings(false); + // if (strstr(field, "hostname")!= NULL) { + // //restart wifi + // startWIFI( CSTR(settingHostname), 240) + // } } // updateSetting()