Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/airthings.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ async def find_devices(self, scans=2, timeout=5):

_LOGGER.debug("Scanning for airthings devices")
for _count in range(scans):
advertisements = await BleakScanner.discover(timeout)
for adv in advertisements:
if 820 in adv.metadata["manufacturer_data"]: # TODO: Not sure if this is the best way to identify Airthings devices
if adv.address not in self.airthing_devices:
self.airthing_devices.append(adv.address)
advertisements = await BleakScanner.discover(timeout, return_adv=True)
for device, adv_data in advertisements.values():
#for adv in advertisements:
if 820 in adv_data.manufacturer_data: # TODO: Not sure if this is the best way to>
if device.address not in self.airthing_devices:
self.airthing_devices.append(device.address)

_LOGGER.debug("Found {} airthings devices".format(len(self.airthing_devices)))
return len(self.airthing_devices)
Expand Down Expand Up @@ -373,4 +374,4 @@ async def main():


if __name__ == "__main__":
asyncio.run(main())
asyncio.run(main())