Add Chip internal temperature as sensor in JSON (#1821)

* Add MCU temperature to json_interface.c

* Write chip temp even if there is no other sensor present

* Send chip temperature always as sensor "ESP32"
This commit is contained in:
MaxineMuster 2025-10-05 00:01:57 +02:00 committed by GitHub
parent f60d242fbb
commit 6279bcd07a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -264,6 +264,10 @@ static int http_tasmota_json_SENSOR(void* request, jsonCb_t printer) {
float chan_val1, chan_val2;
int channel_1, channel_2, g_pin_1 = 0;
printer(request, ",");
#ifndef NO_CHIP_TEMPERATURE
// printer(request, "\"%s\":{\"Temperature\": %.1f},", PLATFORM_MCU_NAME, g_wifi_temperature);
printer(request, "\"ESP32\":{\"Temperature\": %.1f},", g_wifi_temperature);
#endif
if (DRV_IsRunning("SHT3X")) {
g_pin_1 = PIN_FindPinIndexForRole(IOR_SHT3X_DAT, g_pin_1);
channel_1 = g_cfg.pins.channels[g_pin_1];
@ -408,7 +412,11 @@ static int http_tasmota_json_status_SNS(void* request, jsonCb_t printer, bool bA
bHasAnyDHT = true;
break;
}
#ifdef NO_CHIP_TEMPERATURE
if (DRV_IsSensor() || bHasAnyDHT) {
#else
if (1) {
#endif
http_tasmota_json_SENSOR(request, printer);
JSON_PrintKeyValue_String(request, printer, "TempUnit", "C", false);
}