@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.
Files changed (49) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/lib/device/appliance-basic.js +8 -20
  3. package/lib/device/base.js +80 -0
  4. package/lib/device/cooler-single.js +7 -22
  5. package/lib/device/dehumidifier-H7150.js +7 -25
  6. package/lib/device/diffuser-H7161.js +5 -18
  7. package/lib/device/fan-H1370.js +13 -46
  8. package/lib/device/fan-H7100.js +9 -32
  9. package/lib/device/fan-H7105.js +15 -53
  10. package/lib/device/fan-H7107.js +15 -53
  11. package/lib/device/heater-single.js +7 -22
  12. package/lib/device/heater1a.js +11 -40
  13. package/lib/device/heater1b.js +17 -61
  14. package/lib/device/heater2.js +23 -81
  15. package/lib/device/humidifier-H7140.js +9 -32
  16. package/lib/device/humidifier-H7141.js +7 -25
  17. package/lib/device/humidifier-H7142.js +13 -46
  18. package/lib/device/humidifier-H7143.js +7 -25
  19. package/lib/device/humidifier-H7160.js +13 -46
  20. package/lib/device/ice-maker-H7172.js +8 -25
  21. package/lib/device/index.js +2 -2
  22. package/lib/device/kettle.js +5 -16
  23. package/lib/device/light-switch.js +5 -18
  24. package/lib/device/light.js +14 -41
  25. package/lib/device/outlet-single.js +8 -18
  26. package/lib/device/purifier-H7120.js +14 -45
  27. package/lib/device/purifier-H7122.js +14 -45
  28. package/lib/device/purifier-H7123.js +14 -45
  29. package/lib/device/purifier-H7126.js +12 -38
  30. package/lib/device/purifier-single.js +7 -19
  31. package/lib/device/sensor-basic.js +3 -10
  32. package/lib/device/sensor-co2.js +3 -10
  33. package/lib/device/sensor-leak.js +4 -9
  34. package/lib/device/sensor-monitor.js +3 -10
  35. package/lib/device/sensor-presence.js +3 -10
  36. package/lib/device/sensor-probe.js +52 -0
  37. package/lib/device/sensor-thermo-switch.js +4 -9
  38. package/lib/device/sensor-thermo.js +4 -9
  39. package/lib/device/switch-double.js +6 -18
  40. package/lib/device/switch-single.js +6 -19
  41. package/lib/device/switch-triple.js +5 -18
  42. package/lib/device/tap-single.js +7 -19
  43. package/lib/device/template.js +3 -10
  44. package/lib/device/tv-single.js +6 -18
  45. package/lib/device/valve-single.js +7 -19
  46. package/lib/utils/constants.js +17 -3
  47. package/lib/utils/dispatch.js +1 -1
  48. package/package.json +1 -1
  49. package/lib/device/sensor-thermo4.js +0 -66
