Autor Thema: Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags  (Gelesen 18197 mal)

Offline Jamo

  • Sr. Member
  • ****
  • Beiträge: 710
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #135 am: 04 Dezember 2019, 21:17:28 »
So, alles gemacht. Es werden alle Devices gefunden, das ist es also nicht. Es gibt aber 2 Sachen:

1) stateformat:. Wenn ich das "attr stateformat room/rooms" setze, ist der Internal STATE "STATE      flurLE / flurLE,schlafLE", damit wird das device als absent erkannt.
    Das kann ich ändern, aber schöner wäre es, wenn der batteryLevel unabhängig vom stateformat gesetz würde.

2) Timing:
    Schau Dir mal im Logfile die Zeilen 2019.12.04 20:59:00" ünd "2019.12.04 20:59:01" unter dem list vom Presence_Vater_iPhone_BT an.
    Man sieht, das der erste Presence_Vater_Orange_collect und der 2-te Presence_GTag_Black_collect gefunden werden, das gatttool liefert für beide "4b" zurück.
    Danach, also 3 Sekunden später, also ab Zeile "2019.12.04 20:59:04", werden die nächsten GTags (RED/White/Gast) gefunden, aber das gattool liefert nur noch "connect error" oder "no route to host" zurück.
    Da stimmt irgendwas mit dem gattool Timing nicht, oder?? Das geht dem gattool wohl zu schnell :-)

2019.12.04 20:59:00 4: Sub BleTagBattery_Run (myBleTagBattery) - start blocking call
2019.12.04 20:59:00 5: Sub BleTagBattery_stateRequest (myBleTagBattery) - state request called
2019.12.04 20:59:00 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Vater_Orange_collect
2019.12.04 20:59:00 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.04 20:59:00 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.04 20:59:00 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag already saved in hash
2019.12.04 20:59:01 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: handle: 0x001b value: 4b

2019.12.04 20:59:01 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - processing gatttool response: 4b
2019.12.04 20:59:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_Vater_Orange_collect. batteryLevel: 75
2019.12.04 20:59:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Vater_iPhone_BT
2019.12.04 20:59:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device not present.
Internals:
   ADDRESS    ME:IN:EM:AC:AD:DR
   DEF        lan-bluetooth ME:IN:EM:AC:AD:DR 127.0.0.1:5222 60 60
   DeviceName 127.0.0.1:5222
   FUUID      tada
   INTERVAL_NORMAL 60
   INTERVAL_PRESENT 60
   MODE       lan-bluetooth
   NAME       Presence_Vater_iPhone_BT
   NOTIFYDEV  global
   NR         2621
   NTFY_ORDER 50-Presence_Vater_iPhone_BT
   STATE      maybe absent /
   TYPE       PRESENCE
   READINGS:
     2019-12-04 20:48:49   absentSince     2019-12-04 20:48:49
     2019-12-04 20:28:16   command_accepted yes
     2019-12-04 20:57:03   device_name     iPhoneXL
     2019-12-04 20:48:49   lastAbsent      04.12.2019 20:48:49
     2019-12-04 20:57:03   lastPresent     04.12.2019 20:57:03
     2019-12-04 20:58:11   lastabsent      2019-12-04 20:52:01
     2019-12-04 20:58:11   lastpresent     2019-12-04 20:58:11
     2019-12-04 20:28:08   model           lan-bluetooth
     2019-12-04 20:58:11   presence        maybe absent
     2019-12-04 20:53:14   presentSince    2019-12-04 20:53:14
     2019-12-04 20:58:11   room           
     2019-12-04 20:58:11   rooms           
     2019-12-04 20:58:11   rssi           
     2019-12-04 20:58:11   state           maybe absent
     2019-12-04 20:53:14   status          present
   helper:
     ABSENT_COUNT 1
     CURRENT_STATE present
     CURRENT_TIMEOUT normal
Attributes:
   absenceThreshold 3
   alias      iPhoneXL_BT
   event-on-change-reading status,state
   group      PRESENCE,SERVER
   room       Favourites,Presence
   sortby     0390
   stateFormat state / rooms
   timestamp-on-change-reading status
   userReadings status:(present|absent) { ReadingsVal($name,"state","nA") eq "present" ? "present" : "absent" },
