Xiaomi Bluetooth Themometer/Hygrometer mit Display

Begonnen von distel, 05 Januar 2018, 22:07:59

Vorheriges Thema - Nächstes Thema

CoolTux

Ich änder das Mal morgen. Kannst du bitte noch mit -n 0100 probieren.


gatttool -b <MAC> --char-write-req -a 0x10 -n 0100 --listen
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

distel

#16
Zitat von: CoolTux am 09 Januar 2018, 21:24:20
Ich änder das Mal morgen. Kannst du bitte noch mit -n 0100 probieren.

Richtig, 0100 funktioniert auch. Hab das am Anfang des Moduls geändert:
my %XiaomiModels = (
        flowerSens      => {'read' => '0x35'  ,'write' => '0x33'  ,'writeValue' => 'A01F' ,'battery' => '0x38'},
        thermoHygroSens => {'read' => 'none'  ,'write' => '0x10'  ,'writeValue' => '0100' ,'battery' => '0x18'},
    );


Dann kommt allerdings das folgende Reading raus:
54 3d 31 38 2e 37 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value


Die Antwort vom Thermometer ist aber gut und ergibt:
T=18.7 H=41.6

54 = T
3d = =
31 = 1
38 = 8
2e = .
37 = 7
20 = <Space>
48 = H
3d = =
34 = 4
31 = 1
2e = .
36 = 6
00 = <Terminator>

Da scheint die Umwandlung/Interpretation noch im argen. Wenn Du keine generelle HEX => ASCII Funktion schreiben willst, kannst Du auch einfach fixe Stellen der Antwort nehmen.

Da der Sensor aber noch andere Werte als umwandelbare Zeichenfolge zurückgibt (die bspw. für ein AutoDetect des angesprochenen Gerätes dienen könnten *zwinker*) wäre es schon sinnvoll HEX => ASCII zu implementieren.

Dieser Eintrag sollte sich bspw. eignen, da Konstant:
handle: 0x000f, uuid: 00002901-0000-1000-8000-00805f9b34fb
-a 0x000f
HEX: 54 65 6d 70 26 48 75 6d 69
ASCII: Temp&Humi


Auch noch informativ:
0x002c
=>43 6c 65 61 72 67 72 61 73 73 20 49 6e 63 Cleargrass Inc Manufacturer

0x001e
=>44 75 63 6b 5f 52 65 6c 65 61 73 65 Duck_Release Model Number

0x0022
=>32 2e 30 30 2.00 Hardware Revision

0x0024
=>30 30 2e 30 30 2e 36 36 00.00.66 Firmware Revision


Andere sind auch noch interessant, zum Beispiel der Device-Name (sollte auch schreibbar sein, hab ich noch nicht getestet, aber in der Xiaomi App gehts):
handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
-a 0x0003
HEX: 4d 4a 5f 48 54 5f 56 31
ASCII: MJ_HT_V1


NUC-I37100
Docker: eBus, fhem, ha-bridge, unifi
Hardware: Homematic, FS20, Somfy RTS, 1wire, FBAHA, enOcean

CoolTux

Das bringt mir alles nichts. Ich brauche die Logausgaben. Ich muss sehen wie der Programmfluss funktioniert.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

CoolTux

OK habe noch Mal Deine Antwort gelesen.
Entscheidend war, "da kommt das Reading raus".

Er springt also nicht in die Umrechnungsfunktion.

Das änder ich gleich mal.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

distel

Zitat von: CoolTux am 10 Januar 2018, 07:18:28
Er springt also nicht in die Umrechnungsfunktion.

Das Log gibt auch nicht viel mehr preis:
2018.01.09 21:42:43 5: XiaomiBTLESens (xSens) - ExecGatttool_Run: gatttool loop result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 35 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 35 00
Notification handle = 0x000e value,54 3d 31 38 2e 36 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 35 00
Notification handle = 0x000e value,54 3d 31 38 2e 36 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 37 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 35 00

2018.01.09 21:42:43 4: XiaomiBTLESens (xSens) - ExecGatttool_Run: gatttool result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 35 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 35 00
Notification handle = 0x000e value,54 3d 31 38 2e 36 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 35 00
Notification handle = 0x000e value,54 3d 31 38 2e 36 20 48 3d 34 31 2e 36 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 37 00
Notification handle = 0x000e value,54 3d 31 38 2e 37 20 48 3d 34 31 2e 35 00

2018.01.09 21:42:43 4: XiaomiBTLESens (xSens) - ExecGatttool_Done: gatttool return string: xSens|<MAC>|ok|write|0x10|{"gtResult":"54 3d 31 38 2e 37 20 48 3d 34 31 2e 36 00 \nNotification handle = 0x000e value"}
2018.01.09 21:42:43 5: XiaomiBTLESens (xSens) - ProcessingErrors
2018.01.09 21:42:43 4: XiaomiBTLESens (xSens) - WriteReadings: Readings were written


Zum Testen komme ich dann aber erst wieder heute Abend - hoffe ich :)
NUC-I37100
Docker: eBus, fhem, ha-bridge, unifi
Hardware: Homematic, FS20, Somfy RTS, 1wire, FBAHA, enOcean

CoolTux

Habe eben eine neue Version hochgeladen. Alter Link. Nun sollten die korrekten Werte für temperature und humidity kommen.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

distel

Zitat von: CoolTux am 10 Januar 2018, 08:05:01
Habe eben eine neue Version hochgeladen. Alter Link. Nun sollten die korrekten Werte für temperature und humidity kommen.
Hallo,

hab die Version mit wget --no-cache runtergeladen. Im zip ist der Zeitstempel 10.01.2018 -- 07:38 aber...
die 100 ist (noch) nicht in eine 0100 korrigiert:
my %XiaomiModels = (
        flowerSens      => {'read' => '0x35'  ,'write' => '0x33'  ,'writeValue' => 'A01F' ,'battery' => '0x38'},
        thermoHygroSens => {'read' => 'none'  ,'write' => '0x10'  ,'writeValue' => '100' ,'battery' => '0x18'},
    );


Die Version ist "1.99.26".

Wenn ich das manuell korrigiere (sonst kommen ja keine Werte vom Thermometer), das Modul reloade und mein device "enable", bekomme ich die Readings wie gehabt:






Readings
batteryok2018-01-09 21:41:58
batteryLevel1002018-01-09 21:41:58
lastGattError54 3d 31 38 2e 36 20 48 3d 34 34 2e 32 00
Notification handle = 0x000e value
2018-01-10 19:51:50

Im Log sieht das dann so aus:
2018.01.10 19:51:35 4: XiaomiBTLESens (xSens) - WriteSensData: call function ExecGatttool_Run
2018.01.10 19:51:35 5: XiaomiBTLESens (xSens) - ExecGatttool_Run: call gatttool with command timeout 15 gatttool -i hci0 -b <MAC> --char-write-req -a 0x10 -n 0100 --listen 2>&1 /dev/null and loop 0
2018.01.10 19:51:44 3: XiaomiBTLESens (xSens) - disabled
2018.01.10 19:51:50 5: XiaomiBTLESens (xSens) - ExecGatttool_Run: gatttool loop result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 31 38 2e 36 20 48 3d 34 34 2e 32 00
...
Notification handle = 0x000e value,54 3d 31 38 2e 35 20 48 3d 34 34 2e 30 00

2018.01.10 19:51:50 4: XiaomiBTLESens (xSens) - ExecGatttool_Run: gatttool result Characteristic value was written successfully
Notification handle = 0x000e value,54 3d 31 38 2e 36 20 48 3d 34 34 2e 32 00
...
Notification handle = 0x000e value,54 3d 31 38 2e 35 20 48 3d 34 34 2e 30 00

2018.01.10 19:51:50 4: XiaomiBTLESens (xSens) - ExecGatttool_Done: gatttool return string: xSens|<MAC>|ok|write|0x10|{"gtResult":"54 3d 31 38 2e 36 20 48 3d 34 34 2e 32 00 \nNotification handle = 0x000e value"}
2018.01.10 19:51:50 5: XiaomiBTLESens (xSens) - ProcessingErrors
2018.01.10 19:51:50 4: XiaomiBTLESens (xSens) - WriteReadings: Readings were written


Hab leider die alte Version direkt "übergebügelt", kann daher kein diff machen. Ist da ggf. beim Upload ne falsche Version im Zip gelandet?!


Gruß Dirk
NUC-I37100
Docker: eBus, fhem, ha-bridge, unifi
Hardware: Homematic, FS20, Somfy RTS, 1wire, FBAHA, enOcean

CoolTux

Ok schaue ich mir an. Er schreibt es als gatttool error. Die Info hatte mir gefehlt. Muss schauen wo es hängt.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

distel