@@ -4,22 +4,14 @@ import {
4
4
  generateCodeFromHexValues,
5
5
  getTwoItemPosition,
6
6
  hexToTwoItems,
7
- parseError,
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
- export default class {
12
+ export default class extends GoveeDevice {
13
13
  constructor(platform, accessory) {
14
- // Set up variables from the platform
15
- this.hapChar = platform.api.hap.Characteristic
16
- this.hapErr = platform.api.hap.HapStatusError
17
- this.hapServ = platform.api.hap.Service
18
- this.platform = platform
19
-
20
- // Set up variables from the accessory
21
- this.accessory = accessory
22
-
14
+ super(platform, accessory)
23
15
  // Speed codes
24
16
  this.value2Code = {
25
17
  1: 'MwUBAQAAAAAAAAAAAAAAAAAAADY=',
@@ -95,14 +87,9 @@ export default class {
95
87
  this.cacheState = newValue
96
88
  this.accessory.log(`${platformLang.curState} [${this.cacheState}]`)
97
89
  } catch (err) {
98
- // Catch any errors during the process
99
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
100
-
101
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
102
- setTimeout(() => {
90
+ this.failUpdate(err, () => {
103
91
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
104
- }, 2000)
105
- throw new this.hapErr(-70402)
92
+ })
106
93
  }
107
94
  }
108
95
 
@@ -134,14 +121,9 @@ export default class {
134
121
  this.cacheSpeed = value
135
122
  this.accessory.log(`${platformLang.curSpeed} [${value}]`)
136
123
  } catch (err) {
137
- // Catch any errors during the process
138
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
139
-
140
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
141
- setTimeout(() => {
124
+ this.failUpdate(err, () => {
142
125
  this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSpeed)
143
- }, 2000)
144
- throw new this.hapErr(-70402)
126
+ })
145
127
  }
146
128
  }
147
129
 
@@ -182,14 +164,9 @@ export default class {
182
164
  this.accessory.log(`${platformLang.curLight} [${newValue}]`)
183
165
  }
184
166
  } catch (err) {
185
- // Catch any errors during the process
186
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
187
-
188
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
189
- setTimeout(() => {
167
+ this.failUpdate(err, () => {
190
168
  this.lightService.updateCharacteristic(this.hapChar.On, this.cacheLightState === 'on')
191
- }, 2000)
192
- throw new this.hapErr(-70402)
169
+ })
193
170
  }
194
171
  }
195
172
 
@@ -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
  H7141
@@ -41,17 +41,9 @@ import { logUnknownData } from '../utils/report-unknown.js'
41
41
  }
42
42
  }
43
43
  */
44
- export default class {
44
+ export default class extends GoveeDevice {
45
45
  constructor(platform, accessory) {
46
- // Set up variables from the platform
47
- this.hapChar = platform.api.hap.Characteristic
48
- this.hapErr = platform.api.hap.HapStatusError
49
- this.hapServ = platform.api.hap.Service
50
- this.platform = platform
51
-
52
- // Set up variables from the accessory
53
- this.accessory = accessory
54
-
46
+ super(platform, accessory)
55
47
  // Speed codes
56
48
  this.value2Code = {
57
49
  1: 'MwUBAQAAAAAAAAAAAAAAAAAAADY=',
@@ -118,14 +110,9 @@ export default class {
118
110
  this.cacheState = newValue
119
111
  this.accessory.log(`${platformLang.curState} [${this.cacheState}]`)
120
112
  } catch (err) {
121
- // Catch any errors during the process
122
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
123
-
124
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
125
- setTimeout(() => {
113
+ this.failUpdate(err, () => {
126
114
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
127
- }, 2000)
128
- throw new this.hapErr(-70402)
115
+ })
129
116
  }
130
117
  }
131
118
 
@@ -157,14 +144,9 @@ export default class {
157
144
  this.cacheSpeed = value
158
145
  this.accessory.log(`${platformLang.curSpeed} [${value}]`)
159
146
  } catch (err) {
160
- // Catch any errors during the process
161
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
162
-
163
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
164
- setTimeout(() => {
147
+ this.failUpdate(err, () => {
165
148
  this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSpeed)
166
- }, 2000)
167
- throw new this.hapErr(-70402)
149
+ })
168
150
  }
169
151
  }
170
152
 
@@ -6,11 +6,11 @@ import {
6
6
  getTwoItemPosition,
7
7
  hexToDecimal,
8
8
  hexToTwoItems,
9
- parseError,
10
9
  sleep,
11
10
  } from '../utils/functions.js'
12
11
  import platformLang from '../utils/lang-en.js'
13
12
  import { logUnknownData } from '../utils/report-unknown.js'
13
+ import GoveeDevice from './base.js'
14
14
 
15
15
  /*
16
16
  H7142
@@ -47,17 +47,9 @@ import { logUnknownData } from '../utils/report-unknown.js'
47
47
  }
48
48
  }
49
49
  */
50
- export default class {
50
+ export default class extends GoveeDevice {
51
51
  constructor(platform, accessory) {
52
- // Set up variables from the platform
53
- this.hapChar = platform.api.hap.Characteristic
54
- this.hapErr = platform.api.hap.HapStatusError
55
- this.hapServ = platform.api.hap.Service
56
- this.platform = platform
57
-
58
- // Set up variables from the accessory
59
- this.accessory = accessory
60
-
52
+ super(platform, accessory)
61
53
  // Speed codes
62
54
  this.value2Code = {
63
55
  1: 'MwUBAQAAAAAAAAAAAAAAAAAAADY=',
@@ -180,14 +172,9 @@ export default class {
180
172
  this.accessory.log(`current light state [${this.cacheLightState}]`)
181
173
  }
182
174
  } catch (err) {
183
- // Catch any errors during the process
184
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
185
-
186
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
187
- setTimeout(() => {
175
+ this.failUpdate(err, () => {
188
176
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
189
- }, 2000)
190
- throw new this.hapErr(-70402)
177
+ })
191
178
  }
192
179
  }
193
180
 
@@ -219,14 +206,9 @@ export default class {
219
206
  this.cacheSpeed = value
220
207
  this.accessory.log(`${platformLang.curSpeed} [${value}]`)
221
208
  } catch (err) {
222
- // Catch any errors during the process
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(() => {
209
+ this.failUpdate(err, () => {
227
210
  this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSpeed)
228
- }, 2000)
229
- throw new this.hapErr(-70402)
211
+ })
230
212
  }
231
213
  }
232
214
 
@@ -267,14 +249,9 @@ export default class {
267
249
  this.accessory.log(`${platformLang.curLight} [${newValue}]`)
268
250
  }
269
251
  } catch (err) {
270
- // Catch any errors during the process
271
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
272
-
273
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
274
- setTimeout(() => {
252
+ this.failUpdate(err, () => {
275
253
  this.lightService.updateCharacteristic(this.hapChar.On, this.cacheLightState === 'on')
276
- }, 2000)
277
- throw new this.hapErr(-70402)
254
+ })
278
255
  }
