Try Unpair then Pair.
Beiträge von seillehs
-
-
Changelog | Shelly Technical DocumentationAll major changes to Shelly BLU Devices API Docs will be reflected here.shelly-api-docs.shelly.cloud
-
It's now OK with firmware 1.1.0.
-
-
-
Interesting your discoveries...
I am also discovering this world of Bluetooth.
For the moment I treat UUIDs with a blacklist (with UUID fea0, more than 100 MAC addresses in 24 hours) but in the long term it will be by whitelist to only keep my devices.
-
-
I have no problem with base16. I just replaced in your code btoa => btoh and it is ok for me.
pls take a look here
-
Maybe here?
Zitat
Note: This is not available in devices with low flash memory -
I will come back to follow up on the project.
The script following my need.
Code
Alles anzeigenlet debug = false; let genTopic = 'shellies/script/bluetooth/'; let uuidsBan = ['fea0']; function isMacValid(mac) { if (mac.length !== 17) { return false; } for (let i=0; i<17; i++) { if (i%3 === 2) { if (mac.at(i) !== 0x3a) { //0x3a = : return false; } } else { //0x30 = 0, 0x39 = 9, 0x61 = a et 0x66 = f if (mac.at(i) < 0x30 || (mac.at(i) > 0x39 && mac.at(i) < 0x61) || mac.at(i) > 0x66) { return false; } } } return true; } function ScanCB(status, response) { if (status !== BLE.Scanner.SCAN_RESULT || !response.service_data) return; //exit if Scan status stopped or no Sevice Data if (!isMacValid(response.addr)) return; try{ let uuids = Object.keys(response.service_data); uuids.forEach(function (uuid) { //if (uuidsBan.includes(uuid)) return; if (uuid === 'fea0') return; let manuuuids = Object.keys(response.manufacturer_data); let manudata; if (typeof manuuuids[0] !== 'undefined') manudata = btoh(response.manufacturer_data[manuuuids[0]]); let mqttData = { id: response.addr, //ok theengs mac_type: response.addr_type, //ok theengs advertisementdata: btoh(response.advData), scanRsp: response.scanRsp, rssi: response.rssi, //ok theengs flags: response.flags, localname: response.local_name, manufacturerdatauuid: manuuuids[0], manufacturerdata: manudata, //ok theengs servicedatauuid: uuid, servicedata: btoh(response.service_data[uuid]), //Convert into Base16 to get around utf8 Error. txpower: response.tx_power_level, //ok theengs }; if(debug) print('Debug: ',mqttData); let unixtime = (Shelly.getComponentStatus("sys").unixtime + 2 * 3600) * 1000; let dateScan = new Date(unixtime); if(MQTT.isConnected()){ if(debug) print('Debug: sending MQTT Data'); topic = genTopic + response.addr + ':' + uuid; MQTT.publish(topic + '/undecoded', JSON.stringify(mqttData), 0, true); //MQTT.publish(topic + '/date', dateScan.toLocaleString(), 0, true); MQTT.publish(topic + '/date', JSON.stringify(dateScan), 0, true); return; } print('Error: MQTT is not Ready, cant send MQTT Data'); }); }catch(e){print(e);} } print('Status: started Script'); BLE.Scanner.Start({ duration_ms: BLE.Scanner.INFINITE_SCAN, active: true}, ScanCB);
but I am not sure if your gateway can handle the Base64 format.
TheengsGateway needs base16 (btoh).
In the editor, these functions are offered but they generate errors (Function "includes" not found! and Function "toLocaleString" not found!).
I cannot yet test with TheengsGateway because its stable version 1.1.0 does not yet contain my bluetooth devices.
To be continued in the next episode...
-
Thank you for your script.
I'll look at it and try to adapt it to my needs.
I will come back in a few days to provide news on this project.
-
-
- Are you looking for a Shelly Blu script?
A script for Shelly Gen2.
-What BT device is this script for?
All devices compatible with Theengs Gateway.
Theengs Compatible DevicesDiscover the extensive catalog of Bluetooth devices compatible with Theengs ecosystem, including our MQTT gateway, web parser, and OpenMQTTGateway. Find out…decoder.theengs.io-Why are you publishing it to MQTT?
For the MQTTtoMQTT decoding
Finally, I have to publish a JSON.
For test, you have a parser.
-
If I ask you for an example of a script it's because for several weeks I haven't been able to get anything done.
Code
Alles anzeigenfunction scanCB(ev, res) { if (ev === BLE.Scanner.SCAN_RESULT) { if (res.addr !== "dc:5f:6c:11:11:11") return; let unixtime = Shelly.getComponentStatus("sys").unixtime; MQTT.publish('shellies/script/bluetooth/'+res.addr+'/addr_type', JSON.stringify(res.addr_type), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/advDatatypeof', typeof res.advData, 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/advData', res.advData, 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/scanRsp', JSON.stringify(res.scanRsp), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/rssi', JSON.stringify(res.rssi), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/flags', JSON.stringify(res.flags), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/local_name', JSON.stringify(res.local_name), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/manufacturer_data_typeof', typeof res.manufacturer_data, 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/manufacturer_data', JSON.stringify(res.manufacturer_data), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/service_uuids', JSON.stringify(res.service_uuids), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/service_data_typeof', typeof res.service_data, 0, true); //MQTT.publish('shellies/script/bluetooth/'+res.addr+'/service_data_objet', JSON.stringify(res.service_data), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/service_data', res.service_data['180a'], 0, true); console.log(res.service_data); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/tx_power_level', JSON.stringify(res.tx_power_level), 0, true); MQTT.publish('shellies/script/bluetooth/'+res.addr+'/unixtime', JSON.stringify(unixtime), 0, true); } } BLE.Scanner.Start({ duration_ms: -1}, scanCB);
-
You can extract the UUID from a Script Bluetooth Scanner.
Thanks,
Do you have an example of this Script Bluetooth Scanner?
-
Hello,
Thank you for your answer.
I'm not looking to unpack Service Data.
This work can be done with Theengs Gateway.What I'm looking for is just to have the Service Data UUID and Service Data.
I looked at the ble-shelly-btn.js and ble-shelly-dw.js scripts but I don't see how to get these elements.
-
Hello,
I am looking for an example script to retrieve the servicedatauuid and servicedata of any bluetooth device.
as :
- uuid => 0xfdcd
- data => 08094411444422880104e500c6020702aa2702012d
Thanks
-
Ticket in progress.
-
beta-version 1.2.3-beta1
Hi,
Is there somewhere a changelog for the firmware of this device ?
Regards.
-
Hi,
Before opening a ticket on Shelly support, I would like to know if you are experiencing this problem since firmware 1.0.3?
ZitatMQTT.subscribe(
"my/topic/#",
function ................. {
..........;
},
);
If I publish on topic my/topic/toto, the script don't see this publication.