diff --git a/CHANGELOG.md b/CHANGELOG.md index 5afd4066a..ae972b3c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - Support for Ethernet in ESP32 safeboot firmware (#16388) - Flowrate meter flow amount/duration, show values in table format (#16385) - Zigbee prepare for Green Power support (#16407) +- Command ``SetOption146 1`` to enable display of ESP32 internal temperature ### Changed - TasmotaModbus library from v3.5.0 to v3.6.0 (#16351) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index c128647a0..efcc3a1c2 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -109,6 +109,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo ## Changelog v12.1.1.1 ### Added +- Command ``SetOption146 1`` to enable display of ESP32 internal temperature - Command ``StatusRetain`` [#11109](https://github.com/arendst/Tasmota/issues/11109) - Support for SGP40 gas and air quality sensor [#16341](https://github.com/arendst/Tasmota/issues/16341) - Support for Modbus writing using ModbusBridge by JeroenSt [#16351](https://github.com/arendst/Tasmota/issues/16351) diff --git a/tasmota/include/tasmota_types.h b/tasmota/include/tasmota_types.h index b6eaad2cc..16a29c6ae 100644 --- a/tasmota/include/tasmota_types.h +++ b/tasmota/include/tasmota_types.h @@ -179,7 +179,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu typedef union { // Restricted by MISRA-C Rule 18.4 but so useful... uint32_t data; // Allow bit manipulation using SetOption struct { // SetOption146 .. SetOption177 - uint32_t spare00 : 1; // bit 0 + uint32_t use_esp32_temperature : 1; // bit 0 (v12.1.1.1) - SetOption146 - (ESP32) Show ESP32 internal temperature sensor uint32_t spare01 : 1; // bit 1 uint32_t spare02 : 1; // bit 2 uint32_t spare03 : 1; // bit 3 diff --git a/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino b/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino index 93c9b24eb..6da0baaca 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino @@ -54,63 +54,71 @@ void Esp32SensorInit(void) { #endif // CONFIG_IDF_TARGET_ESP32 void Esp32SensorShow(bool json) { - static bool add_global_temp = false; + bool json_end = false; - if (json) { - add_global_temp = !ResponseContains_P(PSTR(D_JSON_TEMPERATURE)); + if (Settings->flag6.use_esp32_temperature) { // SetOption146 - (ESP32) Show ESP32 internal temperature sensor + float c = CpuTemperature(); // in Celsius + float t = ConvertTempToFahrenheit(c); + + if (json) { + if (!ResponseContains_P(PSTR(D_JSON_TEMPERATURE))) { + UpdateGlobalTemperature(c); + } + ResponseAppend_P(PSTR(",\"ESP32\":{\"" D_JSON_TEMPERATURE "\":%*_f"), Settings->flag2.temperature_resolution, &t); + json_end = true; + +#ifdef USE_DOMOTICZ +// Instead of below code use a rule like 'on tele-esp32#temperature do dzsend1 9988,%value% endon' +// where 9988 is the domoticz sensor Idx +// if (0 == TasmotaGlobal.tele_period) { +// if (!ResponseContains_P(PSTR(D_JSON_TEMPERATURE))) { // Only send if no other sensor already did +// DomoticzFloatSensor(DZ_TEMP, t); +// } +// } +#endif // USE_DOMOTICZ + +#ifdef USE_WEBSERVER + } else { + WSContentSend_Temp("ESP32", t); +#endif // USE_WEBSERVER + } } - float c = CpuTemperature(); // in Celsius - if (add_global_temp) { - UpdateGlobalTemperature(c); - } - float t = ConvertTempToFahrenheit(c); #if CONFIG_IDF_TARGET_ESP32 - int value = 0; if (HEData.present) { + int value = 0; for (uint32_t i = 0; i < HALLEFFECT_SAMPLE_COUNT; i++) { value += hallRead(); } value /= HALLEFFECT_SAMPLE_COUNT; + + if (json) { + if (!json_end) { + ResponseAppend_P(PSTR(",\"ESP32\":{")); + } else { + ResponseAppend_P(PSTR(",")); + } + ResponseAppend_P(PSTR("\"" D_JSON_HALLEFFECT "\":%d"), value); + json_end = true; + +#ifdef USE_DOMOTICZ +// Instead of below code use a rule like 'on tele-esp32#halleffect do dzsend1 9988,%value% endon' +// where 9988 is the domoticz sensor Idx +// if (0 == TasmotaGlobal.tele_period) { +// DomoticzSensor(DZ_COUNT, value); +// } +#endif // USE_DOMOTICZ + +#ifdef USE_WEBSERVER + } else { + WSContentSend_P(HTTP_SNS_HALL_EFFECT, "ESP32", value); +#endif // USE_WEBSERVER + } } #endif // CONFIG_IDF_TARGET_ESP32 - if (json) { - bool temperature_present = (ResponseContains_P(PSTR(D_JSON_TEMPERATURE))); - ResponseAppend_P(PSTR(",\"ESP32\":{\"" D_JSON_TEMPERATURE "\":%*_f"), Settings->flag2.temperature_resolution, &t); - -#if CONFIG_IDF_TARGET_ESP32 - if (HEData.present) { - ResponseAppend_P(PSTR(",\"" D_JSON_HALLEFFECT "\":%d"), value); - } -#endif // CONFIG_IDF_TARGET_ESP32 - + if (json_end) { ResponseJsonEnd(); -#ifdef USE_DOMOTICZ - if (0 == TasmotaGlobal.tele_period) { - if (!temperature_present) { // Only send if no other sensor already did - DomoticzFloatSensor(DZ_TEMP, t); - } - -#if CONFIG_IDF_TARGET_ESP32 - if (HEData.present) { - DomoticzSensor(DZ_COUNT, value); - } -#endif // CONFIG_IDF_TARGET_ESP32 - - } -#endif // USE_DOMOTICZ -#ifdef USE_WEBSERVER - } else { - WSContentSend_Temp("ESP32", t); - -#if CONFIG_IDF_TARGET_ESP32 - if (HEData.present) { - WSContentSend_P(HTTP_SNS_HALL_EFFECT, "ESP32", value); - } -#endif // CONFIG_IDF_TARGET_ESP32 - -#endif // USE_WEBSERVER } } diff --git a/tools/decode-status.py b/tools/decode-status.py index 8923981d3..92de04297 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -201,7 +201,8 @@ a_setoption = [[ "(Zigbee) Include time in `ZbReceived` messages like other sensors", "(MQTT) Retain on Status" ],[ - "","","","", + "(ESP32) Show ESP32 internal temperature sensor", + "","","", "","","","", "","","","", "","","","", @@ -319,7 +320,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v12.1.0.1 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v12.1.1.1 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj))