rules: Device and Action rule conditions match on codename and name
This commit is contained in:
parent
62aaeac595
commit
94f4c3230b
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue