Sometimes I see the device 2 times.
When I choose this I see only %
$if(nc(bt)=0,offline,nc(bt)=1,enabled,nc(bt)=2 & nc(abatt, 0)>0,nc(abatt, 0)+“%”,nc(aname, 0))$
The # is the index number of the connected Bluetooth device.
Sometimes it may be possible that a Bluetooth device get a different index number everytime it connect to the phone (if there are multiple connected Bluetooth devices). So, you might need to check the name of the connected Bluetooth device before getting its battery level info.
Not exactly, the index number should be written as a plain integer, without any other characters.
Example:
nc(abatt, 0) ➞ get the battery level of the first connected Bluetooth device (which usually is the phone itself)
nc(abatt, 1) ➞ get the battery level of the second connected Bluetooth device (if supported by the device)
… and so on
As far as I know, some Bluetooth headsets support the battery level info, I have a pair of them that gives the battery level info. But my Bluetooth speaker and my Bluetooth keyboard do not support it.
Here is my example of Kustom script to iterate the connected Bluetooth devices, and if the name of one of them match then show its battery level (if supported by the device).
I use fl() function for the loop to check every connected Bluetooth device.
If nc(abatt, #) gives -1 result, then it’s not supported by the device. In other words, the device does not provide the information about its battery level.