From 129c26c695c43319a57f35a1c33f604571c488ac Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 25 Jan 2021 16:25:17 +0100 Subject: [PATCH] Refactor module logging --- tasmota/xdrv_01_webserver.ino | 6 ++++-- tasmota/xdrv_07_domoticz.ino | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 991394762..2c2838ac7 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -484,6 +484,8 @@ void StartWebserver(int type, IPAddress ipweb) #else AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str()); +// AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %_I"), +// NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", (uint32_t)ipweb); #endif // LWIP_IPV6 = 1 TasmotaGlobal.rules_flag.http_init = 1; } @@ -1587,12 +1589,12 @@ void ModuleSaveSettings(void) } else { if (ValidGPIO(i, template_gp.io[i])) { Settings.my_gp.io[i] = WebGetGpioArg(i); - gpios += F(", "); gpios += String(i); gpios += F(" "); gpios += String(Settings.my_gp.io[i]); + gpios += F(", IO"); gpios += String(i); gpios += F(" "); gpios += String(Settings.my_gp.io[i]); } } } - AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str()); + AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str()); } /*-------------------------------------------------------------------------------------------*/ diff --git a/tasmota/xdrv_07_domoticz.ino b/tasmota/xdrv_07_domoticz.ino index 96a6d4e3c..d3a16ed86 100644 --- a/tasmota/xdrv_07_domoticz.ino +++ b/tasmota/xdrv_07_domoticz.ino @@ -397,6 +397,25 @@ void DomoticzSensor(uint8_t idx, uint32_t value) { DomoticzSensor(idx, data); } +void DomoticzFloatSensor(uint8_t idx, float value) { + uint32_t resolution = 1; +/* + switch (idx) { + case DZ_TEMP: resolution = Settings.flag2.temperature_resolution; break; + case DZ_POWER_ENERGY: resolution = Settings.flag2.wattage_resolution; break; + case DZ_VOLTAGE: resolution = Settings.flag2.voltage_resolution; break; + case DZ_CURRENT: resolution = Settings.flag2.current_resolution; break; + } +*/ + if (DZ_TEMP == idx) { resolution = Settings.flag2.temperature_resolution; } + else if (DZ_POWER_ENERGY == idx) { resolution = Settings.flag2.wattage_resolution; } + else if (DZ_VOLTAGE == idx) { resolution = Settings.flag2.voltage_resolution; } + else if (DZ_CURRENT == idx) { resolution = Settings.flag2.current_resolution; } + char data[FLOATSZ]; + dtostrfd(value, resolution, data); + DomoticzSensor(idx, data); +} + //void DomoticzTempHumPressureSensor(float temp, float hum, float baro = -1); void DomoticzTempHumPressureSensor(float temp, float hum, float baro) { char temperature[FLOATSZ];