fhempy: ble_monitor (Bluetooth Low Energy)

Begonnen von dominik, 15 Februar 2022, 23:36:47

Vorheriges Thema - Nächstes Thema

dominik

Achja, teste bitte auch
sudo hcidump --raw hci
Und schau ob du ein Signal bekommst.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Nighthawk

Hmm, da scheint sich das BT Interface komplett verabschiedet zu haben, da kommt nichts mehr..
Ich schau mir das morgen genauer an, danke für deine Unterstützung!

dominik

sudo hciconfig hci0 down
sudo hciconfig hci0 reset
sudo hciconfig hci0 up

Hilft vielleicht.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Nighthawk

Hallo Dominik,

ich bin schon mal ein Stück weiter.
Das Bluetoothmodul hat sich komplett weggeklemmt, Abhilfe schaffte erst ein Abschalten der Stromzufuhr (ist wohl ein bekanntes Problem bei den integrierten Intel Modulen).

Nun bekomme ich beim Rauchmelder Daten rein, allerdings nur wenn kein encryption_key gesetzt ist.
Internals:
   CFGFN     
   DEF        ble_monitor 54:EF:44:E4:6A:81
   FHEMPYTYPE ble_monitor
   FUUID      6214e574-f33f-357a-de6b-c20088c2b5cd74c1
   IODev      local_pybinding
   NAME       Rauchmelder
   NR         718
   PYTHONTYPE ble_monitor
   STATE      ???
   TYPE       fhempy
   Helper:
     DBLOG:
       data:
         logdb:
           TIME       1645536775.83793
           VALUE      0
       firmware:
         logdb:
           TIME       1645536775.83793
           VALUE      Xiaomi (MiBeacon V5 encrypted)
       mac:
         logdb:
           TIME       1645536775.83793
           VALUE      54EF44E46A81
       packet:
         logdb:
           TIME       1645536775.83793
           VALUE      239
       rssi:
         logdb:
           TIME       1645536775.83793
           VALUE      -70
       type:
         logdb:
           TIME       1645536775.83793
           VALUE      JTYJGD03MI
   READINGS:
     2022-02-22 14:32:55   data            0
     2022-02-22 14:32:55   firmware        Xiaomi (MiBeacon V5 encrypted)
     2022-02-22 14:32:55   mac             54EF44E46A81
     2022-02-22 14:32:55   packet          239
     2022-02-22 14:32:55   rssi            -70
     2022-02-22 14:32:55   type            JTYJGD03MI
   args:
     Rauchmelder
     fhempy
     ble_monitor
     54:EF:44:E4:6A:81
   argsh:
Attributes:


Wenn ich den encryption_key zu setzen versuche, bekomme ich folgende Fehlermeldung:

Failed to execute function Attr: Traceback (most recent call last):
  File "/opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/fhem_pythonbinding.py", line 379, in _onMessage
    ret = await asyncio.wait_for(
  File "/usr/lib/python3.9/asyncio/tasks.py", line 481, in wait_for
    return fut.result()
  File "/opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/generic.py", line 169, in Attr
    return await utils.handle_attr(self._conf_attr, self, hash, args, argsh)
  File "/opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/utils.py", line 69, in handle_attr
    return await fct_call(hash)
  File "/opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/ble_monitor/ble_monitor.py", line 66, in set_attr_generic
    self.blemonitor.unregister_device(self)
  File "/opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/ble_monitor/blemonitor.py", line 135, in unregister_device
    self.fhem_devices[simple_mac].remove(fhemdevice)
ValueError: list.remove(x): x not in list

dominik

Sieht gut aus!

Ich habe gerade ein Update gemacht, probier es bitte nochmals.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Nighthawk

Hallo Dominik,

danke für das Update, jetzt lässt sich  der encryption_key zwar setzen, der state bleibt aber durchgängig bei "fhempy server offline".
fhempy ist aber online und auch die Mi Bodyscale funktioniert auch.

Gruß
Alex

dominik

Hi,
ok, fhempy offline sollte nicht weiter stören, da ich das state Reading aktuell danach nicht setze bleibt das offline stehen.
Kommen aber beim Aktivieren noch weitere Readings?
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Nighthawk

#37
Wie man unten an den Timestamps sehen kann, sind wohl Daten reingekommen, leider aber nicht die, die für mich interessant wären  (Battery und Alarm). Ich werd mir mal das Testspray holen um zu schauen ob im Alarmfall noch weitere Daten reinkommen.
Bei Battery wäre mir aber eine gewisse kontinuität schon sehr wichtig.

Internals:
   DEF        ble_monitor 54:EF:44:E4:6A:81
   FHEMPYTYPE ble_monitor
   FUUID      6214e574-f33f-357a-de6b-c20088c2b5cd74c1
   IODev      local_pybinding
   NAME       Rauchmelder
   NR         600
   PYTHONTYPE ble_monitor
   STATE      fhempy server offline
   TYPE       fhempy
   Helper:
     DBLOG:
       packet:
         logdb:
           TIME       1645556485.30564
           VALUE      131
       rssi:
         logdb:
           TIME       1645556485.30564
           VALUE      -76
       state:
         logdb:
           TIME       1645552275.37297
           VALUE      fhempy server offline
   READINGS:
     2022-02-22 14:32:55   data            0
     2022-02-22 14:32:55   firmware        Xiaomi (MiBeacon V5 encrypted)
     2022-02-22 14:32:55   mac             54EF44E46A81
     2022-02-22 20:01:25   packet          131
     2022-02-22 20:01:25   rssi            -76
     2022-02-22 18:51:15   state           fhempy server offline
     2022-02-22 14:32:55   type            JTYJGD03MI
   args:
     Rauchmelder
     fhempy
     ble_monitor
     54:EF:44:E4:6A:81
   argsh:
Attributes:
   encryption_key ************************************

dominik

Die Timestamps sind aber wahrscheinlich noch vor dem encryption key, oder?
Also wenn in der App der Test ankommt, dann sollte das auch im ble_monitor kommen.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Nighthawk

Nein, encryption_key habe ich deutlich früher eingegeben, das war eine regelmäßige Botschaft.
Das Testspray ist bestellt, mal schauen was dabei kommt.

dominik

Weißt ob du die Werte nur mit encryption key gekommen sind oder auch schon vorher?
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Nighthawk

Die beiden kamen sicher danach:
2022-02-22 20:01:25   packet          131
     2022-02-22 20:01:25   rssi            -76

dominik

Lösche bitte mal die Readings mit deletereading auch schau ob dann noch was rein kommt.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Nighthawk

Hallo Dominik,

habe die Readings gelöscht, kurze Zeit später waren sie wieder gefüllt:

Internals:
   DEF        ble_monitor 54:EF:44:E4:6A:81
   FHEMPYTYPE ble_monitor
   FUUID      6214e574-f33f-357a-de6b-c20088c2b5cd74c1
   IODev      local_pybinding
   NAME       Rauchmelder
   NR         600
   PYTHONTYPE ble_monitor
   STATE      fhempy server offline
   TYPE       fhempy
   Helper:
     DBLOG:
       data:
         logdb:
           TIME       1645595633.8223
           VALUE      0
       firmware:
         logdb:
           TIME       1645595633.8223
           VALUE      Xiaomi (MiBeacon V5 encrypted)
       mac:
         logdb:
           TIME       1645595633.8223
           VALUE      54EF44E46A81
       packet:
         logdb:
           TIME       1645597253.9167
           VALUE      183
       rssi:
         logdb:
           TIME       1645597253.9167
           VALUE      -73
       state:
         logdb:
           TIME       1645552275.37297
           VALUE      fhempy server offline
       type:
         logdb:
           TIME       1645595633.8223
           VALUE      JTYJGD03MI
   OLDREADINGS:
   READINGS:
     2022-02-23 06:53:53   data            0
     2022-02-23 06:53:53   firmware        Xiaomi (MiBeacon V5 encrypted)
     2022-02-23 06:53:53   mac             54EF44E46A81
     2022-02-23 07:20:53   packet          183
     2022-02-23 07:20:53   rssi            -73
     2022-02-23 06:53:53   type            JTYJGD03MI
   args:
     Rauchmelder
     fhempy
     ble_monitor
     54:EF:44:E4:6A:81
   argsh:
Attributes:
   encryption_key ****************

dominik

Hi,
ich habe mir nun den Code nochmals angesehen. Solange das Reading data 0 ist, wurden sonstige keine Daten geliefert. Wenn dort mal 1 steht, dann sollten auch weitere Readings da sein.

Es sollte auch der Batteriewert angezeigt werden, das wundert mich, dass das nicht passiert. Auch nach 24h nicht?
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik