Skip to content

Commit

Permalink
Merge pull request #49 from uvjim:fix-up-discovery
Browse files Browse the repository at this point in the history
fix up discovery
  • Loading branch information
uvjim authored Oct 25, 2022
2 parents de33b34 + ad8e3f8 commit fe8b420
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions custom_components/hdhomerun/pyhdhr/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def _find_in_discovered_devices(device_ip: str) -> int | None:

if self._broadcast_address != DEF_BROADCAST_ADDRESS:
discovered_devices = [HDHomeRunDevice(host=self._broadcast_address)]
setattr(discovered_devices[0], "_discovery_method", DiscoverMode.HTTP)
already_discovered = [device.ip for device in discovered_devices]
for device_ip in already_discovered:
discovered_idx = _find_in_discovered_devices(device_ip)
Expand All @@ -163,14 +164,11 @@ def _find_in_discovered_devices(device_ip: str) -> int | None:
"_discovery_method",
DiscoverMode.HTTP,
)
finally:
if self._created_session:
await self._session.close()
# endregion

_LOGGER.debug(
self._log_formatter.format("discovered devices: %s"), discovered_devices
)
if self._created_session:
await self._session.close()

if not discovered_devices:
if self._broadcast_address == DEF_BROADCAST_ADDRESS:
raise HDHomeRunDeviceNotFoundError(device="no devices")
Expand Down

0 comments on commit fe8b420

Please sign in to comment.