-
Notifications
You must be signed in to change notification settings - Fork 42
HomeKit Controller API
This page will describe the stable API for working as a Homekit controller with this python module.
The HomeKit Controller Api will cover the following use cases:
- discover HomeKit enabled devices
- identify unpaired and paired HomeKit devices
- pair HomeKit devices
- read out the HomeKit accessories of a device
- read out one or more characteristics of a accessory
- write back one or more characteristics of a accessory
- register for events send back by the accessory
- remove the pairing with a device
Wifi only at the moment!
The use cases are split onto two main classes. These are shown in the class diagram below:

To make handling of paired accessories easier, pairings will have an alias as a shortcut.
This class replaces the iOS Device acting as Controller in the typical scenario.
This method uses Bonjour / Zeroconf technology to gather HomeKit Accessories from within the same IP network.
-
max_seconds(default: 10): how many seconds is the inquiry running. After that time the result is prepared and returned.
The method returns a list of the discovered devices. The devices are represented by dicts that contain the following keys:
-
name: the Bonjour name of the HomeKit accessory (i.e. Testsensor1._hap._tcp.local.) -
address: the IP address of the accessory -
port: the used IP port -
c#: the configuration number -
ff/flags: the numerical and human readable version of the feature flags (supports pairing or not, see table 5-8 page 69 or homekit.model.FeatureFlags) -
id: the accessory's pairing id -
md: the model name of the accessory -
pv: the protocol version -
s#: the current state number -
sf: the status flag (see table 5-9 page 70) -
ci/category: the category identifier in numerical and human readable form. For more information see table 12-3 page 254 or homekit.model.Categories
This method is used to trigger the identification of an unpaired HomeKit Accessory. It is depending on the device how this call is handled.
-
accessory_id: the HomeKit accessory's pairing id (fieldidof the results ofdiscover)
This method does not return anything but raises a AccessoryNotFoundException if no device could be looked up via
Bonjour.
This method loads previously stored data about the pairings known to this controller. Should be performed after all
methods that change pairing information (perform_pairing and remove_pairing).
-
filename: The file that should be loaded.
This method does not return anything but raises ConfigLoadingException on any error while loading the data.
This method saves data about the pairings known to this controller to a file. Should be performed at the beginning of a program that uses the controller.
-
filename: The file that should be saved.
This method does not return anything but raises ConfigSavingException on any error while loading the data.
This class represents the pairing between the controller and a HomeKit accessory.