diff --git a/accessories/index.js b/accessories/index.js index 3007e668..7017d4bc 100644 --- a/accessories/index.js +++ b/accessories/index.js @@ -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 = { @@ -23,5 +24,6 @@ module.exports = { GarageDoorOpener, Lock, Light, + Window, WindowCovering } diff --git a/accessories/window.js b/accessories/window.js new file mode 100644 index 00000000..36ad533a --- /dev/null +++ b/accessories/window.js @@ -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; diff --git a/platform.js b/platform.js index f0fe656d..a61bf6d3 100644 --- a/platform.js +++ b/platform.js @@ -20,6 +20,7 @@ const classTypes = { 'fan': Accessory.Fan, 'outlet': Accessory.Outlet, 'light': Accessory.Light, + 'window': Accessory.Window, 'window-covering': Accessory.WindowCovering, }