Acidham / alfred-airpod-connector

Alfred Workflow to connect/disconnect AirPods (Airpod1/2, Airpod Pro) and Powerbeats Pro
35 stars 7 forks source link

Airpods3 can't connect #15

Closed alewkinr closed 11 months ago

alewkinr commented 1 year ago

Hello there!

found this problem, trying to connect my Airpods 3 with your workflow.

I guess the problem is in blueutil version. Mine is — 2.9.1

[21:40:40.113] AirPods Connector[Script Filter] Queuing argument '(null)'
[21:40:40.217] AirPods Connector[Script Filter] Script with argv '(null)' finished
[21:40:40.223] ERROR: AirPods Connector[Script Filter] Code 1: Traceback (most recent call last):
  File "airp.py", line 32, in get_paired_airpods
    devices: dict = bt_data['devices_list']
KeyError: 'devices_list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "airp.py", line 97, in <module>
    main()
  File "airp.py", line 70, in main
    for ap_name, status in get_paired_airpods().items():
  File "airp.py", line 37, in get_paired_airpods
    not_connected_devices: list = bt_data['device_not_connected']
KeyError: 'device_not_connected'

There is no key device_not_connected in the dictionary that you parse.

Acidham commented 1 year ago

blueutil version is ok. What is the macOS version you are using? Can you find your airpods when you run system_profiler SPBluetoothDataType -json on terminal?

alewkinr commented 1 year ago

MacOS Monterey 12.4 (21F79)

Yep, I can see them. When AirPods are connected:

{
  "SPBluetoothDataType" : [
    {
      "controller_properties" : {
        "controller_address" : "B0:F1:D8:54:6F:39",
        "controller_chipset" : "BCM_4387",
        "controller_discoverable" : "attrib_off",
        "controller_firmwareVersion" : "19.6.451.5120",
        "controller_productID" : "0x0001",
        "controller_state" : "attrib_on",
        "controller_supportedServices" : "0x382039 < HFP AVRCP A2DP HID Braille AACP GATT Serial >",
        "controller_transport" : "PCIe",
        "controller_vendorID" : "0x004C (Apple)"
      },
      "device_connected" : [
        {
          "AirPods 3 (Рамиль)" : {
            "device_address" : "9C:28:B3:AF:44:D5",
            "device_batteryLevelCase" : "1 %",
            "device_batteryLevelLeft" : "100 %",
            "device_batteryLevelRight" : "56 %",
            "device_firmwareVersion" : "5E133",
            "device_minorType" : "Headphones",
            "device_productID" : "0x2013",
            "device_serialNumber" : "YQR4K9JKDP",
            "device_services" : "0x980019 < HFP AVRCP A2DP AACP GATT ACL >",
            "device_vendorID" : "0x004C"
          }
        }
      ],
      "device_not_connected" : [
        {
          "iPhone (Рамиль)" : {
            "device_address" : "90:A2:5B:E6:8F:DE"
          }
        }
      ]
    }
  ]
}

When they are not connected:

{
  "SPBluetoothDataType" : [
    {
      "controller_properties" : {
        "controller_address" : "B0:F1:D8:54:6F:39",
        "controller_chipset" : "BCM_4387",
        "controller_discoverable" : "attrib_off",
        "controller_firmwareVersion" : "19.6.451.5120",
        "controller_productID" : "0x0001",
        "controller_state" : "attrib_on",
        "controller_supportedServices" : "0x382039 < HFP AVRCP A2DP HID Braille AACP GATT Serial >",
        "controller_transport" : "PCIe",
        "controller_vendorID" : "0x004C (Apple)"
      },
      "device_connected" : [
        {
          "iPhone (Рамиль)" : {
            "device_address" : "90:A2:5B:E6:8F:DE",
            "device_services" : "0x400000 < BLE >"
          }
        }
      ],
      "device_not_connected" : [
        {
          "AirPods 3 (Рамиль)" : {
            "device_address" : "9C:28:B3:AF:44:D5",
            "device_firmwareVersion" : "5E133",
            "device_minorType" : "Headphones",
            "device_productID" : "0x2013",
            "device_serialNumber" : "YQR4K9JKDP",
            "device_vendorID" : "0x004C"
          }
        }
      ]
    }
  ]
}%
Acidham commented 1 year ago

As mentioned bluetutil looks good, I am running the same version.

The KeyError looks strange because the key device_not_connected seems to be there. I can only doubt at this point, but maybe there is an issue with character encoding. Can you change the name AirPods 3 (Рамиль) remove Рамиль and try again?

alewkinr commented 1 year ago

@Acidham renamed the title of my AirPods, from AirPods 3 (Рамиль) to AirPods 3 (Ramil). That's funny, but workflow started to work 😂

Now the key device_not_connected is in the output

{
  "SPBluetoothDataType" : [
    {
      "controller_properties" : {
        "controller_address" : "B0:F1:D8:54:6F:39",
        "controller_chipset" : "BCM_4387",
        "controller_discoverable" : "attrib_off",
        "controller_firmwareVersion" : "19.6.451.5120",
        "controller_productID" : "0x0001",
        "controller_state" : "attrib_on",
        "controller_supportedServices" : "0x382039 < HFP AVRCP A2DP HID Braille AACP GATT Serial >",
        "controller_transport" : "PCIe",
        "controller_vendorID" : "0x004C (Apple)"
      },
      "device_not_connected" : [
        {
          "AirPods 3 (Ramil)" : {
            "device_address" : "9C:28:B3:AF:44:D5",
            "device_firmwareVersion" : "5E133",
            "device_minorType" : "Headphones",
            "device_productID" : "0x2013",
            "device_serialNumber" : "YQR4K9JKDP",
            "device_vendorID" : "0x004C"
          }
        }
      ]
    }
  ]
}%