[BT] Fix HA discovery for motion and door sensor (#1798)

* [BT] Fix HA discovery for motion sensor

* Add status binary sensor and text sensor
This commit is contained in:
Florian authored and GitHub committed 2023-11-13 17:14:21 -06:00
1 parent 5a36034a2f
commit e576b26b8c
4 files changed
+32 -2

No files matched your search

+24
View File
@@ -1030,6 +1030,30 @@ void launchBTDiscovery(bool overrideDiscovery) {
0, "", "", false, "",
model.c_str(), brand.c_str(), model_id.c_str(), macWOdots.c_str(), false,
stateClassMeasurement, nullptr, nullptr, "[\"lb\",\"kg\",\"jin\"]");
} else if (strcmp(prop.key().c_str(), "pres") == 0 || strcmp(prop.key().c_str(), "movement") == 0) {
createDiscovery("binary_sensor",
discovery_topic.c_str(), entity_name.c_str(), unique_id.c_str(),
will_Topic, "motion", value_template.c_str(), // Idealy we should have the decoder give the name here as "motion" but for now it gives "presence"
"True", "False", "",
BTConfig.presenceAwayTimer, "", "", false, "",
model.c_str(), brand.c_str(), model_id.c_str(), macWOdots.c_str(), false,
stateClassNone);
} else if (strcmp(prop.value()["unit"], "string") == 0 && strcmp(prop.key().c_str(), "mac") != 0) {
createDiscovery("sensor",
discovery_topic.c_str(), entity_name.c_str(), unique_id.c_str(),
will_Topic, prop.value()["name"], value_template.c_str(),
"", "", "",
0, "", "", false, "",
model.c_str(), brand.c_str(), model_id.c_str(), macWOdots.c_str(), false,
stateClassNone);
} else if (strcmp(prop.value()["unit"], "status") == 0) {
createDiscovery("binary_sensor",
discovery_topic.c_str(), entity_name.c_str(), unique_id.c_str(),
will_Topic, prop.value()["name"], value_template.c_str(),
"True", "False", "",
0, "", "", false, "",
model.c_str(), brand.c_str(), model_id.c_str(), macWOdots.c_str(), false,
stateClassNone);
} else if (strcmp(prop.key().c_str(), "device") != 0 && strcmp(prop.key().c_str(), "mac") != 0) { // Exception on device and mac as these ones are not sensors
createDiscovery("sensor",
discovery_topic.c_str(), entity_name.c_str(), unique_id.c_str(),