UNPKG

@shadman-a/homebridge-my-ac

Version:

A Homebridge plugin for controlling/monitoring LG ThinQ device via LG ThinQ platform.

82 lines 3.62 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const AirPurifier_1 = __importStar(require("../../devices/AirPurifier")); class AirPurifier extends AirPurifier_1.default { constructor(platform, accessory) { super(platform, accessory); this.platform = platform; this.accessory = accessory; } async setActive(value) { var _a; const device = this.accessory.context.device; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'Operation', value ? '1' : '0')); } async setTargetAirPurifierState(value) { var _a; const device = this.accessory.context.device; if (!this.Status.isPowerOn || (!!value !== this.Status.isNormalMode)) { return; // just skip it } await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'OpMode', value ? '16' : '14')); } async setRotationSpeed(value) { var _a; if (!this.Status.isPowerOn || !this.Status.isNormalMode) { return; } const device = this.accessory.context.device; const values = Object.keys(AirPurifier_1.RotateSpeed); const windStrength = parseInt(values[Math.round(value) - 1]) || AirPurifier_1.RotateSpeed.EXTRA; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'WindStrength', windStrength.toString())); } async setSwingMode(value) { var _a; if (!this.Status.isPowerOn || !this.Status.isNormalMode) { return; } const device = this.accessory.context.device; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'CirculateDir', value ? '1' : '0')); } async setLight(value) { var _a; if (!this.Status.isPowerOn) { return; } const device = this.accessory.context.device; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'SignalLighting', value ? '1' : '0')); } async setAirFastActive(value) { var _a; if (!this.Status.isPowerOn) { return; } const device = this.accessory.context.device; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'AirFast', value ? '1' : '0')); } } exports.default = AirPurifier; //# sourceMappingURL=AirPurifier.js.map