LoLei / razer-cli

CLI for configuring Razer devices
GNU General Public License v3.0
89 stars 11 forks source link

Add check for get_low_battery_threshold capability #71

Closed sk8ersteve closed 1 year ago

sk8ersteve commented 1 year ago

Not every device that has "battery" capability also supports the get_low_battery_threshold method. This capability must be explicitly checked, so I've added the check for this method as well as for get_idle_time. You can see how capabilities are set in openrazer here: https://github.com/openrazer/openrazer/blob/43b4a605e84f7530d8763a804eb875936e7bd5d7/pylib/openrazer/client/devices/__init__.py#L50

See issues: https://github.com/LoLei/razer-cli/issues/66 https://github.com/LoLei/razer-cli/issues/70

Tested on Viper Ultimate. Needs testing on a device that does support the two above methods.

LoLei commented 1 year ago

Thanks! 👍

@lipovac @ifohancroft @GM-Script-Writer-62850
If you can test / review this we can merge it.

GM-Script-Writer-62850 commented 1 year ago

just looked at the code, my mouse does not have a battery (i hate batteries, give me a wire)

I think we should add a indent to lines 49-53

These features should only exist if there is a battery correct? there is no need to test for these if there is not battery. furthermore is somehow they were supported without a battery the data would look odd as printed as subsection of DPI settings, polling rate, or a sub section of the device type

Here is a feature test script people can just run and post the output of razer_feature_test_script.zip

$ python /tmp/razer_feature_test_script.py 
Razer DeathAdder Elite:
   name: True
   type: True
   dpi: True
   available_dpi: False
   dpi_stages: False
   poll_rate: True
   device_image: False
   battery: False
   get_low_battery_threshold: False
   get_idle_time: False

if you take a battery out and use it plugged in does it change the output?

sk8ersteve commented 1 year ago

I agree with your idea to indent @GM-Script-Writer-62850. The patch has been updated. I could imagine that get_idle_time could be a capability for wired devices but I don't any wired-only devices with it in openrazer, so I think this assumption is ok for now.

Unfortunately, I don't have a wire handy that fits this mouse but based on my reading of the openrazer code, it wouldn't make a difference since Razer Viper Ultimate (Wireless) inherits most capabalities including "battery" from the (Wired) device variant. Basically the main difference between these variants from the API standpoint is the USB ID.