Closed ifohancroft closed 1 year ago
I realized I have forgotten to post something:
Even if I don't use the dock at all and I just plug the mouse using its dongle, directly into the PC, I still get an error executing razer-cli -ll.
Also, the error appears to be slightly different as well (not sure if it has anything to do with the number or types of devices plugged in though):
Found 1 Razer device(s)
Razer Viper Ultimate (Wireless):
type: mouse
DPI: (0, 0)
max DPI: 20000
polling rate: 500
battery:
charge: 80
charging: False
Traceback (most recent call last):
File "/usr/bin/razer-cli", line 8, in
P.S. If the openrazer daemon has not been working before executing razer-cli --l, razer-cli manages to get the battery level no problem (whether the battery level is reported accurately, I don't know). However, if the daemon is already running before executing razer-cli -ll (I.e. you start with the daemon not running, you execute razer-cli, then you don't kill the daemon, then you execute razer-cli again) then it probably can't get the battery level properly as it shows it as 0.
Not sure if this is a upstream issue or not, it sounds like your product should have the feature and trying to read it causes a error
If you are still having this issue try this patched file:
/usr/lib/python3.9/site-packages/razer_cli/razer_cli/lister/device_lister.py
device.lister.zip
Back when i wrote this code i do not recall if i was using the daily version of openrazer or not, you may want test with the daily release of openrazer, not sure if that version's feature have made the stable branch, i was writing this code based on the code i read in the openrazer library, the only razer thing i have is a wired mouse and i recently had to replace the button in it (less work than redoing cable management and cheaper than getting a new mouse)
i can't properly test code that tries check battery info
LoLei did test it on his hardware not sure if he has stuff with batteries
The error keeps persisting (for all three options: -l, -ll, -ls) to this day btw.
May I ask why you never tested my patch? i do not have your hardware that makes it VERY difficult to debug your HARDWARE SPECIFIC issue
in this folder ~/.local/lib/python3.10/site-packages/razer_cli/razer_cli/lister/
you will find a file called device_lister.py
note the folder may be ~/.local/lib/python3.9/site-packages/razer_cli/razer_cli/lister/
if you have not upgraded your linux distribution lately
at line 45 you will find this:
if device.has('battery'):
print(" battery:")
print(" charge:", device.battery_level)
print(" charging:", device.is_charging)
print(" low threshold:",
device.get_low_battery_threshold(), '%')
print(" idle delay", device.get_idle_time(), 'seconds')
try using this instead
if device.has('battery'):
print(" battery:")
print(" charge:", device.battery_level)
print(" charging:", device.is_charging)
if hasattr(device,'get_low_battery_threshold'):
print(" low threshold:",
device.get_low_battery_threshold(), '%')
if hasattr(device,'device.get_idle_time'):
print(" idle delay", device.get_idle_time(), 'seconds')
does that work? if not what happens?
I am sorry, I don't know why I didn't try your patch. I must have missed it. I will try it later today and report back.
I'm having the same error. I will try @GM-Script-Writer-62850 patch and report back.
Traceback (most recent call last):
File "/usr/bin/razer-cli", line 33, in <module>
sys.exit(load_entry_point('razer-cli==2.1.0', 'console_scripts', 'razer-cli')())
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/rc.py", line 73, in run
self.device_lister.list()
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/lister/device_lister.py", line 50, in list
device.get_low_battery_threshold(), '%')
File "/usr/lib/python3.10/site-packages/openrazer/client/devices/__init__.py", line 491, in get_low_battery_threshold
return int(self._dbus_interfaces['power'].getLowBatteryThreshold())
File "/usr/lib/python3.10/site-packages/dbus/proxies.py", line 141, in __call__
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3.10/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/dbus/service.py", line 662, in _message_cb
(candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
File "/usr/lib/python3.10/site-packages/dbus/service.py", line 252, in _method_lookup
raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: getLowBatteryThreshold is not a valid method of interface razer.device.power
I do not like using try except, but i really do not see another way, so give this a shot
if device.has('battery'):
print(" battery:")
print(" charge:", device.battery_level)
print(" charging:", device.is_charging)
try:
low=str(device.get_low_battery_threshold())+"%"
except:
low="unsupported by device"
print(" low threshold:",low)
try:
idle=str(device.get_idle_time)+" seconds"
except:
idle="unsupported by device"
print(" idle delay:",idle)
I had the same issue with deathadder v3, on openrazer 3.5.1 which was reeased on Dec 4 2022 a good while after this issue was created.
It does seem the dbus interface is missing the requested function for me aswell.
$ qdbus --session org.razer /org/razer/device/PM2232H27703251 | grep power
method double razer.device.power.getBattery()
method ushort razer.device.power.getIdleTime()
method bool razer.device.power.isCharging()
method void razer.device.power.setIdleTime(ushort idle_time)
The try/except patch works as expected for me.
Found 1 Razer device(s)
Razer DeathAdder V3 Pro (Wireless):
type: mouse
DPI: (600, 600)
max DPI: 30000
DPI stages: (1, [(600, 600), (1500, 1500), (5000, 5000), (30000, 30000)])
polling rate: 1000
battery:
charge: 100
charging: False
low threshold: unsupported by device
idle delay 300 seconds
generic zone:
serial: PM2232H27703251
firmware version: v1.0
driver version: 3.5.1
supported capabilities: name, type, firmware_version, serial, battery, get_idle_time, set_idle_time, poll_rate, dpi, dpi_stages, lighting
A release with this patch would be nice, it would possibly be wise to specify the exception to catch in case something else goes wrong that we do wish to know about.
If the available parameters/methods are dynamic based on device connected maybe it would be helpful to patch all attributes in this manner?
if we are gonna go with a try/except we should at least clean it up
def tryBattery(feature) # case switch in python requires version 3.1 or later, is that a issue?
try:
match feature:
case "get_low_battery_threshold":
return str(device.get_low_battery_threshold())+"%"
case "get_idle_time":
return str(device.get_idle_time)+" seconds"
case _:
return "The tryBattery function does not have a match for: "+str(feature)
except:
return "unsupported by device"
if device.has('battery'):
print(" battery:")
print(" charge:", device.battery_level)
print(" charging:", device.is_charging)
print(" low threshold:",tryBattery("get_low_battery_threshold"))
print(" idle delay:",tryBattery("device.get_idle_time"))
This function could be made more generic in name and used for non battery related features if needed
Personally I would consider it a bug upstream if there is no way to query if a given feature is supported
@GM-Script-Writer-62850 your changed fixed it for me. But I agree cleaning it up a bit would be a good idea. Below is the patch I applied to my fork. I haven't had any other issues with the cli since then.
From 47d6a7502c5d9df4d8372072d75bd0b81b3506c4 Mon Sep 17 00:00:00 2001
From: "jesus m. rodriguez" <jesus.rodriguez@swiftline.com>
Date: Tue, 28 Feb 2023 12:29:27 -0500
Subject: [PATCH] Applied patch from github
Signed-off-by: jesus m. rodriguez <jesus.rodriguez@swiftline.com>
---
razer_cli/razer_cli/lister/device_lister.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/razer_cli/razer_cli/lister/device_lister.py b/razer_cli/razer_cli/lister/device_lister.py
index 83d8064..42a313e 100644
--- a/razer_cli/razer_cli/lister/device_lister.py
+++ b/razer_cli/razer_cli/lister/device_lister.py
@@ -46,9 +46,10 @@ class DeviceLister(Lister):
print(" battery:")
print(" charge:", device.battery_level)
print(" charging:", device.is_charging)
- print(" low threshold:",
- device.get_low_battery_threshold(), '%')
- print(" idle delay", device.get_idle_time(), 'seconds')
+ if device.has('get_low_battery_threshold'):
+ print(" low threshold:", device.get_low_battery_threshold(), '%')
+ if device.has('get_idle_time'):
+ print(" idle delay", device.get_idle_time(), 'seconds')
for i in settings.ZONES:
# Settings
--
2.39.2
IIRC that does not work if your device has the feature, anyone able to prove me wrong
chad@X470-Gaming-Plus:~$ cat /tmp/test.py
#/usr/bin/python3
from openrazer.client import DeviceManager
device=DeviceManager().devices[0]
print(device.has('get_low_battery_threshold'))
print(device.has('get_idle_time'))
chad@X470-Gaming-Plus:~$ python3 /tmp/test.py
False
False
chad@X470-Gaming-Plus:~$
test.py would print True
if this code works, but i suspect it will print false regardless
Maybe that does work, did it not before? maybe i did not use that cause the feature was only in the beta at the time? https://github.com/openrazer/openrazer/blob/master/pylib/openrazer/client/devices/__init__.py#L60-L61
if anyone can check if that works it should be used like that
So when I run the test.py above, I get the same results you did.
$ python3 /tmp/test.py
False
False
I'm using a:
$ razer-cli -l
Found 1 Razer device(s)
Razer DeathAdder V2 Pro (Wired):
type: mouse
DPI: (1800, 1800)
max DPI: 20000
DPI stages: (4, [(400, 400), (800, 800), (1600, 1600), (3200, 3200), (6400, 6400)])
polling rate: 500
battery:
charge: 100
charging: True
generic zone:
effects available: multicolor
logo zone:
brightness: 100.0
colors: ['FF5200', '00FFFF', '0000FF']
effect: breathSingle
speed: 1
wave_dir: 1
effects available: breath_dual, breath_random, breath_single, brightness, none, reactive, spectrum, static
serial: 632052H15710053
firmware version: v1.1
driver version: 3.5.1
supported capabilities: name, type, firmware_version, serial, battery, set_idle_time, set_low_battery_threshold, poll_rate, dpi, dpi_stages, lighting, lighting_led_matrix, lighting_logo, lighting_logo_brightness, lighting_logo_spectrum, lighting_logo_static, lighting_logo_none, lighting_logo_reactive, lighting_logo_breath_single, lighting_logo_breath_dual, lighting_logo_breath_random
@GM-Script-Writer-62850
if hasattr(device,'device.get_idle_time'):
I finally tried this. Sorry it took me so long. I still get the error, when I execute razer-cli -l. Here's the output (at the time of execution I was using the mouse wired, but I also get the error if I am using it wireless. I'll post both just in-case. Wired first:
$ razer-cli -l
Found 2 Razer device(s)
Razer Kraken 7.1 V2:
type: headset
generic zone:
colors: ['00FF00', '00FFFF', '0000FF']
effect: none
speed: 1
wave_dir: 1
effects available: breath_dual, breath_single, breath_triple, none, spectrum, static
serial: HN1739D04701646
firmware version: v2.67
driver version: 3.3.0
supported capabilities: name, type, firmware_version, serial, lighting, lighting_breath_single, lighting_breath_dual, lighting_breath_triple, lighting_none, lighting_spectrum, lighting_static
Razer Viper Ultimate (Wired):
type: mouse
DPI: (1600, 1600)
max DPI: 20000
Traceback (most recent call last):
File "/usr/bin/razer-cli", line 33, in <module>
sys.exit(load_entry_point('razer-cli==2.1.0', 'console_scripts', 'razer-cli')())
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/rc.py", line 73, in run
self.device_lister.list()
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/lister/device_lister.py", line 42, in list
print(" DPI stages:", device.dpi_stages)
File "/usr/lib/python3.10/site-packages/openrazer/client/devices/mice.py", line 110, in dpi_stages
response = self._dbus_interfaces['dpi'].getDPIStages()
File "/usr/lib/python3.10/site-packages/dbus/proxies.py", line 141, in __call__
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3.10/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Python.FileNotFoundError: Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/dbus/service.py", line 715, in _message_cb
retval = candidate_method(self, *args, **keywords)
File "/usr/lib/python3.10/site-packages/openrazer_daemon/dbus_services/dbus_methods/mamba.py", line 270, in get_dpi_stages
with open(driver_path, 'rb') as driver_file:
FileNotFoundError: [Errno 2] No such file or directory: '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0/0003:1532:007A.000D/dpi_stages'
$ razer-cli -l
Found 3 Razer device(s)
Razer Kraken 7.1 V2:
type: headset
generic zone:
colors: ['00FF00', '00FFFF', '0000FF']
effect: none
speed: 1
wave_dir: 1
effects available: breath_dual, breath_single, breath_triple, none, spectrum, static
serial: HN1739D04701646
firmware version: v2.67
driver version: 3.3.0
supported capabilities: name, type, firmware_version, serial, lighting, lighting_breath_single, lighting_breath_dual, lighting_breath_triple, lighting_none, lighting_spectrum, lighting_static
Razer Mouse Dock:
type: accessory
generic zone:
colors: ['00FF00', '00FFFF', '0000FF']
effect: breathRandom
speed: 1
wave_dir: 1
effects available: breath_dual, breath_random, breath_single, none, spectrum, static, multicolor
serial: PM2114U07703352
firmware version: v1.1
driver version: 3.3.0
supported capabilities: name, type, firmware_version, serial, brightness, lighting, lighting_breath_single, lighting_breath_dual, lighting_breath_random, lighting_none, lighting_spectrum, lighting_static, lighting_led_matrix
Razer Viper Ultimate (Wireless):
type: mouse
DPI: (1600, 1600)
max DPI: 20000
Traceback (most recent call last):
File "/usr/bin/razer-cli", line 33, in <module>
sys.exit(load_entry_point('razer-cli==2.1.0', 'console_scripts', 'razer-cli')())
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/rc.py", line 73, in run
self.device_lister.list()
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/lister/device_lister.py", line 42, in list
print(" DPI stages:", device.dpi_stages)
File "/usr/lib/python3.10/site-packages/openrazer/client/devices/mice.py", line 110, in dpi_stages
response = self._dbus_interfaces['dpi'].getDPIStages()
File "/usr/lib/python3.10/site-packages/dbus/proxies.py", line 141, in __call__
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3.10/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Python.FileNotFoundError: Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/dbus/service.py", line 715, in _message_cb
retval = candidate_method(self, *args, **keywords)
File "/usr/lib/python3.10/site-packages/openrazer_daemon/dbus_services/dbus_methods/mamba.py", line 270, in get_dpi_stages
with open(driver_path, 'rb') as driver_file:
FileNotFoundError: [Errno 2] No such file or directory: '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6.1/1-6.1:1.0/0003:1532:007B.0010/dpi_stages'
Should I try the rest of the code changes you've posted above or what should I do?
P.S. When I go to check the mouse's battery, I get this:
razer-cli --battery 'Razer Viper Ultimate (Wireless)'
Does Razer Kraken 7.1 V2 have a battery?
Does Razer Mouse Dock have a battery?
Razer Viper Ultimate (Wireless) battery:
charge: 15
charging: False
Traceback (most recent call last):
File "/usr/bin/razer-cli", line 33, in <module>
sys.exit(load_entry_point('razer-cli==2.1.0', 'console_scripts', 'razer-cli')())
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/rc.py", line 67, in run
self.battery_setter.set()
File "/usr/lib/python3.10/site-packages/razer_cli-2.1.0-py3.10.egg/razer_cli/razer_cli/setter/battery_setter.py", line 18, in set
device.get_low_battery_threshold(), '%')
File "/usr/lib/python3.10/site-packages/openrazer/client/devices/__init__.py", line 494, in get_low_battery_threshold
return int(self._dbus_interfaces['power'].getLowBatteryThreshold())
File "/usr/lib/python3.10/site-packages/dbus/proxies.py", line 141, in __call__
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3.10/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/dbus/service.py", line 662, in _message_cb
(candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
File "/usr/lib/python3.10/site-packages/dbus/service.py", line 252, in _method_lookup
raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: getLowBatteryThreshold is not a valid method of interface razer.device.power
Already made a duplicate bug for this, but I am encountering the same error:
[llipovac@llipovac-DT Downloads]$ razer-cli -l
Found 2 Razer device(s)
Razer Basilisk Ultimate (Receiver):
type: mouse
DPI: (2500, 2500)
max DPI: 20000
polling rate: 500
battery:
charge: 97
charging: False
Traceback (most recent call last):
File "/home/llipovac/.local/bin/razer-cli", line 8, in
sys.exit(main())
^^^^^^
File "/home/llipovac/.local/lib/python3.11/site-packages/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/home/llipovac/.local/lib/python3.11/site-packages/razer_cli/razer_cli/rc.py", line 73, in run
self.device_lister.list()
File "/home/llipovac/.local/lib/python3.11/site-packages/razer_cli/razer_cli/lister/device_lister.py", line 50, in list
device.get_low_battery_threshold(), '%')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/openrazer/client/devices/init.py", line 494, in get_low_battery_threshold
return int(self._dbus_interfaces['power'].getLowBatteryThreshold())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/proxies.py", line 141, in call
return self._connection.call_blocking(self._named_service,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/connection.py", line 634, in call_blocking
reply_message = self.send_message_with_reply_and_block(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):
File "/usr/lib64/python3.11/site-packages/dbus/service.py", line 659, in _message_cb
(candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/service.py", line 249, in _method_lookup
raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: getLowBatteryThreshold is not a valid method of interface razer.device.power
Fixed with https://github.com/LoLei/razer-cli/pull/71
To be in the next release
Basically, when executing razer-cli -l or razer-cli -ll I get the following error/output:
Found 2 Razer device(s) Razer Viper Ultimate (Wireless): type: mouse DPI: (1800, 1800) max DPI: 20000 polling rate: 500 battery: charge: 75 charging: False Traceback (most recent call last): File "/usr/bin/razer-cli", line 33, in
sys.exit(load_entry_point('razer-cli==2.0.1', 'console_scripts', 'razer-cli')())
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/rc.py", line 73, in run
self.device_lister.list()
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/lister/device_lister.py", line 50, in list
device.get_low_battery_threshold(), '%')
File "/usr/lib/python3.9/site-packages/openrazer/client/devices/mice.py", line 281, in get_low_battery_threshold
return int(self._dbus_interfaces['power'].getLowBatteryThreshold())
File "/usr/lib/python3.9/site-packages/dbus/proxies.py", line 141, in call
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3.9/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/dbus/service.py", line 658, in _message_cb
(candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
File "/usr/lib/python3.9/site-packages/dbus/service.py", line 248, in _method_lookup
raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: getLowBatteryThreshold is not a valid method of interface razer.device.power
I have my mouse's dongle plugged into the dock and the dock plugged into the PC. I also have my Razer Kiyo webcam plugged into the PC but since the Kiyo doesn't work with openrazer, I am guessing the 2 devices razer-cli sees are the Mouse and Dock.
I am using razer-cli version 2.0.1 from GitHub, installed by: