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

Commit

Permalink
Renamed sensor_class to device_class (#125)
Browse files Browse the repository at this point in the history
The sensor_class attribute was renamed in Home Assistant to device_class. Update
name here as well.
  • Loading branch information
shmuelzon authored and robbiet480 committed Mar 2, 2017
1 parent ee26a5e commit 1fa895f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Here's a list of the devices that are currently exposed:

### Binary Sensor Support

Binary Sensors must have a `sensor_class` set. Accepted `sensor_class`es are `moisture`, `motion`, `occupancy`, `opening` and `smoke`.
Binary Sensors must have a `device_class` set. Accepted `device_class`es are `moisture`, `motion`, `occupancy`, `opening` and `smoke`.

For binary sensors with the `opening` `sensor_class` you can also set `homebridge_opening_type` to `window` to have the entity display as a window instead of a door to Homebridge.
For binary sensors with the `opening` `device_class` you can also set `homebridge_opening_type` to `window` to have the entity display as a window instead of a door to Homebridge.

### Cover Support

Expand Down
8 changes: 4 additions & 4 deletions accessories/binary_sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ class HomeAssistantBinarySensor {

informationService
.setCharacteristic(Characteristic.Manufacturer, 'Home Assistant')
.setCharacteristic(Characteristic.Model, `${toTitleCase(this.data.attributes.sensor_class)} Binary Sensor`)
.setCharacteristic(Characteristic.Model, `${toTitleCase(this.data.attributes.device_class)} Binary Sensor`)
.setCharacteristic(Characteristic.SerialNumber, this.entity_id);

return [informationService, this.sensorService];
}
}

function HomeAssistantBinarySensorFactory(log, data, client) {
if (!(data.attributes && data.attributes.sensor_class)) {
if (!(data.attributes && data.attributes.device_class)) {
return null;
}
switch (data.attributes.sensor_class) {
switch (data.attributes.device_class) {
case 'moisture':
return new HomeAssistantBinarySensor(log, data, client,
Service.LeakSensor,
Expand Down Expand Up @@ -102,7 +102,7 @@ function HomeAssistantBinarySensorFactory(log, data, client) {
Characteristic.SmokeDetected.SMOKE_DETECTED,
Characteristic.SmokeDetected.SMOKE_NOT_DETECTED);
default:
log.error(`'${data.entity_id}' has a sensor_class of '${data.attributes.sensor_class}' which is not supported by ` +
log.error(`'${data.entity_id}' has a device_class of '${data.attributes.device_class}' which is not supported by ` +
'homebridge-homeassistant. Supported classes are \'moisture\', \'motion\', \'occupancy\', \'opening\' and \'smoke\'. ' +
'See the README.md for more information.');
return null;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ HomeAssistantPlatform.prototype = {
accessory = HomeAssistantDeviceTrackerFactory(that.log, entity, that);
} else if (entityType === 'media_player' && entity.attributes && entity.attributes.supported_features) {
accessory = new HomeAssistantMediaPlayer(that.log, entity, that);
} else if (entityType === 'binary_sensor' && entity.attributes && entity.attributes.sensor_class) {
} else if (entityType === 'binary_sensor' && entity.attributes && entity.attributes.device_class) {
accessory = HomeAssistantBinarySensorFactory(that.log, entity, that);
}

Expand Down

0 comments on commit 1fa895f

Please sign in to comment.