279
256
  }
280
257
 
@@ -325,14 +302,9 @@ export default class {
325
302
  this.accessory.log(`${platformLang.curBright} [${value}%]`)
326
303
  }
327
304
  } catch (err) {
328
- // Catch any errors during the process
329
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
330
-
331
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
332
- setTimeout(() => {
305
+ this.failUpdate(err, () => {
333
306
  this.lightService.updateCharacteristic(this.hapChar.Brightness, this.cacheBright)
334
- }, 2000)
335
- throw new this.hapErr(-70402)
307
+ })
336
308
  }
337
309
  }
338
310
 
@@ -370,14 +342,9 @@ export default class {
370
342
  this.accessory.log(`${platformLang.curColour} [rgb ${newRGB.join(' ')}]`)
371
343
  }
372
344
  } catch (err) {
373
- // Catch any errors during the process
374
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
375
-
376
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
377
- setTimeout(() => {
345
+ this.failUpdate(err, () => {
378
346
  this.lightService.updateCharacteristic(this.hapChar.Hue, this.cacheHue)
379
- }, 2000)
380
- throw new this.hapErr(-70402)
347
+ })
381
348
  }
382
349
  }
383
350
 
@@ -2,22 +2,14 @@ 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
- // Set up variables from the platform
13
- this.hapChar = platform.api.hap.Characteristic
14
- this.hapErr = platform.api.hap.HapStatusError
15
- this.hapServ = platform.api.hap.Service
16
- this.platform = platform
17
-
18
- // Set up variables from the accessory
19
- this.accessory = accessory
20
-
12
+ super(platform, accessory)
21
13
  // Speed codes
