Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getServices: function() {
// you can OPTIONALLY create an information service if you wish to override
// the default values for things like serial number, model, etc.
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Name, this.name)
.setCharacteristic(Characteristic.Manufacturer, "Homebridge")
.setCharacteristic(Characteristic.Model, "File Sensor")
.setCharacteristic(Characteristic.SerialNumber, this.sn);
var service, changeAction;
if(this.sensor_type === "c"){
service = new Service.ContactSensor();
changeAction = function(newState){
service.getCharacteristic(Characteristic.ContactSensorState)
.setValue(newState ? Characteristic.ContactSensorState.CONTACT_DETECTED : Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
};
} else {
service = new Service.MotionSensor();
changeAction = function(newState){
service.getCharacteristic(Characteristic.MotionDetected)
.setValue(newState);
};
getServices: function() {
// you can OPTIONALLY create an information service if you wish to override
// the default values for things like serial number, model, etc.
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, "HTTP Manufacturer")
.setCharacteristic(Characteristic.Model, "HTTP Model")
.setCharacteristic(Characteristic.SerialNumber, "HTTP Serial Number");
var lightbulbService = new Service.Lightbulb();
lightbulbService
.getCharacteristic(Characteristic.On)
.on('set', this.setPowerState.bind(this));
lightbulbService
.addCharacteristic(new Characteristic.Brightness())
.on('set', this.setBrightness.bind(this));
return [informationService, lightbulbService];
}
};
services.forEach(function(service) {
// if you returned an AccessoryInformation service, merge its values with ours
if (service instanceof Service.AccessoryInformation) {
var existingService = accessory.getService(Service.AccessoryInformation);
// pull out any values you may have defined
var manufacturer = service.getCharacteristic(Characteristic.Manufacturer).value;
var model = service.getCharacteristic(Characteristic.Model).value;
var serialNumber = service.getCharacteristic(Characteristic.SerialNumber).value;
var firmwareRevision = service.getCharacteristic(Characteristic.FirmwareRevision).value;
var hardwareRevision = service.getCharacteristic(Characteristic.HardwareRevision).value;
if (manufacturer) existingService.setCharacteristic(Characteristic.Manufacturer, manufacturer);
if (model) existingService.setCharacteristic(Characteristic.Model, model);
if (serialNumber) existingService.setCharacteristic(Characteristic.SerialNumber, serialNumber);
if (firmwareRevision) existingService.setCharacteristic(Characteristic.FirmwareRevision, firmwareRevision);
if (hardwareRevision) existingService.setCharacteristic(Characteristic.HardwareRevision, hardwareRevision);
}
else {
accessory.addService(service);
}
});
getServices: function() {
// you can OPTIONALLY create an information service if you wish to override
// the default values for things like serial number, model, etc.
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, "HTTP Manufacturer")
.setCharacteristic(Characteristic.Model, "HTTP Thermometer")
.setCharacteristic(Characteristic.SerialNumber, "HTTP Serial Number");
var temperatureService = new Service.TemperatureSensor();
temperatureService
.getCharacteristic(Characteristic.CurrentTemperature)
.on('get', this.getCurrentTemperature.bind(this));
return [informationService, temperatureService];
}
};
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);
info.setCharacteristic(Characteristic.Manufacturer, `${toTitleCase(require('../package.json').author.name)}`);
info.setCharacteristic(Characteristic.Model, `${toTitleCase(require('../package.json').name)}`);
info.setCharacteristic(Characteristic.SerialNumber, bridgeConfig.username);
info.setCharacteristic(Characteristic.FirmwareRevision, require('../package.json').version);
this._bridge.on('listening', function(port) {
log.info("Homebridge is running on port %s.", port);
});
var publishInfo = {
username: bridgeConfig.username || "CC:22:3D:E3:CE:30",
port: bridgeConfig.port || 0,
pincode: bridgeConfig.pin || "031-45-154",
category: Accessory.Categories.BRIDGE,
mdns: this._config.mdns
};
function setupAccessory(switchConfig) {
const outletUUID = uuid.v3({
namespace: uuid.namespace.url,
name: switchConfig.id
});
const outlet = new Accessory(switchConfig.name, outletUUID);
outlet
.getService(Service.AccessoryInformation)
.setCharacteristic(Characteristic.Manufacturer, 'HALBERT')
.setCharacteristic(
Characteristic.Model,
`${switchConfig.type}-${switchConfig.protocol}-switch`
)
.setCharacteristic(Characteristic.SerialNumber, switchConfig.id);
outlet.on('identify', (paired, callback) => {
console.logger.info(
`${switchConfig.name} was identified. Paired: ${paired}.`
);
callback();
});
outlet
.addService(Service.Outlet, switchConfig.name)
.getCharacteristic(Characteristic.On)
function setupAccessory(switchConfig) {
const outletUUID = uuid.v3({
namespace: uuid.namespace.url,
name: switchConfig.id
});
const outlet = new Accessory(switchConfig.name, outletUUID);
outlet
.getService(Service.AccessoryInformation)
.setCharacteristic(Characteristic.Manufacturer, 'HALBERT')
.setCharacteristic(Characteristic.Model, `${switchConfig.type}-${switchConfig.protocol}-switch`)
.setCharacteristic(Characteristic.SerialNumber, switchConfig.id);
outlet.on('identify', (paired, callback) => {
console.logger.info(`${switchConfig.name} was identified. Paired: ${paired}.`);
callback();
});
outlet
.addService(Service.Outlet, switchConfig.name)
.getCharacteristic(Characteristic.On)
.on('set', (value, callback) => {
const action = value
? 'switch.on'
: 'switch.off';
ISYOutletAccessory.prototype.getServices = function() {
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, "SmartHome")
.setCharacteristic(Characteristic.Model, this.device.deviceFriendlyName)
.setCharacteristic(Characteristic.SerialNumber, this.device.address);
var outletService = new Service.Outlet();
this.outletService = outletService;
this.informationService = informationService;
outletService
.getCharacteristic(Characteristic.On)
.on('set', this.setOutletState.bind(this));
outletService
.getCharacteristic(Characteristic.On)
.on('get', this.getOutletState.bind(this));
this.displayName = displayName;
this.UUID = UUID;
this.category = category || Accessory.Categories.OTHER;
this.services = [];
this.reachable = false;
this.context = {};
this._associatedPlugin;
this._associatedPlatform;
this._associatedHAPAccessory;
this
.addService(Service.AccessoryInformation)
.setCharacteristic(Characteristic.Name, displayName)
.setCharacteristic(Characteristic.Manufacturer, "Default-Manufacturer")
.setCharacteristic(Characteristic.Model, "Default-Model")
.setCharacteristic(Characteristic.SerialNumber, "Default-SerialNumber");
}
getServices: function() {
var informationService = new Service.AccessoryInformation();
informationService
.setCharacteristic(Characteristic.Manufacturer, "MiLight")
.setCharacteristic(Characteristic.Model, this.type)
.setCharacteristic(Characteristic.SerialNumber, "MILIGHT12345");
var lightbulbService = new Service.Lightbulb();
lightbulbService
.getCharacteristic(Characteristic.On)
.on('set', this.setPowerState.bind(this));
lightbulbService
.addCharacteristic(new Characteristic.Brightness())
.on('set', this.setBrightness.bind(this));
lightbulbService
.addCharacteristic(new Characteristic.Hue())
.on('set', this.setHue.bind(this));