-
Notifications
You must be signed in to change notification settings - Fork 849
Changing WebUI to support end-user setting display BLE advertised device name vs current model_id #2218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changing WebUI to support end-user setting display BLE advertised device name vs current model_id #2218
Changes from 26 commits
70c992f
5f20c72
df1d711
90f1360
8fb8f41
9817461
966c234
56f1bb2
f9df090
6ff9d61
047cfc3
51a7525
8654f57
d72ea57
667c3dc
d71cef5
d30a59d
94dda15
b838e1b
43280c9
5587c49
471839c
f63ccbf
b350e73
66ee03d
6b5dd39
4cd4a82
f073611
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -579,13 +579,39 @@ void XMWSDJ04MMCDiscovery(const char* mac, const char* sensorModel) { | |||
| createDiscoveryFromList(mac, XMWSDJ04MMCsensor, XMWSDJ04MMCparametersCount, "XMWSDJ04MMC", "Xiaomi", sensorModel); | ||||
| } | ||||
|
|
||||
| void xxWSD0xMMCDiscovery(const char* mac, const char* name, const char* sensorModel) { | ||||
1technophile marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| Log.trace(F("xxWSD0xMMCDiscovery" CR)); | ||||
| int xxWSD0xMMCparametersCount = 5; | ||||
| if (strcmp(sensorModel, "LYWSD03MMC/MJWSD05MMC_PVVX_DECR") != 0) xxWSD0xMMCparametersCount = 5; | ||||
| if (strcmp(sensorModel, "LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME") == 0) xxWSD0xMMCparametersCount = 7; | ||||
| const char* xxWSD0xMMCsensor[xxWSD0xMMCparametersCount][9] = { | ||||
| {"sensor", "Battery", mac, "battery", jsonBatt, "", "", "%", stateClassMeasurement}, | ||||
| {"sensor", "Temperature", mac, "temperature", jsonTempc, "", "", "°C", stateClassMeasurement}, | ||||
| {"sensor", "Humidity", mac, "humidity", jsonHum, "", "", "%", stateClassMeasurement}, | ||||
| {"sensor", "RSSI", mac, "signal_strength", jsonRSSI, "", "", "dB", stateClassMeasurement} | ||||
| //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, state class | ||||
| }; | ||||
| if (strcmp(sensorModel, "LYWSD03MMC/MJWSD05MMC_PVVX_DECR") != 0) { // Encrypted PVVX don't have Voltage | ||||
| const char* voltage[9] = {"sensor", "Voltage", mac, "voltage", jsonVolt, "", "", "V", stateClassMeasurement}; | ||||
| memcpy(&xxWSD0xMMCsensor[4], voltage, sizeof(voltage)); | ||||
| }; | ||||
| if (strcmp(sensorModel, "LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME") == 0) { | ||||
| const char* power[9] = {"sensor", "Power", mac, "", jsonPower, "", "", "", stateClassNone}; | ||||
| memcpy(&xxWSD0xMMCsensor[5], power, sizeof(power)); | ||||
| const char* open[9] = {"sensor", "Opening", mac, "", jsonOpen, "", "", "", stateClassNone}; | ||||
| memcpy(&xxWSD0xMMCsensor[6], open, sizeof(open)); | ||||
| }; | ||||
| createDiscoveryFromList(mac, xxWSD0xMMCsensor, xxWSD0xMMCparametersCount, name, "Xiaomi", sensorModel); | ||||
| } | ||||
|
|
||||
| # else | ||||
| void LYWSD03MMCDiscovery(const char* mac, const char* sensorModel) {} | ||||
| void MHO_C401Discovery(const char* mac, const char* sensorModel) {} | ||||
| void HHCCJCY01HHCCDiscovery(const char* mac, const char* sensorModel) {} | ||||
| void DT24Discovery(const char* mac, const char* sensorModel_id) {} | ||||
| void BM2Discovery(const char* mac, const char* sensorModel_id) {} | ||||
| void XMWSDJ04MMCDiscovery(const char* mac, const char* sensorModel_id) {} | ||||
| void xxWSD0xMMCDiscovery(const char* mac, const char* name, const char* sensorModel) {} | ||||
| # endif | ||||
|
|
||||
| /* | ||||
|
|
@@ -955,11 +981,11 @@ void launchBTDiscovery(bool overrideDiscovery) { | |||
| Log.trace(F("properties: %s" CR), properties.c_str()); | ||||
| std::string brand = decoder.getTheengAttribute(p->sensorModel_id, "brand"); | ||||
| std::string model = decoder.getTheengAttribute(p->sensorModel_id, "model"); | ||||
| # if ForceDeviceName | ||||
| if (p->name[0] != '\0') { | ||||
| model = p->name; | ||||
| if (displayDeviceName || ForceDeviceName) { | ||||
| if (p->name[0] != '\0') { | ||||
1technophile marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| model = p->name; | ||||
| } | ||||
| } | ||||
| # endif | ||||
| std::string model_id = decoder.getTheengAttribute(p->sensorModel_id, "model_id"); | ||||
|
|
||||
| // Check for tracker status | ||||
|
|
@@ -996,7 +1022,9 @@ void launchBTDiscovery(bool overrideDiscovery) { | |||
| model.c_str(), brand.c_str(), model_id.c_str(), macWOdots.c_str(), false, | ||||
| stateClassNone); | ||||
| } | ||||
| if (!properties.empty()) { | ||||
| if (displayDeviceName && p->sensorModel_id >= TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_ATC && p->sensorModel_id <= TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_PVVX_BTHOME_2 ) { | ||||
| xxWSD0xMMCDiscovery(macWOdots.c_str(), p->name, model_id.c_str()); | ||||
| } else if (!properties.empty()) { | ||||
| StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer; | ||||
| auto error = deserializeJson(jsonBuffer, properties); | ||||
| if (error) { | ||||
|
|
@@ -1014,7 +1042,12 @@ void launchBTDiscovery(bool overrideDiscovery) { | |||
| Log.trace(F("Key: %s"), prop.key().c_str()); | ||||
| Log.trace(F("Unit: %s"), prop.value()["unit"].as<const char*>()); | ||||
| Log.trace(F("Name: %s"), prop.value()["name"].as<const char*>()); | ||||
| String entity_name = String(model_id.c_str()) + "-" + String(prop.key().c_str()); | ||||
| String entity_name = ""; | ||||
| if (displayDeviceName || ForceDeviceName) { | ||||
| entity_name = String(model.c_str()) + "-" + String(prop.key().c_str()); | ||||
| } else { | ||||
| entity_name = String(model_id.c_str()) + "-" + String(prop.key().c_str()); | ||||
| } | ||||
| String unique_id = macWOdots + "-" + String(prop.key().c_str()); | ||||
| String value_template = "{{ value_json." + String(prop.key().c_str()) + " | is_defined }}"; | ||||
| if (p->sensorModel_id == TheengsDecoder::BLE_ID_NUM::SBS1 && strcmp(prop.key().c_str(), "state") == 0) { | ||||
|
|
@@ -1423,7 +1456,7 @@ void process_bledata(JsonObject& BLEdata) { | |||
| BTConfig.intervalActiveScan = MinTimeBtwScan; | ||||
| BTConfig.scanDuration = MinScanDuration; | ||||
| Log.notice(F("Active and continuous scanning required, parameters adapted" CR)); | ||||
| stateBTMeasures(false); | ||||
| // stateBTMeasures(false); // Disabling as it casues a segfault | ||||
|
||||
| 9500, /* Stack size in bytes */ |
and see if you still get the issue
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same a s above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
instead