UNPKG

@elshaer/homebridge-lg-thinq

Version:

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

128 lines 6.07 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 AirConditioner_1 = __importStar(require("../../devices/AirConditioner")); const AirState_1 = require("../transforms/AirState"); class AC extends AirConditioner_1.default { createHeaterCoolerService() { const { Characteristic, } = this.platform; const device = this.accessory.context.device; super.createHeaterCoolerService(); const currentTemperatureValue = device.deviceModel.value('TempCur'); this.service.getCharacteristic(Characteristic.CurrentTemperature) .setProps({ minValue: currentTemperatureValue.min, maxValue: currentTemperatureValue.max, }); const targetTemperatureValue = device.deviceModel.value('TempCfg'); this.service.getCharacteristic(Characteristic.CoolingThresholdTemperature) .setProps({ minValue: targetTemperatureValue.min, maxValue: targetTemperatureValue.max, }); this.service.getCharacteristic(Characteristic.HeatingThresholdTemperature) .setProps({ minValue: targetTemperatureValue.min, maxValue: targetTemperatureValue.max, }); } async setFanState(value) { var _a; if (!this.Status.isPowerOn) { return; } const device = this.accessory.context.device; const { TargetFanState } = this.platform.Characteristic; const windStrength = value === TargetFanState.AUTO ? 8 : AirConditioner_1.FanSpeed.HIGH; // 8 mean fan auto mode (_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'WindStrength', windStrength); } async setJetModeActive(value) { var _a; const device = this.accessory.context.device; if (this.Status.isPowerOn && this.Status.opMode === 0) { const jetModeValue = value ? '1' : '0'; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'Jet', jetModeValue)); } } async setActive(value) { var _a; const device = this.accessory.context.device; const isOn = value; const op = isOn ? AirState_1.ACOperation.RIGHT_ON : AirState_1.ACOperation.OFF; const opValue = device.deviceModel.enumValue('Operation', op); await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'Operation', opValue)); } async setTargetTemperature(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, 'TempCfg', value)); device.data.snapshot['airState.tempState.target'] = value; this.updateAccessoryCharacteristic(device); } async setFanSpeed(value) { var _a; if (!this.Status.isPowerOn) { return; } const speedValue = Math.max(1, Math.round(value)); const device = this.accessory.context.device; const windStrength = parseInt(Object.keys(AirConditioner_1.FanSpeed)[speedValue - 1]) || AirConditioner_1.FanSpeed.HIGH; (_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'WindStrength', windStrength); } async setSwingMode(value) { var _a, _b; if (!this.Status.isPowerOn) { return; } const swingValue = !!value ? '100' : '0'; const device = this.accessory.context.device; if (this.config.ac_swing_mode === 'BOTH' || this.config.ac_swing_mode === 'VERTICAL') { await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'WDirVStep', swingValue)); device.data.snapshot['airState.wDir.vStep'] = swingValue; } if (this.config.ac_swing_mode === 'BOTH' || this.config.ac_swing_mode === 'HORIZONTAL') { await ((_b = this.platform.ThinQ) === null || _b === void 0 ? void 0 : _b.thinq1DeviceControl(device, 'WDirHStep', swingValue)); device.data.snapshot['airState.wDir.hStep'] = swingValue; } this.updateAccessoryCharacteristic(device); } async setOpMode(opMode) { var _a; const device = this.accessory.context.device; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'OpMode', opMode)); device.data.snapshot['airState.opMode'] = opMode; this.updateAccessoryCharacteristic(device); } async setLight(value) { var _a; const device = this.accessory.context.device; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'DisplayControl', value ? '1' : '0')); } } exports.default = AC; //# sourceMappingURL=AC.js.map