Comments (4)
Interesting. Will it handle a stream of interspersed EVENT/1.0 and HTTP/1.1 messages? Regarding the generation part it really depends how much control it gives, will have a look soon. We have to talk to a lot of very broken hap implementations, and often that means trying to be byte for byte compatible with what iOS does. Aren't there yet with that but it's looking more and more inevitable.
Not applicable to HTTP handling but e.g. recently had a case where a thermostat couldn't handle a space in a valid JSON body. (Actually only some API endpoints were affected by this). A different thermostat would accept 1, 0 and false for a boolean field. But not true. The spec says all 4 are valid, but we now have to send 1 or 0 only which is what the implementation does. We've had some issues with the Host header in the past too.
So try to be as close to the iOS implementation as possible for sending and as forgiving as possible with reading.
There is a lot of stuff like it is because this is a fork of homekit_python. The plan was to do quite a bit of refactoring but my time has been swallowed up so I'm not really actively improving it as I had hoped just reacting to bugs. So code improvements very much welcome.
from aiohomekit.
As suspected, it looks h11 would not work for this particular HTTP dialect (directly). E.g.
https://github.com/python-hyper/h11/blob/master/h11/_abnf.py#L84
This is used in a regex here (via status_line
, defined a few lines below http_version
):
As you probably know, when a HomeKit accessory notifies a controller about an event it violates the HTTP spec and sends a response without a request. This is one of the other reasons we don't use an existing client - they don't tend to like that as they expect strict request/response. As you say it would be nice to use the parsing. But it's not a HTTP/1.1
message, its an EVENT/1.0
message. In every other way, it is HTTP/1/1
compatible, apart from most parsers don't expect the 5 bytes to be anything other than HTTP/
.
You could monkey patch, but that's a terrible idea, especially as the main aim of aiohomekit is to work well in Home Assistant. It may well use h11
itself indirectly.
We could peek at hte data before passing it to h11. That also seems quite grim.
from aiohomekit.
In general the dirty horrible nasty worse thing in the world HTTP parser seems to be coping with real world HAP devices. It has struggled most with homebrew non-certified HAP servers, but the changes needed to support them have been minor.
At the same time vendors attempts at HAP have been quite bad at working with anything that isn't an iOS device, even when we are blatantly following the spec. As we don't have a large test pool, changes are scary.
So at the moment i'm reluctant to change this, especially if it requires doing something awkward to use h11 for event notifications.
I must admit i haven't tried h11, maybe there is some API that avoids the regex i highlighted. I'll leave this open with a help wanted tag for now.
from aiohomekit.
I tried h11
as we use it in HAP-python
. I gave up on this.
The device in home-assistant/core#46785 seems like its tripping up the parser.
I'm going to try to get my hands on one of those
from aiohomekit.
Related Issues (20)
- Don't fetch programmable switch events on reconnect without getting a GATT notify for them HOT 5
- There is a race where we can be waiting for the device to be detected at startup and we get it more than once because we don't clear it before its detected again
- Fetching friendly_name does a linear search
- Using aiohomekit standalone: transport not supported HOT 2
- Eve Degree: Various BLE errors HOT 1
- asyncio.exceptions.TimeoutError during zeroconf search needs to be re-raised as AccessoryNotFoundError
- Log says "pairing established" but any interaction throws "is no known alias" HOT 4
- `first` to get accessory_info at startup is unexpectedly expensive
- Connection refused HOT 2
- BLE Pairing can fail due to race
- BLE callbacks can error if a device is unpairing because the cache has been deleted
- Missing Service cache clear is missing from pairing process
- Many callback to Called async_set_available_state with True at startup HOT 1
- Video & Intercom Doorbell in HA HOT 6
- BLE Events might still be read when processing disconnected notifications
- Out of order pairing steps when using HomeSpan (async race condition?) HOT 15
- Disconnect during operation can result in an empty event
- Implement happy eye balls with aiohappyeyeballs HOT 1
- Consider lowering the Happy Eyeballs delay to 0.1 from 0.25
- Add support for link local ipv6 addresses now that we have Happy Eyeballs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiohomekit.