diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py index 6c5b0b41..15f19384 100644 --- a/lib/logitech_receiver/device.py +++ b/lib/logitech_receiver/device.py @@ -191,37 +191,29 @@ class Device: self._name = _hidpp20.get_name(self) return self._name or self._codename or ('Unknown device %s' % (self.wpid or self.product_id)) + def get_ids(self): + ids = _hidpp20.get_ids(self) + if ids: + self._unitId, self._modelId, self._tid_map = ids + if _log.isEnabledFor(_INFO) and self._serial and self._serial != self._unitId: + _log.info('%s: unitId %s does not match serial %s', self, self._unitId, self._serial) + @property def unitId(self): - if not self._unitId: - if self.online and self.protocol >= 2.0: - ids = _hidpp20.get_ids(self) - if ids: - self._unitId, self._modelId, self._tid_map = ids - if _log.isEnabledFor(_INFO) and self._serial and self._serial != self._unitId: - _log.info('%s: unitId %s does not match serial %s', self, self._unitId, self._serial) + if not self._unitId and self.online and self.protocol >= 2.0: + self.get_ids() return self._unitId @property def modelId(self): - if not self._modelId: - if self.online and self.protocol >= 2.0: - ids = _hidpp20.get_ids(self) - if ids: - self._unitId, self._modelId, self._tid_map = ids - if _log.isEnabledFor(_INFO) and self._serial and self._serial != self._unitId: - _log.info('%s: unitId %s does not match serial %s', self, self._unitId, self._serial) + if not self._modelId and self.online and self.protocol >= 2.0: + self.get_ids() return self._modelId @property def tid_map(self): - if not self._tid_map: - if self.online and self.protocol >= 2.0: - ids = _hidpp20.get_ids(self) - if ids: - self._unitId, self._modelId, self._tid_map = ids - if _log.isEnabledFor(_INFO) and self._serial and self._serial != self._unitId: - _log.info('%s: unitId %s does not match serial %s', self, self._unitId, self._serial) + if not self._tid_map and self.online and self.protocol >= 2.0: + self.get_ids() return self._tid_map def update_pairing_information(self):