Script ble-shelly-dw
Closed this issue · 2 comments
umbertoB67 commented
I am using the script "ble-shelly-dw" (https://github.com/ALLTERCO/shelly-script-examples/blob/main/ble-shelly-dw.js).
Without doing anything, after a certain period of time, the script crashes.
In the debug window I find the following error:
- in function "unpack" called from ...ice_data[BTHOME_SVC_ID_STR]);
- in function "getData" called from let BTHparsed = ShellyBLUParser.getData(res);
- in function called from system
Does anyone know how to solve this problem?
- Device: Shelly 1 GEN3
- Firmware version (last): 20241011-114449/1.4.4-g6d2a586
micha06de commented
The problem is caused by a faulty test for “undefined” in “_let_bth”. In the test, “typeof” must be set before “_bth” (see script excerpt). After this change, the script works reliably for me.
let _bth;
let _value;
while (buffer.length > 0) {
_bth = BTH[buffer.at(0)];
if (_bth === "undefined") { // <---------------------- replace with if (typeof _bth === "undefined") {
console.log("BTH: unknown type");
break;
}
umbertoB67 commented
@micha06de thanks a lot. It seems working fine.
Probably you can help me also for this #125