UNPKG

@raiden733/homebridge-gpio-garagedoor

Version:

Raspberry Pi GPIO based Garage Door plugin for Homebridge

64 lines (63 loc) 2.23 kB
"use strict"; /** * Created by kraig on 7/2/16. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.DoorStateExtension = void 0; exports.getCurrentDoorState = getCurrentDoorState; exports.getTargetDoorState = getTargetDoorState; exports.asDoorState = asDoorState; exports.asOperationState = asOperationState; exports.getCurrentDoorStateDescription = getCurrentDoorStateDescription; exports.getTargetDoorStateDescription = getTargetDoorStateDescription; var Characteristic; class DoorStateExtension { static init(exportedTypes) { Characteristic = exportedTypes.Characteristic; } } exports.DoorStateExtension = DoorStateExtension; function getCurrentDoorState(service) { return service.getCharacteristic(Characteristic.CurrentDoorState).value; } function getTargetDoorState(service) { return service.getCharacteristic(Characteristic.TargetDoorState).value; } function asDoorState(targetState) { switch (targetState) { case Characteristic.TargetDoorState.OPEN: return Characteristic.CurrentDoorState.OPEN; case Characteristic.TargetDoorState.CLOSED: return Characteristic.CurrentDoorState.CLOSED; } } function asOperationState(targetState) { switch (targetState) { case Characteristic.TargetDoorState.OPEN: return Characteristic.CurrentDoorState.OPENING; case Characteristic.TargetDoorState.CLOSED: return Characteristic.CurrentDoorState.CLOSING; } } function getCurrentDoorStateDescription(doorState) { switch (doorState) { case Characteristic.CurrentDoorState.OPEN: return "OPEN"; case Characteristic.CurrentDoorState.OPENING: return "OPENING"; case Characteristic.CurrentDoorState.CLOSING: return "CLOSING"; case Characteristic.CurrentDoorState.CLOSED: return "CLOSED"; case Characteristic.CurrentDoorState.STOPPED: return "STOPPED"; } } function getTargetDoorStateDescription(doorState) { switch (doorState) { case Characteristic.TargetDoorState.OPEN: return "OPEN"; case Characteristic.TargetDoorState.CLOSED: return "CLOSED"; } }