mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-03 22:04:23 +01:00
Add a example to use "identify" event
This commit is contained in:
@@ -74,6 +74,10 @@ SamplePlatform.prototype.configureAccessory = function(accessory) {
|
|||||||
// accessory.updateReachability()
|
// accessory.updateReachability()
|
||||||
accessory.reachable = true;
|
accessory.reachable = true;
|
||||||
|
|
||||||
|
accessory.on('identify', function() {
|
||||||
|
console.log("Identify!!!");
|
||||||
|
});
|
||||||
|
|
||||||
if (accessory.getService(Service.Lightbulb)) {
|
if (accessory.getService(Service.Lightbulb)) {
|
||||||
accessory.getService(Service.Lightbulb)
|
accessory.getService(Service.Lightbulb)
|
||||||
.getCharacteristic(Characteristic.On)
|
.getCharacteristic(Characteristic.On)
|
||||||
@@ -178,7 +182,9 @@ SamplePlatform.prototype.addAccessory = function(accessoryName) {
|
|||||||
uuid = UUIDGen.generate(accessoryName);
|
uuid = UUIDGen.generate(accessoryName);
|
||||||
|
|
||||||
var newAccessory = new Accessory(accessoryName, uuid);
|
var newAccessory = new Accessory(accessoryName, uuid);
|
||||||
|
newAccessory.on('identify', function() {
|
||||||
|
console.log("Identify!!!");
|
||||||
|
});
|
||||||
// Plugin can save context on accessory
|
// Plugin can save context on accessory
|
||||||
// To help restore accessory in configureAccessory()
|
// To help restore accessory in configureAccessory()
|
||||||
// newAccessory.context.something = "Something"
|
// newAccessory.context.something = "Something"
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ var uuid = require("hap-nodejs").uuid;
|
|||||||
var Accessory = require("hap-nodejs").Accessory;
|
var Accessory = require("hap-nodejs").Accessory;
|
||||||
var Service = require("hap-nodejs").Service;
|
var Service = require("hap-nodejs").Service;
|
||||||
var Characteristic = require("hap-nodejs").Characteristic;
|
var Characteristic = require("hap-nodejs").Characteristic;
|
||||||
|
var inherits = require('util').inherits;
|
||||||
|
var EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -33,6 +35,8 @@ function PlatformAccessory(displayName, UUID, category) {
|
|||||||
.setCharacteristic(Characteristic.SerialNumber, "Default-SerialNumber");
|
.setCharacteristic(Characteristic.SerialNumber, "Default-SerialNumber");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inherits(PlatformAccessory, EventEmitter);
|
||||||
|
|
||||||
PlatformAccessory.prototype.addService = function(service) {
|
PlatformAccessory.prototype.addService = function(service) {
|
||||||
// service might be a constructor like `Service.AccessoryInformation` instead of an instance
|
// service might be a constructor like `Service.AccessoryInformation` instead of an instance
|
||||||
// of Service. Coerce if necessary.
|
// of Service. Coerce if necessary.
|
||||||
|
|||||||
Reference in New Issue
Block a user