mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-31 06:13:11 +01:00
clean it up and get on that modern tip
This commit is contained in:
@@ -192,111 +192,17 @@ HomeAssistantAccessory.prototype = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
getServices: function() {
|
getServices: function() {
|
||||||
var that = this;
|
var lightbulbService = new Service.Lightbulb();
|
||||||
return [{
|
|
||||||
sType: types.ACCESSORY_INFORMATION_STYPE,
|
lightbulbService
|
||||||
characteristics: [{
|
.getCharacteristic(Characteristic.On)
|
||||||
cType: types.NAME_CTYPE,
|
.on('set', this.setPowerState.bind(this));
|
||||||
onUpdate: null,
|
|
||||||
perms: ["pr"],
|
lightbulbService
|
||||||
format: "string",
|
.addCharacteristic(new Characteristic.Brightness())
|
||||||
initialValue: this.name,
|
.on('set', this.setBrightness.bind(this));
|
||||||
supportEvents: false,
|
|
||||||
supportBonjour: false,
|
return [lightbulbService];
|
||||||
manfDescription: "Name of the accessory",
|
|
||||||
designedMaxLength: 255
|
|
||||||
},{
|
|
||||||
cType: types.MANUFACTURER_CTYPE,
|
|
||||||
onUpdate: null,
|
|
||||||
perms: ["pr"],
|
|
||||||
format: "string",
|
|
||||||
initialValue: "HomeAssistant",
|
|
||||||
supportEvents: false,
|
|
||||||
supportBonjour: false,
|
|
||||||
manfDescription: "Manufacturer",
|
|
||||||
designedMaxLength: 255
|
|
||||||
},{
|
|
||||||
cType: types.MODEL_CTYPE,
|
|
||||||
onUpdate: null,
|
|
||||||
perms: ["pr"],
|
|
||||||
format: "string",
|
|
||||||
initialValue: "Rev-1",
|
|
||||||
supportEvents: false,
|
|
||||||
supportBonjour: false,
|
|
||||||
manfDescription: "Model",
|
|
||||||
designedMaxLength: 255
|
|
||||||
},{
|
|
||||||
cType: types.SERIAL_NUMBER_CTYPE,
|
|
||||||
onUpdate: null,
|
|
||||||
perms: ["pr"],
|
|
||||||
format: "string",
|
|
||||||
initialValue: "A1S2NASF88EW",
|
|
||||||
supportEvents: false,
|
|
||||||
supportBonjour: false,
|
|
||||||
manfDescription: "SN",
|
|
||||||
designedMaxLength: 255
|
|
||||||
},{
|
|
||||||
cType: types.IDENTIFY_CTYPE,
|
|
||||||
onUpdate: null,
|
|
||||||
perms: ["pw"],
|
|
||||||
format: "bool",
|
|
||||||
initialValue: false,
|
|
||||||
supportEvents: false,
|
|
||||||
supportBonjour: false,
|
|
||||||
manfDescription: "Identify Accessory",
|
|
||||||
designedMaxLength: 1
|
|
||||||
}]
|
|
||||||
},{
|
|
||||||
sType: types.LIGHTBULB_STYPE,
|
|
||||||
characteristics: [{
|
|
||||||
cType: types.NAME_CTYPE,
|
|
||||||
onUpdate: null,
|
|
||||||
perms: ["pr"],
|
|
||||||
format: "string",
|
|
||||||
initialValue: this.name,
|
|
||||||
supportEvents: true,
|
|
||||||
supportBonjour: false,
|
|
||||||
manfDescription: "Name of service",
|
|
||||||
designedMaxLength: 255
|
|
||||||
},{
|
|
||||||
cType: types.POWER_STATE_CTYPE,
|
|
||||||
onUpdate: function(value) {
|
|
||||||
that.setPowerState(value);
|
|
||||||
},
|
|
||||||
onRead: function(callback) {
|
|
||||||
that.getPowerState(function(powerState){
|
|
||||||
callback(powerState);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
perms: ["pw","pr","ev"],
|
|
||||||
format: "bool",
|
|
||||||
initialValue: 0,
|
|
||||||
supportEvents: true,
|
|
||||||
supportBonjour: false,
|
|
||||||
manfDescription: "Change the power state of the Bulb",
|
|
||||||
designedMaxLength: 1
|
|
||||||
},{
|
|
||||||
cType: types.BRIGHTNESS_CTYPE,
|
|
||||||
onUpdate: function(value) {
|
|
||||||
that.setBrightness(value);
|
|
||||||
},
|
|
||||||
onRead: function(callback) {
|
|
||||||
that.getBrightness(function(level){
|
|
||||||
callback(level);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
perms: ["pw","pr","ev"],
|
|
||||||
format: "int",
|
|
||||||
initialValue: 0,
|
|
||||||
supportEvents: true,
|
|
||||||
supportBonjour: false,
|
|
||||||
manfDescription: "Adjust Brightness of Light",
|
|
||||||
designedMinValue: 0,
|
|
||||||
designedMaxValue: 255,
|
|
||||||
designedMinStep: 1,
|
|
||||||
unit: "%"
|
|
||||||
}]
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user