From f203a2ac6f0c1f085e184410522f94e28142ac29 Mon Sep 17 00:00:00 2001 From: Marci Date: Thu, 31 Mar 2016 15:50:50 +0100 Subject: [PATCH 1/8] Ref #582 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref#582 Add ‘--unsafe-perm’ flag to npm install command to get round all the .gyp warns etc. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc96ba9..d4ec52b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ You can also chat with us in our nascent [Slack instance](http://homebridge-slac Homebridge is published through [NPM](https://www.npmjs.com/package/homebridge) and should be installed "globally" by typing: - sudo npm install -g homebridge + sudo npm install -g --unsafe-perm homebridge Now you should be able to run Homebridge: From e6648375c7b92336c90f05765726008756df7f11 Mon Sep 17 00:00:00 2001 From: Edgar To Date: Sun, 24 Jul 2016 22:38:05 +0200 Subject: [PATCH 2/8] different add times will create different UUIDs -> no crash with the second add call --- example-plugins/homebridge-samplePlatform/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/example-plugins/homebridge-samplePlatform/index.js b/example-plugins/homebridge-samplePlatform/index.js index 353513e..71315b2 100644 --- a/example-plugins/homebridge-samplePlatform/index.js +++ b/example-plugins/homebridge-samplePlatform/index.js @@ -28,7 +28,7 @@ function SamplePlatform(log, config, api) { this.requestServer = http.createServer(function(request, response) { if (request.url === "/add") { - this.addAccessory(); + this.addAccessory(new Date().toISOString()); response.writeHead(204); response.end(); } @@ -176,10 +176,6 @@ SamplePlatform.prototype.addAccessory = function(accessoryName) { console.log("Add Accessory"); var uuid; - if (!accessoryName) { - accessoryName = "Test Accessory" - } - uuid = UUIDGen.generate(accessoryName); var newAccessory = new Accessory(accessoryName, uuid); @@ -216,4 +212,4 @@ SamplePlatform.prototype.removeAccessory = function() { this.api.unregisterPlatformAccessories("homebridge-samplePlatform", "SamplePlatform", this.accessories); this.accessories = []; -} \ No newline at end of file +} From 15c8eaaf29c54fa0441d831d86f47b442630aefc Mon Sep 17 00:00:00 2001 From: Edgar To Date: Sun, 24 Jul 2016 22:43:21 +0200 Subject: [PATCH 3/8] use of the own log method instead of the general console.log(); added accessory.displayName to the log output if possible/ useful --- .../homebridge-samplePlatform/index.js | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/example-plugins/homebridge-samplePlatform/index.js b/example-plugins/homebridge-samplePlatform/index.js index 353513e..0ab4b50 100644 --- a/example-plugins/homebridge-samplePlatform/index.js +++ b/example-plugins/homebridge-samplePlatform/index.js @@ -21,7 +21,8 @@ module.exports = function(homebridge) { // config may be null // api may be null if launched from old homebridge version function SamplePlatform(log, config, api) { - console.log("SamplePlatform Init"); + log("SamplePlatform Init"); + var platform = this; this.log = log; this.config = config; this.accessories = []; @@ -47,7 +48,7 @@ function SamplePlatform(log, config, api) { }.bind(this)); this.requestServer.listen(18081, function() { - console.log("Server Listening..."); + platform.log("Server Listening..."); }); if (api) { @@ -58,7 +59,7 @@ function SamplePlatform(log, config, api) { // Platform Plugin should only register new accessory that doesn't exist in homebridge after this event. // Or start discover new accessories this.api.on('didFinishLaunching', function() { - console.log("Plugin - DidFinishLaunching"); + platform.log("DidFinishLaunching"); }.bind(this)); } } @@ -67,7 +68,8 @@ function SamplePlatform(log, config, api) { // Developer can configure accessory at here (like setup event handler) // Update current value SamplePlatform.prototype.configureAccessory = function(accessory) { - console.log("Plugin - Configure Accessory: " + accessory.displayName); + this.log(accessory.displayName, "Configure Accessory"); + var platform = this; // set the accessory to reachable if plugin can currently process the accessory // otherwise set to false and update the reachability later by invoking @@ -75,7 +77,7 @@ SamplePlatform.prototype.configureAccessory = function(accessory) { accessory.reachable = true; accessory.on('identify', function(paired, callback) { - console.log("Identify!!!"); + platform.log(accessory.displayName, "Identify!!!"); callback(); }); @@ -83,7 +85,7 @@ SamplePlatform.prototype.configureAccessory = function(accessory) { accessory.getService(Service.Lightbulb) .getCharacteristic(Characteristic.On) .on('set', function(value, callback) { - console.log("Light -> " + value); + platform.log(accessory.displayName, "Light -> " + value); callback(); }); } @@ -94,8 +96,8 @@ SamplePlatform.prototype.configureAccessory = function(accessory) { //Handler will be invoked when user try to config your plugin //Callback can be cached and invoke when nessary SamplePlatform.prototype.configurationRequestHandler = function(context, request, callback) { - console.log("Context: ", JSON.stringify(context)); - console.log("Request: ", JSON.stringify(request)); + this.log("Context: ", JSON.stringify(context)); + this.log("Request: ", JSON.stringify(request)); // Check the request response if (request && request.response && request.response.inputs && request.response.inputs.name) { @@ -173,7 +175,8 @@ SamplePlatform.prototype.configurationRequestHandler = function(context, request // Sample function to show how developer can add accessory dynamically from outside event SamplePlatform.prototype.addAccessory = function(accessoryName) { - console.log("Add Accessory"); + this.log("Add Accessory"); + var platform = this; var uuid; if (!accessoryName) { @@ -184,7 +187,7 @@ SamplePlatform.prototype.addAccessory = function(accessoryName) { var newAccessory = new Accessory(accessoryName, uuid); newAccessory.on('identify', function(paired, callback) { - console.log("Identify!!!"); + platform.log(accessory.displayName, "Identify!!!"); callback(); }); // Plugin can save context on accessory @@ -194,7 +197,7 @@ SamplePlatform.prototype.addAccessory = function(accessoryName) { newAccessory.addService(Service.Lightbulb, "Test Light") .getCharacteristic(Characteristic.On) .on('set', function(value, callback) { - console.log("Light -> " + value); + platform.log(accessory.displayName, "Light -> " + value); callback(); }); @@ -203,7 +206,7 @@ SamplePlatform.prototype.addAccessory = function(accessoryName) { } SamplePlatform.prototype.updateAccessoriesReachability = function() { - console.log("Update Reachability"); + this.log("Update Reachability"); for (var index in this.accessories) { var accessory = this.accessories[index]; accessory.updateReachability(false); @@ -212,8 +215,8 @@ SamplePlatform.prototype.updateAccessoriesReachability = function() { // Sample function to show how developer can remove accessory dynamically from outside event SamplePlatform.prototype.removeAccessory = function() { - console.log("Remove Accessory"); + this.log("Remove Accessory"); this.api.unregisterPlatformAccessories("homebridge-samplePlatform", "SamplePlatform", this.accessories); this.accessories = []; -} \ No newline at end of file +} From 5944365bc65b4cb827f6fc795d4407a3cbf014f1 Mon Sep 17 00:00:00 2001 From: cflurin Date: Tue, 6 Sep 2016 14:49:53 +0200 Subject: [PATCH 4/8] Warning config.json not found --- lib/server.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/server.js b/lib/server.js index 0fc54d0..e702cdb 100644 --- a/lib/server.js +++ b/lib/server.js @@ -150,6 +150,8 @@ Server.prototype._loadConfig = function() { // Complain and exit if it doesn't exist yet if (!fs.existsSync(configPath)) { + log.warn("config.json (%s) not found.", configPath); + var config = {}; config.bridge = { From 4740bf1fc5afae62bb481b0f135833969c833ae8 Mon Sep 17 00:00:00 2001 From: Alessio Dionisi Date: Tue, 13 Sep 2016 13:54:37 +0200 Subject: [PATCH 5/8] New bridge configs "bridge": { "manufacturer": "Manufacturer here", "serialNumber": "Serial number here", "model": "Model here" } --- lib/server.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/server.js b/lib/server.js index e702cdb..2bf84c1 100644 --- a/lib/server.js +++ b/lib/server.js @@ -87,6 +87,14 @@ Server.prototype.run = function() { Server.prototype._publish = function() { // pull out our custom Bridge settings from config.json, if any var bridgeConfig = this._config.bridge || {}; + + var info = this._bridge.getService(Service.AccessoryInformation); + if (bridgeConfig.manufacturer) + info.setCharacteristic(Characteristic.Manufacturer, bridgeConfig.manufacturer); + if (bridgeConfig.model) + info.setCharacteristic(Characteristic.Model, bridgeConfig.model); + if (bridgeConfig.serialNumber) + info.setCharacteristic(Characteristic.SerialNumber, bridgeConfig.serialNumber); this._printPin(bridgeConfig.pin); this._bridge.publish({ From d70fa741d8870c36c01f94f769cb010b79a69086 Mon Sep 17 00:00:00 2001 From: Kevin Jonson Date: Thu, 15 Sep 2016 14:07:09 -0700 Subject: [PATCH 6/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8e4af30..cb7d2b3 100644 --- a/README.md +++ b/README.md @@ -83,9 +83,9 @@ You can explore all available plugins at the NPM website by [searching for the k # Adding Homebridge to iOS -HomeKit is actually not an app; it's a "database" similar to HealthKit and PassKit. But where HealthKit has the companion _Health_ app and PassKit has _Passbook_, Apple has supplied no app for managing your HomeKit database (at least [not yet](http://9to5mac.com/2015/05/20/apples-planned-ios-9-home-app-uses-virtual-rooms-to-manage-homekit-accessories/)). However, the HomeKit API is open for developers to write their own apps for adding devices to HomeKit. +HomeKit itself is actually not an app; it's a "database" similar to HealthKit and PassKit. Where HealthKit has the companion _Health_ app and PassKit has _Passbook_, Apple simply built _Home_ which was release with iOS 10 -Fortunately, there are now a few apps in the App Store that can manage your HomeKit devices. The most comprehensive one I've used is [MyTouchHome](https://itunes.apple.com/us/app/mytouchhome/id965142360?mt=8&at=11lvmd&ct=mhweb) which costs $2. +There are also a few 3rd party apps in the App Store that can manage your HomeKit devices. The most comprehensive one I've used is [MyTouchHome](https://itunes.apple.com/us/app/mytouchhome/id965142360?mt=8&at=11lvmd&ct=mhweb) which costs $2. There are also some free apps that work OK. Try [Insteon+](https://itunes.apple.com/US/app/id919270334?mt=8) or [Lutron](https://itunes.apple.com/us/app/lutron-app-for-caseta-wireless/id886753021?mt=8) or a number of others. From f49229d73cdca74d7fd6bd5bce2c744acc77e67e Mon Sep 17 00:00:00 2001 From: Nick Farina Date: Thu, 15 Sep 2016 21:05:39 -0700 Subject: [PATCH 7/8] Update README to reflect the new iOS 10 Home app. --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cb7d2b3..74f3992 100644 --- a/README.md +++ b/README.md @@ -83,15 +83,11 @@ You can explore all available plugins at the NPM website by [searching for the k # Adding Homebridge to iOS -HomeKit itself is actually not an app; it's a "database" similar to HealthKit and PassKit. Where HealthKit has the companion _Health_ app and PassKit has _Passbook_, Apple simply built _Home_ which was release with iOS 10 +HomeKit itself is actually not an app; it's a "database" similar to HealthKit and PassKit. Where HealthKit has the companion _Health_ app and PassKit has _Passbook_, HomeKit has the _Home_ app, introduced with iOS 10. -There are also a few 3rd party apps in the App Store that can manage your HomeKit devices. The most comprehensive one I've used is [MyTouchHome](https://itunes.apple.com/us/app/mytouchhome/id965142360?mt=8&at=11lvmd&ct=mhweb) which costs $2. +If you are a member of the iOS developer program, you might also find Apple's [HomeKit Catalog](https://developer.apple.com/library/ios/samplecode/HomeKitCatalog/Introduction/Intro.html) app to be useful, as it provides straightforward and comprehensive management of all HomeKit database "objects". -There are also some free apps that work OK. Try [Insteon+](https://itunes.apple.com/US/app/id919270334?mt=8) or [Lutron](https://itunes.apple.com/us/app/lutron-app-for-caseta-wireless/id886753021?mt=8) or a number of others. - -If you are a member of the iOS developer program, I highly recommend Apple's [HomeKit Catalog](https://developer.apple.com/library/ios/samplecode/HomeKitCatalog/Introduction/Intro.html) app, as it is reliable and comprehensive and free (and open source). - -Once you've gotten a HomeKit app running on your iOS device, it should "discover" the single accessory "Homebridge", assuming that you're still running Homebridge and you're on the same Wifi network. Adding this accessory will automatically add all accessories and platforms defined in `config.json`. +Using the Home app (or most other HomeKit apps), you should be able to add the single accessory "Homebridge", assuming that you're still running Homebridge and you're on the same Wifi network. Adding this accessory will automatically add all accessories and platforms defined in `config.json`. When you attempt to add Homebridge, it will ask for a "PIN code". The default code is `031-45-154` (but this can be changed, see `config-sample.json`). From 8c476b45a0819affb1ddf9b8fdc39b91f9bbbed1 Mon Sep 17 00:00:00 2001 From: Nathan Robinson Date: Sun, 18 Sep 2016 21:13:38 -0400 Subject: [PATCH 8/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 74f3992..d7706b5 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,9 @@ 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 live in your home directory inside `.homebridge`. The full error message 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; these apps will corrupt the formatting of the file in hard-to-debug ways. I suggest using the free [Atom text editor](http://atom.io). +**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). Once you've added your config file, you should be able to run Homebridge again: