@mp-consulting/homebridge-lg-thinq 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +15 -0
- package/CHANGELOG.md +98 -0
- package/LICENSE +176 -0
- package/README.md +114 -0
- package/config.schema.json +399 -0
- package/dist/__tests__/baseDevice.spec.d.ts +1 -0
- package/dist/__tests__/baseDevice.spec.js +96 -0
- package/dist/__tests__/baseDevice.spec.js.map +1 -0
- package/dist/__tests__/deviceControl.coercion.spec.d.ts +1 -0
- package/dist/__tests__/deviceControl.coercion.spec.js +53 -0
- package/dist/__tests__/deviceControl.coercion.spec.js.map +1 -0
- package/dist/__tests__/helper.spec.d.ts +1 -0
- package/dist/__tests__/helper.spec.js +74 -0
- package/dist/__tests__/helper.spec.js.map +1 -0
- package/dist/baseDevice.d.ts +40 -0
- package/dist/baseDevice.js +85 -0
- package/dist/baseDevice.js.map +1 -0
- package/dist/baseDevice.spec.d.ts +1 -0
- package/dist/baseDevice.spec.js +107 -0
- package/dist/baseDevice.spec.js.map +1 -0
- package/dist/characteristics/TotalConsumption.d.ts +2 -0
- package/dist/characteristics/TotalConsumption.js +17 -0
- package/dist/characteristics/TotalConsumption.js.map +1 -0
- package/dist/characteristics/index.d.ts +2 -0
- package/dist/characteristics/index.js +7 -0
- package/dist/characteristics/index.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +89 -0
- package/dist/cli.js.map +1 -0
- package/dist/devices/AeroTower.d.ts +24 -0
- package/dist/devices/AeroTower.js +113 -0
- package/dist/devices/AeroTower.js.map +1 -0
- package/dist/devices/AirConditioner.d.ts +425 -0
- package/dist/devices/AirConditioner.js +1253 -0
- package/dist/devices/AirConditioner.js.map +1 -0
- package/dist/devices/AirPurifier.d.ts +50 -0
- package/dist/devices/AirPurifier.js +281 -0
- package/dist/devices/AirPurifier.js.map +1 -0
- package/dist/devices/Dehumidifier.d.ts +28 -0
- package/dist/devices/Dehumidifier.js +175 -0
- package/dist/devices/Dehumidifier.js.map +1 -0
- package/dist/devices/Dishwasher.d.ts +64 -0
- package/dist/devices/Dishwasher.js +740 -0
- package/dist/devices/Dishwasher.js.map +1 -0
- package/dist/devices/Microwave.d.ts +128 -0
- package/dist/devices/Microwave.js +1939 -0
- package/dist/devices/Microwave.js.map +1 -0
- package/dist/devices/Oven.d.ts +148 -0
- package/dist/devices/Oven.js +1850 -0
- package/dist/devices/Oven.js.map +1 -0
- package/dist/devices/RangeHood.d.ts +16 -0
- package/dist/devices/RangeHood.js +99 -0
- package/dist/devices/RangeHood.js.map +1 -0
- package/dist/devices/Refrigerator.d.ts +50 -0
- package/dist/devices/Refrigerator.js +325 -0
- package/dist/devices/Refrigerator.js.map +1 -0
- package/dist/devices/Styler.d.ts +27 -0
- package/dist/devices/Styler.js +76 -0
- package/dist/devices/Styler.js.map +1 -0
- package/dist/devices/WasherDryer.d.ts +39 -0
- package/dist/devices/WasherDryer.js +170 -0
- package/dist/devices/WasherDryer.js.map +1 -0
- package/dist/devices/WasherDryer2.d.ts +9 -0
- package/dist/devices/WasherDryer2.js +16 -0
- package/dist/devices/WasherDryer2.js.map +1 -0
- package/dist/errors/AuthenticationError.d.ts +2 -0
- package/dist/errors/AuthenticationError.js +3 -0
- package/dist/errors/AuthenticationError.js.map +1 -0
- package/dist/errors/ManualProcessNeeded.d.ts +3 -0
- package/dist/errors/ManualProcessNeeded.js +4 -0
- package/dist/errors/ManualProcessNeeded.js.map +1 -0
- package/dist/errors/MonitorError.d.ts +2 -0
- package/dist/errors/MonitorError.js +3 -0
- package/dist/errors/MonitorError.js.map +1 -0
- package/dist/errors/NotConnectedError.d.ts +3 -0
- package/dist/errors/NotConnectedError.js +4 -0
- package/dist/errors/NotConnectedError.js.map +1 -0
- package/dist/errors/TokenError.d.ts +2 -0
- package/dist/errors/TokenError.js +3 -0
- package/dist/errors/TokenError.js.map +1 -0
- package/dist/errors/TokenExpiredError.d.ts +3 -0
- package/dist/errors/TokenExpiredError.js +4 -0
- package/dist/errors/TokenExpiredError.js.map +1 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.js +7 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/helper.d.ts +24 -0
- package/dist/helper.js +66 -0
- package/dist/helper.js.map +1 -0
- package/dist/helper.spec.d.ts +1 -0
- package/dist/helper.spec.js +74 -0
- package/dist/helper.spec.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/API.d.ts +141 -0
- package/dist/lib/API.js +362 -0
- package/dist/lib/API.js.map +1 -0
- package/dist/lib/API.spec.d.ts +1 -0
- package/dist/lib/API.spec.js +55 -0
- package/dist/lib/API.spec.js.map +1 -0
- package/dist/lib/Auth.d.ts +99 -0
- package/dist/lib/Auth.js +348 -0
- package/dist/lib/Auth.js.map +1 -0
- package/dist/lib/Auth.spec.d.ts +1 -0
- package/dist/lib/Auth.spec.js +111 -0
- package/dist/lib/Auth.spec.js.map +1 -0
- package/dist/lib/Device.d.ts +88 -0
- package/dist/lib/Device.js +95 -0
- package/dist/lib/Device.js.map +1 -0
- package/dist/lib/Device.spec.d.ts +1 -0
- package/dist/lib/Device.spec.js +53 -0
- package/dist/lib/Device.spec.js.map +1 -0
- package/dist/lib/DeviceModel.d.ts +164 -0
- package/dist/lib/DeviceModel.js +321 -0
- package/dist/lib/DeviceModel.js.map +1 -0
- package/dist/lib/DeviceModel.spec.d.ts +1 -0
- package/dist/lib/DeviceModel.spec.js +90 -0
- package/dist/lib/DeviceModel.spec.js.map +1 -0
- package/dist/lib/Gateway.d.ts +18 -0
- package/dist/lib/Gateway.js +25 -0
- package/dist/lib/Gateway.js.map +1 -0
- package/dist/lib/Gateway.spec.d.ts +1 -0
- package/dist/lib/Gateway.spec.js +35 -0
- package/dist/lib/Gateway.spec.js.map +1 -0
- package/dist/lib/Persist.d.ts +101 -0
- package/dist/lib/Persist.js +245 -0
- package/dist/lib/Persist.js.map +1 -0
- package/dist/lib/Persist.spec.d.ts +1 -0
- package/dist/lib/Persist.spec.js +90 -0
- package/dist/lib/Persist.spec.js.map +1 -0
- package/dist/lib/Session.d.ts +80 -0
- package/dist/lib/Session.js +100 -0
- package/dist/lib/Session.js.map +1 -0
- package/dist/lib/Session.spec.d.ts +1 -0
- package/dist/lib/Session.spec.js +43 -0
- package/dist/lib/Session.spec.js.map +1 -0
- package/dist/lib/ThinQ.d.ts +28 -0
- package/dist/lib/ThinQ.js +373 -0
- package/dist/lib/ThinQ.js.map +1 -0
- package/dist/lib/__tests__/API.spec.d.ts +1 -0
- package/dist/lib/__tests__/API.spec.js +55 -0
- package/dist/lib/__tests__/API.spec.js.map +1 -0
- package/dist/lib/__tests__/Auth.spec.d.ts +1 -0
- package/dist/lib/__tests__/Auth.spec.js +110 -0
- package/dist/lib/__tests__/Auth.spec.js.map +1 -0
- package/dist/lib/__tests__/Device.spec.d.ts +1 -0
- package/dist/lib/__tests__/Device.spec.js +53 -0
- package/dist/lib/__tests__/Device.spec.js.map +1 -0
- package/dist/lib/__tests__/DeviceModel.spec.d.ts +1 -0
- package/dist/lib/__tests__/DeviceModel.spec.js +90 -0
- package/dist/lib/__tests__/DeviceModel.spec.js.map +1 -0
- package/dist/lib/__tests__/Gateway.spec.d.ts +1 -0
- package/dist/lib/__tests__/Gateway.spec.js +35 -0
- package/dist/lib/__tests__/Gateway.spec.js.map +1 -0
- package/dist/lib/__tests__/Persist.spec.d.ts +1 -0
- package/dist/lib/__tests__/Persist.spec.js +90 -0
- package/dist/lib/__tests__/Persist.spec.js.map +1 -0
- package/dist/lib/__tests__/Session.spec.d.ts +1 -0
- package/dist/lib/__tests__/Session.spec.js +43 -0
- package/dist/lib/__tests__/Session.spec.js.map +1 -0
- package/dist/lib/constants.d.ts +95 -0
- package/dist/lib/constants.js +106 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/request.d.ts +2 -0
- package/dist/lib/request.js +66 -0
- package/dist/lib/request.js.map +1 -0
- package/dist/platform.d.ts +41 -0
- package/dist/platform.js +229 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.d.ts +8 -0
- package/dist/settings.js +9 -0
- package/dist/settings.js.map +1 -0
- package/dist/status/BaseStatus.d.ts +48 -0
- package/dist/status/BaseStatus.js +59 -0
- package/dist/status/BaseStatus.js.map +1 -0
- package/dist/types/snapshots.d.ts +142 -0
- package/dist/types/snapshots.js +6 -0
- package/dist/types/snapshots.js.map +1 -0
- package/dist/utils/__tests__/normalize.spec.d.ts +1 -0
- package/dist/utils/__tests__/normalize.spec.js +95 -0
- package/dist/utils/__tests__/normalize.spec.js.map +1 -0
- package/dist/utils/normalize.d.ts +22 -0
- package/dist/utils/normalize.js +51 -0
- package/dist/utils/normalize.js.map +1 -0
- package/dist/v1/__tests__/prepareControlData.spec.d.ts +1 -0
- package/dist/v1/__tests__/prepareControlData.spec.js +48 -0
- package/dist/v1/__tests__/prepareControlData.spec.js.map +1 -0
- package/dist/v1/devices/AC.d.ts +13 -0
- package/dist/v1/devices/AC.js +112 -0
- package/dist/v1/devices/AC.js.map +1 -0
- package/dist/v1/devices/AirPurifier.d.ts +15 -0
- package/dist/v1/devices/AirPurifier.js +57 -0
- package/dist/v1/devices/AirPurifier.js.map +1 -0
- package/dist/v1/devices/RangeHood.d.ts +6 -0
- package/dist/v1/devices/RangeHood.js +12 -0
- package/dist/v1/devices/RangeHood.js.map +1 -0
- package/dist/v1/devices/Refrigerator.d.ts +17 -0
- package/dist/v1/devices/Refrigerator.js +69 -0
- package/dist/v1/devices/Refrigerator.js.map +1 -0
- package/dist/v1/devices/Washer.d.ts +10 -0
- package/dist/v1/devices/Washer.js +23 -0
- package/dist/v1/devices/Washer.js.map +1 -0
- package/dist/v1/devices/index.d.ts +6 -0
- package/dist/v1/devices/index.js +7 -0
- package/dist/v1/devices/index.js.map +1 -0
- package/dist/v1/helper.d.ts +14 -0
- package/dist/v1/helper.js +111 -0
- package/dist/v1/helper.js.map +1 -0
- package/dist/v1/transforms/AirPurifierState.d.ts +2 -0
- package/dist/v1/transforms/AirPurifierState.js +9 -0
- package/dist/v1/transforms/AirPurifierState.js.map +1 -0
- package/dist/v1/transforms/AirState.d.ts +9 -0
- package/dist/v1/transforms/AirState.js +55 -0
- package/dist/v1/transforms/AirState.js.map +1 -0
- package/dist/v1/transforms/HoodState.d.ts +17 -0
- package/dist/v1/transforms/HoodState.js +20 -0
- package/dist/v1/transforms/HoodState.js.map +1 -0
- package/dist/v1/transforms/RefState.d.ts +6 -0
- package/dist/v1/transforms/RefState.js +29 -0
- package/dist/v1/transforms/RefState.js.map +1 -0
- package/dist/v1/transforms/WasherDryer.d.ts +49 -0
- package/dist/v1/transforms/WasherDryer.js +56 -0
- package/dist/v1/transforms/WasherDryer.js.map +1 -0
- package/docs/authorization.md +40 -0
- package/docs/device-configuration.md +68 -0
- package/homebridge-ui/public/index.html +120 -0
- package/homebridge-ui/public/js/app.js +300 -0
- package/homebridge-ui/public/js/countries.js +233 -0
- package/homebridge-ui/public/styles.css +185 -0
- package/homebridge-ui/server.js +103 -0
- package/jest.config.ts +39 -0
- package/package.json +83 -0
- package/sample/README.md +10 -0
- package/sample/airconditioner-model.json +3080 -0
- package/sample/airconditioner-snapshot.json +49 -0
- package/sample/airconditioner.json +157 -0
- package/sample/dishwasher-model.json +869 -0
- package/sample/dishwasher.json +125 -0
- package/sample/washer_dryer-model.json +1294 -0
- package/sample/washer_dryer.json +126 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import { AccessoryContext, BaseDevice } from '../baseDevice.js';
|
|
2
|
+
import { LGThinQHomebridgePlatform } from '../platform.js';
|
|
3
|
+
import { CharacteristicValue, Logger, PlatformAccessory, Service } from 'homebridge';
|
|
4
|
+
import { Device } from '../lib/Device.js';
|
|
5
|
+
import { EnumValue, RangeValue } from '../lib/DeviceModel.js';
|
|
6
|
+
export declare enum ACModelType {
|
|
7
|
+
AWHP = "AWHP",
|
|
8
|
+
RAC = "RAC"
|
|
9
|
+
}
|
|
10
|
+
export declare const FAN_SPEED_AUTO = 8;
|
|
11
|
+
export declare enum FanSpeed {
|
|
12
|
+
LOW = 2,
|
|
13
|
+
LOW_MEDIUM = 3,
|
|
14
|
+
MEDIUM = 4,
|
|
15
|
+
MEDIUM_HIGH = 5,
|
|
16
|
+
HIGH = 6
|
|
17
|
+
}
|
|
18
|
+
export declare enum OpMode {
|
|
19
|
+
AUTO = 6,
|
|
20
|
+
COOL = 0,
|
|
21
|
+
HEAT = 4,
|
|
22
|
+
FAN = 2,
|
|
23
|
+
DRY = 1,
|
|
24
|
+
AIR_CLEAN = 5
|
|
25
|
+
}
|
|
26
|
+
export type Config = {
|
|
27
|
+
ac_swing_mode: string;
|
|
28
|
+
ac_air_quality: boolean;
|
|
29
|
+
ac_mode: string;
|
|
30
|
+
ac_temperature_sensor: boolean;
|
|
31
|
+
ac_humidity_sensor: boolean;
|
|
32
|
+
ac_led_control: boolean;
|
|
33
|
+
ac_fan_control: boolean;
|
|
34
|
+
ac_jet_control: boolean;
|
|
35
|
+
ac_temperature_unit: string;
|
|
36
|
+
ac_buttons: {
|
|
37
|
+
name: string;
|
|
38
|
+
op_mode: string;
|
|
39
|
+
}[];
|
|
40
|
+
ac_air_clean: boolean;
|
|
41
|
+
ac_energy_save: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Represents an LG ThinQ Air Conditioner device.
|
|
45
|
+
* This class extends the `baseDevice` class and provides functionality to control and monitor
|
|
46
|
+
* various features of an air conditioner, such as temperature, fan speed, swing mode, and more.
|
|
47
|
+
*/
|
|
48
|
+
export default class AirConditioner extends BaseDevice {
|
|
49
|
+
readonly platform: LGThinQHomebridgePlatform;
|
|
50
|
+
readonly accessory: PlatformAccessory<AccessoryContext>;
|
|
51
|
+
protected service: Service;
|
|
52
|
+
protected serviceAirQuality: Service | undefined;
|
|
53
|
+
protected serviceSensor: Service | undefined;
|
|
54
|
+
protected serviceHumiditySensor: Service | undefined;
|
|
55
|
+
protected serviceLight: Service | undefined;
|
|
56
|
+
protected serviceFanV2: Service | undefined;
|
|
57
|
+
protected serviceJetMode: Service | undefined;
|
|
58
|
+
protected serviceQuietMode: Service | undefined;
|
|
59
|
+
protected serviceEnergySaveMode: Service | undefined;
|
|
60
|
+
protected serviceAirClean: Service | undefined;
|
|
61
|
+
/** @deprecated Use AC_MODEL_FEATURES from lib/constants.js instead */
|
|
62
|
+
protected jetModeModels: string[];
|
|
63
|
+
/** @deprecated Use AC_MODEL_FEATURES from lib/constants.js instead */
|
|
64
|
+
protected quietModeModels: string[];
|
|
65
|
+
/** @deprecated Use AC_MODEL_FEATURES from lib/constants.js instead */
|
|
66
|
+
protected energySaveModeModels: string[];
|
|
67
|
+
protected airCleanModels: string[];
|
|
68
|
+
protected currentTargetState: number;
|
|
69
|
+
protected serviceLabelButtons: Service | undefined;
|
|
70
|
+
protected monitorInterval: ReturnType<typeof setInterval> | undefined;
|
|
71
|
+
constructor(platform: LGThinQHomebridgePlatform, accessory: PlatformAccessory<AccessoryContext>, logger: Logger);
|
|
72
|
+
destroy(): void;
|
|
73
|
+
protected createFanService(): void;
|
|
74
|
+
protected createAirQualityService(): void;
|
|
75
|
+
protected createHeaterCoolerService(): void;
|
|
76
|
+
get config(): Config;
|
|
77
|
+
get Status(): ACStatus;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the energy-saving mode for the air conditioner.
|
|
80
|
+
*
|
|
81
|
+
* @param value - A boolean indicating whether to enable or disable energy-saving mode.
|
|
82
|
+
*/
|
|
83
|
+
setEnergySaveActive(value: CharacteristicValue): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the air purification mode for the air conditioner.
|
|
86
|
+
*
|
|
87
|
+
* @param value - A boolean indicating whether to enable or disable air purification mode.
|
|
88
|
+
*/
|
|
89
|
+
setAirCleanActive(value: CharacteristicValue): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Sets the quiet mode for the air conditioner.
|
|
92
|
+
*
|
|
93
|
+
* @param value - A boolean indicating whether to enable or disable quiet mode.
|
|
94
|
+
*/
|
|
95
|
+
setQuietModeActive(value: CharacteristicValue): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Sets the jet mode active state for the air conditioner device.
|
|
98
|
+
*
|
|
99
|
+
* @param value - The desired state of jet mode, where `true` activates jet mode and `false` deactivates it.
|
|
100
|
+
* @returns The resulting state of jet mode after the operation.
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* - Jet mode can only be activated if the device is powered on and the operation mode (`opMode`) is set to 0.
|
|
104
|
+
* - If the operation fails, an error is logged, and the method returns the opposite state of the requested value.
|
|
105
|
+
* - If jet mode is not supported in the current state, the method logs a debug message and returns `INACTIVE`.
|
|
106
|
+
*
|
|
107
|
+
* @throws Logs an error if there is an issue with the device control operation.
|
|
108
|
+
*/
|
|
109
|
+
setJetModeActive(value: CharacteristicValue): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Sets the fan state of the air conditioner to either AUTO or MANUAL mode.
|
|
112
|
+
*
|
|
113
|
+
* @param value - The desired fan state, represented as a `CharacteristicValue`.
|
|
114
|
+
* It can be either `TargetFanState.AUTO` or `TargetFanState.MANUAL`.
|
|
115
|
+
* @returns The updated fan state, which will match the input value if the operation succeeds,
|
|
116
|
+
* or the opposite state if the operation fails or the power is off.
|
|
117
|
+
*
|
|
118
|
+
* @remarks
|
|
119
|
+
* - If the air conditioner is powered off, the method logs a debug message and returns
|
|
120
|
+
* the opposite of the requested fan state.
|
|
121
|
+
* - If the air conditioner is powered on, it attempts to update the fan state via the
|
|
122
|
+
* ThinQ API. On success, the fan state is updated in the device's context. On failure,
|
|
123
|
+
* an error is logged, and the opposite fan state is returned.
|
|
124
|
+
* - The AUTO mode corresponds to a wind strength value of 8, while MANUAL mode corresponds
|
|
125
|
+
* to a high fan speed.
|
|
126
|
+
*
|
|
127
|
+
* @throws This method does not throw errors directly but logs them if the ThinQ API call fails.
|
|
128
|
+
*/
|
|
129
|
+
setFanState(value: CharacteristicValue): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Updates the accessory characteristics based on the current device state.
|
|
132
|
+
*
|
|
133
|
+
* @param device - The device object containing the current state.
|
|
134
|
+
*/
|
|
135
|
+
updateAccessoryCharacteristic(device: Device): void;
|
|
136
|
+
/**
|
|
137
|
+
* Updates the "Active" characteristic of the accessory's service to reflect the current power status.
|
|
138
|
+
*
|
|
139
|
+
* This method checks the power status of the device (`isPowerOn`) and updates the "Active" characteristic
|
|
140
|
+
* accordingly. If the device is powered on, the characteristic is set to `ACTIVE`, otherwise it is set to `INACTIVE`.
|
|
141
|
+
*/
|
|
142
|
+
updateAccessoryActiveCharacteristic(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Updates the `CurrentTemperature` characteristic of the accessory's service
|
|
145
|
+
* with the current temperature value from the device's status.
|
|
146
|
+
*
|
|
147
|
+
* This method ensures that the Homebridge platform reflects the most recent
|
|
148
|
+
* temperature reading from the air conditioner.
|
|
149
|
+
*/
|
|
150
|
+
updateAccessoryCurrentTemperatureCharacteristic(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Updates the state characteristics of the accessory based on the current status of the air conditioner.
|
|
153
|
+
*
|
|
154
|
+
* This method synchronizes the accessory's characteristics with the current operational state of the air conditioner,
|
|
155
|
+
* including power status, operating mode, and temperature settings. It updates the `CurrentHeaterCoolerState` and
|
|
156
|
+
* `TargetHeaterCoolerState` characteristics accordingly.
|
|
157
|
+
*
|
|
158
|
+
* Behavior:
|
|
159
|
+
* - If the air conditioner is powered off, the state is set to `INACTIVE`.
|
|
160
|
+
* - If the operating mode is `COOL`, the state is set to `COOLING` and the target state to `COOL`.
|
|
161
|
+
* - If the operating mode is `HEAT`, the state is set to `HEATING` and the target state to `HEAT`.
|
|
162
|
+
* - If the operating mode is `AUTO` or undefined (`-1`), the state is determined based on the current and target temperatures:
|
|
163
|
+
* - If the current temperature is below the target temperature, the state is set to `HEATING` and the target state to `HEAT`.
|
|
164
|
+
* - Otherwise, the state is set to `COOLING` and the target state to `COOL`.
|
|
165
|
+
* - For other modes, no specific behavior is defined.
|
|
166
|
+
*
|
|
167
|
+
* @remarks
|
|
168
|
+
* This method assumes that the `Status` object contains the necessary properties (`isPowerOn`, `opMode`, `currentTemperature`,
|
|
169
|
+
* and `targetTemperature`) and that the `service` object provides the `updateCharacteristic` method.
|
|
170
|
+
*/
|
|
171
|
+
updateAccessoryStateCharacteristics(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Updates the accessory's temperature characteristics based on the current state
|
|
174
|
+
* of the heater or cooler. Depending on whether the device is in heating or cooling
|
|
175
|
+
* mode, it updates the corresponding threshold temperature characteristic.
|
|
176
|
+
*
|
|
177
|
+
* - If the current state is `HEATING`, the `HeatingThresholdTemperature` characteristic
|
|
178
|
+
* is updated with the target temperature.
|
|
179
|
+
* - If the current state is `COOLING`, the `CoolingThresholdTemperature` characteristic
|
|
180
|
+
* is updated with the target temperature, and a debug log is generated.
|
|
181
|
+
*
|
|
182
|
+
* @remarks
|
|
183
|
+
* This method relies on the `Status.targetTemperature` property to determine the
|
|
184
|
+
* target temperature and the `CurrentHeaterCoolerState` characteristic to determine
|
|
185
|
+
* the current operating mode of the device.
|
|
186
|
+
*/
|
|
187
|
+
updateAccessoryTemperatureCharacteristics(): void;
|
|
188
|
+
/**
|
|
189
|
+
* Updates the fan state characteristics of the accessory.
|
|
190
|
+
*
|
|
191
|
+
* This method updates the `RotationSpeed` and `SwingMode` characteristics
|
|
192
|
+
* of the accessory's service based on the current status of the device.
|
|
193
|
+
*
|
|
194
|
+
* - `RotationSpeed` is updated using the `windStrength` value from the device status.
|
|
195
|
+
* - `SwingMode` is updated based on whether the swing mode is enabled or disabled.
|
|
196
|
+
*
|
|
197
|
+
* @remarks
|
|
198
|
+
* The `SwingMode` characteristic is set to `SWING_ENABLED` if the swing mode is on,
|
|
199
|
+
* otherwise it is set to `SWING_DISABLED`.
|
|
200
|
+
*/
|
|
201
|
+
updateAccessoryFanStateCharacteristics(): void;
|
|
202
|
+
/**
|
|
203
|
+
* Updates the Total Consumption characteristic of the accessory with the current consumption value.
|
|
204
|
+
* This method retrieves the current consumption from the device's status and updates the
|
|
205
|
+
* corresponding custom characteristic in the Homebridge service.
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* Ensure that the `TotalConsumption` custom characteristic is properly defined in the platform
|
|
209
|
+
* and that the `Status.currentConsumption` value is up-to-date before calling this method.
|
|
210
|
+
*/
|
|
211
|
+
updateAccessoryTotalConsumptionCharacteristic(): void;
|
|
212
|
+
/**
|
|
213
|
+
* Updates the air quality characteristics of the accessory based on the current air quality status.
|
|
214
|
+
* This method checks if the air quality feature is enabled and updates the corresponding characteristics
|
|
215
|
+
* in the Homebridge service with the current air quality readings.
|
|
216
|
+
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* The method updates the `AirQuality`, `PM2_5Density`, and `PM10Density` characteristics if the air quality
|
|
219
|
+
* data is available and the air quality feature is enabled.
|
|
220
|
+
*/
|
|
221
|
+
updateAccessoryAirQualityCharacteristic(): void;
|
|
222
|
+
/**
|
|
223
|
+
* Updates the temperature sensor characteristics of the accessory.
|
|
224
|
+
*
|
|
225
|
+
* This method checks if the air conditioner temperature sensor is enabled in the configuration
|
|
226
|
+
* and if the temperature sensor service (`serviceSensor`) is available. If both conditions are met,
|
|
227
|
+
* it updates the following characteristics:
|
|
228
|
+
*
|
|
229
|
+
* - `CurrentTemperature`: Reflects the current temperature reported by the air conditioner.
|
|
230
|
+
* - `StatusActive`: Indicates whether the air conditioner is powered on.
|
|
231
|
+
*
|
|
232
|
+
* @remarks
|
|
233
|
+
* Ensure that the `config.ac_temperature_sensor` is properly set and that the `serviceSensor` is initialized
|
|
234
|
+
* before calling this method to avoid runtime errors.
|
|
235
|
+
*/
|
|
236
|
+
updateAccessoryTemperatureSensorCharacteristic(): void;
|
|
237
|
+
/**
|
|
238
|
+
* Updates the characteristics of the humidity sensor accessory.
|
|
239
|
+
*
|
|
240
|
+
* This method updates the `CurrentRelativeHumidity` and `StatusActive` characteristics
|
|
241
|
+
* of the humidity sensor service if the humidity sensor is enabled in the configuration
|
|
242
|
+
* (`ac_humidity_sensor`) and the `serviceHumiditySensor` is defined.
|
|
243
|
+
*
|
|
244
|
+
* - `CurrentRelativeHumidity` is updated with the current relative humidity value from the device status.
|
|
245
|
+
* - `StatusActive` is updated based on whether the air conditioner is powered on.
|
|
246
|
+
*/
|
|
247
|
+
updateAccessoryHumiditySensorCharacteristic(): void;
|
|
248
|
+
/**
|
|
249
|
+
* Updates the characteristics of the Fan V2 service for the accessory.
|
|
250
|
+
*
|
|
251
|
+
* This method synchronizes the accessory's Fan V2 service characteristics with the current
|
|
252
|
+
* status of the air conditioner, including power state, swing mode, wind strength, and
|
|
253
|
+
* whether the fan is in auto or manual mode.
|
|
254
|
+
*
|
|
255
|
+
* The following characteristics are updated:
|
|
256
|
+
* - `Active`: Indicates whether the fan is active or inactive based on the power state.
|
|
257
|
+
* - `TargetFanState`: Sets the fan state to AUTO or MANUAL depending on the wind strength mode.
|
|
258
|
+
* - `RotationSpeed`: Updates the fan's rotation speed if in manual mode.
|
|
259
|
+
* - `SwingMode`: Indicates whether the swing mode is enabled or disabled.
|
|
260
|
+
*
|
|
261
|
+
* This method only performs updates if the `ac_fan_control` configuration is enabled and
|
|
262
|
+
* the `serviceFanV2` is defined.
|
|
263
|
+
*/
|
|
264
|
+
updateAccessoryFanV2Characteristic(): void;
|
|
265
|
+
/**
|
|
266
|
+
* Updates the LED control characteristic of the accessory.
|
|
267
|
+
*
|
|
268
|
+
* This method checks the current status of the accessory's light and updates
|
|
269
|
+
* the corresponding characteristic in the Homebridge service if the LED control
|
|
270
|
+
* configuration is enabled and the serviceLight is defined.
|
|
271
|
+
*
|
|
272
|
+
* @remarks
|
|
273
|
+
* - The `isLightOn` status is retrieved from the accessory's current status.
|
|
274
|
+
* - The `ac_led_control` configuration determines whether the LED control feature is enabled.
|
|
275
|
+
* - The `serviceLight` represents the Homebridge service responsible for the light characteristic.
|
|
276
|
+
*/
|
|
277
|
+
updateAccessoryLedControlCharacteristic(): void;
|
|
278
|
+
updateAccessoryJetModeCharacteristic(): void;
|
|
279
|
+
updateAccessoryquietModeModelsCharacteristic(): void;
|
|
280
|
+
updateAccessoryenergySaveModeModelsCharacteristic(): void;
|
|
281
|
+
updateAccessoryairCleanModelsCharacteristic(): void;
|
|
282
|
+
setLight(value: CharacteristicValue): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* Sets the target state of the air conditioner based on the provided HomeKit characteristic value.
|
|
285
|
+
* Maps the HomeKit target states to the corresponding LG operation modes and updates the device state.
|
|
286
|
+
*
|
|
287
|
+
* @param value - The target state value from HomeKit, represented as a `CharacteristicValue`.
|
|
288
|
+
* Possible values include AUTO, HEAT, and COOL.
|
|
289
|
+
* @returns The updated target state value if successful, or `null` if an error occurs.
|
|
290
|
+
*
|
|
291
|
+
* @throws Logs an error if the operation mode cannot be updated on the device.
|
|
292
|
+
*/
|
|
293
|
+
setTargetState(value: CharacteristicValue): Promise<void>;
|
|
294
|
+
setActive(value: CharacteristicValue): Promise<void>;
|
|
295
|
+
/**
|
|
296
|
+
* Sets the target temperature for the air conditioner.
|
|
297
|
+
*
|
|
298
|
+
* @param value - The desired target temperature as a `CharacteristicValue`.
|
|
299
|
+
*
|
|
300
|
+
* @returns The target temperature if successfully set, or `null` if an error occurs or the operation is invalid.
|
|
301
|
+
*
|
|
302
|
+
* @remarks
|
|
303
|
+
* - If the air conditioner is powered off, the method logs an error and returns `null`.
|
|
304
|
+
* - If the provided value is not a number, the method logs an error and returns `null`.
|
|
305
|
+
* - The method checks whether the target temperature is within the valid range for the current mode
|
|
306
|
+
* (cooling or heating). If the value is out of range, it logs an error and returns `null`.
|
|
307
|
+
* - If the target temperature is the same as the current temperature, no action is taken, and the method logs a debug message.
|
|
308
|
+
* - The temperature value is converted from HomeKit format to LG format before being sent to the device.
|
|
309
|
+
* - If the operation fails, an error is logged, and the method returns `null`.
|
|
310
|
+
*
|
|
311
|
+
* @throws This method does not throw exceptions but logs errors instead.
|
|
312
|
+
*/
|
|
313
|
+
setTargetTemperature(value: CharacteristicValue): Promise<void>;
|
|
314
|
+
/**
|
|
315
|
+
* Sets the fan speed of the air conditioner.
|
|
316
|
+
*
|
|
317
|
+
* @param value - The desired fan speed value, which is expected to be a number.
|
|
318
|
+
* The value is rounded and constrained to a minimum of 1.
|
|
319
|
+
* @returns The provided fan speed value if the operation is successful, or `null` if the power is off
|
|
320
|
+
* or an error occurs during the operation.
|
|
321
|
+
*
|
|
322
|
+
* @remarks
|
|
323
|
+
* - If the air conditioner is not powered on (`this.Status.isPowerOn` is `false`), the method exits early and returns `null`.
|
|
324
|
+
* - The fan speed value is mapped to a corresponding wind strength value using the `FanSpeed` enumeration.
|
|
325
|
+
* - The method sends a control command to the ThinQ platform to update the fan speed.
|
|
326
|
+
* - If the operation is successful, the updated wind strength value is stored in the device's snapshot.
|
|
327
|
+
* - Any errors encountered during the operation are logged, and the method returns `null`.
|
|
328
|
+
*
|
|
329
|
+
* @throws This method does not throw exceptions directly but logs errors internally if the operation fails.
|
|
330
|
+
*/
|
|
331
|
+
setFanSpeed(value: CharacteristicValue): Promise<void>;
|
|
332
|
+
setSwingMode(value: CharacteristicValue): Promise<void>;
|
|
333
|
+
setOpMode(deviceId: string, opMode: number): Promise<boolean>;
|
|
334
|
+
protected isJetModeEnabled(model: string): boolean;
|
|
335
|
+
setupButton(device: Device): void;
|
|
336
|
+
protected setupButtonOpmode(device: Device, name: string, opMode: number): void;
|
|
337
|
+
/**
|
|
338
|
+
* Handles the operation mode button press for the air conditioner.
|
|
339
|
+
*
|
|
340
|
+
* @param value - The characteristic value indicating the button state (true for pressed, false for released).
|
|
341
|
+
* @param opMode - The operation mode to set when the button is pressed.
|
|
342
|
+
*
|
|
343
|
+
* When the button is pressed (`value` is true) and the current operation mode (`this.Status.opMode`)
|
|
344
|
+
* is different from the provided `opMode`, the method updates the operation mode to the provided `opMode`.
|
|
345
|
+
*
|
|
346
|
+
* When the button is released (`value` is false), the method resets the operation mode to `OpMode.COOL`,
|
|
347
|
+
* updates the accessory state characteristics, and restores the target state to the current target state.
|
|
348
|
+
*
|
|
349
|
+
* @returns A promise that resolves when the operation mode and related states are successfully updated.
|
|
350
|
+
*/
|
|
351
|
+
handleButtonOpmode(value: CharacteristicValue, opMode: number): Promise<void>;
|
|
352
|
+
}
|
|
353
|
+
export declare class ACStatus {
|
|
354
|
+
protected data: any;
|
|
355
|
+
protected device: Device;
|
|
356
|
+
protected config: Config;
|
|
357
|
+
private logger;
|
|
358
|
+
constructor(data: any, device: Device, config: Config, logger: Logger);
|
|
359
|
+
/**
|
|
360
|
+
* detect fahrenheit unit device by country code
|
|
361
|
+
* list: us
|
|
362
|
+
*/
|
|
363
|
+
get isFahrenheitUnit(): boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Converts temperature from Homekit to LG format.
|
|
366
|
+
* @param temperatureInCelsius The temperature in Celsius to convert.
|
|
367
|
+
* @returns The converted temperature in LG format.
|
|
368
|
+
*/
|
|
369
|
+
convertTemperatureCelsiusFromHomekitToLG(temperatureInCelsius: CharacteristicValue): number;
|
|
370
|
+
/**
|
|
371
|
+
* algorithm conversion LG vs Homekit is different
|
|
372
|
+
* so we need to handle it before submit to homekit
|
|
373
|
+
*/
|
|
374
|
+
convertTemperatureCelsiusFromLGToHomekit(temperature: number): number;
|
|
375
|
+
get opMode(): number;
|
|
376
|
+
get isPowerOn(): boolean;
|
|
377
|
+
get currentRelativeHumidity(): number;
|
|
378
|
+
get currentTemperature(): number;
|
|
379
|
+
get targetTemperature(): number;
|
|
380
|
+
get airQuality(): {
|
|
381
|
+
isOn: any;
|
|
382
|
+
overall: number;
|
|
383
|
+
PM2: number;
|
|
384
|
+
PM10: number;
|
|
385
|
+
} | null;
|
|
386
|
+
get windStrength(): number;
|
|
387
|
+
get isWindStrengthAuto(): boolean;
|
|
388
|
+
get isSwingOn(): boolean;
|
|
389
|
+
get isLightOn(): boolean;
|
|
390
|
+
get currentConsumption(): number;
|
|
391
|
+
get type(): string;
|
|
392
|
+
/**
|
|
393
|
+
* Retrieves the temperature range based on the provided minimum and maximum range values.
|
|
394
|
+
*
|
|
395
|
+
* @param [minRange, maxRange] - A tuple containing the minimum and maximum range values as `EnumValue` objects.
|
|
396
|
+
* @returns A `RangeValue` object representing the temperature range, including its type, minimum, maximum, and step values.
|
|
397
|
+
*
|
|
398
|
+
* The method first attempts to calculate the temperature range using the provided `minRange` and `maxRange` values.
|
|
399
|
+
* If these values are not sufficient to determine a valid range, it falls back to retrieving the range from the device model's
|
|
400
|
+
* `airState.tempState.limitMin` or `airState.tempState.target` properties.
|
|
401
|
+
*/
|
|
402
|
+
getTemperatureRange([minRange, maxRange]: [EnumValue, EnumValue]): RangeValue;
|
|
403
|
+
/**
|
|
404
|
+
* Retrieves the temperature range for heating based on the air conditioner's model type.
|
|
405
|
+
*
|
|
406
|
+
* For AWHP models, the range is determined using water temperature heating limits.
|
|
407
|
+
* For other models, the range is determined using general heating limits.
|
|
408
|
+
*
|
|
409
|
+
* @returns A tuple containing two `EnumValue` objects:
|
|
410
|
+
* - The first element represents the minimum heating temperature.
|
|
411
|
+
* - The second element represents the maximum heating temperature.
|
|
412
|
+
*/
|
|
413
|
+
getTemperatureRangeForHeating(): [EnumValue, EnumValue];
|
|
414
|
+
/**
|
|
415
|
+
* Retrieves the temperature range for cooling based on the air conditioner's model type.
|
|
416
|
+
*
|
|
417
|
+
* For AWHP models, the range is determined using water temperature cooling limits.
|
|
418
|
+
* For other models, the range is determined using general cooling limits.
|
|
419
|
+
*
|
|
420
|
+
* @returns A tuple containing two `EnumValue` objects:
|
|
421
|
+
* - The first element represents the minimum cooling temperature.
|
|
422
|
+
* - The second element represents the maximum cooling temperature.
|
|
423
|
+
*/
|
|
424
|
+
getTemperatureRangeForCooling(): [EnumValue, EnumValue];
|
|
425
|
+
}
|