Skip to content

Commit

Permalink
Add Aqara Wireless Switch 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Petrov committed Nov 7, 2018
1 parent 2ee490c commit 9bd43ec
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions lib/devices/lumi.remote.b1acn01.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const HomeKitDevice = require('../HomeKitDevice')
const { mountXiaomiButteryCharacteristics } = require('../utils/xiaomi')

class AqaraWirelessSwitch2 extends HomeKitDevice {
static get description() {
return {
model: 'lumi.remote.b1acn01',
manufacturer: 'LUMI',
name: 'Aqara Wireless Switch 2',
}
}

getAvailbleServices() {
return [{
name: 'Button',
type: 'StatelessProgrammableSwitch',
}, {
name: 'Battery',
type: 'BatteryService',
}]
}

onDeviceReady() {
this.zigbee.update({ status: 'online', joinTime: Math.floor(Date.now() / 1000) })
this.mountServiceCharacteristic({
endpoint: 1,
cluster: 'genMultistateInput',
service: 'Button',
characteristic: 'ProgrammableSwitchEvent',
report: 'presentValue',
reportMinInt: 1,
reportMaxInt: 60,
reportChange: null,
reportParser: this.handleClickReport,
})
mountXiaomiButteryCharacteristics(this, {
reportMinInt: 1,
reportMaxInt: 60,
})
}

handleClickReport(data, device) {
switch (data) {
case 1:
return device.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS
case 2:
return device.Characteristic.ProgrammableSwitchEvent.DOUBLE_PRESS
case 255:
return device.Characteristic.ProgrammableSwitchEvent.LONG_PRESS
default:
// Do nothing
}
}
}

module.exports = AqaraWirelessSwitch2

0 comments on commit 9bd43ec

Please sign in to comment.