[74_XiaomiBTLESens.pm] Xiaomi Bluetooth Sensoren FlowerSens/Thermometer

Begonnen von CoolTux, 11 Januar 2018, 15:42:45

Vorheriges Thema - Nächstes Thema

t1me2die

Nah!
Wie kommst du auf die Idee?  :o
Schon verstanden, habe das GPUtils geupdatet.
Reload hat geklappt.

Kann es sein, dass bei Statement 1166 was fehlt?


    readingsBulkUpdateIfChanged($hash, "state",($readings->{'lastGattError'} ? 'error' : 'active' ) )if ( AttrVal( $name, 'model', 'none' ) eq 'flowerSens' );
    readingsBulkUpdateIfChanged( $hash, "state",
        ( $readings->{'lastGattError'} ? 'error' : 'active' ) )
      if ( AttrVal( $name, 'model', 'none' ) eq 'flowerSens' );
    readingsBulkUpdateIfChanged(
        $hash, "state",
        (
            $readings->{'lastGattError'}
            ? 'error'
            : 'T: '
              . ReadingsVal( $name, 'temperature', 0 ) . ' H: '
              . ReadingsVal( $name, 'humidity',    0 )
        )
    ) if (( AttrVal( $name, 'model', 'none' ) eq 'thermoHygroSens' ) or ( AttrVal( $name, 'model', 'none' ) eq 'clearGrassSens'));


Hier ein List

Internals:
   BTMAC      58:2D:34:10:4C:FA
   DEF        58:2D:34:10:4C:FA
   FUUID      5d8cd259-f33f-5bc8-f8d0-febfa4c6b28c768c
   INTERVAL   300
   NAME       wz_Xiaomi_Sensor_unten
   NOTIFYDEV  global,wz_Xiaomi_Sensor_unten
   NR         26
   NTFY_ORDER 50-wz_Xiaomi_Sensor_unten
   STATE      read sensor data
   TYPE       XiaomiBTLESens
   VERSION    v2.7.54
   loglevel   4
   READINGS:
     2019-10-11 12:14:10   batteryPercent  254
     2019-10-11 12:14:10   batteryState    ok
     2019-10-11 09:28:56   devicename      ClearGrass Temp & RH
     2019-10-11 09:28:46   firmware        1.1.2_0020
     2019-10-11 12:14:56   humidity        60.5
     2019-10-11 09:28:36   lastGattError   No route to host (113)
     2019-10-10 12:37:51   macInverted     FA:4C:10:34:2D:58
     2019-10-10 12:38:03   manufactor      Qingping Technology (Beijing) Co., Ltd.
     2019-10-10 12:58:41   productID       CGG1
     2019-10-11 12:14:53   state           read sensor data
     2019-10-11 12:14:56   temperature     17.7
   helper:
     CallBattery 0
     CallSensDataCounter 0
     updateTimeCallBattery 1570788850.5141
     updateTimestampCallBattery 2019-10-11 12:14:10
Attributes:
   model      clearGrassSens
   room       XiaomiBTLESens
   verbose    0

CoolTux

Habe ich angepasst.

Kannst Du bitte das neue Modul einspielen, dann ein Reload machen und das Device löschen um es dann neu wieder an zu legen.
Und wenn dann Daten gekommen sind bitte wieder ein list vom Device.


Danke Dir im übrigen für die tolle Arbeit.
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

bei der Batterie schein aber noch was zu klemmen, da habe ich bestimmt einen falschen handle erwischt.
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

t1me2die

Zitat von: CoolTux am 11 Oktober 2019, 12:28:37
bei der Batterie schein aber noch was zu klemmen, da habe ich bestimmt einen falschen handle erwischt.

Ganz sicher  :)
Wie gesagt, ich suche noch den richtigen handle!

List

Internals:
   BTMAC      58:2D:34:10:4C:FA
   CFGFN     
   DEF        58:2D:34:10:4C:FA
   FUUID      5da05990-f33f-5bc8-ef85-3ac9f283a69f804c
   INTERVAL   300
   NAME       wz_Xiaomi_Sensor_unten
   NOTIFYDEV  global,wz_Xiaomi_Sensor_unten
   NR         140
   NTFY_ORDER 50-wz_Xiaomi_Sensor_unten
   STATE      T: 17.7 H: 60.5
   TYPE       XiaomiBTLESens
   VERSION    v2.7.54
   loglevel   4
   READINGS:
     2019-10-11 12:30:48   batteryPercent  254
     2019-10-11 12:30:48   batteryState    ok
     2019-10-11 12:29:48   firmware        1.1.2_0020
     2019-10-11 12:30:48   humidity        60.5
     2019-10-11 12:30:48   state           T: 17.7 H: 60.5
     2019-10-11 12:30:48   temperature     17.7
   helper:
     CallBattery 0
     CallSensDataCounter 0
     updateTimeCallBattery 1570789848.21398
     updateTimestampCallBattery 2019-10-11 12:30:48
