Skip to content

Commit

Permalink
Support for a “window” accessory that mimic the functionality of a wi…
Browse files Browse the repository at this point in the history
…ndow-covering (#494)
  • Loading branch information
Luke Rhodes committed Jan 1, 2020
1 parent 4a8f5e9 commit fe8dea9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions accessories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Fan = require('./fan');
const GarageDoorOpener = require('./garageDoorOpener');
const Lock = require('./lock');
const Light = require('./light');
const Window = require('./window');
const WindowCovering = require('./windowCovering');

module.exports = {
Expand All @@ -23,5 +24,6 @@ module.exports = {
GarageDoorOpener,
Lock,
Light,
Window,
WindowCovering
}
50 changes: 50 additions & 0 deletions accessories/window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { assert } = require('chai');

const delayForDuration = require('../helpers/delayForDuration');
const ServiceManagerTypes = require('../helpers/serviceManagerTypes');
const catchDelayCancelError = require('../helpers/catchDelayCancelError');
const WindowCoveringAccessory = require('./windowCovering');

class WindowAccessory extends WindowCoveringAccessory {

setupServiceManager () {
const { data, log, name, serviceManagerType } = this;

this.serviceManager = new ServiceManagerTypes[serviceManagerType](name, Service.Window, log);

this.serviceManager.addToggleCharacteristic({
name: 'currentPosition',
type: Characteristic.CurrentPosition,
bind: this,
getMethod: this.getCharacteristicValue,
setMethod: this.setCharacteristicValue,
props: {

}
});

this.serviceManager.addToggleCharacteristic({
name: 'positionState',
type: Characteristic.PositionState,
bind: this,
getMethod: this.getCharacteristicValue,
setMethod: this.setCharacteristicValue,
props: {

}
});

this.serviceManager.addToggleCharacteristic({
name: 'targetPosition',
type: Characteristic.TargetPosition,
bind: this,
getMethod: this.getCharacteristicValue,
setMethod: this.setCharacteristicValue,
props: {
setValuePromise: this.setTargetPosition.bind(this)
}
});
}
}

module.exports = WindowCoveringAccessory;
1 change: 1 addition & 0 deletions platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const classTypes = {
'fan': Accessory.Fan,
'outlet': Accessory.Outlet,
'light': Accessory.Light,
'window': Accessory.Window,
'window-covering': Accessory.WindowCovering,
}

Expand Down

0 comments on commit fe8dea9

Please sign in to comment.