homebridge-lg-thinq-2 2.0.3 → 2.0.5
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/CHANGELOG.md +28 -0
- package/dist/baseDevice.js +7 -1
- package/dist/devices/AirConditioner.js +23 -8
- package/dist/lib/API.js +22 -2
- package/dist/lib/mqttCertificate.js +12 -2
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## v2.0.5
|
|
4
|
+
|
|
5
|
+
Fixes from [nVuln/homebridge-lg-thinq#401](https://github.com/nVuln/homebridge-lg-thinq/pull/401) by Vojtech Knyttl, which was never merged in the original repository.
|
|
6
|
+
|
|
7
|
+
### Air Conditioner
|
|
8
|
+
|
|
9
|
+
* The fan speed control now uses LG's own 5 speeds (HomeKit values 1 to 5) instead of a 0 to 100 percentage. With the percentage, most slider positions mapped to the speed the AC was already using, so the control seemed stuck and snapped back. Now every position selects a different speed. HomeKit speed 0 selects the lowest speed, because turning the AC off is a separate control.
|
|
10
|
+
|
|
11
|
+
### Devices
|
|
12
|
+
|
|
13
|
+
* The accessory name shown in HomeKit now follows the device name. Before, a device renamed in the ThinQ app or in the plugin config kept showing its old name in the Home app.
|
|
14
|
+
|
|
15
|
+
### Logging and Reliability
|
|
16
|
+
|
|
17
|
+
* Commands that a device rejects as not supported (ThinQ result codes `0101` and `9006`), such as the AC temperature keep-alive on some models, are now logged at debug level instead of as errors, which flooded the log every few minutes ([nVuln/homebridge-lg-thinq#391](https://github.com/nVuln/homebridge-lg-thinq/issues/391)).
|
|
18
|
+
* When ThinQ does not return an MQTT certificate, the plugin now logs a clear error and retries, instead of failing with `Cannot read properties of undefined (reading 'certificatePem')`.
|
|
19
|
+
|
|
20
|
+
### Dependencies
|
|
21
|
+
|
|
22
|
+
* Cleared all known vulnerabilities in the published package's dependencies (`npm audit --omit=dev` reports 0, was 9): `node-forge` 1.4.3, `qs` 6.17.1, and overrides for `ws` 8.23.0, `glob` 14.0.6, and `brace-expansion` 5.0.13. `ws` is forced to 8.x for `aws-iot-device-sdk` and `mqtt`, which pin a vulnerable 7.x; the plugin connects to MQTT over TLS, not websockets, and was verified to still connect.
|
|
23
|
+
|
|
24
|
+
## v2.0.4
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* Raised the minimum axios version to 1.21.1 (was 1.16.0). axios versions before 1.16.1 send HTTPS requests to an HTTPS proxy as plain requests instead of opening a `CONNECT` tunnel, so proxies reject them (HTTP 405). With 1.21.1, requests through an `HTTPS_PROXY` work. Installs from npm already resolved to a newer axios, so this mainly guarantees the plugin never runs with an affected version.
|
|
29
|
+
* The axios update also brings patched `follow-redirects` and `form-data` versions, and lowers the dependency issues reported by `npm audit` for the published package from 12 to 9 (high: from 6 to 3). The remaining ones come from `aws-iot-device-sdk` (through `mqtt` and `glob`).
|
|
30
|
+
|
|
3
31
|
## v2.0.3
|
|
4
32
|
|
|
5
33
|
### Login
|
package/dist/baseDevice.js
CHANGED
|
@@ -18,7 +18,13 @@ export class BaseDevice extends EventEmitter {
|
|
|
18
18
|
serviceAccessoryInformation
|
|
19
19
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'LG')
|
|
20
20
|
.setCharacteristic(this.platform.Characteristic.Model, device.salesModel || device.model || 'Unknown')
|
|
21
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.config.serial_number || device.serialNumber || 'Unknown')
|
|
21
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.config.serial_number || device.serialNumber || 'Unknown')
|
|
22
|
+
// Keep the accessory-information name in sync with the device name. This
|
|
23
|
+
// characteristic is what controllers show as the accessory's identity, and
|
|
24
|
+
// it is restored from the accessory cache - so without this a device that
|
|
25
|
+
// was renamed in the ThinQ app keeps displaying its old name indefinitely,
|
|
26
|
+
// even though the accessory's displayName and its other services update.
|
|
27
|
+
.setCharacteristic(this.platform.Characteristic.Name, device.name);
|
|
22
28
|
}
|
|
23
29
|
updateAccessoryCharacteristic(device) {
|
|
24
30
|
this.accessory.context.device = device;
|
|
@@ -19,10 +19,22 @@ export var FanSpeed;
|
|
|
19
19
|
FanSpeed[FanSpeed["MEDIUM_HIGH"] = 5] = "MEDIUM_HIGH";
|
|
20
20
|
FanSpeed[FanSpeed["HIGH"] = 6] = "HIGH";
|
|
21
21
|
})(FanSpeed || (FanSpeed = {}));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
// The LG fan has a small number of discrete steps (LOW..HIGH), so RotationSpeed
|
|
23
|
+
// is exposed as a step count rather than a 0-100 percentage: HomeKit speed N maps
|
|
24
|
+
// to the Nth LG step. A percentage scale collapses many slider positions onto the
|
|
25
|
+
// same windStrength, which makes the control send the speed the unit is already
|
|
26
|
+
// at and then snap back to the quantised readback.
|
|
27
|
+
const LG_FAN_SPEEDS = [
|
|
28
|
+
FanSpeed.LOW,
|
|
29
|
+
FanSpeed.LOW_MEDIUM,
|
|
30
|
+
FanSpeed.MEDIUM,
|
|
31
|
+
FanSpeed.MEDIUM_HIGH,
|
|
32
|
+
FanSpeed.HIGH,
|
|
33
|
+
];
|
|
34
|
+
const HOMEKIT_FAN_SPEED_MAX = LG_FAN_SPEEDS.length;
|
|
35
|
+
// Automatic (or unrecognised) fan speed has no step of its own; report the top of
|
|
36
|
+
// the range, matching the behaviour this plugin has always had.
|
|
37
|
+
const HOMEKIT_FAN_SPEED_DEFAULT = HOMEKIT_FAN_SPEED_MAX;
|
|
26
38
|
var OpMode;
|
|
27
39
|
(function (OpMode) {
|
|
28
40
|
OpMode[OpMode["AUTO"] = 6] = "AUTO";
|
|
@@ -95,8 +107,9 @@ function readWindStrength(data) {
|
|
|
95
107
|
if (num === FAN_SPEED_AUTO) {
|
|
96
108
|
return HOMEKIT_FAN_SPEED_DEFAULT;
|
|
97
109
|
}
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
const step = LG_FAN_SPEEDS.indexOf(num);
|
|
111
|
+
if (step !== -1) {
|
|
112
|
+
return step + 1;
|
|
100
113
|
}
|
|
101
114
|
}
|
|
102
115
|
return HOMEKIT_FAN_SPEED_DEFAULT;
|
|
@@ -288,8 +301,10 @@ export function windStrengthFromRotationSpeed(value) {
|
|
|
288
301
|
if (vNum === null) {
|
|
289
302
|
return null;
|
|
290
303
|
}
|
|
291
|
-
|
|
292
|
-
|
|
304
|
+
// Speed 0 means "off" in HomeKit, but the AC has no off fan step - treat it as
|
|
305
|
+
// the slowest speed, as turning the unit off is a separate characteristic.
|
|
306
|
+
const step = Math.min(HOMEKIT_FAN_SPEED_MAX, Math.max(1, Math.round(vNum)));
|
|
307
|
+
return LG_FAN_SPEEDS[step - 1];
|
|
293
308
|
}
|
|
294
309
|
export function swingCommandsForMode(value, swingMode) {
|
|
295
310
|
if (!isSwingModeEnabled(swingMode)) {
|
package/dist/lib/API.js
CHANGED
|
@@ -8,6 +8,16 @@ import { ManualProcessNeeded, MonitorError, NotConnectedError, TokenExpiredError
|
|
|
8
8
|
import crypto from 'crypto';
|
|
9
9
|
import axios from 'axios';
|
|
10
10
|
import { createNoopLogger } from './noopLogger.js';
|
|
11
|
+
/**
|
|
12
|
+
* ThinQ result codes returned for commands a device simply does not support
|
|
13
|
+
* (for example the AC temperature keep-alive on models that reject it). The
|
|
14
|
+
* calling code already treats these as a non-fatal "not supported", so they are
|
|
15
|
+
* logged at debug level instead of error to avoid flooding the log. (#391)
|
|
16
|
+
*/
|
|
17
|
+
const BENIGN_REQUEST_RESULT_CODES = new Set([
|
|
18
|
+
'0101', // command not supported by device
|
|
19
|
+
'9006', // device rejected the (optional) command
|
|
20
|
+
]);
|
|
11
21
|
/**
|
|
12
22
|
* The `API` class provides methods to interact with the LG ThinQ API, enabling
|
|
13
23
|
* device management, home management, and command execution. It handles
|
|
@@ -133,8 +143,18 @@ export class API {
|
|
|
133
143
|
throw err;
|
|
134
144
|
}
|
|
135
145
|
if (axios.isAxiosError(err)) {
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
const resultCode = err.response?.data?.resultCode;
|
|
147
|
+
// Some device models reject optional commands - e.g. the AC
|
|
148
|
+
// temperature keep-alive (`allEventEnable` / `airState.mon.timeout`) -
|
|
149
|
+
// with a benign result code. These failures are already handled by the
|
|
150
|
+
// caller, so logging them at error level only floods the log. (#391)
|
|
151
|
+
if (resultCode !== undefined && BENIGN_REQUEST_RESULT_CODES.has(resultCode)) {
|
|
152
|
+
this.logger.debug('request rejected by device (resultCode ' + resultCode + '): ', err.response?.data, data);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.logger.error('axios request error: ', err.response?.data, data);
|
|
156
|
+
this.logger.error(err.stack || 'No stack error');
|
|
157
|
+
}
|
|
138
158
|
}
|
|
139
159
|
else {
|
|
140
160
|
this.logger.error('request error: ', err);
|
|
@@ -48,9 +48,19 @@ export function createMqttCsr(keys) {
|
|
|
48
48
|
}
|
|
49
49
|
export async function requestMqttCertificate(api, csr) {
|
|
50
50
|
await api.postRequest(MQTT_CLIENT_PATH, {});
|
|
51
|
-
|
|
51
|
+
const response = await api.postRequest(MQTT_CERTIFICATE_PATH, {
|
|
52
52
|
csr: certificateRequestBody(csr),
|
|
53
|
-
})
|
|
53
|
+
});
|
|
54
|
+
const certificate = response?.result;
|
|
55
|
+
// `API.request` resolves to `{}` when the ThinQ API returns an error, so
|
|
56
|
+
// `result` (and therefore the certificate) can be missing. Fail with an
|
|
57
|
+
// actionable message instead of letting a downstream read of
|
|
58
|
+
// `certificate.certificatePem` throw a cryptic TypeError, which previously
|
|
59
|
+
// surfaced as an unhandled rejection on MQTT reconnect. (#391)
|
|
60
|
+
if (!certificate || typeof certificate.certificatePem !== 'string') {
|
|
61
|
+
throw new Error('ThinQ did not return an MQTT certificate; skipping this connection attempt.');
|
|
62
|
+
}
|
|
63
|
+
return certificate;
|
|
54
64
|
}
|
|
55
65
|
export async function loadMqttConnectionSetup(options) {
|
|
56
66
|
const { api, persist, logger, createKeys = generateMqttKeyPair, createCsr = createMqttCsr, } = options;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Homebridge LG ThinQ 2",
|
|
3
3
|
"name": "homebridge-lg-thinq-2",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.5",
|
|
5
5
|
"description": "Community-maintained continuation of homebridge-lg-thinq: a Homebridge plugin for controlling/monitoring LG ThinQ devices via the LG ThinQ platform.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
@@ -76,19 +76,21 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@homebridge/plugin-ui-utils": "^2.2.3",
|
|
78
78
|
"aws-iot-device-sdk": "^2.2.16",
|
|
79
|
-
"axios": "^1.
|
|
79
|
+
"axios": "^1.21.1",
|
|
80
80
|
"axios-retry": "^4.5.0",
|
|
81
81
|
"commander": "^14.0.3",
|
|
82
82
|
"luxon": "^3.7.2",
|
|
83
|
-
"node-forge": "^1.4.
|
|
83
|
+
"node-forge": "^1.4.3",
|
|
84
84
|
"node-persist": "^4.0.4",
|
|
85
|
-
"qs": "^6.
|
|
85
|
+
"qs": "^6.17.1"
|
|
86
86
|
},
|
|
87
87
|
"overrides": {
|
|
88
|
-
"glob": "^
|
|
88
|
+
"glob": "^14.0.6",
|
|
89
89
|
"help-me": {
|
|
90
|
-
"glob": "^
|
|
90
|
+
"glob": "^14.0.6"
|
|
91
91
|
},
|
|
92
|
-
"node-persist": "^4.0.4"
|
|
92
|
+
"node-persist": "^4.0.4",
|
|
93
|
+
"brace-expansion": "^5.0.13",
|
|
94
|
+
"ws": "^8.23.0"
|
|
93
95
|
}
|
|
94
96
|
}
|