Closed james-rose closed 3 years ago
Hi james,
This preset shows NC when battery is 0 or connection status is false, both retrieved from the bluetooth plist file managed by macOS.
I am on vacations and do not have my mac with me, I'll have a look when I back to the office.
Thanks for your patience~
Hi @noonchen , thanks for your reply. I think I found the issue, even though I don't know why it happens. When I run the script from the terminal (and not from BTT) and look at the output of BT_dict, I get this:
BT_dict: 'James AirPods': ['1', 'b8-b2-f8-3d-90-66'],... '
However, when I run it from BTT, BT_dict returns:
'James AirPods': ['true', 'b8-b2-f8-3d-90-66'],..}
So basically it was failing because it was looking for 1 and got 'true'. I changed the line to:
connected = True if BT_dict[devNAME][0] == "true" else False
it in the BTT script and it now works for me. Any ideas what's wrong on my setup?
Hi @james-rose,
I did not reproduce this behavior on my machine (macOS 11.1 intel-base):
'James AirPods': ['true', 'b8-b2-f8-3d-90-66'],..}
The style of 'true'
is not from python (it should be True
), likely from bash or AppleScript, that's why I think the connection status is converted to true/false before python processes it in M1 machine.
I'd like you to
use framework "IOBluetooth"
set deviceList to current application's IOBluetoothDevice's pairedDevices() set devNames to (deviceList's valueForKey:"name") as list set devStatus to (deviceList's valueForKey:"connected") as list [devNames, devStatus]
2. run the following code in Terminal:
osascript -e "use framework \"IOBluetooth\"" -e "set deviceList to current application's IOBluetoothDevice's pairedDevices()" -e "set devNames to (deviceList's valueForKey:\"name\") as list" -e "set devStatus to (deviceList's valueForKey:\"connected\") as list" -e "[devNames, devStatus]"
It will print device names and their connection status, I just want to know if it's the root cause. BTW, the status is still number on my intel-based mac.
in AppleScript:
{{"James AirPods", "James’s MacBook Pro (2)", "Jabra Elite Active 75t", "Apple Watch", "James’s iPhone"}, {false, false, false, false, false}}
in terminal:
James AirPods, James’s MacBook Pro (2), Jabra Elite Active 75t, Apple Watch, James’s iPhone, false, false, false, false, false
in AppleScript:
{{"James AirPods", "James’s MacBook Pro (2)", "Jabra Elite Active 75t", "Apple Watch", "James’s iPhone"}, {false, false, false, false, false}}
in terminal:
James AirPods, James’s MacBook Pro (2), Jabra Elite Active 75t, Apple Watch, James’s iPhone, false, false, false, false, false
Hi @james-rose, It seems M1 machine have changed the data type of connection from integer to boolean. I'll double comfirm it in Apple's documentation and then release a new version.
Thanks.
@james-rose please try the new release to see if it works for you :)
Since there is no update, I'll close this issue, you can reopen it if something's wrong.
Hi @noonchen, sorry for the late reply. I applied the new release and it's working perfectly. Thanks!
I'm using AppleHeadphone_v1_1.bttpreset 63 (same issue with 1.0) and I think I configured everything according to instructions. However, I'm getting "NC" even when my AirPods are playing.
Output of python script: {"text": "đź…› NC\nđź…ˇ NC", "icon_path": "/System/Library/Frameworks/IOBluetoothUI.framework/Versions/A/Resources/AirPods.png", "background_color": "59,59,59,255", "font_size": 11}
What could I be doing wrong? MBP M1, macOS 11.1