homebridge-lg-thinq-2 2.0.6 → 2.0.8

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 CHANGED
@@ -1,5 +1,36 @@
1
1
  # Change Log
2
2
 
3
+ ## v2.0.8
4
+
5
+ ### Security
6
+
7
+ * The plugin no longer writes LG credentials to the Homebridge log. When refreshing the access token failed, the error was logged with its request body, which contains the refresh token; other errors could include the access token, or the username and password hash after a failed login. Errors are now logged as a short description (type, message, HTTP status, LG code, and URL without query parameters). Users often share these logs in public issues.
8
+ * The MQTT private key (`key.pem`) is now readable only by the user that runs Homebridge (mode 600, folder 700). Before, any user on the machine could read it. Existing files are fixed on the next start.
9
+ * When LG requires new terms, the plugin now loads the terms of the account's country and language (it always used Vietnam), and logs which terms it accepted on the account's behalf instead of accepting them silently.
10
+
11
+ ### Reliability
12
+
13
+ * A command that failed while the plugin was not waiting for it (microwave and oven commands, and AC mode buttons), for example because LG reported the device as offline, was an unhandled promise rejection, and Homebridge shuts down on those. These commands now log the error instead. Added lint rules (`no-floating-promises`, `no-misused-promises`) so the problem cannot come back.
14
+
15
+ ### Development
16
+
17
+ * Updated development dependencies to clear all `npm audit` reports and Dependabot alerts (16, from critical to low): `handlebars`, `js-yaml`, `browserslist`, `baseline-browser-mapping`, `@babel/core`, `eslint`, `typescript-eslint`, `@humanfs/node`, and `minimatch`. `nodemon` is given `minimatch` 11 through an override, because every 10.x release is affected and nodemon still asks for 10.x. These packages are only used to build and test the plugin and are not part of the published package.
18
+
19
+ ## v2.0.7
20
+
21
+ ### Security
22
+
23
+ * Removed jQuery 3.2.1, Bootstrap 4.0.0, and Popper.js from the plugin settings screen in the Homebridge UI. These 2017-2018 versions have known cross-site scripting vulnerabilities, and the screen only used them for two collapsible panels and basic page updates. The screen now uses plain JavaScript and the Bootstrap 5 styles that the Homebridge UI already provides, and behaves the same. The package is about 137 kB smaller.
24
+ * The settings screen no longer breaks when the saved country or language contains unexpected characters, and the username label is linked to its field again.
25
+
26
+ ### Documentation
27
+
28
+ * Rewrote the README: supported devices, requirements, installation, migration, all platform and per-device options with their defaults, troubleshooting for common errors, the `thinq` command, development and release process, and credits.
29
+ * Added a contributing guide, a security policy (private reporting through GitHub), and a code of conduct (Contributor Covenant 2.1).
30
+ * Replaced the issue templates with issue forms for bug reports and device requests, sent questions to Discussions, and added a pull request template.
31
+ * Added copyright lines to `NOTICE`.
32
+ * Removed the funding file, which pointed to the original author's donation page.
33
+
3
34
  ## v2.0.6
4
35
 
5
36
  ### Reliability
package/NOTICE CHANGED
@@ -1,6 +1,9 @@
1
1
  Homebridge LG ThinQ 2
2
2
  https://github.com/santiagosony/homebridge-lg-thinq-2
3
3
 
4
+ Copyright 2021-2026 nVuln and the homebridge-lg-thinq contributors
5
+ Copyright 2026 santiagosony and the homebridge-lg-thinq-2 contributors
6
+
4
7
  This product is a modified version of "homebridge-lg-thinq"
5
8
  (https://github.com/nVuln/homebridge-lg-thinq), originally created by nVuln
6
9
  and its contributors, and distributed under the Apache License, Version 2.0.
@@ -10,4 +13,7 @@ git commit history. Development of these modifications is assisted by Claude,
10
13
  an AI assistant made by Anthropic.
11
14
 
12
15
  This project is not affiliated with, endorsed by, or sponsored by LG
13
- Electronics. "LG" and "ThinQ" are trademarks of their respective owners.
16
+ Electronics. "LG" and "ThinQ" are trademarks of LG Electronics.
17
+
18
+ Dependencies are installed by npm and keep their own licenses. No third-party
19
+ code is bundled in this package.
package/README.md CHANGED
@@ -1,71 +1,118 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/homebridge/branding/latest/logos/homebridge-wordmark-logo-vertical.png" width="150">
2
+ <img src="https://raw.githubusercontent.com/homebridge/branding/latest/logos/homebridge-wordmark-logo-vertical.png" width="150" alt="Homebridge logo">
3
3
  </p>
4
4
 
5
- # Homebridge LG ThinQ 2
5
+ <h1 align="center">Homebridge LG ThinQ 2</h1>
6
6
 
7
- [![npm](https://img.shields.io/npm/v/homebridge-lg-thinq-2/latest?label=latest)](https://www.npmjs.com/package/homebridge-lg-thinq-2)
8
- [![npm](https://img.shields.io/npm/dt/homebridge-lg-thinq-2)](https://www.npmjs.com/package/homebridge-lg-thinq-2)
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/homebridge-lg-thinq-2"><img src="https://img.shields.io/npm/v/homebridge-lg-thinq-2?label=npm" alt="npm version"></a>
9
+ <a href="https://www.npmjs.com/package/homebridge-lg-thinq-2"><img src="https://img.shields.io/npm/dt/homebridge-lg-thinq-2" alt="npm downloads"></a>
10
+ <a href="https://github.com/santiagosony/homebridge-lg-thinq-2/actions/workflows/build.yml"><img src="https://github.com/santiagosony/homebridge-lg-thinq-2/actions/workflows/build.yml/badge.svg" alt="CI status"></a>
11
+ <img src="https://img.shields.io/node/v/homebridge-lg-thinq-2" alt="Node.js version">
12
+ <a href="https://socket.dev/npm/package/homebridge-lg-thinq-2"><img src="https://socket.dev/api/badge/npm/package/homebridge-lg-thinq-2" alt="Socket security score"></a>
13
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/santiagosony/homebridge-lg-thinq-2" alt="License: Apache-2.0"></a>
14
+ </p>
15
+
16
+ <p align="center">
17
+ A <a href="https://homebridge.io">Homebridge</a> plugin to control and monitor LG ThinQ appliances from Apple Home.
18
+ </p>
9
19
 
10
20
  > [!IMPORTANT]
11
21
  > **About this project**
12
22
  >
13
- > This plugin is based entirely on [nVuln/homebridge-lg-thinq](https://github.com/nVuln/homebridge-lg-thinq), created by [nVuln](https://github.com/nVuln) and its contributors.
14
- > The original repository stopped receiving updates (open issues and pull requests went unanswered for months), so its code was cloned into this new repository to keep working on it: Node.js 24 support, login fixes, and pending community fixes.
23
+ > This plugin is based entirely on [nVuln/homebridge-lg-thinq](https://github.com/nVuln/homebridge-lg-thinq), created by [nVuln](https://github.com/nVuln) and its contributors. The original repository stopped receiving updates (issues and pull requests went unanswered for months), so its code, including its full commit history, was moved to this repository to keep it working: Node.js 24 and 26 support, login fixes, and pending community fixes.
15
24
  >
16
- > All credit for the original work goes to its authors. This is not an official release of the original plugin, and it is not affiliated with or endorsed by LG.
25
+ > All credit for the original work goes to its authors. This is not an official release of the original plugin, and it is not affiliated with or endorsed by LG Electronics.
17
26
  >
18
- > **Vibe-coded with Claude:** development of this version is being done with the help of [Claude](https://claude.ai/code), Anthropic's AI assistant. Changes are built, linted, and tested before release, but please review them and report any problems you find.
19
-
20
- ## Overview
21
-
22
- Homebridge LG ThinQ is a Homebridge platform plugin for controlling and monitoring LG ThinQ appliances.
23
-
24
- This plugin is not an official LG API client. It works with LG ThinQ account data and supports most current ThinQ2 devices, with optional support for some legacy ThinQ1 devices.
27
+ > **Vibe-coded with Claude:** this version is being developed with the help of [Claude](https://claude.ai/code), Anthropic's AI assistant. Every change is built, linted, and tested on Node.js 22, 24, and 26 before release, but please review the changes and [report any problem](https://github.com/santiagosony/homebridge-lg-thinq-2/issues/new/choose) you find.
28
+
29
+ ## Contents
30
+
31
+ - [Supported devices](#supported-devices)
32
+ - [Requirements](#requirements)
33
+ - [Installation](#installation)
34
+ - [Migrating from homebridge-lg-thinq](#migrating-from-homebridge-lg-thinq)
35
+ - [Configuration](#configuration)
36
+ - [Troubleshooting](#troubleshooting)
37
+ - [Command-line tool](#command-line-tool)
38
+ - [Development](#development)
39
+ - [Contributing and support](#contributing-and-support)
40
+ - [Credits](#credits)
41
+ - [License](#license)
42
+
43
+ ## Supported devices
44
+
45
+ The plugin works with devices linked to an LG ThinQ account. Most current devices use the **ThinQ2** platform and get instant updates. Some older devices use the legacy **ThinQ1** platform, which must be enabled manually and is only refreshed periodically.
46
+
47
+ | Device | Monitoring | Control | ThinQ2 | ThinQ1 |
48
+ | --- | --- | --- | --- | --- |
49
+ | Air Conditioner | Yes | Yes | Yes | Yes |
50
+ | Air Purifier | Yes | Yes | Yes | Yes |
51
+ | AeroTower | Yes | Yes | Yes | No |
52
+ | Refrigerator | Yes | Yes | Yes | Yes |
53
+ | Washer / Dryer / WashTower | Yes | Limited | Yes | Yes |
54
+ | Dishwasher | Yes | No | Yes | No |
55
+ | Dehumidifier | Yes | Partial | Yes | No |
56
+ | Styler | Yes | Limited | Yes | No |
57
+ | Range Hood | Yes | Yes | Yes | Yes |
58
+ | Oven | Yes | Partial | Yes | No |
59
+ | Microwave | Yes | Partial | Yes | No |
60
+
61
+ Support depends on the model data that LG returns. If a device appears in the LG ThinQ app but not in Homebridge, [request it](https://github.com/santiagosony/homebridge-lg-thinq-2/issues/new/choose) with the device type, model, country, and debug logs.
62
+
63
+ This plugin is not an official LG API client. It uses the same services as the LG ThinQ mobile app.
25
64
 
26
65
  ## Requirements
27
66
 
28
- * Homebridge `^1.11.2` or Homebridge `^2.0.0`
29
- * Node.js `^22.13.0`, `^24.0.0`, or `^26.0.0`
30
-
31
- Node.js 26 requires Homebridge `2.3.0` or later, because older Homebridge versions do not support Node.js 26.
67
+ - **Homebridge** `1.11.2` or later, or Homebridge `2.x`.
68
+ - **Node.js** `22.13.0` or later in the 22 line, `24.x`, or `26.x`.
69
+ - Node.js 26 requires Homebridge `2.3.0` or later.
70
+ - An **LG ThinQ account** with your devices already added in the LG ThinQ app.
32
71
 
33
72
  ## Installation
34
73
 
35
- Install the plugin from the Homebridge UI (search for `homebridge-lg-thinq-2`), or install it manually:
74
+ Search for `homebridge-lg-thinq-2` in the **Plugins** page of the Homebridge UI and install it.
75
+
76
+ To install it from the command line instead:
36
77
 
37
78
  ```sh
38
79
  npm install -g homebridge-lg-thinq-2
39
80
  ```
40
81
 
41
- ### Migrating from `homebridge-lg-thinq`
82
+ Then follow the [configuration](#configuration) steps.
83
+
84
+ ## Migrating from homebridge-lg-thinq
42
85
 
43
- This plugin uses the same platform name (`LGThinQ`) and the same configuration format as the original plugin, so your existing config can be kept.
86
+ This plugin uses the same platform name (`LGThinQ`) and the same configuration format as the original plugin, so you can keep your existing configuration.
44
87
 
45
- 1. Uninstall `homebridge-lg-thinq`, keeping its configuration.
88
+ 1. Uninstall `homebridge-lg-thinq`, and choose to keep its configuration.
46
89
  2. Install `homebridge-lg-thinq-2`.
47
90
  3. Restart Homebridge.
48
91
 
49
- Do not install both plugins at the same time, because they register the same platform name. Device cache data is stored in a new folder, so the first start may take a little longer while devices are discovered again.
92
+ > [!WARNING]
93
+ > Do not install both plugins at the same time: they register the same platform name.
94
+
95
+ The device cache is stored in a new folder, so the first start can take a little longer while your devices are discovered again. HomeKit may treat the devices as new accessories, so check your rooms, scenes, and automations afterwards.
50
96
 
51
97
  ## Configuration
52
98
 
53
- The Homebridge UI plugin settings are recommended.
99
+ ### Using the Homebridge UI (recommended)
100
+
101
+ 1. Open the Homebridge UI and go to **Plugins**.
102
+ 2. Open the settings of **Homebridge LG ThinQ 2**.
103
+ 3. Select the **country** and **language** of your LG account.
104
+ 4. Sign in with your LG account to get a refresh token.
105
+ 5. Click **Save** in the Homebridge UI.
106
+ 6. Restart Homebridge, or the plugin's child bridge.
107
+ 7. Open the plugin settings again to review the discovered devices and their options.
54
108
 
55
- 1. Open Homebridge UI.
56
- 2. Go to the Plugins page.
57
- 3. Open the settings for Homebridge LG ThinQ.
58
- 4. Select the country and language for your LG account.
59
- 5. Sign in with your LG account to get a refresh token.
60
- 6. Click the Homebridge UI Save button.
61
- 7. Restart Homebridge or the plugin child bridge.
62
- 8. Reopen the plugin settings to review discovered devices and device options.
109
+ If no devices are listed in the configuration, all supported devices in the LG account are added. Add device entries only to rename devices, change device options, or add only some devices.
63
110
 
64
- If no devices are listed in the plugin config, all supported devices in the LG account are enabled. Add device entries only when you want to rename devices, configure device options, or enable only specific devices.
111
+ If you sign in to LG with Google, Apple, or another external account, get the refresh token with the [`thinq auth`](#command-line-tool) command or follow the [Plugin Authorization Setting](https://github.com/nVuln/homebridge-lg-thinq/wiki/Plugin-Authorization-Setting) guide of the original project.
65
112
 
66
- ## Manual Configuration
113
+ ### Manual configuration
67
114
 
68
- Manual editing is supported, but the Homebridge UI is recommended.
115
+ Add the platform to the `platforms` section of your Homebridge `config.json`:
69
116
 
70
117
  ```json
71
118
  {
@@ -78,7 +125,7 @@ Manual editing is supported, but the Homebridge UI is recommended.
78
125
  }
79
126
  ```
80
127
 
81
- To enable or configure only specific devices, list them by device id:
128
+ To add only some devices, or to set device options, list the devices by id:
82
129
 
83
130
  ```json
84
131
  {
@@ -90,37 +137,168 @@ To enable or configure only specific devices, list them by device id:
90
137
  "devices": [
91
138
  {
92
139
  "id": "device-id",
93
- "name": "Laundry Room Washer"
140
+ "name": "Laundry Room Washer",
141
+ "washer_trigger": true
94
142
  }
95
143
  ]
96
144
  }
97
145
  ```
98
146
 
99
- | Option | Required | Description |
147
+ Device ids are shown in the Homebridge log when the plugin discovers devices.
148
+
149
+ ### Platform options
150
+
151
+ | Option | Required | Default | Description |
152
+ | --- | --- | --- | --- |
153
+ | `platform` | Yes | | Must be `LGThinQ`. |
154
+ | `auth_mode` | Yes | `account` | `token` to sign in with a refresh token, or `account` to sign in with username and password. |
155
+ | `refresh_token` | With `token` | | Refresh token from the LG login (Homebridge UI or `thinq` command). |
156
+ | `username` | With `account` | | LG ThinQ account username. |
157
+ | `password` | With `account` | | LG ThinQ account password. |
158
+ | `country` | Yes | `US` | Country of the LG account, as an ISO 3166-1 alpha-2 code, for example `US` or `ES`. |
159
+ | `language` | Yes | `en-US` | Language of the LG account, for example `en-US` or `es-ES`. |
160
+ | `devices` | No | all devices | Devices to add, with their options. Empty or missing adds all supported devices. |
161
+ | `thinq1` | No | `false` | Advanced. Set to `true` to add legacy ThinQ1 devices. |
162
+ | `refresh_interval` | No | `60` | Seconds between status refreshes from LG. ThinQ2 devices also get instant updates, so this is only a fallback for them; ThinQ1 devices are updated only by this refresh. Low values can make LG reject requests with HTTP 429 (too many requests). Not shown in the Homebridge UI. |
163
+
164
+ ### Device options
165
+
166
+ Every device entry accepts `id` (required), `name`, and `serial_number`. The options below depend on the device type. The Homebridge UI shows only the options that apply to each discovered device.
167
+
168
+ #### Air Conditioner
169
+
170
+ | Option | Default | Description |
171
+ | --- | --- | --- |
172
+ | `ac_mode` | `BOTH` | Modes shown in HomeKit: `BOTH`, `COOLING`, or `HEATING`. |
173
+ | `ac_swing_mode` | `BOTH` | Swing directions to control: `BOTH`, `VERTICAL`, `HORIZONTAL`, or `NONE`. |
174
+ | `ac_temperature_unit` | `C` | Temperature unit of the AC: `C` or `F`. |
175
+ | `ac_air_quality` | `false` | Add an air quality sensor, if the AC has one. |
176
+ | `ac_temperature_sensor` | `false` | Add the current temperature as a separate sensor. |
177
+ | `ac_humidity_sensor` | `false` | Add a humidity sensor. |
178
+ | `ac_led_control` | `false` | Add a switch for the display light. |
179
+ | `ac_fan_control` | `false` | Add a separate fan control. |
180
+ | `ac_jet_control` | `false` | Add a switch for jet mode. |
181
+ | `ac_energy_save` | `true` | Add a switch for energy saving. |
182
+ | `ac_air_clean` | `true` | Add a switch for air purification. |
183
+ | `ac_buttons` | `[]` | Extra switches for operation modes, as `{ "name": "...", "op_mode": number }`. |
184
+
185
+ #### Washer and Dryer
186
+
187
+ | Option | Default | Description |
188
+ | --- | --- | --- |
189
+ | `washer_trigger` | `false` | Add a sensor that triggers when a program finishes, for automations. |
190
+ | `washer_tub_clean` | `false` | Add a sensor for the tub clean reminder. |
191
+ | `washer_door_lock` | `false` | Add the door lock status (ThinQ2 only). |
192
+
193
+ #### Dishwasher
194
+
195
+ | Option | Default | Description |
196
+ | --- | --- | --- |
197
+ | `dishwasher_trigger` | `false` | Add a sensor that triggers when a program finishes, for automations. |
198
+
199
+ #### Refrigerator
200
+
201
+ | Option | Default | Description |
202
+ | --- | --- | --- |
203
+ | `ref_express_freezer` | `false` | Add a switch for Express Freezer or Ice Plus. |
204
+ | `ref_express_fridge` | `false` | Add a switch for Express Fridge. |
205
+ | `ref_eco_friendly` | `false` | Add a switch for Eco Friendly mode. |
206
+
207
+ #### Air Purifier
208
+
209
+ | Option | Default | Description |
100
210
  | --- | --- | --- |
101
- | `platform` | Yes | Must be `LGThinQ`. |
102
- | `auth_mode` | Yes | Use `token` for refresh-token auth. `account` is also accepted for username/password config. |
103
- | `refresh_token` | Yes, for token auth | Refresh token returned by the LG login flow. |
104
- | `username` | Yes, for account auth | LG ThinQ account username. |
105
- | `password` | Yes, for account auth | LG ThinQ account password. |
106
- | `country` | Yes | LG account country alpha-2 code, for example `US`. |
107
- | `language` | Yes | LG account language code, for example `en-US`. |
108
- | `devices` | No | Empty or omitted enables all supported discovered devices. |
109
- | `thinq1` | No | Advanced legacy option. Set to `true` manually to enable ThinQ1 devices. |
110
- | `refresh_interval` | No | Seconds between device status refreshes from LG. Default `60`. ThinQ2 devices also get instant updates over MQTT, so this is only a fallback for them; ThinQ1 devices are updated only by this refresh. Low values can make LG reject requests with HTTP 429 (too many requests). |
211
+ | `air_fast_mode` | `false` | Add a switch for fast mode. |
212
+
213
+ ## Troubleshooting
214
+
215
+ Turn on Homebridge **debug mode** (Homebridge UI → Settings) to see detailed logs, and consider running the plugin in its own **child bridge**.
216
+
217
+ | Problem | What to do |
218
+ | --- | --- |
219
+ | `LG pre-login failed: Request failed with status code 403` | LG rejected the login request. Update to version `2.0.3` or later. |
220
+ | `Request failed with status code 429` or result code `9012` | LG received too many requests. Update to version `2.0.6` or later, and do not set a low `refresh_interval`. |
221
+ | `Missing required config parameter.` | Set `country`, `language`, and either a `refresh_token` or `username` and `password`. |
222
+ | `The plugin requires a Node.js version of ...` | Update the plugin. Node.js 26 also needs Homebridge `2.3.0` or later. |
223
+ | A device is missing | Check that it works in the LG ThinQ app. Legacy devices need `"thinq1": true`. If it is still missing, [request it](https://github.com/santiagosony/homebridge-lg-thinq-2/issues/new/choose). |
224
+
225
+ When you report a problem, include the plugin version, Homebridge and Node.js versions, country, language, device type and model, and the debug log. Remove tokens, passwords, and other personal data first.
226
+
227
+ ## Command-line tool
111
228
 
112
- Device type is detected from LG discovery data. Device-specific settings appear in the Homebridge UI after devices have been discovered.
229
+ The plugin includes a `thinq` command to get a refresh token outside the Homebridge UI. It is available when the plugin is installed globally with npm.
113
230
 
114
- ## Support
231
+ ```text
232
+ Usage: thinq [options] [command]
233
+
234
+ Options:
235
+ -c, --country <type> Country code for account (default: "US")
236
+ -l, --language <type> Language code for account (default: "en-US")
237
+ -h, --help display help for command
238
+
239
+ Commands:
240
+ login <username> <password> Obtain refresh_token from LG account
241
+ auth Obtain refresh_token from account logged by
242
+ Google Account, Apple ID
243
+ help [command] display help for command
244
+ ```
245
+
246
+ For example, for an account in Spain:
247
+
248
+ ```sh
249
+ thinq -c ES -l es-ES auth
250
+ ```
115
251
 
116
- If you would like to report a bug or ask a question, open an [issue](https://github.com/santiagosony/homebridge-lg-thinq-2/issues/new/choose) in this repository.
252
+ ## Development
253
+
254
+ You need Node.js 22, 24, or 26.
255
+
256
+ ```sh
257
+ git clone https://github.com/santiagosony/homebridge-lg-thinq-2.git
258
+ cd homebridge-lg-thinq-2
259
+ npm ci
260
+ npm run build
261
+ npm run lint
262
+ npm test
263
+ ```
264
+
265
+ | Script | What it does |
266
+ | --- | --- |
267
+ | `npm run build` | Compiles TypeScript from `src/` to `dist/`. |
268
+ | `npm run lint` | Runs ESLint with no warnings allowed. |
269
+ | `npm test` | Runs the Jest test suite. Some tests call the LG servers and need internet access. |
270
+ | `npm run watch` | Builds, links the plugin into your local Homebridge, and rebuilds on changes. |
271
+
272
+ ### Releases
273
+
274
+ Releases are automated with GitHub Actions:
275
+
276
+ 1. Add the changes to `CHANGELOG.md` under a new `## vX.Y.Z` heading.
277
+ 2. Update the version in `package.json` and `package-lock.json`, for example with `npm version patch --no-git-tag-version`.
278
+ 3. Push to `main`.
279
+
280
+ The [publish workflow](.github/workflows/publish.yml) then lints, builds, and tests the plugin, publishes it to npm with [trusted publishing](https://docs.npmjs.com/trusted-publishers) and provenance (no npm tokens are stored), and creates the `vX.Y.Z` tag and a GitHub release with the notes from the changelog. Pushes that do not change the version only run the checks.
281
+
282
+ ## Contributing and support
283
+
284
+ - **Bugs and device requests:** open an [issue](https://github.com/santiagosony/homebridge-lg-thinq-2/issues/new/choose).
285
+ - **Questions and ideas:** start a [discussion](https://github.com/santiagosony/homebridge-lg-thinq-2/discussions).
286
+ - **Contributions:** read the [contributing guide](CONTRIBUTING.md). This project follows a [code of conduct](CODE_OF_CONDUCT.md).
287
+ - **Security issues:** follow the [security policy](SECURITY.md); do not report them in public issues.
117
288
 
118
289
  Please do not report problems with this version in the original repository.
119
290
 
120
- ## Credits and License
291
+ ## Credits
292
+
293
+ - [nVuln](https://github.com/nVuln), who created [homebridge-lg-thinq](https://github.com/nVuln/homebridge-lg-thinq), and all of its contributors. The full commit history of the original project is kept in this repository.
294
+ - [carlosgamezvillegas](https://github.com/carlosgamezvillegas), for the Oven and Microwave support ([nVuln/homebridge-lg-thinq#87](https://github.com/nVuln/homebridge-lg-thinq/issues/87)).
295
+ - [ZeliardM](https://github.com/ZeliardM), for the Homebridge 2 and Node.js 24 work in the original repository.
296
+ - The authors of pull requests that were never merged in the original repository and are included here: [vojkny](https://github.com/vojkny) ([#401](https://github.com/nVuln/homebridge-lg-thinq/pull/401)), [faune](https://github.com/faune) ([#395](https://github.com/nVuln/homebridge-lg-thinq/pull/395)), [pharmville](https://github.com/pharmville) ([#400](https://github.com/nVuln/homebridge-lg-thinq/pull/400)), and [asafdav](https://github.com/asafdav) ([#394](https://github.com/nVuln/homebridge-lg-thinq/pull/394)).
297
+
298
+ See [CHANGELOG.md](CHANGELOG.md) for the changes in each version.
121
299
 
122
- This project is a continuation of [homebridge-lg-thinq](https://github.com/nVuln/homebridge-lg-thinq) by [nVuln](https://github.com/nVuln), licensed under the [Apache License 2.0](LICENSE). The full commit history of the original project is preserved in this repository. See [NOTICE](NOTICE) for attribution details.
300
+ ## License
123
301
 
124
- ## Contributors
302
+ Licensed under the [Apache License 2.0](LICENSE). See [NOTICE](NOTICE) for attribution.
125
303
 
126
- Special thanks to [carlosgamezvillegas](https://github.com/carlosgamezvillegas) for implementing Oven and Microwave device support. More detail in [nVuln/homebridge-lg-thinq#87](https://github.com/nVuln/homebridge-lg-thinq/issues/87).
304
+ LG and ThinQ are trademarks of LG Electronics. This project is not affiliated with, endorsed by, or sponsored by LG Electronics. Homebridge is not affiliated with this project.
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter } from 'events';
2
+ import { describeError } from './lib/errorFormat.js';
2
3
  export function isDeviceOnlineForHomeKit(device) {
3
4
  return device.online !== false;
4
5
  }
@@ -37,6 +38,18 @@ export class BaseDevice extends EventEmitter {
37
38
  }
38
39
  this.updateAccessoryCharacteristic(this.accessory.context.device);
39
40
  }
41
+ /**
42
+ * Runs a device command without waiting for it, and logs it if it fails.
43
+ *
44
+ * Commands can fail, for example when LG reports the device as offline. An
45
+ * unawaited promise that rejects is an unhandled rejection, which makes Homebridge
46
+ * shut down, so every command started without `await` must go through here.
47
+ */
48
+ runInBackground(command, action) {
49
+ command.catch(err => {
50
+ this.logger.error(`[${this.accessory.context.device.name}] ${action} failed:`, describeError(err));
51
+ });
52
+ }
40
53
  get isOnlineForHomeKit() {
41
54
  return isDeviceOnlineForHomeKit(this.accessory.context.device);
42
55
  }
package/dist/cli.js CHANGED
@@ -4,6 +4,7 @@ import { API } from './lib/API.js';
4
4
  import { Auth } from './lib/Auth.js';
5
5
  import { URL } from 'url';
6
6
  import * as readline from 'readline';
7
+ import { describeError } from './lib/errorFormat.js';
7
8
  const makeLogger = () => console;
8
9
  const input = (question) => new Promise((resolve) => {
9
10
  const rl = readline.createInterface(process.stdin, process.stdout);
@@ -38,7 +39,7 @@ program
38
39
  console.info('Your refresh_token:', session.refreshToken);
39
40
  }
40
41
  catch (err) {
41
- console.error(err);
42
+ console.error(describeError(err));
42
43
  }
43
44
  process.exit(0);
44
45
  });
@@ -84,7 +85,7 @@ program
84
85
  console.info('Your refresh_token:', session.refreshToken);
85
86
  }
86
87
  catch (err) {
87
- console.error(err);
88
+ console.error(describeError(err));
88
89
  }
89
90
  process.exit(0);
90
91
  });
@@ -3,6 +3,7 @@ import { ValueType } from '../lib/DeviceModel.js';
3
3
  import { normalizeBoolean, normalizeNumber } from '../utils/normalize.js';
4
4
  import { cToF, fToC } from '../utils/temperature.js';
5
5
  import { hasSnapshotKey, snapshotBoolean, snapshotNumber } from './helpers.js';
6
+ import { describeError } from '../lib/errorFormat.js';
6
7
  export var ACModelType;
7
8
  (function (ACModelType) {
8
9
  ACModelType["AWHP"] = "AWHP";
@@ -62,7 +63,7 @@ function convertTemperatureCelsiusFromLGToHomekit(temperature, device, config, l
62
63
  }
63
64
  }
64
65
  catch (e) {
65
- logger.warn('Temperature mapping lookup failed, falling back to direct conversion.', e);
66
+ logger.warn('Temperature mapping lookup failed, falling back to direct conversion.', describeError(e));
66
67
  }
67
68
  const c = Math.round(fToC(tempNum) * 100) / 100;
68
69
  return c;
@@ -83,7 +84,7 @@ function convertTemperatureCelsiusFromHomekitToLG(temperatureInCelsius, device,
83
84
  }
84
85
  }
85
86
  catch (e) {
86
- logger.warn('Temperature mapping lookup failed, falling back to direct conversion.', e);
87
+ logger.warn('Temperature mapping lookup failed, falling back to direct conversion.', describeError(e));
87
88
  }
88
89
  return temperatureInFahrenheit;
89
90
  }
@@ -494,11 +495,11 @@ export default class AirConditioner extends BaseDevice {
494
495
  if (this.temperatureKeepAliveFailureCount >= AIR_CONDITIONER_TEMPERATURE_KEEP_ALIVE_MAX_FAILURES) {
495
496
  const message = `[${device.name}] AC temperature keep-alive command failed `
496
497
  + `${this.temperatureKeepAliveFailureCount} consecutive times; disabling keep-alive for this device.`;
497
- this.logger.debug(message, error);
498
+ this.logger.debug(message, describeError(error));
498
499
  this.stopTemperatureKeepAlive();
499
500
  return;
500
501
  }
501
- this.logger.debug(`[${device.name}] AC temperature keep-alive command failed; will retry.`, error);
502
+ this.logger.debug(`[${device.name}] AC temperature keep-alive command failed; will retry.`, describeError(error));
502
503
  }
503
504
  setupTemperatureSensorService(accessory) {
504
505
  const { Service: { TemperatureSensor, }, Characteristic, } = this.platform;
@@ -747,7 +748,7 @@ export default class AirConditioner extends BaseDevice {
747
748
  updateAccessoryCharacteristic();
748
749
  }
749
750
  catch (error) {
750
- this.logger.error(errorMessage, error);
751
+ this.logger.error(errorMessage, describeError(error));
751
752
  }
752
753
  }
753
754
  /**
@@ -829,7 +830,7 @@ export default class AirConditioner extends BaseDevice {
829
830
  this.updateAccessoryFanV2Characteristic();
830
831
  }
831
832
  catch (error) {
832
- this.logger.error('Error setting fan state:', error);
833
+ this.logger.error('Error setting fan state:', describeError(error));
833
834
  }
834
835
  }
835
836
  /**
@@ -1119,7 +1120,7 @@ export default class AirConditioner extends BaseDevice {
1119
1120
  this.updateAccessoryLedControlCharacteristic();
1120
1121
  }
1121
1122
  catch (error) {
1122
- this.logger.error('Error setting light state:', error);
1123
+ this.logger.error('Error setting light state:', describeError(error));
1123
1124
  }
1124
1125
  }
1125
1126
  /**
@@ -1145,7 +1146,7 @@ export default class AirConditioner extends BaseDevice {
1145
1146
  await this.setOpMode(this.accessory.context.device.id, opMode);
1146
1147
  }
1147
1148
  catch (error) {
1148
- this.logger.error('Error setting target state:', error);
1149
+ this.logger.error('Error setting target state:', describeError(error));
1149
1150
  }
1150
1151
  }
1151
1152
  async setActive(value) {
@@ -1169,7 +1170,7 @@ export default class AirConditioner extends BaseDevice {
1169
1170
  }
1170
1171
  }
1171
1172
  catch (error) {
1172
- this.logger.error('Error setting active state:', error);
1173
+ this.logger.error('Error setting active state:', describeError(error));
1173
1174
  }
1174
1175
  }
1175
1176
  /**
@@ -1223,7 +1224,7 @@ export default class AirConditioner extends BaseDevice {
1223
1224
  return;
1224
1225
  }
1225
1226
  catch (error) {
1226
- this.logger.error('Error setting target temperature:', error);
1227
+ this.logger.error('Error setting target temperature:', describeError(error));
1227
1228
  }
1228
1229
  }
1229
1230
  /**
@@ -1266,7 +1267,7 @@ export default class AirConditioner extends BaseDevice {
1266
1267
  this.accessory.context.device.data.snapshot['airState.windStrength'] = windStrength;
1267
1268
  }
1268
1269
  catch (error) {
1269
- this.logger.error('Error setting fan speed:', error);
1270
+ this.logger.error('Error setting fan speed:', describeError(error));
1270
1271
  }
1271
1272
  }
1272
1273
  async setSwingMode(value) {
@@ -1291,7 +1292,7 @@ export default class AirConditioner extends BaseDevice {
1291
1292
  this.updateAccessoryFanV2Characteristic();
1292
1293
  }
1293
1294
  catch (error) {
1294
- this.logger.error('Error setting swing mode:', error);
1295
+ this.logger.error('Error setting swing mode:', describeError(error));
1295
1296
  }
1296
1297
  }
1297
1298
  async setOpMode(deviceId, opMode) {
@@ -1332,7 +1333,7 @@ export default class AirConditioner extends BaseDevice {
1332
1333
  return this.Status.opMode === opMode;
1333
1334
  }))
1334
1335
  .onSet((value) => {
1335
- this.handleButtonOpmode(value, opMode);
1336
+ this.runInBackground(this.handleButtonOpmode(value, opMode), 'Mode button command');
1336
1337
  });
1337
1338
  this.serviceLabelButtons.addLinkedService(serviceButton);
1338
1339
  }