diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 25138f27f..4ca8ef419 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -380,17 +380,25 @@ void Thermostat::publish_ha_config_hc(std::shared_ptrroomTemp); + if (Mqtt::nested_format() == 1) { // nested format snprintf(hc_mode_s, sizeof(hc_mode_s), "value_json.hc%d.mode", hc_num); snprintf(seltemp_s, sizeof(seltemp_s), "{{value_json.hc%d.seltemp}}", hc_num); - snprintf(currtemp_s, sizeof(currtemp_s), "{{value_json.hc%d.currtemp}}", hc_num); + if (have_current_room_temp) { + snprintf(currtemp_s, sizeof(currtemp_s), "{{value_json.hc%d.currtemp}}", hc_num); + } snprintf(topic_t, sizeof(topic_t), "~/%s", Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_NONE).c_str()); } else { // single format snprintf(hc_mode_s, sizeof(hc_mode_s), "value_json.mode"); snprintf(seltemp_s, sizeof(seltemp_s), "{{value_json.seltemp}}"); - snprintf(currtemp_s, sizeof(currtemp_s), "{{value_json.currtemp}}"); + if (have_current_room_temp) { + snprintf(currtemp_s, sizeof(currtemp_s), "{{value_json.currtemp}}"); + } snprintf(topic_t, sizeof(topic_t), "~/%s", Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_HC1 + hc_num - 1).c_str()); } @@ -416,11 +424,15 @@ void Thermostat::publish_ha_config_hc(std::shared_ptr hc) { return; } - // only if it has a valid seltemp and currtemp - // mode always defaults to auto - if (Helpers::hasValue(hc->roomTemp) && Helpers::hasValue(hc->selTemp)) { + // only if it has a valid seltemp (roomtemp is optional) + if (Helpers::hasValue(hc->selTemp)) { publish_ha_config_hc(hc); hc->ha_climate_created(true); // only create it once } diff --git a/src/version.h b/src/version.h index 25c352621..1157224e3 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.4.0b1" +#define EMSESP_APP_VERSION "3.4.0b2"