aiohomekit

raw JSON →
3.2.20 verified Fri May 01 auth: no python

An asyncio-based HomeKit client library for Python. Version 3.2.20, actively maintained, with frequent releases following HomeKit protocol updates.

pip install aiohomekit
error ImportError: cannot import name 'HomeKitController' from 'aiohomekit'
cause Class renamed in v3.0.
fix
Use from aiohomekit import Controller instead.
error AttributeError: module 'aiohomekit' has no attribute 'discover'
cause Discover is a method on Controller, not a top-level function.
fix
Create a Controller instance and call await controller.discover().
breaking In version 3.0, the API was rewritten. The old `HomeKitController` class was removed; use `Controller` instead. The `pair` and `list_accessories` methods changed signature.
fix Use `from aiohomekit import Controller` and consult the 3.0 migration guide.
deprecated The `async def discover()` method returns a list of `DiscoverableDevice` objects instead of raw dicts as in older versions.
fix Access attributes like `dev.description` directly.
gotcha The `Controller` must be started with `await controller.start()` before any discovery or pairing operations. Forgetting this results in no devices found.
fix Always call `await controller.start()` in your async setup.

Creates a Controller, starts discovery, prints discovered HomeKit accessories.

import asyncio
from aiohomekit import Controller

async def main():
    controller = Controller()
    await controller.start()
    # Discover devices
    discoveries = await controller.discover()
    for dev in discoveries:
        print(dev.description)
    await controller.stop()

asyncio.run(main())