Giter Club home page Giter Club logo

homekit's Introduction

HomeKit homekit

A HomeKit Accessory implementation in Node.js

Installation

$ npm i homekit

Note:

On Linux and other systems using the avahi daemon the avahi dns_sd compat library and its header files are required. On debianesque systems the package name is libavahi-compat-libdnssd-dev. On other platforms Apple's mDNSResponder is recommended. Care should be taken not to install more than one mDNS stack on a system.

On Windows you are going to need Apples "Bonjour SDK for Windows". You can download it either from Apple (registration required) or various unofficial sources. Take your pick. After installing the SDK restart your shell or command prompt and make sure the BONJOUR_SDK_HOME environment variable is set. You'll also need a compiler. Microsoft Visual Studio Express will do. On Windows node >=0.7.9 is required.

sudo apt-get install avahi-daemon avahi-discover libnss-mdns libavahi-compat-libdnssd-dev

Example

const HomeKit = require('homekit');

const uuid = HomeKit.UUID.generate("homekit:yeelight");
const acce = new HomeKit.Accessory('Simple Light', uuid);

acce.on('identify', function(paired, callback) {
  console.log("Identify!");
  callback(); // success
});

acce
.addService(HomeKit.Service.Lightbulb, 'Yeelight')
.getCharacteristic(HomeKit.Characteristic.On)
.on('set', function(value, callback) {
  light.set_power(value, callback);
})

// Publish the Accessory on the local network.
acce.publish({
  port    : 51826,
  username: "CC:22:3D:E3:CE:F6",
  pincode : "031-45-154"
});

Contributing

  • Fork this Repo first
  • Clone your Repo
  • Install dependencies by $ npm install
  • Checkout a feature branch
  • Feel free to add your features
  • Make sure your features are fully tested
  • Publish your local branch, Open a pull request
  • Enjoy hacking <3

MIT

Copyright (c) 2016 Lsong <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


homekit's People

Contributors

gpmcadam avatar matkappert avatar song940 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

homekit's Issues

multiple devices

Hello,

Can I create multiple devices using the same code ?

It seems I can only generate one device ...

Thx

WindowCovering keeps waiting

Hello, I'm trying to set up my window covering. But I'm not getting them to work completely. Since there is no example of this service, I have my accessory set up the way all the over examples are set up.

The coverage do appear in my Home app, but when I tap it to open or close, it keeps thinking and eventually nothing happens. So this is my code .. Also both console logs '1' and '3' never appear in the log. '2' plus it's correct value DO appear.

var blinds = new Accessory ('blinds', UUID.generate ('homekit:blinds'));
...
blinds
    .addService (Service.WindowCovering, BlindsController.name)
    .getCharacteristic (Characteristic.CurrentPosition)
    .on ('get', (callback) => {
        console.log (1);
        callback (null, BlindsController.tilt);
    });

blinds
    .getService (Service.WindowCovering)
    .getCharacteristic (Characteristic.TargetPosition)
    .on ('set', (value, callback) => {
        console.log (2, value);
        BlindsController.setTilt (value);
        callback (); /* sync */
    });

blinds
    .getService (Service.WindowCovering)
    .getCharacteristic (Characteristic.PositionState)
    .on ('get', (callback) => {
        console.log (3);
        callback (null, BlindsController.tilt); /* sync */
    });

Am I doing something wrong or did I ran into a bug?
Thanks in advance! 👍

Error when creating const HomeKit

I have seemingly followed the instructions that you have provided but am hit with this error when running the example code provided:

/home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/bindings/bindings.js:91
throw err
^

Error: Could not locate the bindings file. Tried:
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/build/ed25519.node
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/build/Debug/ed25519.node
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/build/Release/ed25519.node
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/out/Debug/ed25519.node
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/Debug/ed25519.node
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/out/Release/ed25519.node
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/Release/ed25519.node
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/build/default/ed25519.node
→ /home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/compiled/4.2.6/linux/x64/ed25519.node
at bindings (/home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/bindings/bindings.js:88:9)
at Object. (/home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/ed25519/index.js:1:99)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/jamesubuntuvm/Desktop/projects/homekittest/node_modules/homekit/lib/HAPServer.js:5:27)
at Module._compile (module.js:410:26)

Two Bug

First, node-persist as storage is not initialization, I cost many time to debug it
the second, the cache system is not work well, this._cache = {} is not initialization,it show undefined type when running

at the last, the project is not work very well, did you test it before you publish it?

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.