aiohomekit


Nameaiohomekit JSON
Version 3.1.5 PyPI version JSON
download
home_pagehttps://github.com/Jc2k/aiohomekit
SummaryAn asyncio HomeKit client
upload_time2024-02-27 18:27:03
maintainer
docs_urlNone
authorJohn Carr
requires_python>=3.10,<4.0
licenseApache-2.0
keywords homekit home automation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # aiohomekit

![CI](https://github.com/Jc2k/aiohomekit/workflows/CI/badge.svg?event=push) [![codecov](https://codecov.io/gh/Jc2k/aiohomekit/branch/master/graph/badge.svg)](https://codecov.io/gh/Jc2k/aiohomekit)

This library implements the HomeKit protocol for controlling Homekit accessories using asyncio.

It's primary use is for with Home Assistant. We target the same versions of python as them and try to follow their code standards.

At the moment we don't offer any API guarantees. API stability and documentation will happen after we are happy with how things are working within Home Assistant.

## Contributing

`aiohomekit` is primarily for use with Home Assistant. Lots of users are using it with devices from a wide array of vendors. As a community open source project we do not have the hardware or time resources to certify every device with multiple vendors projects. We may be conservative about larger changes or changes that are low level. We do ask where possible that any changes should be tested with a certified HomeKit implementations of shipping products, not just against emulators or other uncertified implementations.

Because API breaking changes would hamper our ability to quickly update Home Assistant to the latest code, if you can please submit a PR to update [homekit_controller](https://github.com/home-assistant/core/tree/dev/homeassistant/components/homekit_controller) too. If they don't your PR maybe on hold until someone is available to write such a PR.

Please bear in mind that some shipping devices interpret the HAP specification loosely. In general we prefer to match the behaviour of real HAP controllers even where their behaviour is not strictly specified. Here are just some of the kinds of problems we've had to work around:

* Despite the precise formatting of JSON being unspecified, there are devices in the wild that cannot handle spaces when parsing JSON. For example, `{"foo": "bar"}` vs `{"foo":"bar"}`. This means we never use a "pretty" encoding of JSON.
* Despite a boolean being explicitly defined as `0`, `1`, `true` or `false` in the spec, some devices only support 3 of the 4. This means booleans must be encoded as `0` or `1`.
* Some devices have shown themselves to be sensitive to headers being missing, in the wrong order or if there are extra headers. So we ensure that only the headers iOS sends are present, and that the casing and ordering is the same.
* Some devices are sensitive to a HTTP message being split into separate TCP packets. So we take care to only write a full message to the network stack.

And so on. As a rule we need to be strict about what we send and loose about what we receive.

## Device compatibility

`aiohomekit` is primarily tested via Home Assistant with a Phillips Hue bridge and an Eve Extend bridge. It is known to work to some extent with many more devices though these are not currently explicitly documented anywhere at the moment.

You can look at the problems your device has faced in the home-assistant [issues list](https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+homekit_controller%22).

## FAQ

### How do I use this?

It's published on pypi as `aiohomekit` but its still under early development - proceed with caution.

The main consumer of the API is the [homekit_controller](https://github.com/home-assistant/core/tree/dev/homeassistant/components/homekit_controller) in Home Assistant so that's the best place to get a sense of the API.

### Does this support BLE accessories?

No. Eventually we hope to via [aioble](https://github.com/detectlabs/aioble) which provides an asyncio bluetooth abstraction that works on Linux, macOS and Windows.

### Can i use this to make a homekit accessory?

No, this is just the client part. You should use one the of other implementations:

 * [homekit_python](https://github.com/jlusiardi/homekit_python/) (this is used a lot during aiohomekit development)
 * [HAP-python](https://github.com/ikalchev/HAP-python)

### Why doesn't Home Assistant use library X instead?

At the time of writing this is the only python 3.7/3.8 asyncio HAP client with events support.

### Why doesn't aiohomekit use library X instead?

Where possible aiohomekit uses libraries that are easy to install with pip, are ready available as wheels (including on Raspberry Pi via piwheels), are cross platform (including Windows) and are already used by Home Assistant. They should not introduce hard dependencies on uncommon system libraries. The intention here is to avoid any difficulty in the Home Assistant build process.

People are often alarmed at the hand rolled HTTP code and suggest using an existing HTTP library like `aiohttp`. High level HTTP libraries are pretty much a non-starter because:

* Of the difficulty of adding in HAP session security without monkey patches.
* They don't expect responses without requests (i.e. events).
* As mentioned above, some of these devices are very sensitive. We don't care if your change is compliant with every spec if it still makes a real world device cry. We are not in a position to demand these devices be fixed. So instead we strive for byte-for-byte accuracy on our write path. Any library would need to give us that flexibility.
* Some parts of the responses are actually not HTTP, even though they look it.

We are also just reluctant to make a change that large for something that is working with a lot of devices. There is a big chance of introducing a regression.

Of course a working proof of concept (using a popular well maintained library) that has been tested with something like a Tado internet bridge (including events) would be interesting.

## Thanks

This library wouldn't have been possible without homekit_python, a synchronous implementation of both the client and server parts of HAP. 

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Jc2k/aiohomekit",
    "name": "aiohomekit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "HomeKit,home,automation",
    "author": "John Carr",
    "author_email": "john.carr@unrouted.co.uk",
    "download_url": "https://files.pythonhosted.org/packages/4d/b4/b5b990e193953ccf0461a618d09356be8a5b779bcd6c3e9ddad271832a6b/aiohomekit-3.1.5.tar.gz",
    "platform": null,
    "description": "# aiohomekit\n\n![CI](https://github.com/Jc2k/aiohomekit/workflows/CI/badge.svg?event=push) [![codecov](https://codecov.io/gh/Jc2k/aiohomekit/branch/master/graph/badge.svg)](https://codecov.io/gh/Jc2k/aiohomekit)\n\nThis library implements the HomeKit protocol for controlling Homekit accessories using asyncio.\n\nIt's primary use is for with Home Assistant. We target the same versions of python as them and try to follow their code standards.\n\nAt the moment we don't offer any API guarantees. API stability and documentation will happen after we are happy with how things are working within Home Assistant.\n\n## Contributing\n\n`aiohomekit` is primarily for use with Home Assistant. Lots of users are using it with devices from a wide array of vendors. As a community open source project we do not have the hardware or time resources to certify every device with multiple vendors projects. We may be conservative about larger changes or changes that are low level. We do ask where possible that any changes should be tested with a certified HomeKit implementations of shipping products, not just against emulators or other uncertified implementations.\n\nBecause API breaking changes would hamper our ability to quickly update Home Assistant to the latest code, if you can please submit a PR to update [homekit_controller](https://github.com/home-assistant/core/tree/dev/homeassistant/components/homekit_controller) too. If they don't your PR maybe on hold until someone is available to write such a PR.\n\nPlease bear in mind that some shipping devices interpret the HAP specification loosely. In general we prefer to match the behaviour of real HAP controllers even where their behaviour is not strictly specified. Here are just some of the kinds of problems we've had to work around:\n\n* Despite the precise formatting of JSON being unspecified, there are devices in the wild that cannot handle spaces when parsing JSON. For example, `{\"foo\": \"bar\"}` vs `{\"foo\":\"bar\"}`. This means we never use a \"pretty\" encoding of JSON.\n* Despite a boolean being explicitly defined as `0`, `1`, `true` or `false` in the spec, some devices only support 3 of the 4. This means booleans must be encoded as `0` or `1`.\n* Some devices have shown themselves to be sensitive to headers being missing, in the wrong order or if there are extra headers. So we ensure that only the headers iOS sends are present, and that the casing and ordering is the same.\n* Some devices are sensitive to a HTTP message being split into separate TCP packets. So we take care to only write a full message to the network stack.\n\nAnd so on. As a rule we need to be strict about what we send and loose about what we receive.\n\n## Device compatibility\n\n`aiohomekit` is primarily tested via Home Assistant with a Phillips Hue bridge and an Eve Extend bridge. It is known to work to some extent with many more devices though these are not currently explicitly documented anywhere at the moment.\n\nYou can look at the problems your device has faced in the home-assistant [issues list](https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+homekit_controller%22).\n\n## FAQ\n\n### How do I use this?\n\nIt's published on pypi as `aiohomekit` but its still under early development - proceed with caution.\n\nThe main consumer of the API is the [homekit_controller](https://github.com/home-assistant/core/tree/dev/homeassistant/components/homekit_controller) in Home Assistant so that's the best place to get a sense of the API.\n\n### Does this support BLE accessories?\n\nNo. Eventually we hope to via [aioble](https://github.com/detectlabs/aioble) which provides an asyncio bluetooth abstraction that works on Linux, macOS and Windows.\n\n### Can i use this to make a homekit accessory?\n\nNo, this is just the client part. You should use one the of other implementations:\n\n * [homekit_python](https://github.com/jlusiardi/homekit_python/) (this is used a lot during aiohomekit development)\n * [HAP-python](https://github.com/ikalchev/HAP-python)\n\n### Why doesn't Home Assistant use library X instead?\n\nAt the time of writing this is the only python 3.7/3.8 asyncio HAP client with events support.\n\n### Why doesn't aiohomekit use library X instead?\n\nWhere possible aiohomekit uses libraries that are easy to install with pip, are ready available as wheels (including on Raspberry Pi via piwheels), are cross platform (including Windows) and are already used by Home Assistant. They should not introduce hard dependencies on uncommon system libraries. The intention here is to avoid any difficulty in the Home Assistant build process.\n\nPeople are often alarmed at the hand rolled HTTP code and suggest using an existing HTTP library like `aiohttp`. High level HTTP libraries are pretty much a non-starter because:\n\n* Of the difficulty of adding in HAP session security without monkey patches.\n* They don't expect responses without requests (i.e. events).\n* As mentioned above, some of these devices are very sensitive. We don't care if your change is compliant with every spec if it still makes a real world device cry. We are not in a position to demand these devices be fixed. So instead we strive for byte-for-byte accuracy on our write path. Any library would need to give us that flexibility.\n* Some parts of the responses are actually not HTTP, even though they look it.\n\nWe are also just reluctant to make a change that large for something that is working with a lot of devices. There is a big chance of introducing a regression.\n\nOf course a working proof of concept (using a popular well maintained library) that has been tested with something like a Tado internet bridge (including events) would be interesting.\n\n## Thanks\n\nThis library wouldn't have been possible without homekit_python, a synchronous implementation of both the client and server parts of HAP. \n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "An asyncio HomeKit client",
    "version": "3.1.5",
    "project_urls": {
        "Homepage": "https://github.com/Jc2k/aiohomekit",
        "Repository": "https://github.com/Jc2k/aiohomekit"
    },
    "split_keywords": [
        "homekit",
        "home",
        "automation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d700b373cb490bb91d6b136f79a455341736af1514b01166fe7bcc525fc00362",
                "md5": "2733fb900b26b0fcbd978377d67e6cb0",
                "sha256": "113a81030def5a69cc433f710b7ebc035dba7d0a88276537bb1a01669fb3698d"
            },
            "downloads": -1,
            "filename": "aiohomekit-3.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2733fb900b26b0fcbd978377d67e6cb0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 163149,
            "upload_time": "2024-02-27T18:27:00",
            "upload_time_iso_8601": "2024-02-27T18:27:00.568648Z",
            "url": "https://files.pythonhosted.org/packages/d7/00/b373cb490bb91d6b136f79a455341736af1514b01166fe7bcc525fc00362/aiohomekit-3.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4db4b5b990e193953ccf0461a618d09356be8a5b779bcd6c3e9ddad271832a6b",
                "md5": "5d11fb29129cf9ad4cdc35018b54e10e",
                "sha256": "241cb22bf1071387828767e174ca9c532d9c85b4264c3d314f6e888a9cf9abd8"
            },
            "downloads": -1,
            "filename": "aiohomekit-3.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "5d11fb29129cf9ad4cdc35018b54e10e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 121343,
            "upload_time": "2024-02-27T18:27:03",
            "upload_time_iso_8601": "2024-02-27T18:27:03.933483Z",
            "url": "https://files.pythonhosted.org/packages/4d/b4/b5b990e193953ccf0461a618d09356be8a5b779bcd6c3e9ddad271832a6b/aiohomekit-3.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-27 18:27:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Jc2k",
    "github_project": "aiohomekit",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "aiohomekit"
}
        
Elapsed time: 0.42981s