Skip to content
This repository was archived by the owner on Jun 23, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
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
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