absentSince:status:.absent   {if (ReadingsVal($name,"status","nA") eq "absent")  {ReadingsTimestamp($name,"status","nA")} else {ReadingsVal($name,"absentSince","nA")}},
presentSince:status:.present {if (ReadingsVal($name,"status","nA") eq "present") {ReadingsTimestamp($name,"status","nA")} else {ReadingsVal($name,"presentSince","nA")}},
lastpresent {if (ReadingsVal($name,"status","nA") eq "present") {ReadingsTimestamp($name, "state", "nA")} else {ReadingsVal($name,"lastpresent","nA")}},
lastabsent {if (ReadingsVal($name,"status","nA") eq "absent") {ReadingsTimestamp($name, "state", "nA")} else {ReadingsVal($name,"lastabsent","nA")}},
lastPresent:present {ReadingsTimestamp($name,"state","") =~ /^(\d+)-(\d+)-(\d+)\s(\d+:\d+:\d+)$/;; "$3.$2.$1 $4"},
lastAbsent:absent {ReadingsTimestamp($name,"state","") =~ /^(\d+)-(\d+)-(\d+)\s(\d+:\d+:\d+)$/;; "$3.$2.$1 $4"}
   verbose    0
   webCmd     statusRequest

2019.12.04 20:59:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_GTag_Black_collect
2019.12.04 20:59:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.04 20:59:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.04 20:59:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.04 20:59:04 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: handle: 0x001b value: 4b

2019.12.04 20:59:04 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - processing gatttool response: 4b
2019.12.04 20:59:04 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_GTag_Black_collect. batteryLevel: 75
2019.12.04 20:59:04 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_GTag_RED_collect
2019.12.04 20:59:04 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.04 20:59:04 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.04 20:59:04 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Software caused connection abort (103)

2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with random
2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect: No route to host (113)

2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag not supported
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_GTag_RED_collect. batteryLevel:
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_GTag_White_collect
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect: No route to host (113)

2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with random
2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect: No route to host (113)

2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag not supported
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_GTag_White_collect. batteryLevel:
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Gast_Orange_collect
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect: No route to host (113)

2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with random
2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect: No route to host (113)

2019.12.04 20:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag not supported
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_Gast_Orange_collect. batteryLevel:
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Gast_iBTon_collect
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device not present.
Internals:
   ADDRESS    ME:IN:EM:AC:AD:DR
   DEF        lan-bluetooth ME:IN:EM:AC:AD:DR 127.0.0.1:5222 60 60
   DeviceName 127.0.0.1:5222
   FUUID      tada
   INTERVAL_NORMAL 60
   INTERVAL_PRESENT 60
   MODE       lan-bluetooth
   NAME       Presence_Gast_iBTon_collect
   NOTIFYDEV  global
   NR         2717
   NTFY_ORDER 50-Presence_Gast_iBTon_collect
   STATE      disabled /
   TYPE       PRESENCE
   READINGS:
     2019-06-07 00:20:16   absentSince     2019-06-07 00:20:16
     2019-11-02 18:00:54   command_accepted yes
     2019-08-04 08:55:37   device_name     iPhone
     2019-12-04 20:28:14   lastabsent      2019-12-04 20:28:14
     2019-12-04 20:28:14   lastpresent     2019-08-04 08:56:09
     2019-12-04 20:28:08   model           lan-bluetooth
     2019-08-04 08:57:23   presence        absent
     2019-06-07 00:14:22   presentSince    2019-06-07 00:14:22
     2019-11-02 18:00:02   room           
     2019-11-02 18:00:02   rooms           
     2019-11-02 18:00:02   rssi           
     2019-12-04 20:28:14   state           disabled
     2019-11-02 16:09:31   status          absent
   helper:
     ABSENT_COUNT 1
     DISABLED   1
     PRESENT_COUNT 0
Attributes:
   absenceThreshold 2
   disable    1
   event-on-change-reading presence,state
   group      PRESENCE
   room       Presence
   sortby     049
   stateFormat state / rooms
   timestamp-on-change-reading presence
   userReadings status:(present|absent) { ReadingsVal($name,"state","nA") eq 'present' ? "present" : "absent" },
absentSince:status:.absent   {if (ReadingsVal($name,"status","nA") eq "absent")  {ReadingsTimestamp($name,"status","nA")} else {ReadingsVal($name,"absentSince","nA")}},
presentSince:status:.present {if (ReadingsVal($name,"status","nA") eq "present") {ReadingsTimestamp($name,"status","nA")} else {ReadingsVal($name,"presentSince","nA")}},
lastpresent {if (ReadingsVal($name,"status","nA") eq "present") {ReadingsTimestamp($name, "state", "nA")} else {ReadingsVal($name,"lastpresent","nA")}},
lastabsent {if (ReadingsVal($name,"status","nA") eq "absent") {ReadingsTimestamp($name, "state", "nA")} else {ReadingsVal($name,"lastabsent","nA")}}
   verbose    0
   webCmd     statusRequest

2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Mutter_Green_collect
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device not present.
Internals:
   ADDRESS    ME:IN:EM:AC:AD:DR
   DEF        lan-bluetooth ME:IN:EM:AC:AD:DR 127.0.0.1:5222 60 60
   DeviceName 127.0.0.1:5222
   FUUID      tada
   INTERVAL_NORMAL 60
   INTERVAL_PRESENT 60
   MODE       lan-bluetooth
   NAME       Presence_Mutter_Green_collect
   NOTIFYDEV  global
   NR         2687
   NTFY_ORDER 50-Presence_Mutter_Green_collect
   STATE      absent  /
   TYPE       PRESENCE
   READINGS:
     2019-05-24 23:31:11   BatterieWechsel 20.05.2019 (1 Jahr, last 05.05.2018)
     2019-12-02 07:11:35   absentSince     2019-12-02 07:11:35
     2019-12-01 23:22:48   battery         ok
     2019-12-01 23:22:48   batteryLevel    75
     2019-12-04 20:28:16   command_accepted yes
     2019-12-02 07:09:52   daemon          lepresenced V0.9
     2019-12-02 07:09:52   device_name     Gigaset G-tag
     2019-12-04 20:58:38   lastabsent      2019-12-04 20:58:38
     2019-12-04 20:58:38   lastpresent     2019-12-02 07:09:52
     2019-12-04 20:28:08   model           lan-bluetooth
     2019-12-04 20:58:38   presence        absent
     2019-12-01 18:34:42   presentSince    2019-12-01 18:34:42
     2019-12-04 20:58:38   room           
     2019-12-04 20:58:38   rooms           
     2019-12-04 20:58:38   rssi           
     2019-12-02 07:09:52   rssi_flurLE     -89
     2019-12-02 07:09:45   rssi_schlafLE   -75
     2019-12-02 07:09:50   rssi_wohnLE     -82
     2019-12-02 07:09:33   rssi_zeroLE     -73
     2019-12-04 20:58:38   state           absent
     2019-12-02 07:11:35   status          absent
   helper:
     ABSENT_COUNT 1
     CURRENT_TIMEOUT normal
Attributes:
   absenceThreshold 2
   event-on-change-reading battery,batteryLevel,status,state
   group      PRESENCE
   room       Presence
   sortby     063
   stateFormat state room / rooms
   timestamp-on-change-reading status
   userReadings status:(present|absent) { ReadingsVal($name,"state","nA") eq 'present' ? "present" : "absent" },
absentSince:status:.absent   {if (ReadingsVal($name,"status","nA") eq "absent")  {ReadingsTimestamp($name,"status","nA")} else {ReadingsVal($name,"absentSince","nA")}},
presentSince:status:.present {if (ReadingsVal($name,"status","nA") eq "present") {ReadingsTimestamp($name,"status","nA")} else {ReadingsVal($name,"presentSince","nA")}},
lastpresent {if (ReadingsVal($name,"state","nA") eq "present") {ReadingsTimestamp($name, "state", "nA")} else {ReadingsVal($name,"lastpresent","nA")}},
lastabsent  {if (ReadingsVal($name,"state","nA") eq "absent")  {ReadingsTimestamp($name, "state", "nA")} else {ReadingsVal($name,"lastabsent","nA")}}
   verbose    0
   webCmd     statusRequest

