@soulforged Hallo, ich habe das Script etwas angepasst. Bei mir läuft es nun mit 6 Thermometern (die kleinen quadratischen Kästchen).
const pollrate_m = 5; //Abfrageintervall in Minuten (Empfehlung alle 5 Minuten / Temperaturänderung ist langsam / Schont die Batterie) const bluetooth_macs = ['A4:C1:38:15:0D:18','A4:C1:38:19:34:B7','A4:C1:38:2B:A7:0C','A4:C1:38:5E:0B:9B','A4:C1:38:6A:F8:3C','A4:C1:38:FA:CC:07']; const bluetooth_str = ['Bad','Schlafzimmer','Küche','Arbeitszimmer','Wohnzimmer','Gästezimmer']; const dpID = "javascript.0.Bluetooth.XiaomiHygroTemp"; const s_temp = "Temperatur"; const s_hygro = "Luftfeuchte"; const s_spann = "Spannung"; for(let i = 0; i < bluetooth_str.length; i++){ createState(dpID + "." + bluetooth_str[i] + "." + s_temp, 0,{unit: "°C", name: "Temperatur"}); createState(dpID + "." + bluetooth_str[i] + "." + s_hygro, 0,{unit: "%", name: "Luftfeuchte"}); createState(dpID + "." + bluetooth_str[i] + "." + s_spann, 0,{unit: "V", name: "Spannung"}); } var cronstring = "*/" + pollrate_m + " * * * *"; schedule(cronstring, async function () { for(let i = 0; i < bluetooth_macs.length; i++) poll_XiaomiHygroTemp(bluetooth_macs[i], i); await sleep(5000); }); function poll_XiaomiHygroTemp(mac, i){ var bluetooth_message = ''; var temperatur; var feuchte; var spannung; var spawn = require('child_process').spawn, gattool = spawn('gatttool',['-b', mac , '--char-write-req', '-a', '0x0038', '-n', '0100' ,'--listen']); gattool.stdout.on('data', function (data) { bluetooth_message += data.toString(); if(bluetooth_message.length > 96) { gattool.kill(/*'SIGQUIT'*/'SIGKILL'); //gatttool in kommandozeile unsanft beenden const pos1 = bluetooth_message.indexOf("value: ") + 7; const tempStr = bluetooth_message.substring(pos1, pos1 + 15).split(" "); temperatur = Math.round(parseInt(tempStr[1]+tempStr[0], 16)/10)/10; spannung = parseInt(tempStr[4]+tempStr[3], 16)/1000; feuchte = parseInt(tempStr[2], 16); console.log(i + ": " + temperatur + ", " + feuchte + ", " + spannung + ", " + bluetooth_str[i]); setState(dpID + "." + bluetooth_str[i] + "." + s_temp, temperatur, true); setState(dpID + "." + bluetooth_str[i] + "." + s_hygro, feuchte, true); setState(dpID + "." + bluetooth_str[i] + "." + s_spann, spannung, true); /* Antwort: Characteristic value was written successfully Notification handle = 0x0036 value: f8 07 4a d6 0b Bescheibung: f8 07 is the temperature as signed INT16 in little endian format. Divide it by 100 to get the temperature in degree Celsius. 4a is the humidity. Only integer output. d6 0b are the battery voltage in Millivolts in little endian format. Terminal: sudo hcitool lescan - Nach BLE Geräten suchen. */ } }); gattool.stderr.on('data', function (data) { //console.log('stderr: ' + data.toString()); log(i + ": " + bluetooth_str[i] + " hat nicht geantwortet. Warte auf nächsten Poll") }) };Grüße Martin