homebridge-lg-thinq-2 2.0.17 → 2.0.19
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 +25 -0
- package/README.md +25 -2
- package/config.schema.json +119 -60
- package/dist/devices/AirConditioner.js +20 -3
- package/homebridge-ui/public/index.html +60 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## v2.0.19
|
|
4
|
+
|
|
5
|
+
### Homebridge UI
|
|
6
|
+
|
|
7
|
+
* Cleaner device settings: one heading per device type ("Washer and dryer options", "Air conditioner options", and so on) with a separator line, instead of a "Device Settings" title plus a "specific settings" title and a description.
|
|
8
|
+
* Every option has a short name and a one-line explanation, for example **Program finished sensor** instead of "Enable program finished trigger?".
|
|
9
|
+
* Air conditioner: the three lists come first and show the mode in use (both heating and cooling, both swing directions, Celsius) instead of "None". The **Display light switch** option, which was missing from the form, is shown.
|
|
10
|
+
* Air conditioner **Mode buttons**: explained, with a list of modes (Cool, Dry, Fan, Heat, Air clean, Auto) instead of a number field. The empty row the form always shows is not saved.
|
|
11
|
+
|
|
12
|
+
### Air conditioner
|
|
13
|
+
|
|
14
|
+
* Mode buttons without a name or a mode are skipped, so an empty row in the settings no longer creates an unnamed switch.
|
|
15
|
+
|
|
16
|
+
## v2.0.18
|
|
17
|
+
|
|
18
|
+
### Homebridge UI
|
|
19
|
+
|
|
20
|
+
* The guide link in **Other login methods** now opens in a new browser tab. It opened inside the settings window, where GitHub refuses to be shown ("This content is blocked").
|
|
21
|
+
* The link now goes to a new [Other sign-in methods](README.md#other-sign-in-methods) section of the README instead of the original project's wiki, which told users to install the original package.
|
|
22
|
+
* **Other login methods** has a field to paste a refresh token from the `thinq` command and use it, instead of editing the config JSON.
|
|
23
|
+
|
|
24
|
+
### Documentation
|
|
25
|
+
|
|
26
|
+
* Added the Other sign-in methods section to the README: getting a refresh token with `npx -y -p homebridge-lg-thinq-2 thinq ... auth` (works with Google, Apple, and Facebook accounts), and using a second LG account.
|
|
27
|
+
|
|
3
28
|
## v2.0.17
|
|
4
29
|
|
|
5
30
|
### Login
|
package/README.md
CHANGED
|
@@ -108,7 +108,30 @@ The device cache is stored in a new folder, so the first start can take a little
|
|
|
108
108
|
|
|
109
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.
|
|
110
110
|
|
|
111
|
-
If you sign in to LG with Google, Apple, or
|
|
111
|
+
If you sign in to LG with Google, Apple, or Facebook, or the sign-in does not work for your account, see [Other sign-in methods](#other-sign-in-methods).
|
|
112
|
+
|
|
113
|
+
### Other sign-in methods
|
|
114
|
+
|
|
115
|
+
#### Get a refresh token with the `thinq` command
|
|
116
|
+
|
|
117
|
+
The command opens LG's own sign-in page, so it works with Google, Apple, and Facebook accounts, and with any verification LG asks for. You need Node.js 22 or later on any computer.
|
|
118
|
+
|
|
119
|
+
1. Run the command with your account's country and language, for example for Spain:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
npx -y -p homebridge-lg-thinq-2 thinq -c ES -l es-ES auth
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
2. Open the link that the command prints, and sign in to LG.
|
|
126
|
+
3. When the sign-in finishes, the browser goes to a page that may be blank or show an error. Copy the full address from the address bar and paste it in the terminal.
|
|
127
|
+
4. The command prints `Your refresh_token: ...`.
|
|
128
|
+
5. In the plugin settings, open **Other login methods**, paste the token, and click **Use Token**. Then click **Save** and restart Homebridge.
|
|
129
|
+
|
|
130
|
+
Keep the refresh token private: it gives access to your LG devices.
|
|
131
|
+
|
|
132
|
+
#### Use a second LG account
|
|
133
|
+
|
|
134
|
+
Accounts created with Google, Apple, or Facebook have no password that the plugin can use. Create a second LG account with an email and password, share your home with it from the LG ThinQ app, and sign in with that account in the plugin settings. LG treats it as a separate account, even with the same email address.
|
|
112
135
|
|
|
113
136
|
### Manual configuration
|
|
114
137
|
|
|
@@ -183,7 +206,7 @@ Every device entry accepts `id` (required), `name`, and `serial_number`. The opt
|
|
|
183
206
|
| `ac_jet_control` | `false` | Add a switch for jet mode. |
|
|
184
207
|
| `ac_energy_save` | `true` | Add a switch for energy saving. |
|
|
185
208
|
| `ac_air_clean` | `true` | Add a switch for air purification. |
|
|
186
|
-
| `ac_buttons` | `[]` |
|
|
209
|
+
| `ac_buttons` | `[]` | Mode buttons: a switch for each entry, as `{ "name": "...", "op_mode": number }`, where `op_mode` is 0 cool, 1 dry, 2 fan, 4 heat, 5 air clean, or 6 auto. Turning a switch on sets that mode; turning it off goes back to cooling. Entries without a name or mode are ignored. |
|
|
187
210
|
|
|
188
211
|
#### Washer and Dryer
|
|
189
212
|
|
package/config.schema.json
CHANGED
|
@@ -100,28 +100,32 @@
|
|
|
100
100
|
"type": "string"
|
|
101
101
|
},
|
|
102
102
|
"dishwasher_trigger": {
|
|
103
|
-
"title": "
|
|
104
|
-
"type": "boolean"
|
|
103
|
+
"title": "Program finished sensor",
|
|
104
|
+
"type": "boolean",
|
|
105
|
+
"description": "Adds an occupancy sensor that turns on when a program finishes. Use it in a HomeKit automation, for example to get a notification."
|
|
105
106
|
},
|
|
106
107
|
"washer_tub_clean": {
|
|
107
|
-
"title": "
|
|
108
|
-
"type": "boolean"
|
|
108
|
+
"title": "Tub clean reminder",
|
|
109
|
+
"type": "boolean",
|
|
110
|
+
"description": "Adds an occupancy sensor that turns on when the washer recommends a tub clean."
|
|
109
111
|
},
|
|
110
112
|
"washer_trigger": {
|
|
111
|
-
"title": "
|
|
112
|
-
"type": "boolean"
|
|
113
|
+
"title": "Program finished sensor",
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"description": "Adds an occupancy sensor that turns on when a program finishes. Use it in a HomeKit automation, for example to get a notification."
|
|
113
116
|
},
|
|
114
117
|
"washer_door_lock": {
|
|
115
|
-
"title": "
|
|
116
|
-
"type": "boolean"
|
|
118
|
+
"title": "Door lock status",
|
|
119
|
+
"type": "boolean",
|
|
120
|
+
"description": "Shows whether the door is locked, as a lock in HomeKit. Only for models that report it."
|
|
117
121
|
},
|
|
118
122
|
"ac_air_quality": {
|
|
119
|
-
"title": "
|
|
120
|
-
"description": "if
|
|
123
|
+
"title": "Air quality sensor",
|
|
124
|
+
"description": "Adds an air quality sensor, if the air conditioner has one.",
|
|
121
125
|
"type": "boolean"
|
|
122
126
|
},
|
|
123
127
|
"ac_mode": {
|
|
124
|
-
"title": "
|
|
128
|
+
"title": "Modes shown in HomeKit",
|
|
125
129
|
"type": "string",
|
|
126
130
|
"oneOf": [
|
|
127
131
|
{
|
|
@@ -145,7 +149,7 @@
|
|
|
145
149
|
]
|
|
146
150
|
},
|
|
147
151
|
"ac_swing_mode": {
|
|
148
|
-
"title": "Swing
|
|
152
|
+
"title": "Swing control",
|
|
149
153
|
"type": "string",
|
|
150
154
|
"oneOf": [
|
|
151
155
|
{
|
|
@@ -175,50 +179,98 @@
|
|
|
175
179
|
]
|
|
176
180
|
},
|
|
177
181
|
"ac_temperature_sensor": {
|
|
178
|
-
"title": "
|
|
179
|
-
"type": "boolean"
|
|
182
|
+
"title": "Temperature sensor",
|
|
183
|
+
"type": "boolean",
|
|
184
|
+
"description": "Adds the current room temperature as a separate sensor."
|
|
180
185
|
},
|
|
181
186
|
"ac_humidity_sensor": {
|
|
182
|
-
"title": "
|
|
183
|
-
"type": "boolean"
|
|
187
|
+
"title": "Humidity sensor",
|
|
188
|
+
"type": "boolean",
|
|
189
|
+
"description": "Adds a humidity sensor, if the air conditioner reports humidity."
|
|
184
190
|
},
|
|
185
191
|
"ac_led_control": {
|
|
186
|
-
"title": "
|
|
187
|
-
"type": "boolean"
|
|
192
|
+
"title": "Display light switch",
|
|
193
|
+
"type": "boolean",
|
|
194
|
+
"description": "Adds a switch to turn the display light on and off."
|
|
188
195
|
},
|
|
189
196
|
"ac_fan_control": {
|
|
190
|
-
"title": "
|
|
191
|
-
"type": "boolean"
|
|
197
|
+
"title": "Separate fan control",
|
|
198
|
+
"type": "boolean",
|
|
199
|
+
"description": "Adds a fan to control the fan speed separately from the air conditioner."
|
|
192
200
|
},
|
|
193
201
|
"ac_jet_control": {
|
|
194
|
-
"title": "
|
|
195
|
-
"type": "boolean"
|
|
202
|
+
"title": "Jet mode switch",
|
|
203
|
+
"type": "boolean",
|
|
204
|
+
"description": "Adds a switch for jet mode, on models that support it."
|
|
196
205
|
},
|
|
197
206
|
"ac_buttons": {
|
|
198
|
-
"title": "
|
|
207
|
+
"title": "Mode buttons",
|
|
199
208
|
"type": "array",
|
|
200
209
|
"items": {
|
|
201
210
|
"type": "object",
|
|
202
211
|
"properties": {
|
|
203
212
|
"name": {
|
|
204
|
-
"
|
|
213
|
+
"title": "Button name",
|
|
214
|
+
"type": "string",
|
|
215
|
+
"description": "The name of the switch in HomeKit, for example \"Dry mode\". Leave empty if you do not want mode buttons."
|
|
205
216
|
},
|
|
206
217
|
"op_mode": {
|
|
207
|
-
"
|
|
218
|
+
"title": "Mode",
|
|
219
|
+
"type": "integer",
|
|
220
|
+
"oneOf": [
|
|
221
|
+
{
|
|
222
|
+
"title": "Cool",
|
|
223
|
+
"enum": [
|
|
224
|
+
0
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"title": "Dry",
|
|
229
|
+
"enum": [
|
|
230
|
+
1
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"title": "Fan",
|
|
235
|
+
"enum": [
|
|
236
|
+
2
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"title": "Heat",
|
|
241
|
+
"enum": [
|
|
242
|
+
4
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"title": "Air clean",
|
|
247
|
+
"enum": [
|
|
248
|
+
5
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"title": "Auto",
|
|
253
|
+
"enum": [
|
|
254
|
+
6
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
]
|
|
208
258
|
}
|
|
209
259
|
}
|
|
210
260
|
}
|
|
211
261
|
},
|
|
212
262
|
"ac_energy_save": {
|
|
213
|
-
"title": "Energy
|
|
214
|
-
"type": "boolean"
|
|
263
|
+
"title": "Energy saving switch",
|
|
264
|
+
"type": "boolean",
|
|
265
|
+
"description": "Adds a switch for energy saving mode, on models that support it."
|
|
215
266
|
},
|
|
216
267
|
"ac_air_clean": {
|
|
217
|
-
"title": "Air
|
|
218
|
-
"type": "boolean"
|
|
268
|
+
"title": "Air purification switch",
|
|
269
|
+
"type": "boolean",
|
|
270
|
+
"description": "Adds a switch for air purification, on models that support it."
|
|
219
271
|
},
|
|
220
272
|
"ac_temperature_unit": {
|
|
221
|
-
"title": "Temperature
|
|
273
|
+
"title": "Temperature unit",
|
|
222
274
|
"type": "string",
|
|
223
275
|
"oneOf": [
|
|
224
276
|
{
|
|
@@ -233,23 +285,28 @@
|
|
|
233
285
|
"F"
|
|
234
286
|
]
|
|
235
287
|
}
|
|
236
|
-
]
|
|
288
|
+
],
|
|
289
|
+
"description": "The unit the air conditioner uses."
|
|
237
290
|
},
|
|
238
291
|
"ref_express_freezer": {
|
|
239
|
-
"title": "Express Freezer / Ice Plus",
|
|
240
|
-
"type": "boolean"
|
|
292
|
+
"title": "Express Freezer / Ice Plus switch",
|
|
293
|
+
"type": "boolean",
|
|
294
|
+
"description": "Adds a switch for Express Freezer or Ice Plus, if the refrigerator has it."
|
|
241
295
|
},
|
|
242
296
|
"ref_express_fridge": {
|
|
243
|
-
"title": "Express Fridge",
|
|
244
|
-
"type": "boolean"
|
|
297
|
+
"title": "Express Fridge switch",
|
|
298
|
+
"type": "boolean",
|
|
299
|
+
"description": "Adds a switch for Express Fridge, if the refrigerator has it."
|
|
245
300
|
},
|
|
246
301
|
"ref_eco_friendly": {
|
|
247
|
-
"title": "Eco Friendly",
|
|
248
|
-
"type": "boolean"
|
|
302
|
+
"title": "Eco Friendly switch",
|
|
303
|
+
"type": "boolean",
|
|
304
|
+
"description": "Adds a switch for Eco Friendly mode, if the refrigerator has it."
|
|
249
305
|
},
|
|
250
306
|
"air_fast_mode": {
|
|
251
|
-
"title": "
|
|
252
|
-
"type": "boolean"
|
|
307
|
+
"title": "Fast mode switch",
|
|
308
|
+
"type": "boolean",
|
|
309
|
+
"description": "Adds a switch for the fast mode of the air purifier."
|
|
253
310
|
}
|
|
254
311
|
}
|
|
255
312
|
}
|
|
@@ -288,23 +345,21 @@
|
|
|
288
345
|
{
|
|
289
346
|
"key": "devices[]",
|
|
290
347
|
"type": "fieldset",
|
|
291
|
-
"title": "Device Settings",
|
|
292
348
|
"items": [
|
|
293
349
|
{
|
|
294
350
|
"type": "fieldset",
|
|
295
|
-
"title": "Air purifier
|
|
296
|
-
"description": "Configure air purifier device settings.",
|
|
351
|
+
"title": "Air purifier options",
|
|
297
352
|
"items": [
|
|
298
353
|
"devices[].air_fast_mode"
|
|
299
354
|
],
|
|
300
355
|
"condition": {
|
|
301
356
|
"functionBody": "return model.devices && model.devices[arrayIndices] && ['AIR_PURIFIER'].includes(model.devices[arrayIndices].type);"
|
|
302
|
-
}
|
|
357
|
+
},
|
|
358
|
+
"htmlClass": "border-top mt-4 pt-3"
|
|
303
359
|
},
|
|
304
360
|
{
|
|
305
361
|
"type": "fieldset",
|
|
306
|
-
"title": "Washer
|
|
307
|
-
"description": "Configure washer/dryer device settings.",
|
|
362
|
+
"title": "Washer and dryer options",
|
|
308
363
|
"items": [
|
|
309
364
|
"devices[].washer_trigger",
|
|
310
365
|
"devices[].washer_tub_clean",
|
|
@@ -312,43 +367,46 @@
|
|
|
312
367
|
],
|
|
313
368
|
"condition": {
|
|
314
369
|
"functionBody": "return model.devices && model.devices[arrayIndices] && ['WASHER','WASHER_NEW', 'WASH_TOWER', 'DRYER', 'WASH_TOWER_2'].includes(model.devices[arrayIndices].type);"
|
|
315
|
-
}
|
|
370
|
+
},
|
|
371
|
+
"htmlClass": "border-top mt-4 pt-3"
|
|
316
372
|
},
|
|
317
373
|
{
|
|
318
374
|
"type": "fieldset",
|
|
319
|
-
"title": "Air conditioner
|
|
320
|
-
"description": "Configure AC device settings.",
|
|
375
|
+
"title": "Air conditioner options",
|
|
321
376
|
"items": [
|
|
322
|
-
"devices[].ac_air_quality",
|
|
323
377
|
"devices[].ac_mode",
|
|
324
378
|
"devices[].ac_swing_mode",
|
|
379
|
+
"devices[].ac_temperature_unit",
|
|
380
|
+
"devices[].ac_air_quality",
|
|
325
381
|
"devices[].ac_temperature_sensor",
|
|
326
382
|
"devices[].ac_humidity_sensor",
|
|
383
|
+
"devices[].ac_led_control",
|
|
327
384
|
"devices[].ac_fan_control",
|
|
328
385
|
"devices[].ac_jet_control",
|
|
329
386
|
"devices[].ac_energy_save",
|
|
330
387
|
"devices[].ac_air_clean",
|
|
331
|
-
"devices[].ac_temperature_unit",
|
|
332
388
|
{
|
|
333
389
|
"key": "devices[].ac_buttons",
|
|
334
|
-
"title": "
|
|
335
|
-
"description": "
|
|
390
|
+
"title": "Mode buttons",
|
|
391
|
+
"description": "Adds a switch for each mode you list. Turning a switch on sets the air conditioner to that mode; turning it off goes back to cooling.",
|
|
336
392
|
"type": "array",
|
|
337
393
|
"buttonText": "Add button",
|
|
338
394
|
"items": [
|
|
339
395
|
"devices[].ac_buttons[].name",
|
|
340
396
|
"devices[].ac_buttons[].op_mode"
|
|
341
|
-
]
|
|
397
|
+
],
|
|
398
|
+
"listItems": 0,
|
|
399
|
+
"htmlClass": "mt-3"
|
|
342
400
|
}
|
|
343
401
|
],
|
|
344
402
|
"condition": {
|
|
345
403
|
"functionBody": "return model.devices && model.devices[arrayIndices] && ['AC'].includes(model.devices[arrayIndices].type);"
|
|
346
|
-
}
|
|
404
|
+
},
|
|
405
|
+
"htmlClass": "border-top mt-4 pt-3"
|
|
347
406
|
},
|
|
348
407
|
{
|
|
349
408
|
"type": "fieldset",
|
|
350
|
-
"title": "Refrigerator
|
|
351
|
-
"description": "Configure refrigerator device settings.",
|
|
409
|
+
"title": "Refrigerator options",
|
|
352
410
|
"items": [
|
|
353
411
|
"devices[].ref_express_freezer",
|
|
354
412
|
"devices[].ref_express_fridge",
|
|
@@ -356,18 +414,19 @@
|
|
|
356
414
|
],
|
|
357
415
|
"condition": {
|
|
358
416
|
"functionBody": "return model.devices && model.devices[arrayIndices] && ['REFRIGERATOR'].includes(model.devices[arrayIndices].type);"
|
|
359
|
-
}
|
|
417
|
+
},
|
|
418
|
+
"htmlClass": "border-top mt-4 pt-3"
|
|
360
419
|
},
|
|
361
420
|
{
|
|
362
421
|
"type": "fieldset",
|
|
363
|
-
"title": "Dishwasher
|
|
364
|
-
"description": "Configure dishwasher device settings.",
|
|
422
|
+
"title": "Dishwasher options",
|
|
365
423
|
"items": [
|
|
366
424
|
"devices[].dishwasher_trigger"
|
|
367
425
|
],
|
|
368
426
|
"condition": {
|
|
369
427
|
"functionBody": "return model.devices && model.devices[arrayIndices] && ['DISHWASHER'].includes(model.devices[arrayIndices].type);"
|
|
370
|
-
}
|
|
428
|
+
},
|
|
429
|
+
"htmlClass": "border-top mt-4 pt-3"
|
|
371
430
|
}
|
|
372
431
|
]
|
|
373
432
|
}
|
|
@@ -307,6 +307,22 @@ export function windStrengthFromRotationSpeed(value) {
|
|
|
307
307
|
const step = Math.min(HOMEKIT_FAN_SPEED_MAX, Math.max(1, Math.round(vNum)));
|
|
308
308
|
return LG_FAN_SPEEDS[step - 1];
|
|
309
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* The mode buttons to create from the `ac_buttons` setting. The settings form always
|
|
312
|
+
* shows one button row, so rows without a name or a mode are skipped.
|
|
313
|
+
*/
|
|
314
|
+
export function modeButtonsFromConfig(buttons) {
|
|
315
|
+
if (!Array.isArray(buttons)) {
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
return buttons
|
|
319
|
+
.map(button => ({
|
|
320
|
+
name: typeof button?.name === 'string' ? button.name.trim() : '',
|
|
321
|
+
opMode: typeof button?.op_mode === 'number' ? button.op_mode
|
|
322
|
+
: typeof button?.op_mode === 'string' && button.op_mode.trim() !== '' ? Number(button.op_mode) : NaN,
|
|
323
|
+
}))
|
|
324
|
+
.filter(button => button.name !== '' && Number.isInteger(button.opMode));
|
|
325
|
+
}
|
|
310
326
|
export function swingCommandsForMode(value, swingMode) {
|
|
311
327
|
if (!isSwingModeEnabled(swingMode)) {
|
|
312
328
|
return [];
|
|
@@ -1306,7 +1322,8 @@ export default class AirConditioner extends BaseDevice {
|
|
|
1306
1322
|
return this.jetModeModels.includes(model); // cool mode only
|
|
1307
1323
|
}
|
|
1308
1324
|
setupButton(device) {
|
|
1309
|
-
|
|
1325
|
+
const buttons = modeButtonsFromConfig(this.config.ac_buttons);
|
|
1326
|
+
if (!buttons.length) {
|
|
1310
1327
|
return;
|
|
1311
1328
|
}
|
|
1312
1329
|
this.serviceLabelButtons = this.accessory.getService('Buttons')
|
|
@@ -1315,8 +1332,8 @@ export default class AirConditioner extends BaseDevice {
|
|
|
1315
1332
|
for (let i = 0; i < this.serviceLabelButtons.linkedServices.length; i++) {
|
|
1316
1333
|
this.accessory.removeService(this.serviceLabelButtons.linkedServices[i]);
|
|
1317
1334
|
}
|
|
1318
|
-
for (
|
|
1319
|
-
this.setupButtonOpmode(device,
|
|
1335
|
+
for (const button of buttons) {
|
|
1336
|
+
this.setupButtonOpmode(device, button.name, button.opMode);
|
|
1320
1337
|
}
|
|
1321
1338
|
}
|
|
1322
1339
|
setupButtonOpmode(device, name, opMode) {
|
|
@@ -290,7 +290,19 @@
|
|
|
290
290
|
</div>
|
|
291
291
|
<div aria-labelledby="headingTwo" class="collapse" id="collapseTwo">
|
|
292
292
|
<div class="card-body">
|
|
293
|
-
<p>
|
|
293
|
+
<p>
|
|
294
|
+
If you sign in to LG with Google, Apple, or Facebook, or prefer not to enter your password here,
|
|
295
|
+
get a refresh token with the <code>thinq</code> command and paste it below. The
|
|
296
|
+
<a href="https://github.com/santiagosony/homebridge-lg-thinq-2#other-sign-in-methods" target="_blank" rel="noopener noreferrer"><b>Other sign-in methods</b></a>
|
|
297
|
+
guide explains how.
|
|
298
|
+
</p>
|
|
299
|
+
<div class="mb-3">
|
|
300
|
+
<label class="form-label" for="refreshTokenInput">Refresh token</label>
|
|
301
|
+
<input autocomplete="off" class="form-control" id="refreshTokenInput" spellcheck="false" type="password">
|
|
302
|
+
</div>
|
|
303
|
+
<div class="text-center mt-3">
|
|
304
|
+
<button class="btn btn-primary" id="useTokenButton" type="button">Use Token</button>
|
|
305
|
+
</div>
|
|
294
306
|
</div>
|
|
295
307
|
</div>
|
|
296
308
|
</div>
|
|
@@ -351,6 +363,18 @@
|
|
|
351
363
|
return error?.error || error?.message || fallback;
|
|
352
364
|
}
|
|
353
365
|
|
|
366
|
+
// Stores a refresh token in the config and shows the settings, as after a successful login.
|
|
367
|
+
async function applyRefreshToken(configuration, refreshToken) {
|
|
368
|
+
configuration.auth_mode = 'token';
|
|
369
|
+
configuration.refresh_token = refreshToken;
|
|
370
|
+
await homebridge.updatePluginConfig([configuration]);
|
|
371
|
+
homebridge.enableSaveButton();
|
|
372
|
+
|
|
373
|
+
await renderConfigForm(configuration, { hideDevices: true });
|
|
374
|
+
hideElement(byId('loginForm'));
|
|
375
|
+
showSaveNotice();
|
|
376
|
+
}
|
|
377
|
+
|
|
354
378
|
function setLoginButtonLoading(btn, label) {
|
|
355
379
|
btn.disabled = true;
|
|
356
380
|
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>';
|
|
@@ -431,11 +455,24 @@
|
|
|
431
455
|
return device;
|
|
432
456
|
}
|
|
433
457
|
|
|
434
|
-
|
|
458
|
+
const next = {
|
|
435
459
|
...device,
|
|
436
460
|
ac_energy_save: typeof device.ac_energy_save === 'boolean' ? device.ac_energy_save : true,
|
|
437
461
|
ac_air_clean: typeof device.ac_air_clean === 'boolean' ? device.ac_air_clean : true,
|
|
462
|
+
// Same defaults as the plugin, so the lists show the mode in use instead of "None".
|
|
463
|
+
ac_mode: device.ac_mode || 'BOTH',
|
|
464
|
+
ac_swing_mode: device.ac_swing_mode || 'BOTH',
|
|
465
|
+
ac_temperature_unit: device.ac_temperature_unit || 'C',
|
|
438
466
|
};
|
|
467
|
+
|
|
468
|
+
// The form always shows one mode button row; do not save it while it is empty.
|
|
469
|
+
if (Array.isArray(next.ac_buttons)) {
|
|
470
|
+
next.ac_buttons = next.ac_buttons.filter(button => button
|
|
471
|
+
&& ((typeof button.name === 'string' && button.name.trim() !== '')
|
|
472
|
+
|| (button.op_mode !== undefined && button.op_mode !== null && button.op_mode !== '')));
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return next;
|
|
439
476
|
}
|
|
440
477
|
|
|
441
478
|
function pruneDeviceSettingsForType(device, options = {}) {
|
|
@@ -688,6 +725,26 @@
|
|
|
688
725
|
await homebridge.updatePluginConfig([configuration]);
|
|
689
726
|
});
|
|
690
727
|
|
|
728
|
+
byId('useTokenButton').addEventListener('click', async (e) => {
|
|
729
|
+
e.preventDefault();
|
|
730
|
+
const refreshToken = byId('refreshTokenInput').value.trim();
|
|
731
|
+
if (!refreshToken) {
|
|
732
|
+
homebridge.toast.error('Paste the refresh token from the thinq command first.', 'Error');
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
const btn = e.currentTarget;
|
|
737
|
+
btn.disabled = true;
|
|
738
|
+
try {
|
|
739
|
+
await applyRefreshToken(configuration, refreshToken);
|
|
740
|
+
byId('refreshTokenInput').value = '';
|
|
741
|
+
}
|
|
742
|
+
catch (error) {
|
|
743
|
+
homebridge.toast.error(requestErrorMessage(error, 'Unable to save the refresh token.'), 'Error');
|
|
744
|
+
btn.disabled = false;
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
|
|
691
748
|
byId('getTokenButton').addEventListener('click', async (e) => {
|
|
692
749
|
e.preventDefault();
|
|
693
750
|
const username = byId('usernameInput').value;
|
|
@@ -710,7 +767,6 @@
|
|
|
710
767
|
resetLoginButton(btn);
|
|
711
768
|
}
|
|
712
769
|
else {
|
|
713
|
-
configuration.refresh_token = data.token;
|
|
714
770
|
if (byId('rememberUsername').checked) {
|
|
715
771
|
configuration.username = username;
|
|
716
772
|
configuration.password = password;
|
|
@@ -720,12 +776,7 @@
|
|
|
720
776
|
configuration.password = '';
|
|
721
777
|
}
|
|
722
778
|
|
|
723
|
-
await
|
|
724
|
-
homebridge.enableSaveButton();
|
|
725
|
-
|
|
726
|
-
await renderConfigForm(configuration, { hideDevices: true });
|
|
727
|
-
hideElement(byId('loginForm'));
|
|
728
|
-
showSaveNotice();
|
|
779
|
+
await applyRefreshToken(configuration, data.token);
|
|
729
780
|
btn.disabled = true;
|
|
730
781
|
btn.textContent = 'Get Token';
|
|
731
782
|
}
|
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.19",
|
|
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",
|