skillfed

HAP-python

HomeKit Accessory Protocol implementation in python

hap-python v5.0.0 88.8K downloads/30d#13,706 on PyPI669
Permissive license Apache-2.0 AGING released

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-python

uv

uv add hap-python

poetry

poetry add hap-python

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: End Users/DesktopNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Home AutomationTopic :: Software Development :: Libraries :: Python Modules

Tags

homekit accessory protocol pythonapple home app integrationsmart home device pythonhomekit python librarylocal network home automationsiri voice control deviceshomekit camera streaming
homekitsmart-homeasyncio

More Python Modules packages