diff --git a/src/core/analogsensor.cpp b/src/core/analogsensor.cpp index 067f2b334..ff3d7baf8 100644 --- a/src/core/analogsensor.cpp +++ b/src/core/analogsensor.cpp @@ -594,7 +594,12 @@ void AnalogSensor::publish_values(const bool force) { if (sensor.type() == AnalogType::DIGITAL_IN || sensor.type() == AnalogType::DIGITAL_OUT) { Helpers::render_boolean(sample_val, false); } - config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + " else " + sample_val + "}}"; + // don't bother with value template conditions if using Domoticz which doesn't fully support MQTT Discovery + if (Mqtt::discovery_type() == Mqtt::discoveryType::HOMEASSISTANT) { + config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + "}}"; + } else { + config["val_tpl"] = (std::string) "{{" + val_obj + "}}"; + } char uniq_s[70]; if (Mqtt::entity_format() == Mqtt::entityFormat::MULTI_SHORT) { diff --git a/src/core/shower.cpp b/src/core/shower.cpp index b92ccd84f..6905b50cf 100644 --- a/src/core/shower.cpp +++ b/src/core/shower.cpp @@ -222,8 +222,15 @@ void Shower::set_shower_state(bool state, bool force) { snprintf(stat_t, sizeof(stat_t), "%s/shower_data", Mqtt::base().c_str()); doc["stat_t"] = stat_t; - doc["name"] = "Shower Duration"; - doc["val_tpl"] = "{{value_json.duration if value_json.duration is defined else 0}}"; + doc["name"] = "Shower Duration"; + + // don't bother with value template conditions if using Domoticz which doesn't fully support MQTT Discovery + if (Mqtt::discovery_type() == Mqtt::discoveryType::HOMEASSISTANT) { + doc["val_tpl"] = "{{value_json.duration if value_json.duration is defined else 0}}"; + } else { + doc["val_tpl"] = "{{value_json.duration}}"; + } + doc["unit_of_meas"] = "s"; doc["stat_cla"] = "measurement"; doc["dev_cla"] = "duration"; diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index 7b4311391..411c1fae3 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -1881,13 +1881,13 @@ void Boiler::process_UBAErrorMessage2(std::shared_ptr telegram) return; } - uint32_t date = 0; - char code[sizeof(lastCode_)] = {0}; - uint16_t codeNo = EMS_VALUE_INT16_NOTSET; - code[0] = telegram->message_data[5]; - code[1] = telegram->message_data[6]; - code[2] = telegram->message_data[7]; - code[3] = 0; + uint32_t date = 0; + char code[sizeof(lastCode_)] = {0}; + uint16_t codeNo = EMS_VALUE_INT16_NOTSET; + code[0] = telegram->message_data[5]; + code[1] = telegram->message_data[6]; + code[2] = telegram->message_data[7]; + code[3] = 0; telegram->read_value(codeNo, 8); if (!std::isprint(code[0]) || !std::isprint(code[1]) || !std::isprint(code[2])) { return; @@ -1947,13 +1947,13 @@ void Boiler::process_UBAErrorMessage3(std::shared_ptr telegram) return; } - uint32_t date = 0; - char code[sizeof(lastCode_)] = {0}; - uint16_t codeNo = EMS_VALUE_INT16_NOTSET; - code[0] = telegram->message_data[6]; - code[1] = telegram->message_data[7]; - code[2] = telegram->message_data[8]; - code[3] = 0; + uint32_t date = 0; + char code[sizeof(lastCode_)] = {0}; + uint16_t codeNo = EMS_VALUE_INT16_NOTSET; + code[0] = telegram->message_data[6]; + code[1] = telegram->message_data[7]; + code[2] = telegram->message_data[8]; + code[3] = 0; telegram->read_value(codeNo, 9); if (!std::isprint(code[0]) || !std::isprint(code[1]) || !std::isprint(code[2])) { return; diff --git a/src/devices/boiler.h b/src/devices/boiler.h index 5befbffbf..aa66281b7 100644 --- a/src/devices/boiler.h +++ b/src/devices/boiler.h @@ -149,7 +149,7 @@ class Boiler : public EMSdevice { char lastCode_[55]; // last error code char serviceCode_[4]; // 3 character status/service code uint16_t serviceCodeNumber_; // error/service code - uint32_t lastCodeDate_ = 0; // last code date + uint32_t lastCodeDate_ = 0; // last code date uint8_t emergencyOps_; uint8_t emergencyTemp_; uint16_t headertemp_; // see #1317 diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index c6a346769..790c4cba4 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -399,7 +399,12 @@ void WebCustomEntityService::publish(const bool force) { char val_cond[65]; snprintf(val_obj, sizeof(val_obj), "value_json['%s']", entityItem.name.c_str()); snprintf(val_cond, sizeof(val_cond), "%s is defined", val_obj); - config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + "}}"; + // don't bother with value template conditions if using Domoticz which doesn't fully support MQTT Discovery + if (Mqtt::discovery_type() == Mqtt::discoveryType::HOMEASSISTANT) { + config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + "}}"; + } else { + config["val_tpl"] = (std::string) "{{" + val_obj + "}}"; + } char uniq_s[70]; snprintf(uniq_s, sizeof(uniq_s), "%s_%s", F_(custom), entityItem.name.c_str()); diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index af6eed9f8..599672659 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -267,7 +267,12 @@ void WebSchedulerService::publish(const bool force) { char val_cond[65]; snprintf(val_obj, sizeof(val_obj), "value_json['%s']", scheduleItem.name.c_str()); snprintf(val_cond, sizeof(val_cond), "%s is defined", val_obj); - config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + "}}"; + + if (Mqtt::discovery_type() == Mqtt::discoveryType::HOMEASSISTANT) { + config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + "}}"; + } else { + config["val_tpl"] = (std::string) "{{" + val_obj + "}}"; // omit value conditional Jinja2 template code + } char uniq_s[70]; snprintf(uniq_s, sizeof(uniq_s), "%s_%s", F_(scheduler), scheduleItem.name.c_str());