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)
|
self._name = _hidpp20.get_name(self)
|
||||||
return self._name or self._codename or ('Unknown device %s' % (self.wpid or self.product_id))
|
return self._name or self._codename or ('Unknown device %s' % (self.wpid or self.product_id))
|
||||||
|
|
||||||
@property
|
def get_ids(self):
|
||||||
def unitId(self):
|
|
||||||
if not self._unitId:
|
|
||||||
if self.online and self.protocol >= 2.0:
|
|
||||||
ids = _hidpp20.get_ids(self)
|
ids = _hidpp20.get_ids(self)
|
||||||
if ids:
|
if ids:
|
||||||
self._unitId, self._modelId, self._tid_map = ids
|
self._unitId, self._modelId, self._tid_map = ids
|
||||||
if _log.isEnabledFor(_INFO) and self._serial and self._serial != self._unitId:
|
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)
|
_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
|
return self._unitId
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def modelId(self):
|
def modelId(self):
|
||||||
if not self._modelId:
|
if not self._modelId and self.online and self.protocol >= 2.0:
|
||||||
if self.online and self.protocol >= 2.0:
|
self.get_ids()
|
||||||
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)
|
|
||||||
return self._modelId
|
return self._modelId
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tid_map(self):
|
def tid_map(self):
|
||||||
if not self._tid_map:
|
if not self._tid_map and self.online and self.protocol >= 2.0:
|
||||||
if self.online and self.protocol >= 2.0:
|
self.get_ids()
|
||||||
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)
|
|
||||||
return self._tid_map
|
return self._tid_map
|
||||||
|
|
||||||
def update_pairing_information(self):
|
def update_pairing_information(self):
|
||||||
|
|
Loading…
Reference in New Issue