2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Mutter_iBTon_collect
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device not present.
Internals:
   ADDRESS    ME:IN:EM:AC:AD:DR
   DEF        lan-bluetooth ME:IN:EM:AC:AD:DR 127.0.0.1:5222 60 60
   DeviceName 127.0.0.1:5222
   FUUID      toda
   INTERVAL_NORMAL 60
   INTERVAL_PRESENT 60
   MODE       lan-bluetooth
   NAME       Presence_Mutter_iBTon_collect
   NOTIFYDEV  global
   NR         2684
   NTFY_ORDER 50-Presence_Mutter_iBTon_collect
   STATE      absent /
   TYPE       PRESENCE
   READINGS:
     2019-12-02 07:11:19   absentSince     2019-12-02 07:11:19
     2019-12-04 20:28:16   command_accepted yes
     2019-12-02 07:08:20   device_name     iPhone7
     2019-12-04 20:58:59   lastabsent      2019-12-04 20:58:59
     2019-12-04 20:58:59   lastpresent     2019-12-02 07:10:07
     2019-12-04 20:28:08   model           lan-bluetooth
     2019-12-04 20:58:59   presence        absent
     2019-12-02 06:28:11   presentSince    2019-12-02 06:28:11
     2019-12-04 20:58:59   room           
     2019-12-04 20:58:59   rooms           
     2019-12-04 20:58:59   rssi           
     2019-12-04 20:58:59   state           absent
     2019-12-02 07:11:19   status          absent
   helper:
     ABSENT_COUNT 2
     CURRENT_TIMEOUT normal
Attributes:
   absenceThreshold 3
   event-on-change-reading status,state
   genericDeviceType OccupancySensor
   group      PRESENCE
   room       Presence
   sortby     060
   stateFormat state / rooms
   timestamp-on-change-reading status
   userReadings status:(present|absent) { ReadingsVal($name,"state","nA") eq "present" ? "present" : "absent" },
absentSince:status:.absent   {if (ReadingsVal($name,"status","nA") eq "absent")  {ReadingsTimestamp($name,"status","nA")} else {ReadingsVal($name,"absentSince","nA")}},
presentSince:status:.present {if (ReadingsVal($name,"status","nA") eq "present") {ReadingsTimestamp($name,"status","nA")} else {ReadingsVal($name,"presentSince","nA")}},
lastpresent {if (ReadingsVal($name,"status","nA") eq "present") {ReadingsTimestamp($name, "state", "nA")} else {ReadingsVal($name,"lastpresent","nA")}},
lastabsent {if (ReadingsVal($name,"status","nA") eq "absent") {ReadingsTimestamp($name, "state", "nA")} else {ReadingsVal($name,"lastabsent","nA")}}
   verbose    0
   webCmd     statusRequest

2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - set readings batteryLevel and battery of device: Presence_Vater_Orange_collect
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - setting saved into hash: public
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - set readings batteryLevel and battery of device: Presence_GTag_Black_collect
2019.12.04 20:59:05 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - done
« Letzte Änderung: 04 Dezember 2019, 21:20:13 von Jamo »
Intel NUC7i3BNK, VCCU+Homematic, Homematic-IP über Debmatic, HUEBridge, Sonos, etc

Offline mumpitzstuff

  • Developer
  • Hero Member
  • ****
  • Beiträge: 1584
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #136 am: 05 Dezember 2019, 02:44:14 »
Ich habe jetzt mal etwas gebastelt. In dieser Version sollte der presence status vom reading und nicht mehr vom internal abhängen. Außerdem habe ich wieder 2 Versuche aktiviert und zusätzlich einen workaround für dieses "no route to host". Ob das jetzt was bringt kann ich nicht sagen.
Dummerweise muss man für den workaround hcitool oder hciconfig aufrufen, beides erfordert jedoch admin Rechte. Deshalb ist folgendes notwendig:

