HAP-python
HomeKit Accessory Protocol implementation in python
What it is and what it does
HAP-python is a Python implementation of Apple's HomeKit Accessory Protocol that lets you turn any Python-capable device into a HomeKit-compatible smart home accessory. You define accessories by subclassing Accessory, add services like TemperatureSensor or Lightbulb with their characteristics, and let the AccessoryDriver handle the HAP server, local network advertising via mDNS, and secure pairing. The library supports asyncio for concurrent operations and includes out-of-the-box definitions for Apple-defined services.
The package is built on six core dependencies: async_timeout for timeout handling, cryptography and chacha20poly1305-reuseable for secure pairing, orjson for efficient JSON serialization, zeroconf for mDNS advertising, and h11 for HTTP/1.1 protocol handling. It's designed to run on resource-constrained devices like Raspberry Pi but works on any platform with Python 3.9+. Once running, your accessory appears in the Home app, can be controlled via the Home app UI, and responds to Siri voice commands.
Use it for:
- Build a temperature or humidity sensor that reports readings to the Home app periodically
- Create a smart light or switch that can be toggled from the Home app or controlled by Siri
- Stream video from a camera accessory to HomeKit clients with negotiated resolution and audio
- Run multiple accessories in a single process using asyncio for concurrent state management
- Integrate existing IoT devices or GPIO-based hardware into HomeKit without a separate bridge
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
HAP-python implements the HomeKit Accessory Protocol, letting you create smart home accessories that integrate with Apple's Home app and respond to Siri commands over a local network.
Yes, if you want to add HomeKit support to a Python project on a local network. The library is stable and production-ready, with low install friction and permissive licensing. The aging maintenance status (354 days since last release) is a minor concern for new features but not a blocker for existing functionality. Requires system-level Avahi/Bonjour setup and Python 3.9+.
Install
hap-python on PyPI
pip
pip install hap-pythonuv
uv add hap-pythonpoetry
poetry add hap-pythonInstalling HAP-python
Before you install
Low install friction with a pure-wheel distribution. Maintenance is aging—last release was 354 days ago—but the project remains active with recent commits and stable production status. Requires Avahi/Bonjour system library (libavahi-compat-libdnssd-dev on Raspberry Pi).
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions, making it safe for both hobby and production smart home projects.
Quickstart
pip3 install HAP-python[QRCode]
from pyhap.accessory import Accessory, Category
class MyAccessory(Accessory):
category = Category.SENSOR
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
service = self.add_preload_service('TemperatureSensor')
self.temp = service.get_characteristic('CurrentTemperature')
Requires Avahi/Bonjour system library; on Raspberry Pi install libavahi-compat-libdnssd-dev first. Minimum Python 3.9.
Verify before relying
- Whether camera streaming works reliably with modern ffmpeg versions and various platforms
- Current state of Home Assistant integration and whether it remains actively maintained
- Performance and stability under high accessory counts or frequent state changes
- Specific port and network configuration requirements for AccessoryDriver setup
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — async_timeout, cryptography, chacha20poly1305-reuseable, orjson, zeroconf, h11 |
| Maintenance | aging — 354 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 88,777/month — #13,706 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: hap_python-5.0.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
aiohomekitAn asyncio-based HomeKit client library for…
permissive · top 15,000 on PyPI
homeassistantHome Assistant is an open-source home…
permissive · top 5,000 on PyPI
ha-ffmpegProvides an asyncio-based Python interface to…
permissive · top 15,000 on PyPI
pyobjc-framework-ExternalAccessoryProvides Python bindings to macOS's…
permissive · top 15,000 on PyPI
airthings-cloudA Python library for communicating with…
permissive · top 15,000 on PyPI
aioslimprotoAsync Python implementation of the SLIMProto…
permissive · top 15,000 on PyPI
pigpioProvides Python access to the pigpio daemon for…
permissive · top 15,000 on PyPI
pyhiveapiA Python library for controlling Hive smart…
permissive · top 15,000 on PyPI
aiohueAsynchronous Python library for controlling…
permissive · top 15,000 on PyPI
pytapoPyTapo is a Python library that communicates…
permissive · top 15,000 on PyPI