UNPKG

@shadman-a/homebridge-my-ac

Version:

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

102 lines 5.3 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 }); exports.Status = void 0; const Refrigerator_1 = __importStar(require("../../devices/Refrigerator")); const helper_1 = require("../../helper"); class Refrigerator extends Refrigerator_1.default { createThermostat(name, key) { const keyMap = { fridgeTemp: 'TempRefrigerator', freezerTemp: 'TempFreezer', }; return super.createThermostat(name, keyMap[key]); } async setTemperature(key, temp) { var _a; const device = this.accessory.context.device; await ((_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, key, temp)); } async setExpressMode(value) { var _a; const device = this.accessory.context.device; const On = device.deviceModel.enumValue('IcePlus', '@CP_ON_EN_W'); const Off = device.deviceModel.enumValue('IcePlus', '@CP_OFF_EN_W'); (_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'IcePlus', value ? On : Off); } async setExpressFridge(value) { var _a; const device = this.accessory.context.device; const On = device.deviceModel.enumValue('ExpressFridge', '@CP_ON_EN_W'); const Off = device.deviceModel.enumValue('ExpressFridge', '@CP_OFF_EN_W'); (_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'ExpressFridge', value ? On : Off); } async setEcoFriendly(value) { var _a; const device = this.accessory.context.device; const On = device.deviceModel.enumValue('EcoFriendly', '@CP_ON_EN_W'); const Off = device.deviceModel.enumValue('EcoFriendly', '@CP_OFF_EN_W'); (_a = this.platform.ThinQ) === null || _a === void 0 ? void 0 : _a.thinq1DeviceControl(device, 'EcoFriendly', value ? On : Off); } get Status() { var _a; return new Status((_a = this.accessory.context.device.snapshot) === null || _a === void 0 ? void 0 : _a.refState, this.accessory.context.device.deviceModel); } } exports.default = Refrigerator; class Status extends Refrigerator_1.RefrigeratorStatus { get freezerTemperature() { var _a, _b, _c; // eslint-disable-next-line max-len const defaultValue = this.deviceModel.lookupMonitorValue('TempFreezer', (_a = this.data) === null || _a === void 0 ? void 0 : _a.freezerTemp, '0'); if (this.tempUnit === 'FAHRENHEIT') { return (0, helper_1.fToC)(parseInt(this.deviceModel.lookupMonitorValue('TempFreezer_F', (_b = this.data) === null || _b === void 0 ? void 0 : _b.freezerTemp, defaultValue))); } return parseInt(this.deviceModel.lookupMonitorValue('TempFreezer_C', (_c = this.data) === null || _c === void 0 ? void 0 : _c.freezerTemp, defaultValue)); } get fridgeTemperature() { var _a, _b, _c; // eslint-disable-next-line max-len const defaultValue = this.deviceModel.lookupMonitorValue('TempRefrigerator', (_a = this.data) === null || _a === void 0 ? void 0 : _a.fridgeTemp, '0'); if (this.tempUnit === 'FAHRENHEIT') { return (0, helper_1.fToC)(parseInt(this.deviceModel.lookupMonitorValue('TempRefrigerator_F', (_b = this.data) === null || _b === void 0 ? void 0 : _b.fridgeTemp, defaultValue))); } return parseInt(this.deviceModel.lookupMonitorValue('TempRefrigerator_C', (_c = this.data) === null || _c === void 0 ? void 0 : _c.fridgeTemp, defaultValue)); } get isExpressFridgeOn() { var _a; return ((_a = this.data) === null || _a === void 0 ? void 0 : _a.expressFridge) === this.deviceModel.lookupMonitorName('ExpressFridge', '@CP_ON_EN_W'); } get isExpressModeOn() { var _a; return ((_a = this.data) === null || _a === void 0 ? void 0 : _a.expressMode) === this.deviceModel.lookupMonitorName('IcePlus', '@CP_ON_EN_W'); } get isEcoFriendlyOn() { var _a; return ((_a = this.data) === null || _a === void 0 ? void 0 : _a.ecoFriendly) === this.deviceModel.lookupMonitorName('EcoFriendly', '@CP_ON_EN_W'); } } exports.Status = Status; //# sourceMappingURL=Refrigerator.js.map