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

Asyncio support? #153

Open
Jc2k opened this issue Jul 26, 2019 · 6 comments
Open

Asyncio support? #153

Jc2k opened this issue Jul 26, 2019 · 6 comments

Comments

@Jc2k
Copy link
Collaborator

Jc2k commented Jul 26, 2019

It's been on my long term wishlist for a while to have an asyncio client. I thought it was nice but wouldn't enable new features or have much impact in terms of reliability. But working on #61/#62 has been a bit of a pain because of threading, and it would be nice not to have to deal with threads in HASS.

Do you have any interest in having an asyncio client within homekit_python or would it be better served as a seperate project?

@jlusiardi
Copy link
Owner

Hey,
I never did something with asyncio, so no clue about this topic. But I will not say no without looking at it.
Joachim

@Jc2k
Copy link
Collaborator Author

Jc2k commented Jul 26, 2019

Cool. I will try and make a mockup of what the HTTP client would look like with asyncio, and keep the sync code as is. First pass will be just to get something that works, but definitely lots of opportunity to share code between the two.

If that works, then i'd ditch my prototype from #62 and instead say if you want to multiplex events and request/reply on the same TCP stream like Apple you have to use asyncio.

BLE should be possible too with aioble, but will need to extend that to support descriptors from a cursory glance.

@Jc2k
Copy link
Collaborator Author

Jc2k commented Jul 30, 2019

The http aio prototype is nearly ready, got a test that passed but leaves a thread hanging to sort out and events to test out then will port my hass branch to use it and see how it feels.

@jlusiardi
Copy link
Owner

I will try to have a look at it soon, latest on the weekend in the train!

@Jc2k
Copy link
Collaborator Author

Jc2k commented Jul 31, 2019

Hanging test fixed, test for auto-reconnect added, going to try and get events working today/tomorrow.

@Jc2k
Copy link
Collaborator Author

Jc2k commented Aug 1, 2019

Got it working in HASS with events, though havent tried pairing yet with a real device yet.

Wanted to be able to test events in CI so have added events support to accessory server - see this commit.

I can pull this out as a seperate PR for #51 if you like, or we can keep it together.

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

No branches or pull requests

2 participants