[DISC] Add runtime configuration for OpenHAB (#1658)

* [DISC] Add runtime configuration for OpenHAB

Add an MQTT configurable system key "ohdiscovery" for OpenHAB auto discovery

* Docs and environments update
This commit is contained in:
Florian authored and GitHub committed 2023-05-31 11:35:35 -05:00
1 parent 4a28f491f5
commit 6e23ca029b
11 files changed
+83 -128

No files matched your search

-7
View File
@@ -127,17 +127,10 @@ void launchRTL_433Discovery(bool overrideDiscovery) {
String idWoKey = pdevice->uniqueId;
idWoKey.remove(idWoKey.length() - (strlen(parameters[i][0]) + 1));
DISCOVERY_TRACE_LOG(F("idWoKey %s" CR), idWoKey.c_str());
# if OpenHABDiscovery
String value_template = "{{ value_json." + String(parameters[i][0]) + "}}";
if (strcmp(parameters[i][0], "battery_ok") == 0)) {
value_template = "{{ float(value_json." + String(parameters[i][0]) + ") * 99 + 1 }}"; // https://github.com/merbanan/rtl_433/blob/93f0f30c28cfb6b82b8cc3753415b01a85bee91d/examples/rtl_433_mqtt_hass.py#L187
}
# else
String value_template = "{{ value_json." + String(parameters[i][0]) + " | is_defined }}";
if (strcmp(parameters[i][0], "battery_ok") == 0) {
value_template = "{{ float(value_json." + String(parameters[i][0]) + ") * 99 + 1 | is_defined }}"; // https://github.com/merbanan/rtl_433/blob/93f0f30c28cfb6b82b8cc3753415b01a85bee91d/examples/rtl_433_mqtt_hass.py#L187
}
# endif
String topic = subjectRTL_433toMQTT;
# if valueAsATopic
// Remove the key from the unique id to extract the device id