From 4ec577d6af5d957d9637286d797f909c75c86d5c Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 13 Aug 2024 13:23:59 -0500 Subject: [PATCH] [BT] Switchbot Bot control fix (#2001) * Fix Canary stack trace error during connection attempt * Fix discovery * Fix documentation tip --- docs/use/ble.md | 1 + main/ZgatewayBT.ino | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/use/ble.md b/docs/use/ble.md index 8b53598..fd9c7d8 100644 --- a/docs/use/ble.md +++ b/docs/use/ble.md @@ -371,6 +371,7 @@ Response: ::: tip The `ttl` parameter is the number of attempts to connect (defaults to 1), which occur after the BLE scan completes. `value_type` can be one of: STRING, HEX, INT, FLOAT. Default is STRING if omitted in the message. +::: ## SwitchBot Bot control (available with HA discovery) diff --git a/main/ZgatewayBT.ino b/main/ZgatewayBT.ino index 17b0faf..685423c 100644 --- a/main/ZgatewayBT.ino +++ b/main/ZgatewayBT.ino @@ -1057,14 +1057,14 @@ void launchBTDiscovery(bool overrideDiscovery) { String 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) { + if (p->sensorModel_id == TheengsDecoder::BLE_ID_NUM::SBS1 && strcmp(prop.key().c_str(), "state") == 0) { String payload_on = "{\"SBS1\":\"on\",\"mac\":\"" + String(p->macAdr) + "\"}"; String payload_off = "{\"SBS1\":\"off\",\"mac\":\"" + String(p->macAdr) + "\"}"; createDiscovery("switch", //set Type discovery_topic.c_str(), entity_name.c_str(), unique_id.c_str(), will_Topic, "switch", value_template.c_str(), payload_on.c_str(), payload_off.c_str(), "", 0, - Gateway_AnnouncementMsg, will_Message, false, subjectMQTTtoBTset, + Gateway_AnnouncementMsg, will_Message, false, subjectMQTTtoBT, model.c_str(), brand.c_str(), model_id.c_str(), macWOdots.c_str(), false, stateClassNone, "off", "on"); } else if ((p->sensorModel_id == TheengsDecoder::XMTZC04HMKG || p->sensorModel_id == TheengsDecoder::XMTZC04HMLB || p->sensorModel_id == TheengsDecoder::XMTZC05HMKG || p->sensorModel_id == TheengsDecoder::XMTZC05HMLB) && @@ -1377,7 +1377,7 @@ void startBTActionTask() { xTaskCreatePinnedToCore( immediateBTAction, /* Function to implement the task */ "imActTask", /* Name of the task */ - 5120, /* Stack size in bytes */ + 8000, /* Stack size in bytes */ NULL, /* Task input parameter */ 3, /* Priority of the task (set higher than core task) */ &th, /* Task handle. */