Sei mal so nett. Mich interessiert gerade ob das vom SSH kommt oder generell so nicht ganz sauber läuft.
Danke Dir.
So, hab die aktuelle devel5 nochmal gezogen und probiert. Es scheint wirklich daran zu liegen, dass die Abfragen auf das gelieferte Ergebnis nicht funktionieren, wenn mehr als eine "Antwortzeile" kommt.
Mit dieser Rückgabe klappt es:
2018.01.31 20:30:12 5: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: call gatttool with command ssh fhem@radiohub-1.home 'timeout 15 gatttool -i hci0 -b 4C:65:A8:D0:42:63 --char-write-req -a 0x10 -n 0100 --listen 2>&1 /dev/null' and loop 0
2018.01.31 20:30:27 5: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: gatttool loop result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 36 00
2018.01.31 20:30:27 4: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: gatttool result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 36 00
2018.01.31 20:30:27 5: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Done: gatttool return string: xbtle.temp.eg.flur|4C:65:A8:D0:42:63|ok|write|0x10|{"gtResult":"54 3d 32 31 2e 39 20 48 3d 34 36 2e 36 00 "}
Sekunden später klappt es nicht:
2018.01.31 20:33:38 5: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: call gatttool with command ssh fhem@radiohub-1.home 'timeout 15 gatttool -i hci0 -b 4C:65:A8:D0:42:63 --char-write-req -a 0x10 -n 0100 --listen 2>&1 /dev/null' and loop 0
2018.01.31 20:33:54 5: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: gatttool loop result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 37 00
...
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 35 00
2018.01.31 20:33:54 4: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: gatttool result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 37 00
...
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 35 00
2018.01.31 20:33:55 5: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: call gatttool with command ssh fhem@radiohub-1.home 'gatttool -i hci0 -b 4C:65:A8:D0:42:63 --char-read -a 0x35 2>&1 /dev/null' and loop 0
Das Thermometer hat halt die "Angewohnheit", seine Messwerte bis ca. 10x rauszuposaunen. :-/
Hab in Deinen Code geschaut, und bin irgendwo in der Ecke Zeile 490 hängen geblieben. Leider habe ich keine Ahnung vom Array/String-Handling in Perl, daher kann ich nicht beurteilen, was im jeweiligen Falle in $gtResult[1] drin ist. Daher hab ich zwei Log3 Aufrufe eingefügt:
2018.01.31 20:44:34 5: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: gatttool loop result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 36 00
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 35 00
2018.01.31 20:44:34 4: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: gatttool result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 36 00
Notification handle = 0x000e value,54 3d 32 31 2e 39 20 48 3d 34 36 2e 35 00
2018.01.31 20:44:34 5: XiaomiBTLESens (xbtle.temp.eg.flur) - gtResult[1]: 54 3d 32 31 2e 39 20 48 3d 34 36 2e 36 00
Notification handle = 0x000e value
2018.01.31 20:44:34 5: XiaomiBTLESens (xbtle.temp.eg.flur) - json_notification: {"gtResult":"54 3d 32 31 2e 39 20 48 3d 34 36 2e 36 00 \nNotification handle = 0x000e value"}
2018.01.31 20:44:36 5: XiaomiBTLESens (xbtle.temp.eg.flur) - ExecGatttool_Run: call gatttool with command ssh fhem@radiohub-1.home 'gatt
Knackpunkt dürfte sein, dass im Element [1] nicht nut der "Response"-Teil "54 3d 32 31 2e 39 20 48 3d 34 36 2e 36 00" sondern nach einem Umbruch o.ä. auch noch der Führungstext der nächsten Zeile "Notification handle = 0x000e value" drin ist.
Die folgende RegEx "if($gtResult[1] =~ /^([0-9a-f]{2}(\s?))*$/) {" refrenziert aber auf das Ende des Strings, dass erst nach dem zweiten Teil (Führungstext) erreicht ist. Somit scheint mir klar, warum es funktioniert, wenn nur genau eine Antwortzeile zurückkommt.
Das Zeichen, das für den Umbruch sorgt ist ein "0A" in Hex - also klassischer LineFeed. den müsstest Du noch irgendwie ausfiltern/ersetzen, so dass die Antwort tatsächlich "frei" steht. Ich habe eine Ausgabe vom gatttool angehängt, da dort auch noch ein Leerzeichen vor dem 0A steht. Dann kannst Du dagegen prüfen.
Gruß
Dirk