@homebridge-plugins/homebridge-govee 11.32.2-beta.21 → 11.32.2-beta.22
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 +1 -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/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-thermo-switch.js +4 -9
- package/lib/device/sensor-thermo.js +4 -9
- package/lib/device/sensor-thermo4.js +3 -10
- 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/package.json +1 -1
|
@@ -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
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import platformLang from '../utils/lang-en.js'
|
|
2
2
|
import { logUnknownData } from '../utils/report-unknown.js'
|
|
3
|
+
import GoveeDevice from './base.js'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* A sensor whose broadcasts are not decoded yet.
|
|
@@ -8,17 +9,9 @@ import { logUnknownData } from '../utils/report-unknown.js'
|
|
|
8
9
|
* it does is report every message it receives in one copy-paste line, so an
|
|
9
10
|
* owner can send in exactly what is needed to finish the model off.
|
|
10
11
|
*/
|
|
11
|
-
export default class GoveeSensorBasic {
|
|
12
|
+
export default class GoveeSensorBasic extends GoveeDevice {
|
|
12
13
|
constructor(platform, accessory) {
|
|
13
|
-
|
|
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
|
-
|
|
14
|
+
super(platform, accessory)
|
|
22
15
|
// Output the customised options to the log
|
|
23
16
|
const opts = JSON.stringify({})
|
|
24
17
|
platform.log('[%s] %s %s.', accessory.displayName, platformLang.devInitOpts, opts)
|
package/lib/device/sensor-co2.js
CHANGED
|
@@ -6,22 +6,15 @@ import {
|
|
|
6
6
|
parseError,
|
|
7
7
|
} from '../utils/functions.js'
|
|
8
8
|
import platformLang from '../utils/lang-en.js'
|
|
9
|
+
import GoveeDevice from './base.js'
|
|
9
10
|
|
|
10
11
|
// HomeKit triggers "CO2 detected" abnormal flag at this threshold (ppm).
|
|
11
12
|
// Govee app default warn level is 1000 ppm; override via deviceConf.co2AbnormalThreshold.
|
|
12
13
|
const DEFAULT_CO2_ABNORMAL_PPM = 1000
|
|
13
14
|
|
|
14
|
-
export default class {
|
|
15
|
+
export default class extends GoveeDevice {
|
|
15
16
|
constructor(platform, accessory) {
|
|
16
|
-
|
|
17
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
18
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
19
|
-
this.hapServ = platform.api.hap.Service
|
|
20
|
-
this.platform = platform
|
|
21
|
-
|
|
22
|
-
// Set up variables from the accessory
|
|
23
|
-
this.accessory = accessory
|
|
24
|
-
|
|
17
|
+
super(platform, accessory)
|
|
25
18
|
// Set up custom variables for this device type
|
|
26
19
|
const deviceConf = platform.deviceConf[accessory.context.gvDeviceId] || {}
|
|
27
20
|
this.co2AbnormalThreshold = deviceConf.co2AbnormalThreshold || DEFAULT_CO2_ABNORMAL_PPM
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import platformConsts from '../utils/constants.js'
|
|
2
2
|
import { hasProperty } from '../utils/functions.js'
|
|
3
3
|
import platformLang from '../utils/lang-en.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
|
// Set up custom variables for this device type
|
|
18
13
|
const deviceConf = platform.deviceConf[accessory.context.gvDeviceId]
|
|
19
14
|
this.lowBattThreshold = deviceConf && deviceConf.lowBattThreshold
|
|
@@ -9,18 +9,11 @@ import {
|
|
|
9
9
|
parseError,
|
|
10
10
|
} from '../utils/functions.js'
|
|
11
11
|
import platformLang from '../utils/lang-en.js'
|
|
12
|
+
import GoveeDevice from './base.js'
|
|
12
13
|
|
|
13
|
-
export default class {
|
|
14
|
+
export default class extends GoveeDevice {
|
|
14
15
|
constructor(platform, accessory) {
|
|
15
|
-
|
|
16
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
17
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
18
|
-
this.hapServ = platform.api.hap.Service
|
|
19
|
-
this.platform = platform
|
|
20
|
-
|
|
21
|
-
// Set up variables from the accessory
|
|
22
|
-
this.accessory = accessory
|
|
23
|
-
|
|
16
|
+
super(platform, accessory)
|
|
24
17
|
// Set up custom variables for this device type
|
|
25
18
|
const deviceConf = platform.deviceConf[accessory.context.gvDeviceId]
|
|
26
19
|
this.lowBattThreshold = deviceConf && deviceConf.lowBattThreshold
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { base64ToHex, 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) {
|
|
7
|
-
|
|
8
|
-
this.hapChar = platform.api.hap.Characteristic
|
|
9
|
-
this.hapErr = platform.api.hap.HapStatusError
|
|
10
|
-
this.hapServ = platform.api.hap.Service
|
|
11
|
-
this.platform = platform
|
|
12
|
-
|
|
13
|
-
// Set up variables from the accessory
|
|
14
|
-
this.accessory = accessory
|
|
15
|
-
|
|
8
|
+
super(platform, accessory)
|
|
16
9
|
// Add the occupancy sensor if it does not already exist
|
|
17
10
|
this.service = this.accessory.getService(this.hapServ.OccupancySensor) || this.accessory.addService(this.hapServ.OccupancySensor)
|
|
18
11
|
this.cacheState = this.service.getCharacteristic(this.hapChar.OccupancyDetected).value
|