#23
    if( $respstate eq 'ok' and $gattCmd eq 'read' ) {
        XiaomiBTLESens_ProcessingNotification($hash,$handle,$decode_json->{gtResult});
       
    } elsif( $respstate eq 'ok' and $gattCmd eq 'write' and AttrVal($name,'model','none') ne 'thermoHygroSens' ) {
        XiaomiBTLESens_ReadSensData($hash);
       
    } else {
        XiaomiBTLESens_ProcessingErrors($hash,$decode_json->{gtResult});
    }

Geht es hier nicht für thermoHygroSens immer in den Fehlerzweig?! (Zeile 524)

---

und bei der Auswertung:
$notification =~ s/\s+//g;
                                                                            # 54 3d 31 37 2e 33 20 48 3d 35 32 2e 35 00
my $temp        = pack('H*',join(' ',substr($notification,4,8)));       # 31 37 2e 33
my $hum         = pack('H*',join(' ',substr($notification,18,8)));      # 35 32 2e 35

$readings{'temperature'}    = $temp/10;
$readings{'humidity'}       = $hum;


Die regex entfernt die Leerzeichen, nehme ich an. dann bekommst Du als substr jeweils eine Zahl im Format ##.# in HEX-Darstellung zurück. Das wird wohl durch das pack() konvertiert. Was mich irritiert: temperature teilst Du durch 10 und humidity nicht. Dabei sind doch beide gleich formatiert...
NUC-I37100
Docker: eBus, fhem, ha-bridge, unifi
Hardware: Homematic, FS20, Somfy RTS, 1wire, FBAHA, enOcean

CoolTux

Gerade Mal geschaut. Er kann nur in den Error gehen.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

CoolTux

So neue Version. Kannst Du bitte mal schauen.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

distel

Zitat von: CoolTux am 10 Januar 2018, 21:04:29
So neue Version. Kannst Du bitte mal schauen.
Yay! Messwerte! Nur, die Temperatur ist (fälschlicherweise) durch 10 geteilt - aber das ist ja nun wirklich noch Feintuning (s.o. Zeile 685, falls du keine eingefügt/gelöscht hast)! :D

Dickes Danke!
NUC-I37100
Docker: eBus, fhem, ha-bridge, unifi
Hardware: Homematic, FS20, Somfy RTS, 1wire, FBAHA, enOcean

CoolTux

neue version ist oben.
Wenn es jetzt dann geht, dann brauche ich bitte mal ein list vom device und hier in Codetags bitte eintragen.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

distel

#28
Alles im Lot. Hier das list:
Internals:
   BTMAC      <MAC>
   DEF        <MAC>
   INTERVAL   300
   NAME       xbtle.temp.eg.fenster
   NOTIFYDEV  global
   NR         314
   NTFY_ORDER 50-xSens
   STATE      T: 16.4 °C / H: 54.4 %
   TYPE       XiaomiBTLESens
   VERSION    1.99.31
   loglevel   4
   READINGS:
     2018-01-10 21:44:12   battery         ok
     2018-01-10 21:44:12   batteryLevel    100
     2018-01-10 21:44:27   humidity        54.4
     2018-01-10 21:32:47   lastGattError   Transport endpoint is not connected (107)
     2018-01-10 21:44:27   state           active
     2018-01-10 21:44:27   temperature     16.4
   helper:
     CallBatteryFirmware 0
     CallSensDataCounter 0
     updateTimeCallBatteryFirmware 1515617052.66093
     updateTimestampCallBatteryFirmware 2018-01-10 21:44:12
Attributes:
   alias      Temperatur EG.Fensterbank Flur
   group      Temperatur
   icon       temp_temperature
   model      thermoHygroSens
   room       Sensoren
   stateFormat {"T: " . ReadingsVal($name,"temperature",0) . " °C / H: " . ReadingsVal($name,"humidity",0) . " %"}
   verbose    5


Wo ich es hier grad lese, werde ich wohl verbose noch zurückdrehen :)

Zu schön wäre ja noch ne Anzeige der Empfangsstärke... Aber das scheint nicht so Einfach zu sein, da laut Tante Google zwei Tools in Kombination (Eins für die Verbindeungsparameter, eins für die Connection) notwendig sind. Egal: Erstmal Temperatur. Da muss ich wohl in China noch ein paar ordern...
NUC-I37100
Docker: eBus, fhem, ha-bridge, unifi
Hardware: Homematic, FS20, Somfy RTS, 1wire, FBAHA, enOcean

CoolTux

Bisschen kalt bei Dir  ;D
Ich will noch Firmware und Name auslesen.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net