Code Monkey home page Code Monkey logo

hapclient's Introduction

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:

hapclient's People

Contributors

jlusiardi avatar mrstegeman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.