diff --git a/CHANGELOG.md b/CHANGELOG.md index bee7e547e..ca48b665d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - HASPmota more attributes (#20744) - QMC5883l check for overflow and scale reading (#20643) - TasMesh support for LWT messages (#20392) +- Show calculated heat index if temperature and humidity is available with ``#define USE_HEAT_INDEX`` (#4771) ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ee1f6b76c..ddd9bb3b3 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -118,6 +118,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ## Changelog v13.4.0.1 ### Added +- Show calculated heat index if temperature and humidity is available with ``#define USE_HEAT_INDEX`` [#4771](https://github.com/arendst/Tasmota/issues/4771) - TasMesh support for LWT messages [#20392](https://github.com/arendst/Tasmota/issues/20392) - QMC5883l check for overflow and scale reading [#20643](https://github.com/arendst/Tasmota/issues/20643) - HASPmota `pb.delete` to delete an object [#20735](https://github.com/arendst/Tasmota/issues/20735) diff --git a/tasmota/include/i18n.h b/tasmota/include/i18n.h index 1437473fa..2f57cde82 100644 --- a/tasmota/include/i18n.h +++ b/tasmota/include/i18n.h @@ -95,6 +95,7 @@ #define D_JSON_HALLEFFECT "HallEffect" #define D_JSON_HALTING "Halting" #define D_JSON_HEAPSIZE "Heap" +#define D_JSON_HEATINDEX "HeatIndex" #define D_JSON_HIGH "High" #define D_JSON_HOST_NOT_FOUND "Host not found" #define D_JSON_FILE_NOT_FOUND "File not found" @@ -948,6 +949,7 @@ const char HTTP_SNS_F_ABS_HUM[] PROGMEM = "{s}%s " D_ABSOLUTE_HUMIDITY "{ const char HTTP_SNS_HUM[] PROGMEM = "{s}%s " D_HUMIDITY "{m}%s " D_UNIT_PERCENT "{e}"; const char HTTP_SNS_DEW[] PROGMEM = "{s}%s " D_DEWPOINT "{m}%s " D_UNIT_DEGREE "%c{e}"; +const char HTTP_SNS_HEATINDEX[] PROGMEM = "{s}%s " D_HEATINDEX "{m}%s " D_UNIT_DEGREE "%c{e}"; const char HTTP_SNS_PRESSURE[] PROGMEM = "{s}%s " D_PRESSURE "{m}%s " "%s{e}"; const char HTTP_SNS_SEAPRESSURE[] PROGMEM = "{s}%s " D_PRESSUREATSEALEVEL "{m}%s " "%s{e}"; const char HTTP_SNS_ANALOG[] PROGMEM = "{s}%s " D_ANALOG_INPUT "%d{m}%d" "{e}"; diff --git a/tasmota/language/af_AF.h b/tasmota/language/af_AF.h index a0b81d637..51ce74bee 100644 --- a/tasmota/language/af_AF.h +++ b/tasmota/language/af_AF.h @@ -119,6 +119,7 @@ #define D_GROUP "Groep" #define D_HOST "Gasheer" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Gasheername" #define D_HUMIDITY "Humiditeit" #define D_ILLUMINANCE "Verligting" diff --git a/tasmota/language/bg_BG.h b/tasmota/language/bg_BG.h index eb460a30e..f7cf90215 100644 --- a/tasmota/language/bg_BG.h +++ b/tasmota/language/bg_BG.h @@ -119,6 +119,7 @@ #define D_GROUP "Група" #define D_HOST "Хост" #define D_HALL_EFFECT "Ефект на Хол" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Име на хоста" #define D_HUMIDITY "Влажност" #define D_ILLUMINANCE "Осветеност" diff --git a/tasmota/language/ca_AD.h b/tasmota/language/ca_AD.h index ab32cab34..c5663ff55 100644 --- a/tasmota/language/ca_AD.h +++ b/tasmota/language/ca_AD.h @@ -119,6 +119,7 @@ #define D_GROUP "Grup" #define D_HOST "Hoste" #define D_HALL_EFFECT "Efecte Hall" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Nom de màquina" #define D_HUMIDITY "Humitat" #define D_ILLUMINANCE "Iluminància" diff --git a/tasmota/language/cs_CZ.h b/tasmota/language/cs_CZ.h index 99b050e9d..29d2dbf72 100644 --- a/tasmota/language/cs_CZ.h +++ b/tasmota/language/cs_CZ.h @@ -119,6 +119,7 @@ #define D_GROUP "Skupina" #define D_HOST "Server" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Název serveru" #define D_HUMIDITY "Vlhkost" #define D_ILLUMINANCE "Osvětlení" diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h index 44ea49961..45d9dc734 100644 --- a/tasmota/language/de_DE.h +++ b/tasmota/language/de_DE.h @@ -119,6 +119,7 @@ #define D_GROUP "Gruppe" #define D_HOST "Host" #define D_HALL_EFFECT "Hall Effekt" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Hostname" #define D_HUMIDITY "Feuchtigkeit" #define D_ILLUMINANCE "Beleuchtungsstärke" diff --git a/tasmota/language/el_GR.h b/tasmota/language/el_GR.h index 3355065af..7d6c8e1c3 100644 --- a/tasmota/language/el_GR.h +++ b/tasmota/language/el_GR.h @@ -119,6 +119,7 @@ #define D_GROUP "Ομάδα" #define D_HOST "Host" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Hostname" #define D_HUMIDITY "Υγρασία" #define D_ILLUMINANCE "Φωτεινότητα" diff --git a/tasmota/language/en_GB.h b/tasmota/language/en_GB.h index 6748ed35f..ccdae7d73 100644 --- a/tasmota/language/en_GB.h +++ b/tasmota/language/en_GB.h @@ -119,6 +119,7 @@ #define D_GROUP "Group" #define D_HOST "Host" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Hostname" #define D_HUMIDITY "Humidity" #define D_ILLUMINANCE "Illuminance" diff --git a/tasmota/language/es_ES.h b/tasmota/language/es_ES.h index e6582e91a..66b650bef 100644 --- a/tasmota/language/es_ES.h +++ b/tasmota/language/es_ES.h @@ -119,6 +119,7 @@ #define D_GROUP "Grupo" #define D_HOST "Host" #define D_HALL_EFFECT "Efecto Hall" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Hostname" #define D_HUMIDITY "Humedad" #define D_ILLUMINANCE "Luminancia" diff --git a/tasmota/language/fr_FR.h b/tasmota/language/fr_FR.h index 608e7fbaa..af20f1b83 100644 --- a/tasmota/language/fr_FR.h +++ b/tasmota/language/fr_FR.h @@ -119,6 +119,7 @@ #define D_GROUP "Groupe" #define D_HOST "Hôte" #define D_HALL_EFFECT "Effet Hall" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Nom d'Hôte" #define D_HUMIDITY "Humidité" #define D_ILLUMINANCE "Éclairement" diff --git a/tasmota/language/fy_NL.h b/tasmota/language/fy_NL.h index 86c47c27a..37f74edf7 100644 --- a/tasmota/language/fy_NL.h +++ b/tasmota/language/fy_NL.h @@ -119,6 +119,7 @@ #define D_GROUP "Groep" #define D_HOST "Host" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Hostnamme" #define D_HUMIDITY "Feuchte" #define D_ILLUMINANCE "Beljochting" diff --git a/tasmota/language/he_HE.h b/tasmota/language/he_HE.h index f0ae6001c..7f33543c5 100644 --- a/tasmota/language/he_HE.h +++ b/tasmota/language/he_HE.h @@ -119,6 +119,7 @@ #define D_GROUP "קבוצה" #define D_HOST "מארח" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "שם מארח" #define D_HUMIDITY "לחות" #define D_ILLUMINANCE "רמת חשיפה" diff --git a/tasmota/language/hu_HU.h b/tasmota/language/hu_HU.h index 176dddc0b..f78c7e5f3 100644 --- a/tasmota/language/hu_HU.h +++ b/tasmota/language/hu_HU.h @@ -119,6 +119,7 @@ #define D_GROUP "Csoport" #define D_HOST "Hoszt" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Hosztnév" #define D_HUMIDITY "Páratartalom" #define D_ILLUMINANCE "Megvilágítás" diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index b5d948491..335e72349 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -119,6 +119,7 @@ #define D_GROUP "Gruppo" #define D_HOST "Host" #define D_HALL_EFFECT "Effetto hall" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Nome host" #define D_HUMIDITY "Umidità" #define D_ILLUMINANCE "Illuminazione" diff --git a/tasmota/language/ko_KO.h b/tasmota/language/ko_KO.h index c3248c9f5..598dc12a1 100644 --- a/tasmota/language/ko_KO.h +++ b/tasmota/language/ko_KO.h @@ -119,6 +119,7 @@ #define D_GROUP "그룹" #define D_HOST "호스트" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "호스트이름" #define D_HUMIDITY "습도" #define D_ILLUMINANCE "조도" diff --git a/tasmota/language/nl_NL.h b/tasmota/language/nl_NL.h index 48ff12599..a0aec757c 100644 --- a/tasmota/language/nl_NL.h +++ b/tasmota/language/nl_NL.h @@ -119,6 +119,7 @@ #define D_GROUP "Groep" #define D_HOST "Host" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Hostnaam" #define D_HUMIDITY "Luchtvochtigheid" #define D_ILLUMINANCE "Verlichtingssterkte" diff --git a/tasmota/language/pl_PL.h b/tasmota/language/pl_PL.h index 12ce56032..5d96c6ce6 100644 --- a/tasmota/language/pl_PL.h +++ b/tasmota/language/pl_PL.h @@ -119,6 +119,7 @@ #define D_GROUP "Grupa" #define D_HOST "Serwer" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Nazwa serwera" #define D_HUMIDITY "Wilgotność" #define D_ILLUMINANCE "Podświetlanie" diff --git a/tasmota/language/pt_BR.h b/tasmota/language/pt_BR.h index e3d5e8694..133750f64 100644 --- a/tasmota/language/pt_BR.h +++ b/tasmota/language/pt_BR.h @@ -119,6 +119,7 @@ #define D_GROUP "Grupo" #define D_HOST "Host" #define D_HALL_EFFECT "Efeito Hall" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Nome do Host" #define D_HUMIDITY "Umidade" #define D_ILLUMINANCE "Luminância" diff --git a/tasmota/language/pt_PT.h b/tasmota/language/pt_PT.h index f396d366f..564afed03 100644 --- a/tasmota/language/pt_PT.h +++ b/tasmota/language/pt_PT.h @@ -119,6 +119,7 @@ #define D_GROUP "Grupo" #define D_HOST "Anfitrião" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Nome Anfitrião" #define D_HUMIDITY "Humidade" #define D_ILLUMINANCE "Luminâcia" diff --git a/tasmota/language/ro_RO.h b/tasmota/language/ro_RO.h index 9d05f17b2..d379bc8bd 100644 --- a/tasmota/language/ro_RO.h +++ b/tasmota/language/ro_RO.h @@ -119,6 +119,7 @@ #define D_GROUP "Grup" #define D_HOST "Gazdă" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Hostname" #define D_HUMIDITY "Umiditate" #define D_ILLUMINANCE "Iluminare" diff --git a/tasmota/language/ru_RU.h b/tasmota/language/ru_RU.h index bc2598952..0cdb64b58 100644 --- a/tasmota/language/ru_RU.h +++ b/tasmota/language/ru_RU.h @@ -120,6 +120,7 @@ #define D_GROUP "Группа" #define D_HOST "Хост" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Имя хоста" #define D_HUMIDITY "Влажность" #define D_ILLUMINANCE "Освещенность" diff --git a/tasmota/language/sk_SK.h b/tasmota/language/sk_SK.h index 256feff7e..d6bc76ac1 100644 --- a/tasmota/language/sk_SK.h +++ b/tasmota/language/sk_SK.h @@ -119,6 +119,7 @@ #define D_GROUP "Skupina" #define D_HOST "Server" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Názov servera" #define D_HUMIDITY "Vlhkosť" #define D_ILLUMINANCE "Osvetlenie" diff --git a/tasmota/language/sv_SE.h b/tasmota/language/sv_SE.h index 3c1445193..e0e6c0594 100644 --- a/tasmota/language/sv_SE.h +++ b/tasmota/language/sv_SE.h @@ -119,6 +119,7 @@ #define D_GROUP "Grupp" #define D_HOST "Värd" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Värdnamn" #define D_HUMIDITY "Fuktighet" #define D_ILLUMINANCE "Belysnings" diff --git a/tasmota/language/tr_TR.h b/tasmota/language/tr_TR.h index fd15dd5f4..35609c1c0 100644 --- a/tasmota/language/tr_TR.h +++ b/tasmota/language/tr_TR.h @@ -119,6 +119,7 @@ #define D_GROUP "Grup" #define D_HOST "Host" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Host Adresi" #define D_HUMIDITY "Nem" #define D_ILLUMINANCE "Aydınlık" diff --git a/tasmota/language/uk_UA.h b/tasmota/language/uk_UA.h index bda176a23..fcb3356c0 100644 --- a/tasmota/language/uk_UA.h +++ b/tasmota/language/uk_UA.h @@ -119,6 +119,7 @@ #define D_GROUP "Група" #define D_HOST "Хост" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Назва хосту" #define D_HUMIDITY "Вологість" #define D_ILLUMINANCE "Освітленність" diff --git a/tasmota/language/vi_VN.h b/tasmota/language/vi_VN.h index 27924e49d..097383ce0 100644 --- a/tasmota/language/vi_VN.h +++ b/tasmota/language/vi_VN.h @@ -119,6 +119,7 @@ #define D_GROUP "Nhóm" #define D_HOST "Máy chủ" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "Tên máy chủ" #define D_HUMIDITY "Độ ẩm" #define D_ILLUMINANCE "Độ sáng" diff --git a/tasmota/language/zh_CN.h b/tasmota/language/zh_CN.h index 5064d894c..004fa4b47 100644 --- a/tasmota/language/zh_CN.h +++ b/tasmota/language/zh_CN.h @@ -119,6 +119,7 @@ #define D_GROUP "组:" #define D_HOST "主机" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "主机名" #define D_HUMIDITY "湿度" #define D_ILLUMINANCE "照度" diff --git a/tasmota/language/zh_TW.h b/tasmota/language/zh_TW.h index 4137357a1..1487bc0f2 100644 --- a/tasmota/language/zh_TW.h +++ b/tasmota/language/zh_TW.h @@ -119,6 +119,7 @@ #define D_GROUP "群組:" #define D_HOST "主機" #define D_HALL_EFFECT "Hall Effect" +#define D_HEATINDEX "Heat index" #define D_HOSTNAME "主機名稱" #define D_HUMIDITY "濕度" #define D_ILLUMINANCE "照度" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index c4ef41407..04287c238 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -385,6 +385,8 @@ //#define MY_LANGUAGE zh_CN // Chinese (Simplified) in China //#define MY_LANGUAGE zh_TW // Chinese (Traditional) in Taiwan +//#define USE_HEAT_INDEX // Show calculated Heat index from temperature and humidity (+1k4 code) + // -- Wifi Config tools --------------------------- #define WIFI_SOFT_AP_CHANNEL 1 // Soft Access Point Channel number between 1 and 13 as used by Wi-Fi Manager web GUI #define USE_IMPROV // Add support for IMPROV serial protocol as used by esp-web-tools (+2k code) diff --git a/tasmota/tasmota_support/support.ino b/tasmota/tasmota_support/support.ino index 766a821dc..f6e3b6f55 100755 --- a/tasmota/tasmota_support/support.ino +++ b/tasmota/tasmota_support/support.ino @@ -858,6 +858,33 @@ float CalcTempHumToDew(float t, float h) { return result; } +#ifdef USE_HEAT_INDEX +float CalcTemHumToHeatIndex(float t, float h) { + if (!Settings->flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit + t = t * 1.8f + 32; // Fahrenheit + } + float hi = 0.5 * (t + 61.0 + ((t - 68.0) * 1.2) + (h * 0.094)); + if (hi > 79) { + float pt = t * t; // pow(t, 2) + float ph = h * h; // pow(h, 2) + hi = -42.379 + 2.04901523 * t + 10.14333127 * h + + -0.22475541 * t * h + + -0.00683783 * pt + + -0.05481717 * ph + + 0.00122874 * pt * h + + 0.00085282 * t * ph + + -0.00000199 * pt * ph; + if ((h < 13) && (t >= 80.0) && (t <= 112.0)) { + hi -= ((13.0 - h) * 0.25) * sqrtf((17.0 - abs(t - 95.0)) * 0.05882); + } + else if ((h > 85.0) && (t >= 80.0) && (t <= 87.0)) { + hi += ((h - 85.0) * 0.1) * ((87.0 - t) * 0.2); + } + } + return (Settings->flag.temperature_conversion) ? hi : (hi - 32) / 1.8f; +} +#endif // USE_HEAT_INDEX + float CalcTempHumToAbsHum(float t, float h) { if (isnan(t) || isnan(h)) { return NAN; } // taken from https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/ @@ -1338,13 +1365,19 @@ int ResponseAppendTime(void) return ResponseAppendTimeFormat(Settings->flag2.time_format); } -int ResponseAppendTHD(float f_temperature, float f_humidity) -{ +int ResponseAppendTHD(float f_temperature, float f_humidity) { float dewpoint = CalcTempHumToDew(f_temperature, f_humidity); - return ResponseAppend_P(PSTR("\"" D_JSON_TEMPERATURE "\":%*_f,\"" D_JSON_HUMIDITY "\":%*_f,\"" D_JSON_DEWPOINT "\":%*_f"), - Settings->flag2.temperature_resolution, &f_temperature, - Settings->flag2.humidity_resolution, &f_humidity, - Settings->flag2.temperature_resolution, &dewpoint); + int len = ResponseAppend_P(PSTR("\"" D_JSON_TEMPERATURE "\":%*_f,\"" D_JSON_HUMIDITY "\":%*_f,\"" D_JSON_DEWPOINT "\":%*_f"), + Settings->flag2.temperature_resolution, &f_temperature, + Settings->flag2.humidity_resolution, &f_humidity, + Settings->flag2.temperature_resolution, &dewpoint); +#ifdef USE_HEAT_INDEX + float heatindex = CalcTemHumToHeatIndex(TasmotaGlobal.temperature_celsius, TasmotaGlobal.humidity); + int len2 = ResponseAppend_P(PSTR(",\"" D_JSON_HEATINDEX "\":%*_f"), + Settings->flag2.temperature_resolution, &heatindex); + return len + len2; +#endif // USE_HEAT_INDEX + return len; } int ResponseJsonEnd(void) diff --git a/tasmota/tasmota_support/support_tasmota.ino b/tasmota/tasmota_support/support_tasmota.ino index 94c431e86..12406336e 100644 --- a/tasmota/tasmota_support/support_tasmota.ino +++ b/tasmota/tasmota_support/support_tasmota.ino @@ -1025,8 +1025,13 @@ bool MqttShowSensor(bool call_show_sensor) { } if (2 == add_comma) { float dewpoint = CalcTempHumToDew(TasmotaGlobal.temperature_celsius, TasmotaGlobal.humidity); - ResponseAppend_P(PSTR("%s\"" D_JSON_DEWPOINT "\":%*_f"), - (add_comma)?",":"", Settings->flag2.temperature_resolution, &dewpoint); + ResponseAppend_P(PSTR(",\"" D_JSON_DEWPOINT "\":%*_f"), + Settings->flag2.temperature_resolution, &dewpoint); +#ifdef USE_HEAT_INDEX + float heatindex = CalcTemHumToHeatIndex(TasmotaGlobal.temperature_celsius, TasmotaGlobal.humidity); + ResponseAppend_P(PSTR(",\"" D_JSON_HEATINDEX "\":%*_f"), + Settings->flag2.temperature_resolution, &heatindex); +#endif // USE_HEAT_INDEX } if (TasmotaGlobal.pressure_hpa != 0) { float p = ConvertPressure(TasmotaGlobal.pressure_hpa); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index 1124a60ea..15caa90ab 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -1027,6 +1027,10 @@ void WSContentSend_THD(const char *types, float f_temperature, float f_humidity) WSContentSend_PD(HTTP_SNS_HUM, types, parameter); dtostrfd(CalcTempHumToDew(f_temperature, f_humidity), Settings->flag2.temperature_resolution, parameter); WSContentSend_PD(HTTP_SNS_DEW, types, parameter, TempUnit()); +#ifdef USE_HEAT_INDEX + dtostrfd(CalcTemHumToHeatIndex(f_temperature, f_humidity), Settings->flag2.temperature_resolution, parameter); + WSContentSend_PD(HTTP_SNS_HEATINDEX, types, parameter, TempUnit()); +#endif // USE_HEAT_INDEX } void WSContentEnd(void) {