@homebridge-plugins/homebridge-govee 11.32.2-beta.21 → 11.32.2-beta.23
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 +2 -0
- package/lib/device/appliance-basic.js +8 -20
- package/lib/device/base.js +80 -0
- package/lib/device/cooler-single.js +7 -22
- package/lib/device/dehumidifier-H7150.js +7 -25
- package/lib/device/diffuser-H7161.js +5 -18
- package/lib/device/fan-H1370.js +13 -46
- package/lib/device/fan-H7100.js +9 -32
- package/lib/device/fan-H7105.js +15 -53
- package/lib/device/fan-H7107.js +15 -53
- package/lib/device/heater-single.js +7 -22
- package/lib/device/heater1a.js +11 -40
- package/lib/device/heater1b.js +17 -61
- package/lib/device/heater2.js +23 -81
- package/lib/device/humidifier-H7140.js +9 -32
- package/lib/device/humidifier-H7141.js +7 -25
- package/lib/device/humidifier-H7142.js +13 -46
- package/lib/device/humidifier-H7143.js +7 -25
- package/lib/device/humidifier-H7160.js +13 -46
- package/lib/device/ice-maker-H7172.js +8 -25
- package/lib/device/index.js +2 -2
- package/lib/device/kettle.js +5 -16
- package/lib/device/light-switch.js +5 -18
- package/lib/device/light.js +14 -41
- package/lib/device/outlet-single.js +8 -18
- package/lib/device/purifier-H7120.js +14 -45
- package/lib/device/purifier-H7122.js +14 -45
- package/lib/device/purifier-H7123.js +14 -45
- package/lib/device/purifier-H7126.js +12 -38
- package/lib/device/purifier-single.js +7 -19
- package/lib/device/sensor-basic.js +3 -10
- package/lib/device/sensor-co2.js +3 -10
- package/lib/device/sensor-leak.js +4 -9
- package/lib/device/sensor-monitor.js +3 -10
- package/lib/device/sensor-presence.js +3 -10
- package/lib/device/sensor-probe.js +52 -0
- package/lib/device/sensor-thermo-switch.js +4 -9
- package/lib/device/sensor-thermo.js +4 -9
- package/lib/device/switch-double.js +6 -18
- package/lib/device/switch-single.js +6 -19
- package/lib/device/switch-triple.js +5 -18
- package/lib/device/tap-single.js +7 -19
- package/lib/device/template.js +3 -10
- package/lib/device/tv-single.js +6 -18
- package/lib/device/valve-single.js +7 -19
- package/lib/utils/constants.js +17 -3
- package/lib/utils/dispatch.js +1 -1
- package/package.json +1 -1
- package/lib/device/sensor-thermo4.js +0 -66
package/lib/device/light.js
CHANGED
|
@@ -12,18 +12,16 @@ import {
|
|
|
12
12
|
sleep,
|
|
13
13
|
} from '../utils/functions.js'
|
|
14
14
|
import platformLang from '../utils/lang-en.js'
|
|
15
|
+
import GoveeDevice from './base.js'
|
|
15
16
|
|
|
16
|
-
export default class {
|
|
17
|
+
export default class extends GoveeDevice {
|
|
17
18
|
constructor(platform, accessory) {
|
|
19
|
+
super(platform, accessory)
|
|
20
|
+
|
|
18
21
|
// Set up variables from the platform
|
|
19
22
|
this.cusChar = platform.cusChar
|
|
20
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
21
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
22
|
-
this.hapServ = platform.api.hap.Service
|
|
23
|
-
this.platform = platform
|
|
24
23
|
|
|
25
24
|
// Set up variables from the accessory
|
|
26
|
-
this.accessory = accessory
|
|
27
25
|
this.colourSafeMode = platform.config.colourSafeMode
|
|
28
26
|
this.minKelvin = accessory.context?.supportedCmdsOpts?.colorTem?.range?.min || 2000
|
|
29
27
|
this.maxKelvin = accessory.context?.supportedCmdsOpts?.colorTem?.range?.max || 9000
|
|
@@ -270,14 +268,9 @@ export default class {
|
|
|
270
268
|
this.accessory.log(`${platformLang.curState} [${this.cacheState}]`)
|
|
271
269
|
}
|
|
272
270
|
} catch (err) {
|
|
273
|
-
|
|
274
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
275
|
-
|
|
276
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
277
|
-
setTimeout(() => {
|
|
271
|
+
this.failUpdate(err, () => {
|
|
278
272
|
this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
|
|
279
|
-
}
|
|
280
|
-
throw new this.hapErr(-70402)
|
|
273
|
+
})
|
|
281
274
|
}
|
|
282
275
|
}
|
|
283
276
|
|
|
@@ -360,14 +353,9 @@ export default class {
|
|
|
360
353
|
this.accessory.log(`${platformLang.curBright} [${value}%]`)
|
|
361
354
|
}
|
|
362
355
|
} catch (err) {
|
|
363
|
-
|
|
364
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
365
|
-
|
|
366
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
367
|
-
setTimeout(() => {
|
|
356
|
+
this.failUpdate(err, () => {
|
|
368
357
|
this.service.updateCharacteristic(this.hapChar.Brightness, this.cacheBright)
|
|
369
|
-
}
|
|
370
|
-
throw new this.hapErr(-70402)
|
|
358
|
+
})
|
|
371
359
|
}
|
|
372
360
|
}
|
|
373
361
|
|
|
@@ -435,14 +423,9 @@ export default class {
|
|
|
435
423
|
this.accessory.log(`${platformLang.curColour} [rgb ${this.cacheR} ${this.cacheG} ${this.cacheB}]`)
|
|
436
424
|
}
|
|
437
425
|
} catch (err) {
|
|
438
|
-
|
|
439
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
440
|
-
|
|
441
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
442
|
-
setTimeout(() => {
|
|
426
|
+
this.failUpdate(err, () => {
|
|
443
427
|
this.service.updateCharacteristic(this.hapChar.Hue, this.cacheHue)
|
|
444
|
-
}
|
|
445
|
-
throw new this.hapErr(-70402)
|
|
428
|
+
})
|
|
446
429
|
}
|
|
447
430
|
}
|
|
448
431
|
|
|
@@ -526,14 +509,9 @@ export default class {
|
|
|
526
509
|
}
|
|
527
510
|
}
|
|
528
511
|
} catch (err) {
|
|
529
|
-
|
|
530
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
531
|
-
|
|
532
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
533
|
-
setTimeout(() => {
|
|
512
|
+
this.failUpdate(err, () => {
|
|
534
513
|
this.service.updateCharacteristic(this.hapChar.ColorTemperature, this.cacheMired)
|
|
535
|
-
}
|
|
536
|
-
throw new this.hapErr(-70402)
|
|
514
|
+
})
|
|
537
515
|
}
|
|
538
516
|
}
|
|
539
517
|
|
|
@@ -578,18 +556,13 @@ export default class {
|
|
|
578
556
|
})
|
|
579
557
|
}, 1000)
|
|
580
558
|
} catch (err) {
|
|
581
|
-
|
|
582
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
583
|
-
|
|
584
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
585
|
-
setTimeout(() => {
|
|
559
|
+
this.failUpdate(err, () => {
|
|
586
560
|
if (isService) {
|
|
587
561
|
this.accessory.getService(charName).updateCharacteristic(this.hapChar.On, false)
|
|
588
562
|
} else {
|
|
589
563
|
this.service.updateCharacteristic(this.cusChar[charName], false)
|
|
590
564
|
}
|
|
591
|
-
}
|
|
592
|
-
throw new this.hapErr(-70402)
|
|
565
|
+
})
|
|
593
566
|
}
|
|
594
567
|
}
|
|
595
568
|
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import { base64ToHex, generateRandomString, getTwoItemPosition, hexToTwoItems
|
|
1
|
+
import { base64ToHex, generateRandomString, getTwoItemPosition, hexToTwoItems } from '../utils/functions.js'
|
|
2
2
|
import platformLang from '../utils/lang-en.js'
|
|
3
3
|
import { logUnknownData } from '../utils/report-unknown.js'
|
|
4
|
+
import GoveeDevice from './base.js'
|
|
4
5
|
|
|
5
|
-
export default class {
|
|
6
|
+
export default class extends GoveeDevice {
|
|
6
7
|
constructor(platform, accessory) {
|
|
8
|
+
super(platform, accessory)
|
|
9
|
+
|
|
7
10
|
// Set up variables from the platform
|
|
8
11
|
this.eveChar = platform.eveChar
|
|
9
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
10
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
11
|
-
this.hapServ = platform.api.hap.Service
|
|
12
|
-
this.platform = platform
|
|
13
|
-
|
|
14
|
-
// Set up variables from the accessory
|
|
15
|
-
this.accessory = accessory;
|
|
16
|
-
|
|
17
12
|
// Remove any old services from simulations
|
|
18
|
-
['AirPurifier', 'HeaterCooler', 'Lightbulb', 'Switch', 'Valve'].forEach((service) => {
|
|
13
|
+
;['AirPurifier', 'HeaterCooler', 'Lightbulb', 'Switch', 'Valve'].forEach((service) => {
|
|
19
14
|
if (this.accessory.getService(this.hapServ[service])) {
|
|
20
15
|
this.accessory.removeService(this.accessory.getService(this.hapServ[service]))
|
|
21
16
|
}
|
|
@@ -98,14 +93,9 @@ export default class {
|
|
|
98
93
|
// Add the entry to the Eve history service
|
|
99
94
|
this.accessory.eveService.addEntry({ status: value ? 1 : 0 })
|
|
100
95
|
} catch (err) {
|
|
101
|
-
|
|
102
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
103
|
-
|
|
104
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
105
|
-
setTimeout(() => {
|
|
96
|
+
this.failUpdate(err, () => {
|
|
106
97
|
this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
|
|
107
|
-
}
|
|
108
|
-
throw new this.hapErr(-70402)
|
|
98
|
+
})
|
|
109
99
|
}
|
|
110
100
|
}
|
|
111
101
|
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
base64ToHex,
|
|
3
3
|
getTwoItemPosition,
|
|
4
4
|
hexToTwoItems,
|
|
5
|
-
parseError,
|
|
6
5
|
} from '../utils/functions.js'
|
|
7
6
|
import platformLang from '../utils/lang-en.js'
|
|
8
7
|
import { logUnknownData } from '../utils/report-unknown.js'
|
|
8
|
+
import GoveeDevice from './base.js'
|
|
9
9
|
|
|
10
10
|
/*
|
|
11
11
|
The modes these purifiers report over the api. Low, medium and high are the
|
|
@@ -16,18 +16,12 @@ import { logUnknownData } from '../utils/report-unknown.js'
|
|
|
16
16
|
H7121: Low 1, Medium 2, High 3, "Sleep" 16
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export default class GoveePurifierH7120 {
|
|
19
|
+
export default class GoveePurifierH7120 extends GoveeDevice {
|
|
20
20
|
constructor(platform, accessory) {
|
|
21
|
+
super(platform, accessory)
|
|
22
|
+
|
|
21
23
|
// Set up variables from the platform
|
|
22
24
|
this.cusChar = platform.cusChar
|
|
23
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
24
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
25
|
-
this.hapServ = platform.api.hap.Service
|
|
26
|
-
this.platform = platform
|
|
27
|
-
|
|
28
|
-
// Set up variables from the accessory
|
|
29
|
-
this.accessory = accessory
|
|
30
|
-
|
|
31
25
|
// Rotation speed to value in {1, 2, 3, 4}
|
|
32
26
|
this.speed2Value = speed => Math.min(Math.max(Number.parseInt(speed / 25, 10), 1), 4)
|
|
33
27
|
|
|
@@ -144,14 +138,9 @@ export default class GoveePurifierH7120 {
|
|
|
144
138
|
this.cacheState = newValue
|
|
145
139
|
this.accessory.log(`${platformLang.curState} [${newValue}]`)
|
|
146
140
|
} catch (err) {
|
|
147
|
-
|
|
148
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
149
|
-
|
|
150
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
151
|
-
setTimeout(() => {
|
|
141
|
+
this.failUpdate(err, () => {
|
|
152
142
|
this.service.updateCharacteristic(this.hapChar.Active, this.cacheState === 'on' ? 1 : 0)
|
|
153
|
-
}
|
|
154
|
-
throw new this.hapErr(-70402)
|
|
143
|
+
})
|
|
155
144
|
}
|
|
156
145
|
}
|
|
157
146
|
|
|
@@ -186,14 +175,9 @@ export default class GoveePurifierH7120 {
|
|
|
186
175
|
this.cacheSpeed = newValue * 25
|
|
187
176
|
this.accessory.log(`${platformLang.curSpeed} [${this.cacheSpeed}%]`)
|
|
188
177
|
} catch (err) {
|
|
189
|
-
|
|
190
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
191
|
-
|
|
192
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
193
|
-
setTimeout(() => {
|
|
178
|
+
this.failUpdate(err, () => {
|
|
194
179
|
this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSpeed)
|
|
195
|
-
}
|
|
196
|
-
throw new this.hapErr(-70402)
|
|
180
|
+
})
|
|
197
181
|
}
|
|
198
182
|
}
|
|
199
183
|
|
|
@@ -219,14 +203,9 @@ export default class GoveePurifierH7120 {
|
|
|
219
203
|
this.cacheLight = newValue
|
|
220
204
|
this.accessory.log(`${platformLang.curLight} [${newValue}]`)
|
|
221
205
|
} catch (err) {
|
|
222
|
-
|
|
223
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
224
|
-
|
|
225
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
226
|
-
setTimeout(() => {
|
|
206
|
+
this.failUpdate(err, () => {
|
|
227
207
|
this.service.updateCharacteristic(this.cusChar.NightLight, this.cacheLight === 'on')
|
|
228
|
-
}
|
|
229
|
-
throw new this.hapErr(-70402)
|
|
208
|
+
})
|
|
230
209
|
}
|
|
231
210
|
}
|
|
232
211
|
|
|
@@ -252,17 +231,12 @@ export default class GoveePurifierH7120 {
|
|
|
252
231
|
this.cacheLock = newValue
|
|
253
232
|
this.accessory.log(`${platformLang.curLock} [${newValue}]`)
|
|
254
233
|
} catch (err) {
|
|
255
|
-
|
|
256
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
257
|
-
|
|
258
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
259
|
-
setTimeout(() => {
|
|
234
|
+
this.failUpdate(err, () => {
|
|
260
235
|
this.service.updateCharacteristic(
|
|
261
236
|
this.hapChar.LockPhysicalControls,
|
|
262
237
|
this.cacheLock === 'on' ? 1 : 0,
|
|
263
238
|
)
|
|
264
|
-
}
|
|
265
|
-
throw new this.hapErr(-70402)
|
|
239
|
+
})
|
|
266
240
|
}
|
|
267
241
|
}
|
|
268
242
|
|
|
@@ -288,14 +262,9 @@ export default class GoveePurifierH7120 {
|
|
|
288
262
|
this.cacheDisplay = newValue
|
|
289
263
|
this.accessory.log(`${platformLang.curDisplay} [${newValue}]`)
|
|
290
264
|
} catch (err) {
|
|
291
|
-
|
|
292
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
293
|
-
|
|
294
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
295
|
-
setTimeout(() => {
|
|
265
|
+
this.failUpdate(err, () => {
|
|
296
266
|
this.service.updateCharacteristic(this.cusChar.DisplayLight, this.cacheDisplay === 'on')
|
|
297
|
-
}
|
|
298
|
-
throw new this.hapErr(-70402)
|
|
267
|
+
})
|
|
299
268
|
}
|
|
300
269
|
}
|
|
301
270
|
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
hexToBase64,
|
|
5
5
|
hexToDecimal,
|
|
6
6
|
hexToTwoItems,
|
|
7
|
-
parseError,
|
|
8
7
|
statusToActionCode,
|
|
9
8
|
} from '../utils/functions.js'
|
|
10
9
|
import platformLang from '../utils/lang-en.js'
|
|
11
10
|
import { logUnknownData } from '../utils/report-unknown.js'
|
|
11
|
+
import GoveeDevice from './base.js'
|
|
12
12
|
|
|
13
13
|
/*
|
|
14
14
|
H7122
|
|
@@ -44,18 +44,12 @@ import { logUnknownData } from '../utils/report-unknown.js'
|
|
|
44
44
|
}
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
|
-
export default class {
|
|
47
|
+
export default class extends GoveeDevice {
|
|
48
48
|
constructor(platform, accessory) {
|
|
49
|
+
super(platform, accessory)
|
|
50
|
+
|
|
49
51
|
// Set up variables from the platform
|
|
50
52
|
this.cusChar = platform.cusChar
|
|
51
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
52
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
53
|
-
this.hapServ = platform.api.hap.Service
|
|
54
|
-
this.platform = platform
|
|
55
|
-
|
|
56
|
-
// Set up variables from the accessory
|
|
57
|
-
this.accessory = accessory
|
|
58
|
-
|
|
59
53
|
// Speed codes
|
|
60
54
|
this.value2Code = {
|
|
61
55
|
1: 'OgUFAAAAAAAAAAAAAAAAAAAAADo=', // sleep
|
|
@@ -175,14 +169,9 @@ export default class {
|
|
|
175
169
|
this.cacheState = newValue
|
|
176
170
|
this.accessory.log(`${platformLang.curState} [${newValue}]`)
|
|
177
171
|
} catch (err) {
|
|
178
|
-
|
|
179
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
180
|
-
|
|
181
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
182
|
-
setTimeout(() => {
|
|
172
|
+
this.failUpdate(err, () => {
|
|
183
173
|
this.service.updateCharacteristic(this.hapChar.Active, this.cacheState === 'on' ? 1 : 0)
|
|
184
|
-
}
|
|
185
|
-
throw new this.hapErr(-70402)
|
|
174
|
+
})
|
|
186
175
|
}
|
|
187
176
|
}
|
|
188
177
|
|
|
@@ -214,14 +203,9 @@ export default class {
|
|
|
214
203
|
this.cacheMode = newValueKey
|
|
215
204
|
this.accessory.log(`${platformLang.curMode} [${this.value2Label[this.cacheMode]}]`)
|
|
216
205
|
} catch (err) {
|
|
217
|
-
|
|
218
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
219
|
-
|
|
220
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
221
|
-
setTimeout(() => {
|
|
206
|
+
this.failUpdate(err, () => {
|
|
222
207
|
this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheMode * 20)
|
|
223
|
-
}
|
|
224
|
-
throw new this.hapErr(-70402)
|
|
208
|
+
})
|
|
225
209
|
}
|
|
226
210
|
}
|
|
227
211
|
|
|
@@ -247,14 +231,9 @@ export default class {
|
|
|
247
231
|
this.cacheLight = newValue
|
|
248
232
|
this.accessory.log(`${platformLang.curLight} [${newValue}]`)
|
|
249
233
|
} catch (err) {
|
|
250
|
-
|
|
251
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
252
|
-
|
|
253
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
254
|
-
setTimeout(() => {
|
|
234
|
+
this.failUpdate(err, () => {
|
|
255
235
|
this.service.updateCharacteristic(this.cusChar.NightLight, this.cacheLight === 'on')
|
|
256
|
-
}
|
|
257
|
-
throw new this.hapErr(-70402)
|
|
236
|
+
})
|
|
258
237
|
}
|
|
259
238
|
}
|
|
260
239
|
|
|
@@ -280,17 +259,12 @@ export default class {
|
|
|
280
259
|
this.cacheLock = newValue
|
|
281
260
|
this.accessory.log(`${platformLang.curLock} [${newValue}]`)
|
|
282
261
|
} catch (err) {
|
|
283
|
-
|
|
284
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
285
|
-
|
|
286
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
287
|
-
setTimeout(() => {
|
|
262
|
+
this.failUpdate(err, () => {
|
|
288
263
|
this.service.updateCharacteristic(
|
|
289
264
|
this.hapChar.LockPhysicalControls,
|
|
290
265
|
this.cacheLock === 'on' ? 1 : 0,
|
|
291
266
|
)
|
|
292
|
-
}
|
|
293
|
-
throw new this.hapErr(-70402)
|
|
267
|
+
})
|
|
294
268
|
}
|
|
295
269
|
}
|
|
296
270
|
|
|
@@ -326,14 +300,9 @@ export default class {
|
|
|
326
300
|
this.cacheDisplay = newValue
|
|
327
301
|
this.accessory.log(`${platformLang.curDisplay} [${newValue}]`)
|
|
328
302
|
} catch (err) {
|
|
329
|
-
|
|
330
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
331
|
-
|
|
332
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
333
|
-
setTimeout(() => {
|
|
303
|
+
this.failUpdate(err, () => {
|
|
334
304
|
this.service.updateCharacteristic(this.cusChar.DisplayLight, this.cacheDisplay === 'on')
|
|
335
|
-
}
|
|
336
|
-
throw new this.hapErr(-70402)
|
|
305
|
+
})
|
|
337
306
|
}
|
|
338
307
|
}
|
|
339
308
|
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
getTwoItemPosition,
|
|
4
4
|
hexToBase64,
|
|
5
5
|
hexToTwoItems,
|
|
6
|
-
parseError,
|
|
7
6
|
statusToActionCode,
|
|
8
7
|
} from '../utils/functions.js'
|
|
9
8
|
import platformLang from '../utils/lang-en.js'
|
|
10
9
|
import { logUnknownData } from '../utils/report-unknown.js'
|
|
10
|
+
import GoveeDevice from './base.js'
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
13
|
H7123 and H7124
|
|
@@ -39,18 +39,12 @@ import { logUnknownData } from '../utils/report-unknown.js'
|
|
|
39
39
|
}
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
-
export default class GoveePurifierH7123 {
|
|
42
|
+
export default class GoveePurifierH7123 extends GoveeDevice {
|
|
43
43
|
constructor(platform, accessory) {
|
|
44
|
+
super(platform, accessory)
|
|
45
|
+
|
|
44
46
|
// Set up variables from the platform
|
|
45
47
|
this.cusChar = platform.cusChar
|
|
46
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
47
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
48
|
-
this.hapServ = platform.api.hap.Service
|
|
49
|
-
this.platform = platform
|
|
50
|
-
|
|
51
|
-
// Set up variables from the accessory
|
|
52
|
-
this.accessory = accessory
|
|
53
|
-
|
|
54
48
|
// Speed codes
|
|
55
49
|
this.value2Code = {
|
|
56
50
|
1: 'OgUFAAAAAAAAAAAAAAAAAAAAADo=', // sleep
|
|
@@ -179,14 +173,9 @@ export default class GoveePurifierH7123 {
|
|
|
179
173
|
this.cacheState = newValue
|
|
180
174
|
this.accessory.log(`${platformLang.curState} [${newValue}]`)
|
|
181
175
|
} catch (err) {
|
|
182
|
-
|
|
183
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
184
|
-
|
|
185
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
186
|
-
setTimeout(() => {
|
|
176
|
+
this.failUpdate(err, () => {
|
|
187
177
|
this.service.updateCharacteristic(this.hapChar.Active, this.cacheState === 'on' ? 1 : 0)
|
|
188
|
-
}
|
|
189
|
-
throw new this.hapErr(-70402)
|
|
178
|
+
})
|
|
190
179
|
}
|
|
191
180
|
}
|
|
192
181
|
|
|
@@ -218,14 +207,9 @@ export default class GoveePurifierH7123 {
|
|
|
218
207
|
this.cacheMode = newValueKey
|
|
219
208
|
this.accessory.log(`${platformLang.curMode} [${this.value2Label[this.cacheMode]}]`)
|
|
220
209
|
} catch (err) {
|
|
221
|
-
|
|
222
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
223
|
-
|
|
224
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
225
|
-
setTimeout(() => {
|
|
210
|
+
this.failUpdate(err, () => {
|
|
226
211
|
this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheMode * 20)
|
|
227
|
-
}
|
|
228
|
-
throw new this.hapErr(-70402)
|
|
212
|
+
})
|
|
229
213
|
}
|
|
230
214
|
}
|
|
231
215
|
|
|
@@ -251,14 +235,9 @@ export default class GoveePurifierH7123 {
|
|
|
251
235
|
this.cacheLight = newValue
|
|
252
236
|
this.accessory.log(`${platformLang.curLight} [${newValue}]`)
|
|
253
237
|
} catch (err) {
|
|
254
|
-
|
|
255
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
256
|
-
|
|
257
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
258
|
-
setTimeout(() => {
|
|
238
|
+
this.failUpdate(err, () => {
|
|
259
239
|
this.service.updateCharacteristic(this.cusChar.NightLight, this.cacheLight === 'on')
|
|
260
|
-
}
|
|
261
|
-
throw new this.hapErr(-70402)
|
|
240
|
+
})
|
|
262
241
|
}
|
|
263
242
|
}
|
|
264
243
|
|
|
@@ -284,17 +263,12 @@ export default class GoveePurifierH7123 {
|
|
|
284
263
|
this.cacheLock = newValue
|
|
285
264
|
this.accessory.log(`${platformLang.curLock} [${newValue}]`)
|
|
286
265
|
} catch (err) {
|
|
287
|
-
|
|
288
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
289
|
-
|
|
290
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
291
|
-
setTimeout(() => {
|
|
266
|
+
this.failUpdate(err, () => {
|
|
292
267
|
this.service.updateCharacteristic(
|
|
293
268
|
this.hapChar.LockPhysicalControls,
|
|
294
269
|
this.cacheLock === 'on' ? 1 : 0,
|
|
295
270
|
)
|
|
296
|
-
}
|
|
297
|
-
throw new this.hapErr(-70402)
|
|
271
|
+
})
|
|
298
272
|
}
|
|
299
273
|
}
|
|
300
274
|
|
|
@@ -330,14 +304,9 @@ export default class GoveePurifierH7123 {
|
|
|
330
304
|
this.cacheDisplay = newValue
|
|
331
305
|
this.accessory.log(`${platformLang.curDisplay} [${newValue}]`)
|
|
332
306
|
} catch (err) {
|
|
333
|
-
|
|
334
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
335
|
-
|
|
336
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
337
|
-
setTimeout(() => {
|
|
307
|
+
this.failUpdate(err, () => {
|
|
338
308
|
this.service.updateCharacteristic(this.cusChar.DisplayLight, this.cacheDisplay === 'on')
|
|
339
|
-
}
|
|
340
|
-
throw new this.hapErr(-70402)
|
|
309
|
+
})
|
|
341
310
|
}
|
|
342
311
|
}
|
|
343
312
|
|
|
@@ -2,23 +2,17 @@ import {
|
|
|
2
2
|
base64ToHex,
|
|
3
3
|
getTwoItemPosition,
|
|
4
4
|
hexToTwoItems,
|
|
5
|
-
parseError,
|
|
6
5
|
} from '../utils/functions.js'
|
|
7
6
|
import platformLang from '../utils/lang-en.js'
|
|
8
7
|
import { logUnknownData } from '../utils/report-unknown.js'
|
|
8
|
+
import GoveeDevice from './base.js'
|
|
9
9
|
|
|
10
|
-
export default class {
|
|
10
|
+
export default class extends GoveeDevice {
|
|
11
11
|
constructor(platform, accessory) {
|
|
12
|
+
super(platform, accessory)
|
|
13
|
+
|
|
12
14
|
// Set up variables from the platform
|
|
13
15
|
this.cusChar = platform.cusChar
|
|
14
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
15
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
16
|
-
this.hapServ = platform.api.hap.Service
|
|
17
|
-
this.platform = platform
|
|
18
|
-
|
|
19
|
-
// Set up variables from the accessory
|
|
20
|
-
this.accessory = accessory
|
|
21
|
-
|
|
22
16
|
this.speed2Value = (speed) => {
|
|
23
17
|
if (speed <= 33) {
|
|
24
18
|
return 1
|
|
@@ -128,14 +122,9 @@ export default class {
|
|
|
128
122
|
this.cacheState = newValue
|
|
129
123
|
this.accessory.log(`${platformLang.curState} [${newValue}]`)
|
|
130
124
|
} catch (err) {
|
|
131
|
-
|
|
132
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
133
|
-
|
|
134
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
135
|
-
setTimeout(() => {
|
|
125
|
+
this.failUpdate(err, () => {
|
|
136
126
|
this.service.updateCharacteristic(this.hapChar.Active, this.cacheState === 'on' ? 1 : 0)
|
|
137
|
-
}
|
|
138
|
-
throw new this.hapErr(-70402)
|
|
127
|
+
})
|
|
139
128
|
}
|
|
140
129
|
}
|
|
141
130
|
|
|
@@ -172,14 +161,9 @@ export default class {
|
|
|
172
161
|
this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSpeed)
|
|
173
162
|
this.accessory.log(`${platformLang.curSpeed} [${this.cacheSpeed}%]`)
|
|
174
163
|
} catch (err) {
|
|
175
|
-
|
|
176
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
177
|
-
|
|
178
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
179
|
-
setTimeout(() => {
|
|
164
|
+
this.failUpdate(err, () => {
|
|
180
165
|
this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSpeed)
|
|
181
|
-
}
|
|
182
|
-
throw new this.hapErr(-70402)
|
|
166
|
+
})
|
|
183
167
|
}
|
|
184
168
|
}
|
|
185
169
|
|
|
@@ -205,17 +189,12 @@ export default class {
|
|
|
205
189
|
this.cacheLock = newValue
|
|
206
190
|
this.accessory.log(`${platformLang.curLock} [${newValue}]`)
|
|
207
191
|
} catch (err) {
|
|
208
|
-
|
|
209
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
210
|
-
|
|
211
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
212
|
-
setTimeout(() => {
|
|
192
|
+
this.failUpdate(err, () => {
|
|
213
193
|
this.service.updateCharacteristic(
|
|
214
194
|
this.hapChar.LockPhysicalControls,
|
|
215
195
|
this.cacheLock === 'on' ? 1 : 0,
|
|
216
196
|
)
|
|
217
|
-
}
|
|
218
|
-
throw new this.hapErr(-70402)
|
|
197
|
+
})
|
|
219
198
|
}
|
|
220
199
|
}
|
|
221
200
|
|
|
@@ -241,14 +220,9 @@ export default class {
|
|
|
241
220
|
this.cacheDisplay = newValue
|
|
242
221
|
this.accessory.log(`${platformLang.curDisplay} [${newValue}]`)
|
|
243
222
|
} catch (err) {
|
|
244
|
-
|
|
245
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
246
|
-
|
|
247
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
248
|
-
setTimeout(() => {
|
|
223
|
+
this.failUpdate(err, () => {
|
|
249
224
|
this.service.updateCharacteristic(this.cusChar.DisplayLight, this.cacheDisplay === 'on')
|
|
250
|
-
}
|
|
251
|
-
throw new this.hapErr(-70402)
|
|
225
|
+
})
|
|
252
226
|
}
|
|
253
227
|
}
|
|
254
228
|
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { generateRandomString
|
|
1
|
+
import { generateRandomString } from '../utils/functions.js'
|
|
2
2
|
import platformLang from '../utils/lang-en.js'
|
|
3
|
+
import GoveeDevice from './base.js'
|
|
3
4
|
|
|
4
|
-
export default class {
|
|
5
|
+
export default class extends GoveeDevice {
|
|
5
6
|
constructor(platform, accessory) {
|
|
6
|
-
|
|
7
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
8
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
9
|
-
this.hapServ = platform.api.hap.Service
|
|
10
|
-
this.platform = platform
|
|
11
|
-
|
|
12
|
-
// Set up variables from the accessory
|
|
13
|
-
this.accessory = accessory;
|
|
14
|
-
|
|
7
|
+
super(platform, accessory)
|
|
15
8
|
// Remove any old services from simulations
|
|
16
|
-
['HeaterCooler', 'Lightbulb', 'Outlet', 'Switch', 'Valve'].forEach((service) => {
|
|
9
|
+
;['HeaterCooler', 'Lightbulb', 'Outlet', 'Switch', 'Valve'].forEach((service) => {
|
|
17
10
|
if (this.accessory.getService(this.hapServ[service])) {
|
|
18
11
|
this.accessory.removeService(this.accessory.getService(this.hapServ[service]))
|
|
19
12
|
}
|
|
@@ -85,14 +78,9 @@ export default class {
|
|
|
85
78
|
this.accessory.eveService.addEntry({ status: value ? 1 : 0 })
|
|
86
79
|
this.service.updateCharacteristic(this.hapChar.CurrentAirPurifierState, value === 1 ? 2 : 0)
|
|
87
80
|
} catch (err) {
|
|
88
|
-
|
|
89
|
-
this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
|
|
90
|
-
|
|
91
|
-
// Throw a 'no response' error and set a timeout to revert this after 2 seconds
|
|
92
|
-
setTimeout(() => {
|
|
81
|
+
this.failUpdate(err, () => {
|
|
93
82
|
this.service.updateCharacteristic(this.hapChar.Active, this.cacheState === 'on' ? 1 : 0)
|
|
94
|
-
}
|
|
95
|
-
throw new this.hapErr(-70402)
|
|
83
|
+
})
|
|
96
84
|
}
|
|
97
85
|
}
|
|
98
86
|
|