Skip to content

Commit

Permalink
expose: allow setting the label for Lock()
Browse files Browse the repository at this point in the history
For devices with multiple locks or for devices that have a lock function, allow setting of a label.
e.g. for TRV's with a keypad_lockout it is now called keypad_lockout instead of state which is confusing if there are multiple switches/locks all called 'state'
  • Loading branch information
sjorge committed Mar 14, 2021
1 parent 16dbb48 commit b1a85c1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/exposes.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ class Lock extends Base {
this.features = [];
}

withState(property, valueOn, valueOff, description, access=a.ALL) {
withState(property, valueOn, valueOff, description, access=a.ALL, label='state') {
assert(!this.endpoint, 'Cannot add feature after adding endpoint');
this.features.push(new Binary('state', access, valueOn, valueOff).withProperty(property).withDescription(description));
this.features.push(new Binary(label, access, valueOn, valueOff).withProperty(property).withDescription(description));
return this;
}

withLockState(property, description) {
withLockState(property, description, label='lock_state') {
assert(!this.endpoint, 'Cannot add feature after adding endpoint');
this.features.push(new Enum('lock_state', access.STATE, ['not_fully_locked', 'locked', 'unlocked']).withProperty(property).withDescription(description));
this.features.push(new Enum(label, access.STATE, ['not_fully_locked', 'locked', 'unlocked']).withProperty(property).withDescription(description));
return this;
}
}
Expand Down Expand Up @@ -478,7 +478,7 @@ module.exports = {
humidity: () => new Numeric('humidity', access.STATE).withUnit('%').withDescription('Measured relative humidity'),
illuminance: () => new Numeric('illuminance', access.STATE).withDescription('Raw measured illuminance'),
illuminance_lux: () => new Numeric('illuminance_lux', access.STATE).withUnit('lx').withDescription('Measured illuminance in lux'),
keypad_lockout: () => new Lock().withState('keypad_lockout', 'lock1', 'unlock', 'Enables/disables physical input on the device', a.STATE_ALL),
keypad_lockout: () => new Lock().withState('keypad_lockout', 'lock1', 'unlock', 'Enables/disables physical input on the device', a.STATE_ALL, 'keypad_lockout'),
led_disabled_night: () => new Binary('led_disabled_night', access.STATE_SET, true, false).withDescription('Enable/disable the LED at night'),
light_brightness: () => new Light().withBrightness(),
light_brightness_color: () => new Light().withBrightness().withColor((['xy', 'hs'])),
Expand Down

0 comments on commit b1a85c1

Please sign in to comment.