UNPKG

@hoobs/wink

Version:
52 lines (50 loc) 1.49 kB
const { batteryService } = require("./_shared"); module.exports = ({ Characteristic, Service }) => { return { type: "lock", group: "locks", services: [ { service: Service.LockMechanism, characteristics: [ { characteristic: Characteristic.LockCurrentState, get: state => { switch (state.locked) { case true: return Characteristic.LockCurrentState.SECURED; case false: return Characteristic.LockCurrentState.UNSECURED; default: return Characteristic.LockCurrentState.UNKNOWN; } } }, { characteristic: Characteristic.LockTargetState, get: (state, desired_state) => { switch (desired_state.locked) { case true: return Characteristic.LockCurrentState.SECURED; case false: return Characteristic.LockCurrentState.UNSECURED; default: return Characteristic.LockCurrentState.UNKNOWN; } }, set: value => ({ locked: value === true || value === Characteristic.LockTargetState.SECURED }) } ] }, batteryService({ Characteristic, Service, notCharging: true }) ] }; };