Skip to content

Commit

Permalink
Extra tracing during discovery of Xcom devices
Browse files Browse the repository at this point in the history
  • Loading branch information
ankohanse committed Jan 7, 2025
1 parent 1ea2dd8 commit cd22ba0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "aioxcom"
version = "1.7.0"
version = "1.7.1"
authors = [
{ name="Anko Hanse", email="[email protected]" },
]
Expand Down
13 changes: 11 additions & 2 deletions src/aioxcom/xcom_discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ async def discoverDevices(self, getExtendedInfo = False) -> list[XcomDiscoveredD

for family in XcomDeviceFamilies.getList():

_LOGGER.info(f"trying family {family.id} ({family.model})")

# Get value for the specific discovery nr, or otherwise the first info nr or first param nr
nr = family.nrDiscover or family.nrInfosStart or family.nrParamsStart or None
if not nr:
Expand All @@ -75,6 +77,7 @@ async def discoverDevices(self, getExtendedInfo = False) -> list[XcomDiscoveredD
try:
param = self._dataset.getByNr(nr, family.idForNr)

_LOGGER.info(f"trying device {device_code} on {device_addr} for nr {nr}")
value = await self._api.requestValue(param, device_addr)
if value is not None:
_LOGGER.info(f"Found device {device_code} via {nr}:{device_addr}")
Expand All @@ -85,8 +88,11 @@ async def discoverDevices(self, getExtendedInfo = False) -> list[XcomDiscoveredD

devices.append(device)

else:
_LOGGER.info(f"No device {device_code}; no value returned from Xcom client: {e}")

except Exception as e:
_LOGGER.debug(f"No device {device_code}; no test value returned from Xcom client: {e}")
_LOGGER.info(f"No device {device_code}; no test value returned from Xcom client: {e}")

# Do not test further device addresses in this family
break
Expand All @@ -102,6 +108,7 @@ async def getExtendedDeviceInfo(self, device: XcomDiscoveredDevice) -> XcomDisco
# ID SID
# ID FID msb/lsb
try:
_LOGGER.info(f"Try get extended device info for device {device.code})")
family = XcomDeviceFamilies.getById(device.family_id)

id_type = await self._requestValueByName("ID type", family.id, device.addr)
Expand All @@ -117,8 +124,10 @@ async def getExtendedDeviceInfo(self, device: XcomDiscoveredDevice) -> XcomDisco
device.sw_version = self._decodeIdSW(id_sw_msb, id_sw_lsb)
device.fid = self._decodeFID(id_fid_msb, id_fid_lsb)

_LOGGER.info(f"Found extended device info: model: {device.device_model}, hw_version: {device.hw_version}, sw_version: {device.sw_version}, fid: {device.fid})")

except Exception as e:
_LOGGER.debug(f"Exception in getExtendedDeviceInfo: {e}")
_LOGGER.info(f"Exception in getExtendedDeviceInfo: {e}")

return device

Expand Down

0 comments on commit cd22ba0

Please sign in to comment.