zeitlings / alfred-workflows

Collected Alfred Workflows & Proof of Concept
MIT License
124 stars 5 forks source link

"Bluetooth Device Battery v1.0.0" doesn't display headphones #4

Closed saeedesmaili closed 1 year ago

saeedesmaili commented 1 year ago

Hi I'm trying your new workflow "Bluetooth Device Battery v1.0.0". I have three bluetooth devices connected:

zeitlings commented 1 year ago

Hey @saeedesmaili Since I only posted it on the Alfred forums, you may have missed it:

I only confirmed that it works with connected Apple devices. Other devices I briefly connected for testing were not found by ioreg or the system profiler, or the battery information was simply not there. If you have a device that you think should show up but doesn't, you can print a log to Alfred's debug window by typing -btb. If you see battery status information that the workflow ignores, feel free to send me those logs. That way I can try to fine-tune the parser.

The same goes for specific information about older AirPods and case versions. If you let me know what uniquely identifies them, they can get proper representation.

Can you check if there is any info about the battery level for your devices when you run the debug command by typing -btb in Alfred while the workflow's debug panel open? If there is and you share the logs I can adjust the parser to include those devices.

saeedesmaili commented 1 year ago

Is this helpful? It's strange that the Bose 700 headphone doesn't seem to have the battery level here, but I see the device's battery level in Mac's Bluetooth menu.

Bluetooth Controller:
          Address: F4:D4:88:61:D4:91
          State: On
          Chipset: BCM_4387
          Discoverable: Off
          Firmware Version: 20.5.541.8810
          Product ID: 0x4A05
          Supported services: 0x382039 < HFP AVRCP A2DP HID Braille AACP GATT SerialPort >
          Transport: PCIe
          Vendor ID: 0x004C (Apple)
      Connected:
          Bose NC 700 HP:
              Address: 60:AB:D2:02:C3:4C
              Vendor ID: 0x009E
              Product ID: 0x4024
              Firmware Version: 1.8.2
              Minor Type: Headphones
              Services: 0x800019 < HFP AVRCP A2DP ACL >
          Saeed's Pixel Buds A-Series:
              Address: 74:74:46:EC:D2:67
              Battery Level: 100%
              Minor Type: Headset
              Services: 0x800019 < HFP AVRCP A2DP ACL >
          Saeed’s Magic Trackpad:
              Address: D4:57:63:5D:93:EF
              Vendor ID: 0x004C
              Product ID: 0x0265
              Firmware Version: 1.9.2
              Minor Type: AppleTrackpad
              Services: 0x800020 < HID ACL >
    {
      "IOMatchedAtBoot" = Yes
      "LowBatteryNotificationPercentage" = 2
      "PrimaryUsagePage" = 65280
      "BatteryFaultNotificationType" = "TPBatteryFault"
      "HasBattery" = Yes
      "VendorID" = 76
      "VersionNumber" = 0
      "Built-In" = No
      "DeviceAddress" = "d4-57-63-5d-93-ef"
      "WakeReason" = "Host (0x01)"
      "Product" = "Magic Trackpad"
      "SerialNumber" = "d4-57-63-5d-93-ef"
      "Transport" = "Bluetooth"
      "BatteryLowNotificationType" = "TPLowBattery"
      "ProductID" = 613
      "DeviceUsagePairs" = ({"DeviceUsagePage"=65280,"DeviceUsage"=11},{"DeviceUsagePage"=65280,"DeviceUsage"=20})
      "IOPersonalityPublisher" = "com.apple.driver.AppleTopCaseHIDEventDriver"
      "MTFW Version" = 920
      "BD_ADDR" = <d457635d93ef>
      "BatteryPercent" = 12
      "BatteryStatusNotificationType" = "BatteryStatusChanged"
      "CriticallyLowBatteryNotificationPercentage" = 1
      "ReportInterval" = 11250
      "RadioFW Version" = 402
      "VendorIDSource" = 1
      "STFW Version" = 2144
      "CFBundleIdentifier" = "com.apple.driver.AppleTopCaseHIDEventDriver"
      "IOProviderClass" = "IOHIDInterface"
      "LocationID" = 1667077103
      "BluetoothDevice" = Yes
      "IOClass" = "AppleDeviceManagementHIDEventService"
      "HIDServiceSupport" = No
      "CFBundleIdentifierKernel" = "com.apple.driver.AppleTopCaseHIDEventDriver"
      "ProductIDArray" = (613)
      "BatteryStatusFlags" = 0
      "ColorID" = 33
      "IOMatchCategory" = "IODefaultMatchCategory"
      "CountryCode" = 0
      "IOProbeScore" = 7175
      "PrimaryUsage" = 11
      "IOGeneralInterest" = "IOCommand is not serializable"
      "BTFW Version" = 402
    }
