8 Commits

Author SHA1 Message Date
Khaos Tian
2ea2052769 0.3.1 2016-03-10 20:19:47 -08:00
Khaos Tian
64e8c83d9c Update hap-nodejs 2016-03-10 20:19:42 -08:00
Nick Farina
13333999f3 Update README.md 2016-03-07 14:43:16 -08:00
Nick Farina
87c48d7267 Update README.md 2016-03-07 14:42:28 -08:00
Nick Farina
9b42fafdaf Add README example for plugin development 2016-03-07 11:49:13 -08:00
Khaos Tian
842ec105be Merge pull request #554 from Danimal4326/master
Prepend date/time to logger messages
2016-03-03 10:29:29 -08:00
Danimal4326
df8508a38f Prepend date/time to logger messages 2016-03-03 12:24:54 -06:00
Khaos Tian
9d7c1de9dd Update readme to reflect new API system 2016-03-01 18:41:29 -08:00
3 changed files with 26 additions and 6 deletions

View File

@@ -101,18 +101,32 @@ One final thing to remember is that Siri will almost always prefer its default p
We don't have a lot of documentation right now for creating plugins, but there are many existing plugins you can study. We don't have a lot of documentation right now for creating plugins, but there are many existing plugins you can study.
The best place to start is the included [Example Plugins](https://github.com/nfarina/homebridge/tree/master/example-plugins). Right now this contains a single plugin that registers a fake door lock Accessory. This will show you how to use the Homebridge Plugin API. The best place to start is the included [Example Plugins](https://github.com/nfarina/homebridge/tree/master/example-plugins). Right now this contains a single plugin that registers a platform that offers fake light accessories. This will show you how to use the Homebridge Plugin API.
For more example on how to construct HomeKit Services and Characteristics, see the many Accessories in the [Legacy Plugins](https://github.com/nfarina/homebridge-legacy-plugins/tree/master/accessories) repository. For more example on how to construct HomeKit Services and Characteristics, see the many Accessories in the [Legacy Plugins](https://github.com/nfarina/homebridge-legacy-plugins/tree/master/accessories) repository.
You can also view the [full list of supported HomeKit Services and Characteristics in the HAP-NodeJS protocol repository](https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js). You can also view the [full list of supported HomeKit Services and Characteristics in the HAP-NodeJS protocol repository](https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js).
There isn't currently an example for how to publish a Platform (which allows the user to bridge many discovered devices at once, like a house full of smart lightbulbs), but the process is almost identical to registering an Accessory. Simply modify the example `index.js` in [homebridge-lockitron](https://github.com/nfarina/homebridge/tree/master/example-plugins/homebridge-lockitron) to say something like: And you can find an example plugin that publishes an individual accessory at [here](https://github.com/nfarina/homebridge/tree/6500912f54a70ff479e63e2b72760ab589fa558a/example-plugins/homebridge-lockitron).
homebridge.registerPlatform("homebridge-myplugin", "MyPlatform", MyPlatform);
See more examples on how to create Platform classes in the [Legacy Plugins](https://github.com/nfarina/homebridge-legacy-plugins/tree/master/platforms) repository. See more examples on how to create Platform classes in the [Legacy Plugins](https://github.com/nfarina/homebridge-legacy-plugins/tree/master/platforms) repository.
# Plugin Development
When writing your plugin, you'll want Homebridge to load it from your development directory instead of publishing it to `npm` each time. You can tell Homebridge to look for your plugin at a specific location using the command-line parameter `-P`. For example, if you are in the Homebridge directory (as checked out from Github), you might type:
```sh
DEBUG=* ./bin/homebridge -D -P ../my-great-plugin/
```
This will start up Homebridge and load your in-development plugin from a nearby directory. Note that you can also direct Homebridge to load your configuration from somewhere besides the default `~/.homebridge`, for example:
```sh
DEBUG=* ./bin/homebridge -D -U ~/.homebridge-dev -P ../my-great-plugin/
```
This is very useful when you are already using your development machine to host a "real" Homebridge instance (with all your accessories) that you don't want to disturb.
# Common Issues # Common Issues
### My iOS App Can't Find Homebridge ### My iOS App Can't Find Homebridge
@@ -143,3 +157,5 @@ Technically, the device manufacturers should be the ones implementing the HomeKi
# Credit # 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. The original HomeKit API work was done by [KhaosT](http://twitter.com/khaost) in his [HAP-NodeJS](https://github.com/KhaosT/HAP-NodeJS) project.

View File

@@ -65,6 +65,10 @@ Logger.prototype.log = function(level, msg) {
if (this.prefix) if (this.prefix)
msg = chalk.cyan("[" + this.prefix + "]") + " " + msg; msg = chalk.cyan("[" + this.prefix + "]") + " " + msg;
// prepend timestamp
var date = new Date();
msg = chalk.black("[" + date.toLocaleString() + "]") + " " + msg;
func(msg); func(msg);
} }

View File

@@ -1,7 +1,7 @@
{ {
"name": "homebridge", "name": "homebridge",
"description": "HomeKit support for the impatient", "description": "HomeKit support for the impatient",
"version": "0.3.0", "version": "0.3.1",
"scripts": { "scripts": {
"dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true" "dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true"
}, },
@@ -26,7 +26,7 @@
"dependencies": { "dependencies": {
"chalk": "^1.1.1", "chalk": "^1.1.1",
"commander": "2.8.1", "commander": "2.8.1",
"hap-nodejs": "0.2.6", "hap-nodejs": "0.2.7",
"semver": "5.0.3", "semver": "5.0.3",
"node-persist": "^0.0.8" "node-persist": "^0.0.8"
} }