Skip to content

Commit

Permalink
Issue #7
Browse files Browse the repository at this point in the history
By popular request: homebridge-hue now allows blacklisting each sensor
type individually through the `excludeSensorTypes` config.json
parameter.
  • Loading branch information
ebaauw committed Jan 14, 2017
1 parent 25d0468 commit 92311c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ The following optional parameters can be added to modify homebridge-hue's behavi
- `group0`: Flag whether to include group 0 (all lights) when groups are exposed. Default: `true`;
- `rooms`: Flag whether to include Rooms when groups are exposed. Default: `false`;
- `sensors`: Flag whether to expose Hue bridge sensors to HomeKit. Default: `false`;
- `clipsensors`: Flag whether to include CLIP sensors when sensors are exposed. Default: `true`. If set to `false`, only Zigbee sensors and the built-in Daylight sensor are included.
- `excludeSensorTypes`: A list of sensor types to ignore. Default: empty, expose all sensor types. The sensor type is the (case sensitive) `type` attribute of the bridge sensor object, see **Sensors** above, or "CLIP" as a shortcut for all CLIP sensors. For example, to expose only the Hue Motion `Motion Sensor` and `Light Level` sensors, specify: `"excludeSensorTypes": [ "CLIP", "Geofence", "Daylight", "ZLLTemperature", "ZLLSwitch", "ZGPSwitch"]`;
- `clipsensors`: Deprecated, please use `"excludeSensorTypes": ["CLIP", "Geofence"]` instead;
- `schedules`: Flag whether to expose Hue bridge schedules to HomeKit. Default: `false`;
- `rules`: Flag whether to expose Hue bridge rules to HomeKit. Default: `false`.

Expand All @@ -125,7 +126,7 @@ For reference, below is an example `config.json` that includes all parameters an
"group0": true,
"rooms": false,
"sensors": false,
"clipsensors": true,
"excludeSensorTypes": [],
"schedules": false,
"rules": false
}
Expand Down
9 changes: 5 additions & 4 deletions lib/HueBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,14 @@ HueBridge.prototype.createResources = function() {
if (this.platform.config.sensors) {
for (const id in obj.sensors) {
const sensor = obj.sensors[id];
if (this.platform.config.clipsensors ||
(sensor.type.substring(0, 4) !== "CLIP" && sensor.type !== "Geofence")) {
if (this.platform.config.excludeSensorTypes[sensor.type] ||
(sensor.type.substring(0, 4) === "CLIP" &&
this.platform.config.excludeSensorTypes.CLIP)) {
this.log.debug("%s: %s: ignoring %s sensor", this.name, sensor.name, sensor.type);
} else {
this.log.debug("%s: %s: %s sensor", this.name, sensor.name, sensor.type);
this.sensors[id] = new HueSensor(this, id, sensor);
this.accessoryList.push(this.sensors[id]);
} else {
this.log.debug("%s: %s: ingoring %s sensor", this.name, sensor.name, sensor.type);
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion lib/HuePlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,20 @@ function HuePlatform(log, config, api) {
group0: config.group0 === false ? false : true,
rooms: config.rooms === false ? false : true,
sensors: config.sensors || false,
clipsensors: config.clipsensors === false ? false : true,
excludeSensorTypes: {},
schedules: config.schedules || false,
rules: config.rules || false
};
if (Array.isArray(config.excludeSensorTypes)) {
for (const type of config.excludeSensorTypes) {
this.config.excludeSensorTypes[type] = true;
}
}
if (config.clipsensors === false) {
this.log.error("config.json: warning: \"clipsensors\" has been deprecated");
this.config.excludeSensorTypes.CLIP = true;
this.config.excludeSensorTypes.Geofence = true;
}
if (config.host) {
if (Array.isArray(config.host)) {
this.config.hosts = config.host;
Expand Down

0 comments on commit 92311c0

Please sign in to comment.