lihaoyun6 / AirBattery

Get the battery usage of all your devices on your Mac and put them on the Dock / Menu Bar / Widget! && 在Mac上获取你所有设备的电量信息并显示在Dock / 状态栏 / 小组件上!
https://lihaoyun6.github.io/airbattery/
GNU Affero General Public License v3.0
922 stars 27 forks source link

Logitech mouses not detected #41

Closed Paul-50 closed 3 weeks ago

Paul-50 commented 1 month ago

I have 2 Logitech mouses (MX Anywhere 35 and Signature M650) that are not detected by AirBattery. Both are BTLE energy mouses that are well detected by the Apple Battery app and widget. Thanks for the app!

bpetrynski commented 1 month ago

I noticed that somehow BetterMouse manages to retrieve this data, so theoretically it should be possible to display 🤔

lihaoyun6 commented 1 month ago

Well, I just bought a used Anywhere 2, and I will try to figure out how to do this once it arrives🧐

AnshumGill commented 1 month ago

Since updating to 1.3.7 my mechanical keyboard and mx master 3S have started showing up, it is a bit spotty but they are there sometimes

lihaoyun6 commented 1 month ago

Since updating to 1.3.7 my mechanical keyboard and mx master 3S have started showing up, it is a bit spotty but they are there sometimes

I think I should use something like HIDPP to actively obtain device information, rather than just passively waiting for their random responses. But all this will have to wait until I get the mouse. This will take a few days.

lihaoyun6 commented 3 weeks ago
94a7f77e38863cedf9ce46ba6dffd08e

I have added support for some Logitech devices to AirBattery (the device needs to support HID++ 2.0).
This feature will be implemented soon, please stay tuned

PS: This feature is disabled by default. If you need it, enable "Enhanced HID Scanner" in the settings panel

AnshumGill commented 3 weeks ago

On 1.3.9, the batteries weren't showing up, I tried to execute the hidpp-list-devices binary manually to check what the output was. This is the log libc++abi: terminating due to uncaught exception of type HIDPP20::UnsupportedFeature: Feature [0x1000] BatteryLevelStatus unsupported.

Hope it helps

lihaoyun6 commented 3 weeks ago

Could you please run the following command in your terminal and see what output is there:

log show --predicate 'process == "bluetoothd"' --info --last 1h | grep "statedump: 0x001D"
AnshumGill commented 3 weeks ago
2024-06-22 09:51:37.567611+0530 0x379c8f   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Primary Service      [ serviceUUID: 0x1805, endHandle: 0x0022, discoveredCharacteristics: none ]
2024-06-22 09:51:40.953389+0530 0x37a18a   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.372137+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.375220+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.377731+0530 0x37a237   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.433217+0530 0x37a237   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.492515+0530 0x37a237   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.552267+0530 0x37a18a   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.612256+0530 0x37a18a   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.672004+0530 0x37a18a   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.672484+0530 0x37a18a   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.673931+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.674477+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.674968+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.882162+0530 0x37a237   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.882418+0530 0x37a237   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.882840+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.950245+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:41.982160+0530 0x37a18a   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:42.011545+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:42.042389+0530 0x37a238   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
2024-06-22 09:51:46.210726+0530 0x37a237   Default     0x0                  53298  0    bluetoothd: [com.apple.bluetooth:Server.GATT] statedump: 0x001D Characteristic Value [ 55 ]
lihaoyun6 commented 3 weeks ago

OK, I'm really glad to see it prints the correct information🤩 This is the new way I found to get the battery usage of third-party devices. And I will consider removing HIDPP in the next version and get the information from the bluetoothd log instead.

lihaoyun6 commented 3 weeks ago

I've tried logging the mouse battery level through the system log, but I've also noticed that macOS only writes Bluetooth battery data to the log when the Mac is powered on or wakes from sleep, or when the mouse is reconnected to the Mac🧐
This isn't a problem for me, usually the charge level on these devices changes very slowly, and updating every few hours doesn't cause a huge lag.
But I'm not sure if this is acceptable to you?

AnshumGill commented 3 weeks ago

For me the only goal is to know when to charge them, so infrequent updates are completly fine by me

Paul-50 commented 3 weeks ago

That’s totally acceptable! For me it wouldn’t be a problem if I got the mouse and keyboard power levels only once every day. It changes only 1 or 2 % over such a period.

Op za 22 jun 2024 om 13:17 schreef lihaoyun6 @.***>

I've tried logging the mouse battery level through the system log, but I've also noticed that macOS only writes Bluetooth battery data to the log when the Mac is powered on or wakes from sleep, or when the mouse is reconnected to the Mac🧐 This isn't a problem for me, usually the charge level on these devices changes very slowly, and updating every few hours doesn't cause a huge lag. But I'm not sure if this is acceptable to you?

— Reply to this email directly, view it on GitHub https://github.com/lihaoyun6/AirBattery/issues/41#issuecomment-2183984168, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJEJNYITMIATRHHE4K2D3D3ZIVMLZAVCNFSM6AAAAABJGYE4R2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBTHE4DIMJWHA . You are receiving this because you authored the thread.Message ID: @.***>

lihaoyun6 commented 3 weeks ago

AirBattery.zip

Maybe you want to try this. This version gets data from the system log, and does not require the "input monitoring" permission

AnshumGill commented 3 weeks ago
image

Works great!

Edit -

Did get this though, doesn't seem to be affecting the functionality

image
lihaoyun6 commented 3 weeks ago

Oh, it's a timestamp writing bug, it's very easy to fix. Please wait for v1.4.0 to be released

lihaoyun6 commented 3 weeks ago

v1.4.0 has been released, please update to get all new features and fixes

Paul-50 commented 3 weeks ago

Works perfect now! Thanks! Paul