diff --git a/src/core/mqtt.cpp b/src/core/mqtt.cpp index d31e3086e..614dc6461 100644 --- a/src/core/mqtt.cpp +++ b/src/core/mqtt.cpp @@ -1019,7 +1019,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev std::string topic_str(topic); doc["def_ent_id"] = Helpers::toLower(topic_str.substr(0, topic_str.find("/"))) + "." + Helpers::toLower(uniq_id); - char sample_val[30] = "0"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet + char sample_val[30] = "'None'"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet // we add the command topic parameter for commands if (has_cmd) { @@ -1043,13 +1043,13 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev for (uint8_t i = 0; i < options_size; i++) { option_list.add(Helpers::itoa(i)); // as a string } - snprintf(sample_val, sizeof(sample_val), "'0'"); + // snprintf(sample_val, sizeof(sample_val), "'0'"); } else { // use strings for (uint8_t i = 0; i < options_size; i++) { option_list.add(Helpers::translated_word(options[i])); } - snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::translated_word(options[0])); + // snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::translated_word(options[0])); } } else if (type != DeviceValueType::STRING && type != DeviceValueType::BOOL) { // For numeric's add the range and mode @@ -1071,7 +1071,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev if (dv_set_min != 0 || dv_set_max != 0) { doc["min"] = dv_set_min; doc["max"] = dv_set_max; - snprintf(sample_val, sizeof(sample_val), "%i", dv_set_min); + // snprintf(sample_val, sizeof(sample_val), "%i", dv_set_min); } } @@ -1123,7 +1123,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev // has no unit of measure or icon, and must be true/false (not on/off or 1/0) if (type == DeviceValueType::BOOL) { add_ha_bool(doc.as()); - strlcpy(sample_val, "false", sizeof(sample_val)); // default is "false" + // strlcpy(sample_val, "false", sizeof(sample_val)); // default is "false" } // don't bother with value template conditions if using Domoticz which doesn't fully support MQTT Discovery @@ -1436,7 +1436,7 @@ bool Mqtt::publish_ha_climate_config(const DeviceValue & dv, const bool has_room snprintf(mode_str_tpl, sizeof(mode_str_tpl), - "{%%if %s%%}off{%%elif %s=='%s'%%}heat{%%elif %s=='%s'%%}heat{%%elif %s=='%s'%%}heat{%%elif %s=='%s'%%}off{%%elif %s=='%s'%%}off{%%elif " + "{%%if %s%%}None{%%elif %s=='%s'%%}heat{%%elif %s=='%s'%%}heat{%%elif %s=='%s'%%}heat{%%elif %s=='%s'%%}off{%%elif %s=='%s'%%}off{%%elif " "%s=='%s'%%}off{%%else%%}auto{%%endif%%}", hc_mode_cond, hc_mode_s, @@ -1473,15 +1473,15 @@ bool Mqtt::publish_ha_climate_config(const DeviceValue & dv, const bool has_room doc["mode_stat_tpl"] = mode_str_tpl; doc["temp_cmd_t"] = temp_cmd_s; doc["temp_stat_t"] = topic_t; - doc["temp_stat_tpl"] = (std::string) "{{" + seltemp_s + " if " + seltemp_cond + " else 0}}"; + doc["temp_stat_tpl"] = (std::string) "{{" + seltemp_s + " if " + seltemp_cond + " else 'None'}}"; if (has_roomtemp) { doc["curr_temp_t"] = topic_t; - doc["curr_temp_tpl"] = (std::string) "{{" + currtemp_s + " if " + currtemp_cond + " else 0}}"; + doc["curr_temp_tpl"] = (std::string) "{{" + currtemp_s + " if " + currtemp_cond + " else 'None'}}"; } if (tag >= DeviceValueTAG::TAG_SRC1) { doc["curr_hum_t"] = topic_t; - doc["curr_hum_tpl"] = (std::string) "{{" + currhum_s + " if " + currhum_cond + " else 0}}"; + doc["curr_hum_tpl"] = (std::string) "{{" + currhum_s + " if " + currhum_cond + " else 'None'}}"; } doc["min_temp"] = Helpers::render_value(min_s, min, 0, EMSESP::system_.fahrenheit() ? 2 : 0); diff --git a/src/emsesp_version.h b/src/emsesp_version.h index 0173e604e..929ebedf7 100644 --- a/src/emsesp_version.h +++ b/src/emsesp_version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.9.0-dev.3" +#define EMSESP_APP_VERSION "3.9.0-dev.4"