kjoconnor / pyhatchbabyrest

Python library to control the Hatch Baby Rest device.
MIT License
19 stars 9 forks source link

Allows more flexible scanning #6

Closed ViViDboarder closed 1 year ago

ViViDboarder commented 2 years ago

This patch uses the BleakScanner interface to simplify the scanning as well as provide more means of connecting. With an address, a BLEDevice, or with a user provided scanner.

This change will allow me to implement a Home Assistant integration using Bluetooth discovery.

Other changes: black

ViViDboarder commented 2 years ago

It's worth noting that asyncio.get_event_loop() is deprecated. The Python documentation shows this warning:

Deprecated since version 3.10: Deprecation warning is emitted if there is no running event loop. In future Python releases, this function will be an alias of get_running_loop().

In the future when it does become an alias, it will fail to run if there is no running loop. At that point, using the async helper created here will work but other refactoring may be required to maintain current status quo.