Skip to content

Commit

Permalink
add ability to disable individual sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschilling committed Jan 16, 2021
1 parent dd8c959 commit 5520639
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 22 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ interface of a device, under *Settings -> Device info -> Device ID*.
* `"colorMode"` - set to `"rgbw"` (default) to have HomeKit control all four
channels of the device (R, G, B, and W), or to `"rgb"` to omit the W channel.

#### Shelly senssor configuration
*Applies to DoorWindow / DoorWindow2 / Flood / HT*
Indiciduale sensores of the devises can be disabled:
* `"state": false` (DoorWindow / DoorWindow2 only)
* `"illuminance": false` (DoorWindow / DoorWindow2 only)
* `"temperature": false` (DoorWindow2 / Flood / HT only)
* `"battery": false`
* `"flood": false` (Flood only)
* `"humidity": false` (HT only)

*If you change one of this values, you maybe need to remove the senssor from the cache by removing it from `http://<homebridge host>:8181`.
It will automaticly be readded after the sensor triggers a value change.*

### Example configuration
```json
"platforms": [
Expand All @@ -140,7 +153,8 @@ interface of a device, under *Settings -> Device info -> Device ID*.
{ "id": "A612F0", "username": "admin", "password": "pa$$word2" },
{ "id": "6A78BB", "colorMode": "rgb" },
{ "id": "AD2214", "name": "My Device" },
{ "id": "1D56AF", "type": "outlet" }
{ "id": "1D56AF", "type": "outlet" },
{ "id": "81e421", "temperature": false}
],
"admin": {
"enabled": true,
Expand Down
77 changes: 56 additions & 21 deletions accessories/sensors.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,59 @@ module.exports = homebridge => {

class ShellyDoorWindowAccessory extends ShellySensorAccessory {
constructor(device, index, config, log) {
super(device, index, config, log, [
new ContactSensorAbility('state'),
new LightSensorAbility('illuminance'),
new BatteryAbility('battery'),
])
super(device, index, config, log)

if (config.state !== false) {
this.abilities.push(new ContactSensorAbility('state'))
}

if (config.illuminance !== false) {
this.abilities.push(new LightSensorAbility('illuminance'))
}

if (config.battery !== false) {
this.abilities.push(new BatteryAbility('battery'))
}
}
}

class ShellyDoorWindow2Accessory extends ShellySensorAccessory {
constructor(device, index, config, log) {
super(device, index, config, log, [
new ContactSensorAbility('state'),
new LightSensorAbility('illuminance'),
new TemperatureSensorAbility('temperature'),
new BatteryAbility('battery')
])
super(device, index, config, log)

if (config.state !== false) {
this.abilities.push(new ContactSensorAbility('state'))
}

if (config.illuminance !== false) {
this.abilities.push(new LightSensorAbility('illuminance'))
}

if (config.temperature !== false) {
this.abilities.push(new TemperatureSensorAbility('temperature'))
}

if (config.battery !== false) {
this.abilities.push(new BatteryAbility('battery'))
}
}
}

class ShellyFloodAccessory extends ShellySensorAccessory {
constructor(device, index, config, log) {
super(device, index, config, log, [
new LeakSensorAbility('flood'),
new TemperatureSensorAbility('temperature'),
new BatteryAbility('battery'),
])
super(device, index, config, log)

if (config.flood !== false) {
this.abilities.push(new LeakSensorAbility('flood'))
}

if (config.temperature !== false) {
this.abilities.push(new TemperatureSensorAbility('temperature'))
}

if (config.battery !== false) {
this.abilities.push(new BatteryAbility('battery'))
}
}
}

Expand All @@ -74,11 +101,19 @@ module.exports = homebridge => {

class ShellyHTAccessory extends ShellySensorAccessory {
constructor(device, index, config, log) {
super(device, index, config, log, [
new TemperatureSensorAbility('temperature'),
new HumiditySensorAbility('humidity'),
new BatteryAbility('battery'),
])
super(device, index, config, log)

if (config.temperature !== false) {
this.abilities.push(new TemperatureSensorAbility('temperature'))
}

if (config.humidity !== false) {
this.abilities.push(new HumiditySensorAbility('humidity'))
}

if (config.battery !== false) {
this.abilities.push(new BatteryAbility('battery'))
}
}
}

Expand Down

0 comments on commit 5520639

Please sign in to comment.