Hallo Welt -mein IOB meldet, ich solle ein Script auf Version aktualisieren ("[BLE] 38:39:8f:71:xx:xx (via ShellyPlus2PM-d48afc7dyyyy): Script version 1.0 is not supported (expected 1.1), see documentation for latest Version") oder ("[BLE] 0c:ef:f6:e5:vvvv (via shellyblugw225-fcb46700cccc): Script version 1.0 is not supported (expected 1.1), see documentation for latest version"). Mein Problem ist jedoch, ich habe den Autor vergessen. Kann mir jemand helfen?
Code
Script:// v1.0
const SCRIPT_VERSION = '1.0';
const BTHOME_SVC_ID_STR = 'fcd2';
let SHELLY_ID = undefined;
function convertToHex(str) {
let hex = '';
for (let i = 0; i < str.length; i++) {
h = str.charCodeAt(i).toString(16);
hex += ('00' + h).slice(-2);
}
return hex;
}
// Callback for the BLE scanner object
function bleScanCallback(event, result) {
// exit if not a result of a scan
if (event !== BLE.Scanner.SCAN_RESULT) {
return;
}
// exit if service_data member is missing
if (
typeof result.service_data === 'undefined' ||
typeof result.service_data[BTHOME_SVC_ID_STR] === 'undefined'
) {
return;
}
// create MQTT-Payload
let message = {
scriptVersion: SCRIPT_VERSION,
src: SHELLY_ID,
srcBle: {
type: result.local_name,
mac: result.addr
},
payload: convertToHex(result.service_data[BTHOME_SVC_ID_STR])
};
if (MQTT.isConnected()) {
MQTT.publish(SHELLY_ID + '/events/ble', JSON.stringify(message));
}
}
// Initializes the script and performs the necessary checks and configurations
function init() {
// get the config of ble component
let bleConfig = Shelly.getComponentConfig('ble');
// exit if the BLE isn't enabled
if (!bleConfig.enable) {
console.log('Error: The Bluetooth is not enabled, please enable it in the settings');
return;
}
// check if the scanner is already running
if (BLE.Scanner.isRunning()) {
console.log('Info: The BLE gateway is running, the BLE scan configuration is managed by the device');
} else {
// start the scanner
let bleScanner = BLE.Scanner.Start({
duration_ms: BLE.Scanner.INFINITE_SCAN,
active: true
});
if (!bleScanner) {
console.log('Error: Can not start new scanner');
}
}
BLE.Scanner.Subscribe(bleScanCallback);
}
Shelly.call('Mqtt.GetConfig', '', function (res, err_code, err_msg, ud) {
SHELLY_ID = res['topic_prefix'];
init();
});
Alles anzeigen