zeitlings commented 1 year ago

I have observed the same thing with other devices. It seems that Apple may have access to proprietary information that third-party manufacturers don't share with the general public. But at least there is hope for the Pixel Buds!

LampPrinter commented 1 year ago

EarFun Air Pro 3 I can see battery percentage inside Control Center --> Bluetooth.

[06:56:56.982] Logging Started...
[06:56:58.448] Device Battery[Script Filter] Queuing argument '(null)'
[06:56:58.746] Device Battery[Script Filter] Script with argv '(null)' finished
[06:56:58.752] Device Battery[Script Filter] {"items":[{"title":"No Bluetooth devices connected"}],"rerun":4}
[06:57:02.857] Device Battery[Keyword] Processing complete
[06:57:02.858] Device Battery[Keyword] Passing output '' to Run Script
[06:57:03.050] Device Battery[Run Script] Processing complete
[06:57:03.051] Device Battery[Run Script] Passing output 'Bluetooth:

      Bluetooth Controller:
          Address: 18:3E:EF:C1:90:34
          State: On
          Chipset: BCM_4378
          Discoverable: Off
          Firmware Version: 20.5.508.3352
          Product ID: 0x4A02
          Supported services: 0x382039 < HFP AVRCP A2DP HID Braille AACP GATT SerialPort >
          Transport: PCIe
          Vendor ID: 0x004C (Apple)
      Connected:
          EarFun Air Pro 3:
              Address: 70:5A:6F:60:51:D7
              Battery Level: 100%
              Minor Type: Headset
              RSSI: -28
              Services: 0x800019 < HFP AVRCP A2DP ACL >
[06:57:03.058] Device Battery[Split Arg] Processing complete
[06:57:03.059] Device Battery[Split Arg] Passing output 'Bluetooth:

      Bluetooth Controller:
          Address: 18:3E:EF:C1:90:34
          State: On
          Chipset: BCM_4378
          Discoverable: Off
          Firmware Version: 20.5.508.3352
          Product ID: 0x4A02
          Supported services: 0x382039 < HFP AVRCP A2DP HID Braille AACP GATT SerialPort >
          Transport: PCIe
          Vendor ID: 0x004C (Apple)
      Connected:
          EarFun Air Pro 3:
              Address: 70:5A:6F:60:51:D7
              Battery Level: 100%
              Minor Type: Headset
              RSSI: -28
              Services: 0x800019 < HFP AVRCP A2DP ACL >
[06:57:03.061] Device Battery[Debug] 
==========================================
               Debug Info
------------------------------------------
Alfred:         v5.0.6 (2110)
Device Battery: v1.0.0
==========================================
System Profiler: 
==========================================
Bluetooth:

      Bluetooth Controller:
          Address: 18:3E:EF:C1:90:34
          State: On
          Chipset: BCM_4378
          Discoverable: Off
          Firmware Version: 20.5.508.3352
          Product ID: 0x4A02
          Supported services: 0x382039 < HFP AVRCP A2DP HID Braille AACP GATT SerialPort >
          Transport: PCIe
          Vendor ID: 0x004C (Apple)
      Connected:
          EarFun Air Pro 3:
              Address: 70:5A:6F:60:51:D7
              Battery Level: 100%
              Minor Type: Headset
              RSSI: -28
              Services: 0x800019 < HFP AVRCP A2DP ACL >

==========================================
ioreg Device Info:
==========================================
zeitlings commented 1 year ago

hey @saeedesmaili @LampPrinter, I just updated the workflow and in my tests both of your devices were recognized. Can you let me know if it works for you?

LampPrinter commented 1 year ago

hey @saeedesmaili @LampPrinter, I just updated the workflow and in my tests both of your devices were recognized. Can you let me know if it works for you?

No .workflow file in release.

zeitlings commented 1 year ago

@LampPrinter 😅 now there is.

