Skip to content

Commit

Permalink
[BT] Switchbot Bot control fix (#2001)
Browse files Browse the repository at this point in the history
* Fix Canary stack trace error during connection attempt

* Fix discovery

* Fix documentation tip
  • Loading branch information
1technophile authored Aug 13, 2024
1 parent d43d93f commit 4ec577d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/use/ble.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions main/ZgatewayBT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit 4ec577d

Please sign in to comment.