-
Notifications
You must be signed in to change notification settings - Fork 20
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
Implement async_reachable to see if a device is reachable on the network #370
Conversation
For zeroconf based devices we check if the A/AAAA records are still published. This means we will know if the device is offline within 120s since A/AAAA records typically have a TTL of 120s For BLE based devices we will check if the BLE device is in range and seen by the adapter. This will vary by BLE adapter, but it will likely mean we will know within a few minutes as well
async with asyncio_timeout(timeout): | ||
if discovery := await waiter: | ||
return discovery | ||
if discovery := await waiter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a risk we could raise cancellation into the caller so I used a call later instead of async_timeout here
I need to write a test for the zeroconf case |
Keep getting distracted by beta issues so will have to come back to writing the tests later |
I've been running this for a few days, and all seems well here |
No crashes on the device now. I think this will solve the problem |
I haven't had one crash on the device since implementing this. This puts us much more in-line with the native HomeKit behavior. |
Retested with Jc2k SO_KEEPALIVE idea. All good 👍 |
For zeroconf based devices we check if the A/AAAA records are still published. This means we will know if the device is offline within 120s since A/AAAA records typically have a TTL of 120s
For BLE based devices we will check if the BLE device is in range and seen by the adapter. This will vary by BLE adapter, but it will likely mean we will know within a few minutes as well