22
14
  this.value2Code = {
23
15
  1: 'MwUBAQAAAAAAAAAAAAAAAAAAADY=',
@@ -83,14 +75,9 @@ export default class {
83
75
  this.cacheState = newValue
84
76
  this.accessory.log(`${platformLang.curState} [${this.cacheState}]`)
85
77
  } catch (err) {
86
- // Catch any errors during the process
87
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
88
-
89
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
90
- setTimeout(() => {
78
+ this.failUpdate(err, () => {
91
79
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
92
- }, 2000)
93
- throw new this.hapErr(-70402)
80
+ })
94
81
  }
95
82
  }
96
83
 
@@ -122,14 +109,9 @@ export default class {
122
109
  this.cacheSpeed = value
123
110
  this.accessory.log(`${platformLang.curSpeed} [${value}]`)
124
111
  } catch (err) {
125
- // Catch any errors during the process
126
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
127
-
128
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
129
- setTimeout(() => {
112
+ this.failUpdate(err, () => {
130
113
  this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSpeed)
131
- }, 2000)
132
- throw new this.hapErr(-70402)
114
+ })
133
115
  }
134
116
  }
135
117
 
@@ -6,23 +6,15 @@ import {
6
6
  getTwoItemPosition,
7
7
  hexToDecimal,
8
8
  hexToTwoItems,
9
- parseError,
10
9
  sleep,
11
10
  } from '../utils/functions.js'
12
11
  import platformLang from '../utils/lang-en.js'
13
12
  import { logUnknownData } from '../utils/report-unknown.js'
13
+ import GoveeDevice from './base.js'
14
14
 
15
- export default class {
15
+ export default class extends GoveeDevice {
16
16
  constructor(platform, accessory) {
17
- // Set up variables from the platform
18
- this.hapChar = platform.api.hap.Characteristic
19
- this.hapErr = platform.api.hap.HapStatusError
20
- this.hapServ = platform.api.hap.Service
21
- this.platform = platform
22
-
23
- // Set up variables from the accessory
24
- this.accessory = accessory
25
-
17
+ super(platform, accessory)
26
18
  // Speed codes
27
19
  this.value2Code = {
28
20
  1: 'MwUBAQAAAAAAAAAAAAAAAAAAADY=',
@@ -128,14 +120,9 @@ export default class {
128
120
  this.accessory.log(`current light state [${this.cacheLightState}]`)
129
121
  }
130
122
  } catch (err) {
131
- // Catch any errors during the process
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(() => {
123
+ this.failUpdate(err, () => {
136
124
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
137
- }, 2000)
138
- throw new this.hapErr(-70402)
125
+ })
139
126
  }
140
127
  }
141
128
 
@@ -167,14 +154,9 @@ export default class {
167
154
  this.cacheSpeed = value
168
155
  this.accessory.log(`${platformLang.curSpeed} [${value}]`)
169
156
  } catch (err) {
170
- // Catch any errors during the process
171
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
172
-
173
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
174
- setTimeout(() => {
157
+ this.failUpdate(err, () => {
175
158
  this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSpeed)
176
- }, 2000)
177
- throw new this.hapErr(-70402)
159
+ })
178
160
  }
179
161
  }
180
162
 
@@ -215,14 +197,9 @@ export default class {
215
197
  this.accessory.log(`${platformLang.curLight} [${newValue}]`)
216
198
  }
217
199
  } catch (err) {
218
- // Catch any errors during the process
219
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
220
-
221
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
222
- setTimeout(() => {
200
+ this.failUpdate(err, () => {
223
201
  this.lightService.updateCharacteristic(this.hapChar.On, this.cacheLightState === 'on')
224
- }, 2000)
225
- throw new this.hapErr(-70402)
202
+ })
226
203
  }
227
204
  }
228
205
 
@@ -273,14 +250,9 @@ export default class {
273
250
  this.accessory.log(`${platformLang.curBright} [${value}%]`)
274
251
  }
275
252
  } catch (err) {
276
- // Catch any errors during the process
277
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
278
-
279
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
280
- setTimeout(() => {
253
+ this.failUpdate(err, () => {
281
254
  this.lightService.updateCharacteristic(this.hapChar.Brightness, this.cacheBright)
282
- }, 2000)
283
- throw new this.hapErr(-70402)
255
+ })
284
256
  }
285
257
  }
286
258
 
@@ -318,14 +290,9 @@ export default class {
318
290
  this.accessory.log(`${platformLang.curColour} [rgb ${newRGB.join(' ')}]`)
319
291
  }
320
292
  } catch (err) {
321
- // Catch any errors during the process
322
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
323
-
324
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
325
- setTimeout(() => {
293
+ this.failUpdate(err, () => {
326
294
  this.lightService.updateCharacteristic(this.hapChar.Hue, this.cacheHue)
327
- }, 2000)
328
- throw new this.hapErr(-70402)
295
+ })
329
296
  }
330
297
  }
331
298
 
@@ -1,19 +1,12 @@
1
1
  import { getDeviceCapabilities } from '../utils/device-capabilities.js'
2
- import { base64ToHex, generateCodeFromHexValues, getTwoItemPosition, hexToTwoItems, parseError } from '../utils/functions.js'
2
+ import { base64ToHex, generateCodeFromHexValues, getTwoItemPosition, hexToTwoItems } from '../utils/functions.js'
3
3
  import platformLang from '../utils/lang-en.js'
4
4
  import { logUnknownData } from '../utils/report-unknown.js'
5
+ import GoveeDevice from './base.js'
5
6
 
6
- export default class GoveeIceMaker {
7
+ export default class GoveeIceMaker extends GoveeDevice {
7
8
  constructor(platform, accessory) {
8
- // Set up variables from the platform
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
-
9
+ super(platform, accessory)
17
10
  // Ice size codes: small=1, medium=2, large=3 (matching OpenAPI workMode values)
18
11
  // Small, medium and large are all `33 05 <size>`. Which byte means which
19
12
  // size runs the opposite way on the older models, so the order comes from
@@ -106,14 +99,9 @@ export default class GoveeIceMaker {
106
99
  this.accessory.log(`${platformLang.curState} [${this.cacheState}]`)
107
100
  }
108
101
  } catch (err) {
109
- // Catch any errors during the process
110
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
111
-
112
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
113
- setTimeout(() => {
102
+ this.failUpdate(err, () => {
114
103
  this.service.updateCharacteristic(this.hapChar.Active, this.cacheState === 'on' ? 1 : 0)
115
- }, 2000)
116
- throw new this.hapErr(-70402)
104
+ })
117
105
  }
118
106
  }
119
107
 
@@ -150,14 +138,9 @@ export default class GoveeIceMaker {
150
138
  this.service.updateCharacteristic(this.hapChar.Active, 1)
151
139
  this.accessory.log(`${platformLang.curSpeed} [${this.sizeLabels[value]}]`)
152
140
  } catch (err) {
153
- // Catch any errors during the process
154
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
155
-
156
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
157
- setTimeout(() => {
141
+ this.failUpdate(err, () => {
158
142
  this.service.updateCharacteristic(this.hapChar.RotationSpeed, this.cacheSize)
159
- }, 2000)
160
- throw new this.hapErr(-70402)
143
+ })
161
144
  }
162
145
  }
163
146
 
@@ -37,7 +37,7 @@ import deviceSensorCO2 from './sensor-co2.js'
37
37
  import deviceSensorLeak from './sensor-leak.js'
38
38
  import deviceSensorMonitor from './sensor-monitor.js'
39
39
  import deviceSensorPresence from './sensor-presence.js'
40
- import deviceSensorThermo4 from './sensor-thermo4.js'
40
+ import deviceSensorProbe from './sensor-probe.js'
41
41
  import deviceSensorThermoSwitch from './sensor-thermo-switch.js'
42
42
  import deviceSensorThermo from './sensor-thermo.js'
43
43
  import deviceSwitchDouble, { asOutlet as deviceOutletDouble } from './switch-double.js'
@@ -116,7 +116,7 @@ export default {
116
116
  deviceSensorPresence,
117
117
  deviceSensorThermo,
118
118
  deviceSensorThermoSwitch,
119
- deviceSensorThermo4,
119
+ deviceSensorProbe,
120
120
  deviceSwitchDouble,
121
121
  deviceSwitchSingle,
122
122
  deviceSwitchTriple,
@@ -2,11 +2,11 @@ import {
2
2
  base64ToHex,
3
3
  getTwoItemPosition,
4
4
  hexToTwoItems,
5
- parseError,
6
5
  sleep,
7
6
  } from '../utils/functions.js'
8
7
  import platformLang from '../utils/lang-en.js'
9
8
  import { logUnknownData } from '../utils/report-unknown.js'
9
+ import GoveeDevice from './base.js'
10
10
 
11
11
  /*
12
12
  Custom Mode: aa050001010000000000000000000000000000af
@@ -23,16 +23,10 @@ import { logUnknownData } from '../utils/report-unknown.js'
23
23
  Black Tea/Boil: MwUABQAAAAAAAAAAAAAAAAAAADM= 3305000500000000000000000000000000000033 [switch]
24
24
  MwEBBQAAAAAAAAAAAAAAAAAAADY= 3301010500000000000000000000000000000036 [enable]
25
25
  */
26
- export default class {
26
+ export default class extends GoveeDevice {
27
27
  constructor(platform, accessory) {
28
- // Set up variables from the platform
29
- this.hapChar = platform.api.hap.Characteristic
30
- this.hapErr = platform.api.hap.HapStatusError
31
- this.hapServ = platform.api.hap.Service
32
- this.platform = platform
33
-
28
+ super(platform, accessory)
34
29
  // Set up variables from the accessory
35
- this.accessory = accessory
36
30
  const deviceConf = platform.deviceConf[accessory.context.gvDeviceId] || {}
37
31
 
38
32
  this.codes = {
@@ -232,14 +226,9 @@ export default class {
232
226
  service.updateCharacteristic(this.hapChar.On, false)
233
227
  }, 3000)
234
228
  } catch (err) {
235
- // Catch any errors during the process
236
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
237
-
238
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
239
- setTimeout(() => {
229
+ this.failUpdate(err, () => {
240
230
  service.updateCharacteristic(this.hapChar.On, false)
241
- }, 2000)
242
- throw new this.hapErr(-70402)
231
+ })
243
232
  }
244
233
  }
245
234
 
@@ -1,17 +1,9 @@
1
- import { parseError } from '../utils/functions.js'
2
1
  import platformLang from '../utils/lang-en.js'
2
+ import GoveeDevice from './base.js'
3
3
 
4
- export default class {
4
+ export default class extends GoveeDevice {
5
5
  constructor(platform, accessory) {
6
- // Set up variables from the platform
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
-
6
+ super(platform, accessory)
15
7
  // Remove any lightbulb service
16
8
  if (accessory.getService(this.hapServ.Lightbulb)) {
17
9
  accessory.removeService(accessory.getService(this.hapServ.Lightbulb))
@@ -61,14 +53,9 @@ export default class {
61
53
  this.accessory.log(`${platformLang.curState} [${this.cacheState}]`)
62
54
  }
63
55
  } catch (err) {
64
- // Catch any errors during the process
65
- this.accessory.logWarn(`${platformLang.devNotUpdated} ${parseError(err)}`)
66
-
67
- // Throw a 'no response' error and set a timeout to revert this after 2 seconds
68
- setTimeout(() => {
56
+ this.failUpdate(err, () => {
69
57
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
70
- }, 2000)
71
- throw new this.hapErr(-70402)
58
+ })
72
59
  }
73
60
  }
74
61