mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-09-14 14:14:09 +00:00
val_tpl for undefined: 'None'
This commit is contained in:
@@ -501,7 +501,7 @@ void WebCustomEntityService::publish(const bool force) {
|
||||
snprintf(val_cond, sizeof(val_cond), "%s is defined", val_obj);
|
||||
// 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 + "}}";
|
||||
config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + " else 'None'}}";
|
||||
} else {
|
||||
config["val_tpl"] = (std::string) "{{" + val_obj + "}}";
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ void WebSchedulerService::publish(const bool force) {
|
||||
|
||||
char val_tpl[150];
|
||||
if (Mqtt::discovery_type() == Mqtt::discoveryType::HOMEASSISTANT) {
|
||||
snprintf(val_tpl, sizeof(val_tpl), "{{%s if %s}}", val_obj, val_cond);
|
||||
snprintf(val_tpl, sizeof(val_tpl), "{{%s if %s else 'None'}}", val_obj, val_cond);
|
||||
} else {
|
||||
snprintf(val_tpl, sizeof(val_tpl), "{{%s}}", val_obj); // omit value conditional Jinja2 template code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user