Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.
/ hapclient Public archive

Python library to implement a HAP (HomeKit) controller

Notifications You must be signed in to change notification settings

mrstegeman/hapclient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hapclient

With this code it is possible to implement a HomeKit Controller. This code was originally forked from: https://github.com/jlusiardi/homekit_python

Limitations

  • This code only works with HomeKit IP Accessories.
  • The events interface is not implemented.

The code in this repository was created based on release R1 from 2017-06-07.

Installation

Use pip3 to install the package:

pip3 install --user hapclient

HomeKit Controller

To implement a simple HomeKit controller, you can do the following:

from hapclient.client import HapClient
import json

# Find available devices.
devices = HapClient.discover()
print(json.dumps(devices, indent=2))

# Select a device
device = devices[0]

# Create a client
client = HapClient(device['id'],
                   address=device['address'],
                   port=device['port'])

# Pair with the device
pin = '123-45-678'  # replace this with your PIN
client.pair(pin)

# Print out the pairing data and save it somewhere, as you'll need it.
# The next time you create a HapClient, you won't be able to pair (since you've
# already done so, so instead, you'll pass in this dict as
# `pairing_data=<dict>`.
print(json.dumps(client.pairing_data, indent=2))

# List some things
print(json.dumps(client.get_accessories(), indent=2))
print(json.dumps(client.get_characteristics(['1.11']), indent=2))

# Set a characteristic
client.set_characteristics({'1.11': False})

# If you want to unpair, do the following:
client.unpair()

Tests

The code was tested with the following devices:

About

Python library to implement a HAP (HomeKit) controller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages