diff --git a/interface/package.json b/interface/package.json index a2d884e63..86ab9df9d 100644 --- a/interface/package.json +++ b/interface/package.json @@ -47,7 +47,7 @@ "@preact/preset-vite": "^2.9.1", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/formidable": "^3", - "@types/node": "^22.8.4", + "@types/node": "^22.8.5", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@types/react-router-dom": "^5.3.3", diff --git a/interface/yarn.lock b/interface/yarn.lock index dd14c112b..226e8c8ee 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -1435,12 +1435,12 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^22.8.4": - version: 22.8.4 - resolution: "@types/node@npm:22.8.4" +"@types/node@npm:^22.8.5": + version: 22.8.5 + resolution: "@types/node@npm:22.8.5" dependencies: undici-types: "npm:~6.19.8" - checksum: 10c0/f88d030480630194a9168772462ec09b2d86454f34368c46d2b7fda5dc6e14594b1576fcc5c35cc53b57a4d1e8dd2865a85ae81f34ded0d1af753a0f5d294c25 + checksum: 10c0/5e43553026c83f18bfa381d35c8fd608e69d12d0f0fe4601e8bb98b651a3b240be9d66c1f2f4decdbebb41d55b18e89238b02f3992d820d89801b9b3625ba8ab languageName: node linkType: hard @@ -1657,7 +1657,7 @@ __metadata: "@table-library/react-table-library": "npm:4.1.7" "@trivago/prettier-plugin-sort-imports": "npm:^4.3.0" "@types/formidable": "npm:^3" - "@types/node": "npm:^22.8.4" + "@types/node": "npm:^22.8.5" "@types/react": "npm:^18.3.12" "@types/react-dom": "npm:^18.3.1" "@types/react-router-dom": "npm:^5.3.3" diff --git a/src/mqtt.cpp b/src/mqtt.cpp index d836d0fe7..f20bb34d8 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -983,7 +983,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev add_ha_classes = false; break; default: - // plain old sensor, and make it read-only + // plain old sensor break; } } else { @@ -1117,10 +1117,19 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev strlcpy(sample_val, "false", sizeof(sample_val)); // default is "false" } - doc["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 (discovery_type() == discoveryType::HOMEASSISTANT) { + doc["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + " else " + sample_val + "}}"; - // add the dev json object to the end, not for commands - add_ha_sections_to_doc(nullptr, stat_t, doc, false, val_cond); // no name, since the "dev" has already been adde + // adds availability, dev, ids to the config section to HA Discovery config + // except for commands + add_ha_sections_to_doc(nullptr, stat_t, doc, false, val_cond); // no name, since the "dev" has already been added + } else { + // Domoticz doesn't support value templates, so we just use the value directly + // Also omit the uom and other state classes + doc["val_tpl"] = (std::string) "{{" + val_obj + "}}"; + add_ha_classes = false; // don't add the classes + } } // Add the state class, device class and sometimes the icon.