diff --git a/docs/rules.md b/docs/rules.md index ea76da63..706a35ff 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -133,8 +133,9 @@ or the window's Window manager class or instance name starts with their string a `Device` conditions are true if a particular device originated the notification. `Active` conditions are true if a particular device is active. `Device` and `Active` conditions take one argument, which is the serial number or unit ID of a device, -as shown in Solaar's detail pane. -Some older devices do not have a useful serial number or unit ID and so cannot be tested for by these conditions. +as shown in Solaar's detail pane, or either of its names, as shown by Solaar. +Some older devices do not have a useful serial number or unit ID and so cannot +distinguished from other devices with the same names. ### Host `Host` conditions are true if the computers hostname starts with the condition's argument. diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py index 6552535b..8d391af8 100644 --- a/lib/logitech_receiver/device.py +++ b/lib/logitech_receiver/device.py @@ -207,10 +207,10 @@ class Device: Device.instances.append(self) - def find(self, id): # find a device by serial number or unit ID - assert id, "need serial number or unit ID to find a device" + def find(self, id): # find a device by serial number or unit ID or name or codename + assert id, "need id to find a device" for device in Device.instances: - if device.online and (device.unitId == id or device.serial == id): + if device.online and (device.unitId == id or device.serial == id or device.name == id or device.codename == id): return device @property diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py index 7693adb3..2500c3d2 100644 --- a/lib/logitech_receiver/diversion.py +++ b/lib/logitech_receiver/diversion.py @@ -1118,7 +1118,12 @@ class Device(Condition): def evaluate(self, feature, notification: HIDPPNotification, device, last_result): if logger.isEnabledFor(logging.DEBUG): logger.debug("evaluate condition: %s", self) - return device.unitId == self.devID or device.serial == self.devID + return ( + device.unitId == self.devID + or device.serial == self.devID + or device.codename == self.devID + or device.name == self.devID + ) def data(self): return {"Device": self.devID}