Attributes:
   model      clearGrassSens
   room       XiaomiBTLESens

CoolTux

Ok ich habe mal Deinen Handle genommen. Bitte teste noch mal, musst aber vorher ein resetBatteryTimestamp machen.
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

t1me2die

Zitat von: CoolTux am 11 Oktober 2019, 12:38:49
Ok ich habe mal Deinen Handle genommen. Bitte teste noch mal, musst aber vorher ein resetBatteryTimestamp machen.

Da hast du aber ein altes handle von mir erwischt.
Zur Zeit probiere ich 0x3b aus.

Meine aktuelle Sub für die Batterie:

sub ClearGrassSensHandle0x3b($$) {
    ### Clear Grass Sens - Battery Data
    my ( $hash, $notification ) = @_;

    my $name = $hash->{NAME};
    my %readings;

    Log3 $name, 4, "XiaomiBTLESens ($name) - Clear Grass Sens Handle0x3b";

    chomp($notification);
    $notification =~ s/\s+//g;

    ### neue Vereinheitlichung für Batteriereadings Forum #800017
    $readings{'batteryPercent'} = hex(substr( $notification, 14, 2 ) );
    $readings{'batteryState'}   = ( hex(substr( $notification, 14, 2 )) > 15 ? "ok" : "low" );

    $hash->{helper}{CallBattery} = 1;
    CallBattery_Timestamp($hash);
    return \%readings;
}

Ob der Wert stimmt, ist mehr als fraglich!


List

Internals:
   BTMAC      58:2D:34:10:4C:FA
   CFGFN     
   DEF        58:2D:34:10:4C:FA
   FUUID      5da05990-f33f-5bc8-ef85-3ac9f283a69f804c
   INTERVAL   300
   NAME       wz_Xiaomi_Sensor_unten
   NOTIFYDEV  global,wz_Xiaomi_Sensor_unten
   NR         140
   NTFY_ORDER 50-wz_Xiaomi_Sensor_unten
   STATE      T: 17.7 H: 60.5
   TYPE       XiaomiBTLESens
   VERSION    v2.7.54
   loglevel   4
   READINGS:
     2019-10-11 12:53:22   batteryPercent  77
     2019-10-11 12:53:22   batteryState    ok
     2019-10-11 12:29:48   firmware        1.1.2_0020
     2019-10-11 12:53:22   humidity        60.5
     2019-10-11 12:51:04   lastGattError   No route to host (113)
     2019-10-11 12:53:22   state           T: 17.7 H: 60.5
     2019-10-11 12:53:22   temperature     17.7
   helper:
     CallBattery 0
     CallSensDataCounter 0
     updateTimeCallBattery 1570791202.1444
     updateTimestampCallBattery 2019-10-11 12:53:22
Attributes:
   model      clearGrassSens
   room       XiaomiBTLESens

CoolTux

Irgendwie ist das komisch da alle mir bekannten Batteriehandle eigentlich immer nur ein HEX Wert wieder geben.
Und im normal Fall halten sich die Hersteller da sogar an die Vorgabe also mit immer den selben Characteristic. Ich schaue 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

t1me2die

Wie gesagt, ich konnte bisher noch nicht eindeutig das battery handle identifizieren, liegt aber auch daran, dass ich nicht den genauen %-Stand ablesen kann!

Hier sind meine ganzen handle's + uuid und den jeweiligen HEX-Werten.
Dort wo ein lesbarer Text steht, habe ich den HEX-Wert in ASCII direkt übersetzt, sodass ich dieses handle für mich persönlich abgehakt habe!


handle: 0x0001, uuid: 00002800-0000-1000-8000-00805f9b34fb 00 18
handle: 0x0002, uuid: 00002803-0000-1000-8000-00805f9b34fb 0a 03 00 2a
handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb ClearGrass Temp & RH
handle: 0x0004, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 05 00 01 2a
handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb 00 00
handle: 0x0006, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 07 00 04 2a
handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb 10 00 3c 00 00 00 90 01
handle: 0x0008, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 09 00 a6 2a
handle: 0x0009, uuid: 00002aa6-0000-1000-8000-00805f9b34fb 01
handle: 0x000a, uuid: 00002800-0000-1000-8000-00805f9b34fb 01 18
handle: 0x000b, uuid: 00002803-0000-1000-8000-00805f9b34fb 20 0c 00 05 2a
handle: 0x000c, uuid: 00002a05-0000-1000-8000-00805f9b34fb cant read
handle: 0x000d, uuid: 00002902-0000-1000-8000-00805f9b34fb 00 00
handle: 0x000e, uuid: 00002800-0000-1000-8000-00805f9b34fb 59 fe
handle: 0x000f, uuid: 00002803-0000-1000-8000-00805f9b34fb 18 10 00 50 ea da 30 88 83 b8 9f 60 4f 15 f3 03 00 c9 8e
handle: 0x0010, uuid: 8ec90003-f315-4f60-9fb8-838830daea50 blank
handle: 0x0011, uuid: 00002902-0000-1000-8000-00805f9b34fb 00 00
handle: 0x0012, uuid: 00002800-0000-1000-8000-00805f9b34fb 4d 46 50 44 53 46 42 55 46 45 4a 55 00 00 21 22
handle: 0x0013, uuid: 00002803-0000-1000-8000-00805f9b34fb 0c 14 00 01 00
handle: 0x0014, uuid: 00000001-0000-1000-8000-00805f9b34fb 01 0a
handle: 0x0015, uuid: 00002803-0000-1000-8000-00805f9b34fb 10 16 00 02 00
handle: 0x0016, uuid: 00000002-0000-1000-8000-00805f9b34fb 05 0a 2b 2a 9e 5d
handle: 0x0017, uuid: 00002902-0000-1000-8000-00805f9b34fb 00 00
handle: 0x0018, uuid: 00002803-0000-1000-8000-00805f9b34fb 0c 19 00 03 00
handle: 0x0019, uuid: 00000003-0000-1000-8000-00805f9b34fb fe
handle: 0x001a, uuid: 00002803-0000-1000-8000-00805f9b34fb 10 1b 00 04 00
handle: 0x001b, uuid: 00000004-0000-1000-8000-00805f9b34fb fe
handle: 0x001c, uuid: 00002902-0000-1000-8000-00805f9b34fb 00 00
handle: 0x001d, uuid: 00002803-0000-1000-8000-00805f9b34fb 10 1e 00 00 01
handle: 0x001e, uuid: 00000100-0000-1000-8000-00805f9b34fb 05 08 b0 00 38 02
05 08 b1 00 43 02
05 08 b2 00 5a 02
05 08 b1 00 5d 02
handle: 0x001f, uuid: 00002902-0000-1000-8000-00805f9b34fb 00 00
handle: 0x0020, uuid: 00002800-0000-1000-8000-00805f9b34fb 0a 18
handle: 0x0021, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 22 00 29 2a
handle: 0x0022, uuid: 00002a29-0000-1000-8000-00805f9b34fb Qingping Technology (Beijing) Co., Ltd.
handle: 0x0023, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 24 00 24 2a
handle: 0x0024, uuid: 00002a24-0000-1000-8000-00805f9b34fb CGG1
handle: 0x0025, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 26 00 25 2a
handle: 0x0026, uuid: 00002a25-0000-1000-8000-00805f9b34fb FA4C10342D58 (MAC)
handle: 0x0027, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 28 00 27 2a
handle: 0x0028, uuid: 00002a27-0000-1000-8000-00805f9b34fb 30 30 30 31 -> Revision 0001
handle: 0x0029, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 2a 00 26 2a
handle: 0x002a, uuid: 00002a26-0000-1000-8000-00805f9b34fb Firmware
handle: 0x002b, uuid: 00002800-0000-1000-8000-00805f9b34fb 95 fe
handle: 0x002c, uuid: 00002803-0000-1000-8000-00805f9b34fb 18 2d 00 01 00
handle: 0x002d, uuid: 00000001-0000-1000-8000-00805f9b34fb cant read
handle: 0x002e, uuid: 00002902-0000-1000-8000-00805f9b34fb 00 00
handle: 0x002f, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 30 00 02 00
handle: 0x0030, uuid: 00000002-0000-1000-8000-00805f9b34fb 47 03
handle: 0x0031, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 32 00 04 00
handle: 0x0032, uuid: 00000004-0000-1000-8000-00805f9b34fb 0a 58 c4 7c d3 b7 2a 2b f1 13
handle: 0x0033, uuid: 00002803-0000-1000-8000-00805f9b34fb 18 34 00 05 00
handle: 0x0034, uuid: 00000005-0000-1000-8000-00805f9b34fb cant read
handle: 0x0035, uuid: 00002902-0000-1000-8000-00805f9b34fb 00 00
-handle: 0x0036, uuid: 00002803-0000-1000-8000-00805f9b34fb 08 37 00 10 00
handle: 0x0037, uuid: 00000010-0000-1000-8000-00805f9b34fb cant read
-handle: 0x0038, uuid: 00002803-0000-1000-8000-00805f9b34fb 0a 39 00 13 00
-handle: 0x0039, uuid: 00000013-0000-1000-8000-00805f9b34fb 3b 14 99 26 cf db 34 2a f3 53 45 3b 41 6f a3 9f 29 09 70 38
-handle: 0x003a, uuid: 00002803-0000-1000-8000-00805f9b34fb 02 3b 00 14 00
handle: 0x003b, uuid: 00000014-0000-1000-8000-00805f9b34fb 51 04 bf 7e 7d 10 be 4d 71 7b 8f 2f

CoolTux

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

t1me2die

Ich habe leider keinerlei Zugriff auf ein Android Telefon...
Für iOS gibt es soetwas offiziell nicht, nur in Verbindung eines Jailbreakes.
Ich habe zwar einen, konnte mich mit dem Thema tcpdump und wireshark noch nicht auseinandersetzen.

CoolTux

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

t1me2die


CoolTux

Ich habe nun die vorerst letzte Version ins Git geladen. Kannst Du die bitte nehmen und testen? Geht ja auch um Stabilität.


Grüße
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

t1me2die

Habe ich mal installiert.
Ich werde nun weiter die Werte beobachten  :)

t1me2die

Moin Leon,

irgendwas passt noch nicht so ganz.
Als ich gestern Abend die Werte vergleichen wollte, viel mir auf, dass diese nicht passten, ich hatte gestern jedoch noch keine Zeit dem ganzen auf die Spur zu gehen.

Ein get sensorData brachte falsche Ergebnisse bzw. laut Log wurde mit einem falschen handle ein read gemacht.

Logfile:

2019.10.12 00:18:46 4: XiaomiBTLESens (wz_Xiaomi_Sensor_unten) - Run CreateParamGatttool with mod: read
2019.10.12 00:18:46 5: XiaomiBTLESens (wz_Xiaomi_Sensor_unten) - Read XiaomiBTLESens_ExecGatttool_Run wz_Xiaomi_Sensor_unten|58:2D:34:10:4C:FA|read|0x3a
2019.10.12 00:18:46 5: XiaomiBTLESens (wz_Xiaomi_Sensor_unten) - ExecGatttool_Run: call gatttool with command: gatttool -i hci0 -b 58:2D:34:10:4C:FA --char-read -a 0x3a 2>&1 /dev/null and loop 0
2019.10.12 00:18:56 5: XiaomiBTLESens (wz_Xiaomi_Sensor_unten) - ExecGatttool_Run: gatttool loop result Characteristic value/descriptor,02 3b 00 14 00

2019.10.12 00:18:56 4: XiaomiBTLESens (wz_Xiaomi_Sensor_unten) - ExecGatttool_Run: gatttool result Characteristic value/descriptor,02 3b 00 14 00

2019.10.12 00:18:56 5: XiaomiBTLESens (wz_Xiaomi_Sensor_unten) - ExecGatttool_Done: gatttool return string: wz_Xiaomi_Sensor_unten|58:2D:34:10:4C:FA|ok|read|0x3a|{"gtResult":"02 3b 00 14 00 "}
2019.10.12 00:18:56 4: XiaomiBTLESens (wz_Xiaomi_Sensor_unten) - ProcessingNotification
2019.10.12 00:18:56 4: XiaomiBTLESens (wz_Xiaomi_Sensor_unten) - WriteReadings: Readings were written


Anstatt mit dem handle 0x1e wurde der read mit 0x3a gemacht, was ja nicht korrekt ist.
Ich hatte kurz meine "alte" Version verwendet, da waren die Werte sofort wieder korrekt.
Ich gucke mir heute / Morgen mal deine endgültige Version an und schaue, wo es hapert.

Gruß
Mathze