device: refactor device ID calls
This commit is contained in:
parent
4974989729
commit
e3d62f5dca
|
@ -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))
|
||||
|
||||
@property
|
||||
def unitId(self):
|
||||
if not self._unitId:
|
||||
if self.online and self.protocol >= 2.0:
|
||||
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 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):
|
||||
|
|
Loading…
Reference in New Issue