Skip to content

Commit

Permalink
Update HueSensor.js
Browse files Browse the repository at this point in the history
Lutron Aurora, see #522:
- Support ZLLRelativeRotary for Lutron Aurora;
- Support Lutron Aurora when connected to deCONZ.

- Fix order of buttonevents for IKEA SYMFONISK.
  • Loading branch information
ebaauw committed Feb 14, 2020
1 parent 306d13c commit 058bd05
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions lib/HueSensor.js
Expand Up @@ -368,9 +368,9 @@ function HueSensor (accessory, id, obj) {
) {
// Ikea Symfonisk sound controller
this.createLabel(Characteristic.ServiceLabelNamespace.ARABIC_NUMERALS)
this.createButton(1, 'Click', SINGLE_DOUBLE_LONG)
this.createButton(2, 'Turn Left', LONG)
this.createButton(3, 'Turn Right', LONG)
this.createButton(1, 'Button', SINGLE_DOUBLE_LONG)
this.createButton(2, 'Turn Right', LONG)
this.createButton(3, 'Turn Left', LONG)
this.type = {
key: 'buttonevent',
homekitValue: function (v) { return Math.floor(v / 1000) },
Expand Down Expand Up @@ -584,8 +584,8 @@ function HueSensor (accessory, id, obj) {
}
}
} else if (this.endpoint === '03') {
this.createButton(8, 'Right', SINGLE_DOUBLE_LONG)
this.createButton(9, 'Left', SINGLE_DOUBLE_LONG)
this.createButton(8, 'Turn Right', SINGLE_DOUBLE_LONG)
this.createButton(9, 'Turn Left', SINGLE_DOUBLE_LONG)
this.type = {
key: 'buttonevent',
homekitValue: function (v) { return v > 0 ? 8 : 9 },
Expand Down Expand Up @@ -683,7 +683,13 @@ function HueSensor (accessory, id, obj) {
) {
// Lutron Aurora, see #522.
this.createLabel(Characteristic.ServiceLabelNamespace.ARABIC_NUMERALS)
this.createButton(1, 'Button', SINGLE_LONG)
if (this.bridge.isHue) {
this.createButton(1, 'Button', SINGLE_LONG)
} else {
this.createButton(1, 'Button', SINGLE)
this.createButton(2, 'Turn Right', SINGLE)
this.createButton(3, 'Turn Left', SINGLE)
}
this.type = {
key: 'buttonevent',
homekitValue: function (v) { return Math.floor(v / 1000) },
Expand Down Expand Up @@ -748,6 +754,28 @@ function HueSensor (accessory, id, obj) {
}
break
case 'ZLLRelativeRotary':
// Lutron Aurora, see #522.
if (
this.obj.manufacturername === 'Lutron' &&
this.obj.modelid === 'Z3-1BRL'
) {
this.createLabel(Characteristic.ServiceLabelNamespace.ARABIC_NUMERALS)
this.createButton(2, 'Turn Right', SINGLE)
this.createButton(3, 'Turn Left', SINGLE)
this.type = {
key: 'expectedrotation',
homekitValue: function (v) { return v > 0 ? 2 : 3 },
homekitAction: function () {
return Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS
}
}
} else {
this.log.warn(
'%s: %s: warning: ignoring unknown %s sensor %j',
this.bridge.name, this.resource, this.obj.type, this.obj
)
}
break
case 'CLIPSwitch': // 2.1
// We'd need a way to specify the number of buttons, cf. max value for
// a CLIPGenericStatus sensor.
Expand Down Expand Up @@ -1574,6 +1602,12 @@ HueSensor.prototype.checkState = function (state, event) {
case 'daylight':
this.checkDaylight(state.daylight)
break
case 'eventduration':
case 'expectedeventduration':
break
case 'expectedrotation':
this.checkButtonevent(state.expectedrotation, state.lastupdated, event)
break
case 'gesture':
break
case 'lastupdated':
Expand All @@ -1588,6 +1622,8 @@ HueSensor.prototype.checkState = function (state, event) {
break
case 'orientation':
break
case 'rotaryevent':
break
case 'sunrise':
this.checkSunrise(state.sunrise)
break
Expand Down Expand Up @@ -1799,7 +1835,7 @@ HueSensor.prototype.checkButtonevent = function (
) {
if (event || this.obj.state.lastupdated !== lastupdated) {
this.log.debug(
'%s: sensor buttonevent %j on %s', this.name,
'%s: sensor %s %j on %s', this.name, this.type.key,
buttonevent, this.obj.state.lastupdated
)
const buttonIndex = this.type.homekitValue(buttonevent)
Expand Down

0 comments on commit 058bd05

Please sign in to comment.