Skip to content

Commit

Permalink
Merge pull request #2159 from proddy/dev
Browse files Browse the repository at this point in the history
remove template logic for Domoticz -#2156
  • Loading branch information
proddy authored Oct 31, 2024
2 parents 30b7b6d + 60ac6aa commit 13dfc87
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down
17 changes: 13 additions & 4 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 13dfc87

Please sign in to comment.