saeedesmaili commented 1 year ago

Works with my Pixel Buds! Thanks

LampPrinter commented 1 year ago

Working but battery icon not showing for me.

CleanShot - CleanShot (CleanShot) - 29 May 2023 at 00 47 08

CleanShot - DeviceBattery swift (Code) - 29 May 2023 at 00 45 15

zeitlings commented 1 year ago

See the discussion here about the icons. You will need SF Pro, and/ or possibly SF Symbols.

saeedesmaili commented 11 months ago

Hey @zeitlings Can you take a look into the following log to see if "Powerbeats" headsets can be added as well? They don't show up right now.

==========================================
               Debug Info
------------------------------------------
Alfred:         v5.1.1 (2138)
Device Battery: v1.1.0
==========================================
System Profiler: 
==========================================
Bluetooth:

      Bluetooth Controller:
          Address: F4:D4:88:61:D4:91
          State: On
          Chipset: BCM_4387
          Discoverable: Off
          Firmware Version: 20.5.529.8129
          Product ID: 0x4A05
          Supported services: 0x382039 < HFP AVRCP A2DP HID Braille AACP GATT SerialPort >
          Transport: PCIe
          Vendor ID: 0x004C (Apple)
      Connected:
          Powerbeats:
              Address: 84:AD:8D:10:A9:55
              Vendor ID: 0x004C
              Product ID: 0x200D
              Firmware Version: 4A394
              Minor Type: Headphones
              RSSI: -48
              Serial Number: GYQDMG6YMK72
              Services: 0x980019 < HFP AVRCP A2DP AACP GATT ACL >
          Saeed’s Magic Trackpad:
              Address: D4:57:63:5D:93:EF
              Vendor ID: 0x004C
              Product ID: 0x0265
              Firmware Version: 1.9.2
              Minor Type: AppleTrackpad
              Services: 0x800020 < HID ACL >
==========================================
ioreg Device Info:
==========================================
+-o AppleDeviceManagementHIDEventService  <class AppleDeviceManagementHIDEventService, id 0x10004dc72, registered, matched, active, busy 0 (1 ms), retain 8>
    {
      "IOMatchedAtBoot" = Yes
      "LowBatteryNotificationPercentage" = 2
      "PrimaryUsagePage" = 65280
      "BatteryFaultNotificationType" = "TPBatteryFault"
      "HasBattery" = Yes
      "VendorID" = 76
      "VersionNumber" = 0
      "Built-In" = No
      "DeviceAddress" = "d4-57-63-5d-93-ef"
      "WakeReason" = "Host (0x01)"
      "Product" = "Magic Trackpad"
      "SerialNumber" = "d4-57-63-5d-93-ef"
      "Transport" = "Bluetooth"
      "BatteryLowNotificationType" = "TPLowBattery"
      "ProductID" = 613
      "DeviceUsagePairs" = ({"DeviceUsagePage"=65280,"DeviceUsage"=11},{"DeviceUsagePage"=65280,"DeviceUsage"=20})
      "IOPersonalityPublisher" = "com.apple.driver.AppleTopCaseHIDEventDriver"
      "MTFW Version" = 920
      "BD_ADDR" = <d457635d93ef>
      "BatteryPercent" = 99
      "BatteryStatusNotificationType" = "BatteryStatusChanged"
      "CriticallyLowBatteryNotificationPercentage" = 1
      "ReportInterval" = 11250
      "RadioFW Version" = 402
      "VendorIDSource" = 1
      "STFW Version" = 2144
      "CFBundleIdentifier" = "com.apple.driver.AppleTopCaseHIDEventDriver"
      "IOProviderClass" = "IOHIDInterface"
      "LocationID" = 1667077103
      "BluetoothDevice" = Yes
      "IOClass" = "AppleDeviceManagementHIDEventService"
      "HIDServiceSupport" = No
      "CFBundleIdentifierKernel" = "com.apple.driver.AppleTopCaseHIDEventDriver"
      "ProductIDArray" = (613)
      "BatteryStatusFlags" = 0
      "ColorID" = 33
      "IOMatchCategory" = "IODefaultMatchCategory"
      "CountryCode" = 0
      "IOProbeScore" = 7175
      "PrimaryUsage" = 11
      "IOGeneralInterest" = "IOCommand is not serializable"
      "BTFW Version" = 402
    }