mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 05:31:55 +00:00
Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a561f8754 | ||
|
|
d9d58855cd | ||
|
|
3acded3ea2 | ||
|
|
8a35d75cb5 | ||
|
|
c70cb8be07 | ||
|
|
7406f6c9f3 | ||
|
|
cbae68afdd | ||
|
|
495143e1a1 | ||
|
|
7585cf3f83 | ||
|
|
d521755a49 | ||
|
|
6f4ce80aea | ||
|
|
efda0fac11 | ||
|
|
600760884d | ||
|
|
3a4830ee57 | ||
|
|
582e00a6ef | ||
|
|
debba05d2f | ||
|
|
027a693c0d | ||
|
|
b5e1fc52a8 | ||
|
|
f17fe59590 | ||
|
|
69e3ed5ee4 | ||
|
|
3354842e81 | ||
|
|
e5e2a400ec | ||
|
|
4884087041 | ||
|
|
e1867b2bc0 | ||
|
|
4d0f9d86f6 | ||
|
|
ecda18029f | ||
|
|
7acac442a8 | ||
|
|
efc570e5a9 | ||
|
|
7955049337 | ||
|
|
8c6cb53dcb | ||
|
|
b6cfe3ba7c | ||
|
|
f836d4a42c | ||
|
|
f893322887 | ||
|
|
63ab1025e9 | ||
|
|
9a25a363d4 | ||
|
|
dc43d0b7c4 | ||
|
|
1513e5398f | ||
|
|
7c3543ba61 | ||
|
|
5adb5f3282 | ||
|
|
ffe343c65f | ||
|
|
a2baa93801 | ||
|
|
8192fc2672 | ||
|
|
332385d605 | ||
|
|
41c53f8f10 | ||
|
|
4251b15291 | ||
|
|
3f2cd08383 | ||
|
|
c8cb0731ff | ||
|
|
39af2ebbef | ||
|
|
f73783787d | ||
|
|
b94c3caa3b | ||
|
|
1a710badef | ||
|
|
73fdec5928 | ||
|
|
911f088df9 | ||
|
|
6fade3c3cc | ||
|
|
191c75c281 | ||
|
|
1fb58be2b9 | ||
|
|
ca66cc3499 | ||
|
|
6ae2a19d37 | ||
|
|
ffe4232c3b | ||
|
|
fa9561d98a | ||
|
|
16a29f302d | ||
|
|
40fc7acbed |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,3 +10,5 @@ npm-debug.log
|
||||
# Ignore any extra plugins in the example directory that aren't in Git already
|
||||
# (this is a sandbox for the user)
|
||||
example-plugins
|
||||
|
||||
.idea
|
||||
11
README.md
11
README.md
@@ -1,5 +1,5 @@
|
||||
|
||||
[](https://homebridge-slackin.herokuapp.com)
|
||||
[](https://slackin-xiwztisllv.now.sh)
|
||||
|
||||
# Homebridge
|
||||
|
||||
@@ -49,7 +49,7 @@ Once you've installed a Plugin or two, you can run Homebridge again:
|
||||
|
||||
However, Homebridge won't do anything until you've created a `config.json` file containing your accessories and/or platforms. You can start by copying and modifying the included `config-sample.json` file which includes declarations for some example accessories and platforms. Each Plugin will have its own expected configuration; the documentation for Plugins should give you some real-world examples for that plugin.
|
||||
|
||||
**NOTE**: Your `config.json` file MUST be inside of `.homebridge`, which is inside of your home folder. On MacOS and Linux, the full path for your `config.json` would be `~/.homebridge/config.json`. Any error messages will contain the exact path where your config is expected to be found.
|
||||
**NOTE**: Your `config.json` file MUST be inside of `.homebridge`, which is inside of your home folder. On macOS and Linux, the full path for your `config.json` would be `~/.homebridge/config.json`. Any error messages will contain the exact path where your config is expected to be found.
|
||||
|
||||
**REALLY IMPORTANT**: You must use a "plain text" editor to create or modify `config.json`. Do NOT use apps like TextEdit on Mac or Wordpad on Windows. Apps like these will corrupt the formatting of the file in hard-to-debug ways, making improper `"` signs is an example. I suggest using the free [Atom text editor](http://atom.io).
|
||||
|
||||
@@ -150,6 +150,11 @@ The following errors are experienced when starting Homebridge and can be safely
|
||||
*** WARNING *** For more information see http://0pointerde/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister
|
||||
```
|
||||
|
||||
### Limitations
|
||||
|
||||
* One installation of Homebridge can only expose 100 accessories due to a HomeKit limit. You can however run multiple Homebridge instances by pointing them to different config and persistence paths (see issue #827).
|
||||
* Once an accessory has been added to the Home app, changing its name via Homebridge won't be automatically reflected in iOS. You must change it via the Home app as well.
|
||||
|
||||
# Why Homebridge?
|
||||
|
||||
Technically, the device manufacturers should be the ones implementing the HomeKit API. And I'm sure they will - eventually. When they do, this project will be obsolete, and I hope that happens soon. In the meantime, Homebridge is a fun way to get a taste of the future, for those who just can't bear to wait until "real" HomeKit devices are on the market.
|
||||
@@ -157,5 +162,3 @@ Technically, the device manufacturers should be the ones implementing the HomeKi
|
||||
# Credit
|
||||
|
||||
The original HomeKit API work was done by [KhaosT](http://twitter.com/khaost) in his [HAP-NodeJS](https://github.com/KhaosT/HAP-NodeJS) project.
|
||||
|
||||
|
||||
|
||||
@@ -190,6 +190,7 @@ SamplePlatform.prototype.addAccessory = function(accessoryName) {
|
||||
// To help restore accessory in configureAccessory()
|
||||
// newAccessory.context.something = "Something"
|
||||
|
||||
// Make sure you provided a name for service otherwise it may not visible in some HomeKit apps.
|
||||
newAccessory.addService(Service.Lightbulb, "Test Light")
|
||||
.getCharacteristic(Characteristic.On)
|
||||
.on('set', function(value, callback) {
|
||||
|
||||
@@ -5,6 +5,7 @@ var hapLegacyTypes = require("hap-nodejs/accessories/types.js");
|
||||
var log = require("./logger")._system;
|
||||
var User = require("./user").User;
|
||||
var PlatformAccessory = require("./platformAccessory").PlatformAccessory;
|
||||
var serverVersion = require("./version");
|
||||
|
||||
// The official homebridge API is the object we feed the plugin's exported initializer function.
|
||||
|
||||
@@ -20,7 +21,10 @@ function API() {
|
||||
this._dynamicPlatforms = {}; // this._dynamicPlatforms[pluginName.platformName] = platform constructor
|
||||
|
||||
// expose the homebridge API version
|
||||
this.version = 2.1;
|
||||
this.version = 2.2;
|
||||
|
||||
// expose the homebridge server version
|
||||
this.serverVersion = serverVersion;
|
||||
|
||||
// expose the User class methods to plugins to get paths. Example: homebridge.user.storagePath()
|
||||
this.user = User;
|
||||
|
||||
@@ -178,7 +178,7 @@ BridgeSetupSession.prototype.handleManageAccessory = function(request) {
|
||||
BridgeSetupSession.prototype.sendResponse = function(response) {
|
||||
if (this.validSession) {
|
||||
var serializedReponse = JSON.stringify(response);
|
||||
var respData = Buffer(serializedReponse).toString('base64');
|
||||
var respData = new Buffer(serializedReponse).toString('base64');
|
||||
this.lastResponse = respData;
|
||||
setTimeout(function() {
|
||||
this.controlChar.setValue(respData);
|
||||
|
||||
@@ -67,7 +67,7 @@ Logger.prototype.log = function(level, msg) {
|
||||
|
||||
// prepend timestamp
|
||||
var date = new Date();
|
||||
msg = "[" + date.toLocaleString() + "]" + " " + msg;
|
||||
msg = chalk.white("[" + date.toLocaleString() + "]") + " " + msg;
|
||||
|
||||
func(msg);
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ PlatformAccessory.prototype._dictionaryPresentation = function() {
|
||||
characteristicPresentation.UUID = characteristic.UUID;
|
||||
characteristicPresentation.props = characteristic.props;
|
||||
characteristicPresentation.value = characteristic.value;
|
||||
characteristicPresentation.eventOnlyCharacteristic = characteristic.eventOnlyCharacteristic;
|
||||
characteristics.push(characteristicPresentation);
|
||||
}
|
||||
|
||||
@@ -214,6 +215,7 @@ PlatformAccessory.prototype._configFromData = function(data) {
|
||||
for (var cIndex in service.characteristics) {
|
||||
var characteristic = service.characteristics[cIndex];
|
||||
var hapCharacteristic = new Characteristic(characteristic.displayName, characteristic.UUID, characteristic.props);
|
||||
hapCharacteristic.eventOnlyCharacteristic = characteristic.eventOnlyCharacteristic;
|
||||
hapCharacteristic.value = characteristic.value;
|
||||
characteristics.push(hapCharacteristic);
|
||||
}
|
||||
|
||||
@@ -119,9 +119,10 @@ Plugin.getDefaultPaths = function() {
|
||||
} else {
|
||||
paths.push('/usr/local/lib/node_modules');
|
||||
paths.push('/usr/lib/node_modules');
|
||||
const exec = require('child_process').execSync;
|
||||
paths.push(exec('/bin/echo -n "$(npm -g prefix)/lib/node_modules"').toString('utf8'));
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
@@ -165,10 +166,12 @@ Plugin.installed = function() {
|
||||
|
||||
// reconstruct full path
|
||||
var pluginPath = path.join(requirePath, name);
|
||||
|
||||
try {
|
||||
// we only care about directories
|
||||
if (!fs.statSync(pluginPath).isDirectory()) continue;
|
||||
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
// does this module contain a package.json?
|
||||
var pjson;
|
||||
try {
|
||||
|
||||
@@ -16,6 +16,7 @@ var BridgeSetupManager = require("./bridgeSetupManager").BridgeSetupManager;
|
||||
var log = require("./logger")._system;
|
||||
var Logger = require('./logger').Logger;
|
||||
var mac = require("./util/mac");
|
||||
var chalk = require('chalk');
|
||||
|
||||
'use strict';
|
||||
|
||||
@@ -23,7 +24,9 @@ module.exports = {
|
||||
Server: Server
|
||||
}
|
||||
|
||||
function Server(insecureAccess) {
|
||||
function Server(insecureAccess, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
// Setup Accessory Cache Storage
|
||||
accessoryStorage.initSync({ dir: User.cachedAccessoryPath() });
|
||||
|
||||
@@ -46,7 +49,7 @@ function Server(insecureAccess) {
|
||||
}.bind(this));
|
||||
|
||||
this._plugins = this._loadPlugins(); // plugins[name] = Plugin instance
|
||||
this._config = this._loadConfig();
|
||||
this._config = opts.config || this._loadConfig();
|
||||
this._cachedPlatformAccessories = this._loadCachedPlatformAccessories();
|
||||
this._bridge = this._createBridge();
|
||||
|
||||
@@ -473,7 +476,7 @@ Server.prototype._handlePublishCameraAccessories = function(accessories) {
|
||||
var advertiseAddress = mac.generate(accessory.UUID);
|
||||
|
||||
if (this._publishedCameras[advertiseAddress]) {
|
||||
throw new Error("Camera accessory %s experienced an address collision.", accessory.displayName);
|
||||
throw new Error("Camera accessory " + accessory.displayName + " experienced an address collision.");
|
||||
} else {
|
||||
this._publishedCameras[advertiseAddress] = accessory;
|
||||
}
|
||||
@@ -578,9 +581,9 @@ Server.prototype._handleNewConfig = function(type, name, replace, config) {
|
||||
// Returns the setup code in a scannable format.
|
||||
Server.prototype._printPin = function(pin) {
|
||||
console.log("Scan this code with your HomeKit App on your iOS device to pair with Homebridge:");
|
||||
console.log("\x1b[30;47m%s\x1b[0m", " ");
|
||||
console.log("\x1b[30;47m%s\x1b[0m", " ┌────────────┐ ");
|
||||
console.log("\x1b[30;47m%s\x1b[0m", " │ " + pin + " │ ");
|
||||
console.log("\x1b[30;47m%s\x1b[0m", " └────────────┘ ");
|
||||
console.log("\x1b[30;47m%s\x1b[0m", " ");
|
||||
console.log(chalk.black.bgWhite(" "));
|
||||
console.log(chalk.black.bgWhite(" ┌────────────┐ "));
|
||||
console.log(chalk.black.bgWhite(" │ " + pin + " │ "));
|
||||
console.log(chalk.black.bgWhite(" └────────────┘ "));
|
||||
console.log(chalk.black.bgWhite(" "));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "homebridge",
|
||||
"description": "HomeKit support for the impatient",
|
||||
"version": "0.4.6",
|
||||
"version": "0.4.22",
|
||||
"scripts": {
|
||||
"dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true"
|
||||
},
|
||||
@@ -26,7 +26,7 @@
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.1",
|
||||
"commander": "2.8.1",
|
||||
"hap-nodejs": "0.4.11",
|
||||
"hap-nodejs": "0.4.27",
|
||||
"semver": "5.0.3",
|
||||
"node-persist": "^0.0.8"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user