Skip to content

Commit 9646c1f

Browse files
committed
config: tolerate devices with no unitId
1 parent fc68521 commit 9646c1f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/solaar/configuration.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,25 @@ def named_int_representer(dumper, data):
231231
# So new entries are not created for unseen off-line receiver-connected devices
232232
def persister(device):
233233
def match(wpid, serial, modelId, unitId, c):
234-
return (wpid and wpid == c.get(_KEY_WPID) and serial and serial == c.get(_KEY_SERIAL)) or (
235-
modelId and modelId == c.get(_KEY_MODEL_ID) and unitId and unitId == c.get(_KEY_UNIT_ID)
234+
return (
235+
(wpid and wpid == c.get(_KEY_WPID) and serial and serial == c.get(_KEY_SERIAL))
236+
or (modelId and modelId == c.get(_KEY_MODEL_ID) and unitId and unitId == c.get(_KEY_UNIT_ID))
237+
or (
238+
c.get(_KEY_WPID) is None
239+
and c.get(_KEY_SERIAL) is None
240+
and c.get(_KEY_UNIT_ID) is None
241+
and modelId
242+
and modelId == c.get(_KEY_MODEL_ID)
243+
)
236244
)
237245

238246
with configuration_lock:
239247
if not _config:
240248
_load()
241249
entry = None
242250
# some devices report modelId and unitId as zero so use name and serial for them
243-
modelId = device.modelId if device.modelId != "000000000000" else device._name if device.modelId else None
244-
unitId = device.unitId if device.modelId != "000000000000" else device._serial if device.unitId else None
251+
modelId = device.modelId if device.modelId != "000000000000" else device._name if device._name else None
252+
unitId = device.unitId if device.unitId != "00000000" else device._serial if device._serial else None
245253
for c in _config:
246254
if isinstance(c, _DeviceEntry) and match(device.wpid, device._serial, modelId, unitId, c):
247255
entry = c

0 commit comments

Comments
 (0)