sudo apt-get install libcap2-bin
sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hciconfig`

Danach kann man hciconfig ohne sudo aufrufen bzw. fhem kann es für den workaround aufrufen.

Wenn du das wieder zurück bauen möchtest, dann mach einfach:

sudo setcap -r `which hciconfig`

Offline Jamo

  • Sr. Member
  • ****
  • Beiträge: 710
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #137 am: 05 Dezember 2019, 09:04:17 »
Jetzt siehts so aus :-(

2019.12.05 08:54:53 4: Sub BleTagBattery_Run (myBleTagBattery) - start blocking call
2019.12.05 08:54:53 5: Sub BleTagBattery_stateRequest (myBleTagBattery) - state request called
2019.12.05 08:54:53 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Vater_Orange_collect
2019.12.05 08:54:53 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.05 08:54:53 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 08:54:53 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
connect error: Transport endpoint is not connected (107)
2019.12.05 08:55:01 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: handle: 0x001b value: 42

2019.12.05 08:55:01 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - processing gatttool response: 42
2019.12.05 08:55:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_Vater_Orange_collect. batteryLevel: 66
2019.12.05 08:55:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Vater_iPhone_BT
2019.12.05 08:55:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: iPhoneXL
2019.12.05 08:55:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 08:55:01 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.05 08:55:02 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Software caused connection abort (103)

2019.12.05 08:55:02 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result: Can't set advertise mode on hci0: Network is down (100)

connect error: Transport endpoint is not connected (107)
connect error: Transport endpoint is not connected (107)
connect error: Function not implemented (38)
2019.12.05 08:55:47 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 1, result: connect error: Connection refused (111)

2019.12.05 08:55:47 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:55:50 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 08:55:50 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with random
2019.12.05 08:56:32 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Connection refused (111)

2019.12.05 08:56:32 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:57:17 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 1, result: connect error: Connection refused (111)

2019.12.05 08:57:17 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:57:20 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 08:57:20 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag not supported
2019.12.05 08:57:20 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_Vater_iPhone_BT. batteryLevel:
2019.12.05 08:57:20 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_GTag_Black_collect
2019.12.05 08:57:20 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.05 08:57:20 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 08:57:20 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.05 08:57:25 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Transport endpoint is not connected (107)

2019.12.05 08:57:25 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:57:34 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 1, result: connect error: Transport endpoint is not connected (107)

2019.12.05 08:57:34 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:57:37 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 08:57:37 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with random
2019.12.05 08:58:17 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Connection refused (111)

2019.12.05 08:58:17 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:59:02 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 1, result: connect error: Connection refused (111)

2019.12.05 08:59:02 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:59:05 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 08:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag not supported
2019.12.05 08:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_GTag_Black_collect. batteryLevel:
2019.12.05 08:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_GTag_RED_collect
2019.12.05 08:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.05 08:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 08:59:05 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.05 08:59:13 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Function not implemented (38)

2019.12.05 08:59:13 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:59:21 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 1, result: connect error: Function not implemented (38)

2019.12.05 08:59:21 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call hcitool lescan, result:
2019.12.05 08:59:24 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 08:59:24 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with random
2019.12.05 08:59:53 1: Timeout for BleTagBattery_BlockingRun reached, terminated process 5474
2019.12.05 08:59:53 3: (myBleTagBattery) Sub BleTagBattery_BlockingAborted - BlockingCall process terminated unexpectedly: timeout
Intel NUC7i3BNK, VCCU+Homematic, Homematic-IP über Debmatic, HUEBridge, Sonos, etc

Offline mumpitzstuff

  • Developer
  • Hero Member
  • ****
  • Beiträge: 1584
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #138 am: 05 Dezember 2019, 10:39:33 »
Irgendwie wird der verwendete Bluetooth Adapter von einem anderen Programm verwendet z.b. lepresenced oder das Ding stürzt aus anderen Gründen ab. Bist du sicher, das dieser Adapter Exklusiv genutzt werden kann und niemand sonst darauf zugreift?
Steht irgendwas im syslog bzw. sieht man was wenn man:

dmesg 

in der Shell aufruft?

Offline Jamo

  • Sr. Member
  • ****
  • Beiträge: 710
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #139 am: 05 Dezember 2019, 11:06:59 »
Mmmh - ich habe noch die 74_XiaomiBTLESens für die Blumen per Bluetooth eingebunden, die benutzen auch hci0 soweit ich weiss.
Die machen alle 4 Stunden einen check der Blumen Sensoren. Das sollte doch nicht mit dem BleTagBattery Aufruf in die Quere kommen, oder?
Dann noch presenced / lepresenced mit collectord für Handy/GTAG presence Erkennung. Insgesamt habe ich 3 Raspberry mit BT/BTLE mit lepresence/presence (Räume flurLE,wohnLE,zeroLE), und der Intel NUC (Raum schlafLE), der das ganze über collectord in fhem einsammelt. 

Aber das versteh ich dann nicht, heisst das, dass z.B. 74_BleTagBattery einen Adapter exclusiv belegt, und das Modul 74_XiaomiBTLESens ebenfalls?
Ich dachte immer, das 'lescan' (oder gattool) nur einen String zurückliefert, der dann vom jeweiligen Modul gelesen wird.
Und dann verstehe ich auch nicht, wieso es bei den ersten beiden Presence_Vater_Orange_collect und Presence_GTag_Black_collect funktioniert (wie in Antwort #135), aber danach nicht mehr. 

Wie kann /muss ich das ändern? Danke!

Eispeer hat ja in Antwort #124  so ein ähnliches Problem gelöst glaube ich...
« Letzte Änderung: 05 Dezember 2019, 11:16:45 von Jamo »
Intel NUC7i3BNK, VCCU+Homematic, Homematic-IP über Debmatic, HUEBridge, Sonos, etc

Offline mumpitzstuff

  • Developer
  • Hero Member
  • ****
  • Beiträge: 1584
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #140 am: 05 Dezember 2019, 12:41:09 »
lepresenced und vielleicht auch presenced usw. scannen nach USB Geräten und belegen bei diesem Vorgang den Adapter exklusiv! Wenn jetzt mein Modul kommt, dann stiehlt es sich für kurze Zeit den exklusiven Zugriff. Lepresenced merkt das aber nach einigen Sekunden und holt sich den Zugriff dann zurück.

Wenn du mal alle presenced/lepresenced Dinge auf dem Gerät temporär deaktivierst, dann sollten vermutlich auch deine Gtags alle vom Modul gefunden werden. 

Offline Jamo

  • Sr. Member
  • ****
  • Beiträge: 710
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #141 am: 05 Dezember 2019, 21:59:58 »
DANKE! :-)
Nach einem ''sudo service lepresenced stop'' läuft auch deine originale erste Version 0.0.4 sauber durch. Siehe unten.

Ich habe dann nur noch if ( $deviceList =~ m/\s+\d+-\d+-\d+\s+\d+:\d+:\d+\s+state\s+present/ ) { mit eingebaut, damit die GTags auch mit 'attr stateformat ....' als present gefunden werden.

Die 1) Lösung für mich das ich den lepresenced über ein "at device" stoppe, dann den BleTagBattery statusrequest starte, und danach den lepresenced wieder starte.
Die 2) Lösung ist einen 2-ten Bluetooth dongle anstecken, und BleTagBattery auf hci1 konfigurieren.


2019.12.05 20:42:42 4: Sub BleTagBattery_Run (myBleTagBattery) - start blocking call
2019.12.05 20:42:42 5: Sub BleTagBattery_stateRequest (myBleTagBattery) - state request called
2019.12.05 20:42:42 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Vater_Orange_collect
2019.12.05 20:42:42 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.05 20:42:42 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 20:42:42 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.05 20:42:46 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: handle: 0x001b value: 4b

2019.12.05 20:42:46 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - processing gatttool response: 4b
2019.12.05 20:42:46 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_Vater_Orange_collect. batteryLevel: 75
2019.12.05 20:42:46 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Vater_iPhone_BT
2019.12.05 20:42:46 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: iPhoneXL
2019.12.05 20:42:46 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 20:42:46 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.05 20:43:26 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Connection refused (111)

2019.12.05 20:43:26 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 20:43:26 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with random
2019.12.05 20:44:07 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Connection refused (111)

2019.12.05 20:44:07 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 20:44:07 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag not supported
2019.12.05 20:44:07 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_Vater_iPhone_BT. batteryLevel:
2019.12.05 20:44:07 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_GTag_Black_collect
2019.12.05 20:44:07 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.05 20:44:07 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 20:44:07 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.05 20:44:10 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: handle: 0x001b value: 4b

2019.12.05 20:44:10 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - processing gatttool response: 4b
2019.12.05 20:44:10 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_GTag_Black_collect. batteryLevel: 75
2019.12.05 20:44:10 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_GTag_RED_collect
2019.12.05 20:44:10 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.05 20:44:10 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: 7ME:IN:EM:AC:AD:DR
2019.12.05 20:44:10 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag already saved in hash
2019.12.05 20:44:15 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: handle: 0x001b value: 4b

2019.12.05 20:44:15 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - processing gatttool response: 4b
2019.12.05 20:44:15 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_GTag_RED_collect. batteryLevel: 75
2019.12.05 20:44:15 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_GTag_White_collect
2019.12.05 20:44:15 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.05 20:44:15 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 20:44:15 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.05 20:44:19 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: handle: 0x001b value: 25

2019.12.05 20:44:19 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - processing gatttool response: 25
2019.12.05 20:44:19 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_GTag_White_collect. batteryLevel: 37
2019.12.05 20:44:19 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Gast_Orange_collect
2019.12.05 20:44:19 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device name: Gigaset G-tag
2019.12.05 20:44:19 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device address: ME:IN:EM:AC:AD:DR
2019.12.05 20:44:19 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with public
2019.12.05 20:44:22 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Function not implemented (38)

2019.12.05 20:44:22 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 20:44:22 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - try to connect with random
2019.12.05 20:45:03 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - call gatttool char read loop: 0, result: connect error: Connection refused (111)

2019.12.05 20:45:03 4: Sub BleTagBattery_readSensorValue (myBleTagBattery) - invalid gatttool response
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - tag not supported
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - processing gatttool response for device Presence_Gast_Orange_collect. batteryLevel:
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Gast_iBTon_collect
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device not present.
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Mutter_Green_collect
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device not present.
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device found. device: Presence_Mutter_iBTon_collect
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingRun (myBleTagBattery) - device not present.
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - setting saved into hash: public
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - set readings batteryLevel and battery of device: Presence_Vater_Orange_collect
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - setting saved into hash: public
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - set readings batteryLevel and battery of device: Presence_GTag_Black_collect
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - set readings batteryLevel and battery of device: Presence_GTag_RED_collect
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - setting saved into hash: public
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - set readings batteryLevel and battery of device: Presence_GTag_White_collect
2019.12.05 20:45:03 4: Sub BleTagBattery_BlockingDone (myBleTagBattery) - done
« Letzte Änderung: 05 Dezember 2019, 23:05:19 von Jamo »
Intel NUC7i3BNK, VCCU+Homematic, Homematic-IP über Debmatic, HUEBridge, Sonos, etc

Offline mumpitzstuff

  • Developer
  • Hero Member
  • ****
  • Beiträge: 1584
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #142 am: 06 Dezember 2019, 10:02:25 »
Die Erkennung werde ich ändern und einchecken, dann ist das dauerhaft im Modul enthalten.

Offline Jamo

  • Sr. Member
  • ****
  • Beiträge: 710
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #143 am: 06 Dezember 2019, 10:46:59 »
Danke nochmal für die Hilfe und Geduld. Im übrigen bin ich auch leidenschaftlicher User deines 57_GCALVIEW moduls.
Intel NUC7i3BNK, VCCU+Homematic, Homematic-IP über Debmatic, HUEBridge, Sonos, etc

Offline eispeer

  • New Member
  • *
  • Beiträge: 6
Antw:Neues Modul: 74_BleTagBattery - Batterie Informationen für BLE Tags
« Antwort #144 am: 10 Dezember 2019, 08:19:53 »
@eispeer: Ich habe mal eine neue Version eingecheckt. Könntest du dir bitte ansehen, ob die bei dir funktioniert? Einfach "update all" und danach "shutdown restart" machen.

Hallo @mumpitzstuff,
ich habe gerade die letzte Version (0.0.5) getestet. Bei mir sieht es gut aus.

Vielen Dank,
Peer
Raspberry PI, CUL 433Mhz, CUL 868Mhz v3.4, HM-CC-RT-DN, HM-CFG-USB, ELRO IT

 

decade-submarginal