Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows more flexible scanning #6

Merged
merged 2 commits into from
Nov 20, 2022

Conversation

ViViDboarder
Copy link
Contributor

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

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](https://developers.home-assistant.io/docs/network_discovery/#best-practices-for-library-authors).

Other changes: `black`
@ViViDboarder ViViDboarder force-pushed the more-flexible-scanning branch from 4bc845c to 0362803 Compare August 25, 2022 02:40
The `PyHatchBabyRestAsync` constructor has been updated to allow running
from another async coroutine. This is done by providing constructor
options to skip any async calls within teh constructor and make those
via a future method called on the constructed object.

A helper function and example has been created to make this easier.
@ViViDboarder ViViDboarder force-pushed the more-flexible-scanning branch from be18231 to ffaa2dd Compare August 25, 2022 05:28
@ViViDboarder
Copy link
Contributor Author

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.

Copy link
Owner

@kjoconnor kjoconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you! Sorry for the delay, very excited to see the HA integration, I could very much use it :)

@kjoconnor kjoconnor merged commit 07fa4fb into kjoconnor:master Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants