Skip to content
This repository has been archived by the owner on Jun 13, 2020. It is now read-only.

Now it returns Service Information #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ function HTTP_RGB(log, config) {
this.http_method = config.http_method || 'GET';
this.username = config.username || '';
this.password = config.password || '';

this.manufacturer = config.manufacturer || 'HTTP Manufacturer';
this.model = config.model || 'homebridge-better-http-rgb';
this.serial_number = config.serial_number || 'HTTP Serial Number';

// Handle the basic on/off
this.switch = { powerOn: {}, powerOff: {} };
Expand Down Expand Up @@ -106,9 +110,9 @@ HTTP_RGB.prototype = {
var informationService = new Service.AccessoryInformation();

informationService
.setCharacteristic(Characteristic.Manufacturer, 'HTTP Manufacturer')
.setCharacteristic(Characteristic.Model, 'homebridge-better-http-rgb')
.setCharacteristic(Characteristic.SerialNumber, 'HTTP Serial Number');
.setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
.setCharacteristic(Characteristic.Model, this.model)
.setCharacteristic(Characteristic.SerialNumber, this.serial_number);

switch (this.service) {
case 'Light':
Expand Down Expand Up @@ -148,7 +152,7 @@ HTTP_RGB.prototype = {
.on('set', this.setSaturation.bind(this));
}

return [lightbulbService];
return [informationService, lightbulbService];

case 'Switch':
this.log('creating Switch');
Expand All @@ -164,7 +168,7 @@ HTTP_RGB.prototype = {
.getCharacteristic(Characteristic.On)
.on('set', this.setPowerState.bind(this));
}
return [switchService];
return [informationService, switchService];

/*
These are included here as an example of what other
Expand All @@ -185,7 +189,7 @@ HTTP_RGB.prototype = {
.on('get', this.getLockTarget.bind(this))
.on('set', this.setLockTarget.bind(this));

return [lockService];
return [informationService, lockService];

case 'Smoke':
var smokeService = new Service.SmokeSensor(this.name);
Expand All @@ -194,7 +198,7 @@ HTTP_RGB.prototype = {
.getCharacteristic(Characteristic.SmokeDetected)
.on('set', this.getSmokeDetected.bind(this));

return [smokeService];
return [informationService, smokeService];

case 'Motion':
var motionService = new Service.MotionSensor(this.name);
Expand All @@ -203,7 +207,7 @@ HTTP_RGB.prototype = {
.getCharacteristic(Characteristic.MotionDetected)
.on('get', this.getMotionDetected.bind(this));

return [motionService];
return [informationService, motionService];

case 'Temp':
var temperatureService = new Service.TemperatureSensor(this.name);
Expand All @@ -217,7 +221,7 @@ HTTP_RGB.prototype = {
.getCharacteristic(Characteristic.CurrentRelativeHumidity)
.on('get', this.getHumidity.bind(this));

return [temperatureService, humidityService];
return [informationService, temperatureService, humidityService];

*/

Expand Down