Skip to content

Commit

Permalink
Log details of unknown light or sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
ebaauw committed Mar 5, 2017
1 parent 884afc6 commit 70aef98
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 87 deletions.
47 changes: 14 additions & 33 deletions lib/HueLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
// Homebridge plugin for Philips Hue.
//
// HueLight provides support for Philips Hue lights and groups.
//
// Todo:
// - Table of known lights with supported colour (temperature) ranges.

'use strict';

Expand Down Expand Up @@ -334,7 +331,7 @@ HueLight.prototype.setConfig = function() {
G: {x: 0.2151, y: 0.7106},
B: {x: 0.1380, y: 0.0800}
};
break;
return;
case 'LCT001': // Hue bulb A19
case 'LCT007': // Hue bulb A19
case 'LCT002': // Hue Spot BR30
Expand All @@ -345,7 +342,7 @@ HueLight.prototype.setConfig = function() {
G: {x: 0.4090, y: 0.5180},
B: {x: 0.1670, y: 0.0400}
};
break;
return;
case 'LCT010': // Hue bulb A19
case 'LCT014': // Hue bulb A19
case 'LCT011': // Hue BR30
Expand All @@ -356,7 +353,7 @@ HueLight.prototype.setConfig = function() {
G: {x: 0.1700, y: 0.7000},
B: {x: 0.1530, y: 0.0480}
};
break;
return;
case 'LTW001': // Hue A19 White Ambiance
case 'LTW004': // Hue A19 White Ambiance
case 'LTW013': // Hue GU-10 White Ambiance
Expand All @@ -365,34 +362,26 @@ HueLight.prototype.setConfig = function() {
case 'LLM011': // Color Temperature Module
case 'LLM012': // Color Temperature Module
this.config.maxCT = 454;
break;
return;
case 'LWL001': // Dimmable plug-in unit
case 'LWB004': // Hue A19 lux
case 'LWB006': // Hue A19 lux
case 'LWB007': // Hue A19 lux
case 'LWB010': // Hue A19 lux
case 'LWB014': // Hue A19 lux
break;
return;
default:
this.log.error(
'%s: warning: %s: unknown %s light model', this.name,
this.config.manufacturer, this.config.model
);
break;
}
break;
case 'OSRAM':
switch (this.config.model) {
case 'Plug - LIGHTIFY':
break;
return;
case 'Classic B40 TW - LIGHTIFY':
this.config.maxCT = 370;
break;
return;
default:
this.log.error(
'%s: warning: %s: unknown %s light model', this.name,
this.config.manufacturer, this.config.model
);
break;
}
break;
Expand All @@ -406,14 +395,10 @@ HueLight.prototype.setConfig = function() {
case 'SL 110': // Spot
case 'DL 110': // Spot
this.config.noAlert = true;
break;
return;
case 'RB 162': // Bulb
break;
return;
default:
this.log.error(
'%s: warning: %s: unknown %s light model', this.name,
this.config.manufacturer, this.config.model
);
break;
}
break;
Expand All @@ -422,22 +407,18 @@ HueLight.prototype.setConfig = function() {
case 'FLS-PP3': // FLS-PP lp
case 'FLS-PP3 White':
this.config.subtype = this.obj.uniqueid.split('-')[1];
break;
return;
default:
this.log.error(
'%s: warning: %s: unknown %s light model', this.name,
this.config.manufacturer, this.config.model
);
break;
}
break;
default:
this.log.error(
'%s: warning: %s: unknown light manufacturer', this.name,
this.config.manufacturer
);
break;
}
this.log.error(
'%s: %s: warning: unknown light model %j',
this.bridge.name, this.resource, this.obj
);
};

HueLight.prototype.colorTemperature = function(ct) {
Expand Down
1 change: 0 additions & 1 deletion lib/HuePlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// up a heartbeat to poll the bridges.
//
// Todo:
// - Bridge discovery using local UPnP.
// - Dynamic homebridge accessories.
// - Store user (bridge password) in context of homebridge accessory for bridge.

Expand Down
110 changes: 57 additions & 53 deletions lib/HueSensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function HueSensor(bridge, id, obj) {
this.uuid_base = this.obj.uniqueid.split('-')[0];
} else {
// Hue bridge internal sensor.
this.manufacturer = 'n/a';
this.manufacturer = 'Philips';
this.model = this.obj.type;
this.uuid_base = this.bridge.uuid_base + this.resource;
}
Expand Down Expand Up @@ -253,65 +253,72 @@ function HueSensor(bridge, id, obj) {
}
break;
case 'CLIPSwitch': // 2.1
/* falls through */
this.log.error(
'%s: %s: unsupported sensor type %s',
this.bridge.name, this.resource, this.obj.type
);
break;
default:
this.log.error(
'%s: unsupported sensor type %s', this.name, this.obj.type
'%s: %s: unknown sensor type %j',
this.bridge.name, this.resource, this.obj
);
return;
break;
}
this.serviceList.push(this.service);

this.infoService
.updateCharacteristic(Characteristic.Manufacturer, this.manufacturer)
.updateCharacteristic(Characteristic.Model, this.model)
.updateCharacteristic(Characteristic.SerialNumber, this.uuid_base);

this.refresh();

if (this.type.Characteristic) {
const char = this.service.getCharacteristic(this.type.Characteristic);
if (this.type.props) {
char.setProps(this.type.props);
if (this.service) {
this.refresh();
this.serviceList.push(this.service);
if (this.type.Characteristic) {
const char = this.service.getCharacteristic(this.type.Characteristic);
if (this.type.props) {
char.setProps(this.type.props);
}
char.updateValue(this.hk.value);
if (this.type.setter) {
char.on('set', this.setValue.bind(this));
}
}
char.updateValue(this.hk.value);
if (this.type.setter) {
char.on('set', this.setValue.bind(this));
if (this.hk.dark !== undefined) {
this.service.addOptionalCharacteristic(Characteristic.Dark);
this.service.getCharacteristic(Characteristic.Dark)
.updateValue(this.hk.dark);
}
if (this.hk.daylight !== undefined) {
this.service.addOptionalCharacteristic(Characteristic.Daylight);
this.service.getCharacteristic(Characteristic.Daylight)
.updateValue(this.hk.daylight);
}
this.service.addOptionalCharacteristic(Characteristic.Enabled);
this.service.getCharacteristic(Characteristic.Enabled)
.updateValue(this.hk.enabled)
.on('set', this.setEnabled.bind(this));
this.service.addOptionalCharacteristic(Characteristic.LastUpdated);
this.service.getCharacteristic(Characteristic.LastUpdated)
.updateValue(this.hk.lastupdated);
this.service.addOptionalCharacteristic(Characteristic.StatusActive);
this.service.getCharacteristic(Characteristic.StatusActive)
.updateValue(this.hk.enabled);
if (this.obj.config.reachable !== undefined) {
this.service.addOptionalCharacteristic(Characteristic.StatusFault);
this.service.getCharacteristic(Characteristic.StatusFault)
.updateValue(this.hk.fault);
}
this.service.addOptionalCharacteristic(Characteristic.Resource);
this.service.getCharacteristic(Characteristic.Resource)
.updateValue(this.resource);
if (this.obj.config.battery) {
this.batteryService = new Service.BatteryService(this.name);
this.batteryService
.updateCharacteristic(Characteristic.BatteryLevel, this.hk.battery)
.updateCharacteristic(Characteristic.StatusLowBattery, this.hk.lowBattery)
.updateCharacteristic(Characteristic.ChargingState, this.hk.charging);
}
}
if (this.hk.dark !== undefined) {
this.service.addOptionalCharacteristic(Characteristic.Dark);
this.service.getCharacteristic(Characteristic.Dark)
.updateValue(this.hk.dark);
}
if (this.hk.daylight !== undefined) {
this.service.addOptionalCharacteristic(Characteristic.Daylight);
this.service.getCharacteristic(Characteristic.Daylight)
.updateValue(this.hk.daylight);
}
this.service.addOptionalCharacteristic(Characteristic.Enabled);
this.service.getCharacteristic(Characteristic.Enabled)
.updateValue(this.hk.enabled)
.on('set', this.setEnabled.bind(this));
this.service.addOptionalCharacteristic(Characteristic.LastUpdated);
this.service.getCharacteristic(Characteristic.LastUpdated)
.updateValue(this.hk.lastupdated);
this.service.addOptionalCharacteristic(Characteristic.StatusActive);
this.service.getCharacteristic(Characteristic.StatusActive)
.updateValue(this.hk.enabled);
if (this.obj.config.reachable !== undefined) {
this.service.addOptionalCharacteristic(Characteristic.StatusFault);
this.service.getCharacteristic(Characteristic.StatusFault)
.updateValue(this.hk.fault);
}
this.service.addOptionalCharacteristic(Characteristic.Resource);
this.service.getCharacteristic(Characteristic.Resource)
.updateValue(this.resource);
if (this.obj.config.battery) {
this.batteryService = new Service.BatteryService(this.name);
this.batteryService
.updateCharacteristic(Characteristic.BatteryLevel, this.hk.battery)
.updateCharacteristic(Characteristic.StatusLowBattery, this.hk.lowBattery)
.updateCharacteristic(Characteristic.ChargingState, this.hk.charging);
}
}

Expand All @@ -324,9 +331,6 @@ HueSensor.prototype.getServices = function() {

// Translate bridge values to homekit values.
HueSensor.prototype.refresh = function() {
if (!this.type) {
return;
}
this.value = this.obj.state[this.type.key];
this.hk = {};
this.hk.value = this.type.homekitValue(this.value);
Expand All @@ -351,7 +355,7 @@ HueSensor.prototype.refresh = function() {
// ===== Bridge Events =========================================================

HueSensor.prototype.heartbeat = function(obj) {
if (!this.type) {
if (!this.service) {
return;
}
const old = {
Expand Down

0 comments on commit 70aef98

Please sign in to comment.