mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
Merge pull request #2159 from proddy/dev
remove template logic for Domoticz -#2156
This commit is contained in:
@@ -47,7 +47,7 @@
|
|||||||
"@preact/preset-vite": "^2.9.1",
|
"@preact/preset-vite": "^2.9.1",
|
||||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||||
"@types/formidable": "^3",
|
"@types/formidable": "^3",
|
||||||
"@types/node": "^22.8.4",
|
"@types/node": "^22.8.5",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react-dom": "^18.3.1",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
|
|||||||
@@ -1435,12 +1435,12 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@types/node@npm:^22.8.4":
|
"@types/node@npm:^22.8.5":
|
||||||
version: 22.8.4
|
version: 22.8.5
|
||||||
resolution: "@types/node@npm:22.8.4"
|
resolution: "@types/node@npm:22.8.5"
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: "npm:~6.19.8"
|
undici-types: "npm:~6.19.8"
|
||||||
checksum: 10c0/f88d030480630194a9168772462ec09b2d86454f34368c46d2b7fda5dc6e14594b1576fcc5c35cc53b57a4d1e8dd2865a85ae81f34ded0d1af753a0f5d294c25
|
checksum: 10c0/5e43553026c83f18bfa381d35c8fd608e69d12d0f0fe4601e8bb98b651a3b240be9d66c1f2f4decdbebb41d55b18e89238b02f3992d820d89801b9b3625ba8ab
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -1657,7 +1657,7 @@ __metadata:
|
|||||||
"@table-library/react-table-library": "npm:4.1.7"
|
"@table-library/react-table-library": "npm:4.1.7"
|
||||||
"@trivago/prettier-plugin-sort-imports": "npm:^4.3.0"
|
"@trivago/prettier-plugin-sort-imports": "npm:^4.3.0"
|
||||||
"@types/formidable": "npm:^3"
|
"@types/formidable": "npm:^3"
|
||||||
"@types/node": "npm:^22.8.4"
|
"@types/node": "npm:^22.8.5"
|
||||||
"@types/react": "npm:^18.3.12"
|
"@types/react": "npm:^18.3.12"
|
||||||
"@types/react-dom": "npm:^18.3.1"
|
"@types/react-dom": "npm:^18.3.1"
|
||||||
"@types/react-router-dom": "npm:^5.3.3"
|
"@types/react-router-dom": "npm:^5.3.3"
|
||||||
|
|||||||
17
src/mqtt.cpp
17
src/mqtt.cpp
@@ -983,7 +983,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
add_ha_classes = false;
|
add_ha_classes = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// plain old sensor, and make it read-only
|
// plain old sensor
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} 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"
|
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
|
// adds availability, dev, ids to the config section to HA Discovery config
|
||||||
add_ha_sections_to_doc(nullptr, stat_t, doc, false, val_cond); // no name, since the "dev" has already been adde
|
// 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.
|
// Add the state class, device class and sometimes the icon.
|
||||||
|
|||||||
Reference in New Issue
Block a user