@homebridge-plugins/homebridge-ewelink 12.19.1-beta.3 → 12.19.1-beta.5

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 (87) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/eslint.config.js +9 -2
  3. package/lib/connection/api.js +9 -3
  4. package/lib/connection/http.js +25 -7
  5. package/lib/connection/lan.js +10 -3
  6. package/lib/connection/ws.js +9 -3
  7. package/lib/device/air-conditioner.js +17 -5
  8. package/lib/device/curtain.js +12 -4
  9. package/lib/device/diffuser.js +9 -3
  10. package/lib/device/fan-gear.js +3 -1
  11. package/lib/device/fan.js +44 -13
  12. package/lib/device/group.js +19 -5
  13. package/lib/device/humidifier.js +3 -1
  14. package/lib/device/light-cct.js +3 -1
  15. package/lib/device/light-dimmer.js +12 -4
  16. package/lib/device/light-rgb-cct.js +6 -2
  17. package/lib/device/light-rgb.js +6 -2
  18. package/lib/device/motor.js +25 -7
  19. package/lib/device/outlet-multi.js +68 -21
  20. package/lib/device/outlet-single-inched.js +62 -9
  21. package/lib/device/outlet-single.js +44 -9
  22. package/lib/device/panel.js +14 -4
  23. package/lib/device/sensor-air-quality.js +43 -2
  24. package/lib/device/sensor-ambient.js +3 -1
  25. package/lib/device/sensor-contact.js +9 -3
  26. package/lib/device/simulation/blind.js +12 -4
  27. package/lib/device/simulation/cooler.js +18 -6
  28. package/lib/device/simulation/door.js +12 -4
  29. package/lib/device/simulation/doorbell.js +12 -4
  30. package/lib/device/simulation/garage-eachen.js +14 -4
  31. package/lib/device/simulation/garage-four.js +6 -2
  32. package/lib/device/simulation/garage-one.js +39 -13
  33. package/lib/device/simulation/garage-two.js +57 -19
  34. package/lib/device/simulation/gate-one.js +15 -5
  35. package/lib/device/simulation/heater.js +18 -6
  36. package/lib/device/simulation/light-fan.js +3 -1
  37. package/lib/device/simulation/lock-eachen.js +14 -4
  38. package/lib/device/simulation/lock-one.js +18 -6
  39. package/lib/device/simulation/p-button.js +12 -4
  40. package/lib/device/simulation/purifier.js +33 -11
  41. package/lib/device/simulation/sensor-hidden.js +3 -1
  42. package/lib/device/simulation/sensor-leak.js +9 -3
  43. package/lib/device/simulation/sensor-visible.js +12 -4
  44. package/lib/device/simulation/sensor.js +15 -5
  45. package/lib/device/simulation/switch-valve.js +38 -12
  46. package/lib/device/simulation/tap-one.js +27 -9
  47. package/lib/device/simulation/tap-two.js +47 -15
  48. package/lib/device/simulation/th-cooler.js +18 -6
  49. package/lib/device/simulation/th-dehumidifier.js +18 -6
  50. package/lib/device/simulation/th-heater.js +18 -6
  51. package/lib/device/simulation/th-humidifier.js +18 -6
  52. package/lib/device/simulation/th-thermostat.js +30 -10
  53. package/lib/device/simulation/tv.js +27 -9
  54. package/lib/device/simulation/valve-four.js +19 -5
  55. package/lib/device/simulation/valve-one.js +18 -6
  56. package/lib/device/simulation/valve-two.js +35 -11
  57. package/lib/device/simulation/window.js +12 -4
  58. package/lib/device/switch-man.js +6 -2
  59. package/lib/device/switch-mate.js +6 -2
  60. package/lib/device/switch-multi.js +71 -22
  61. package/lib/device/switch-single-inched.js +63 -9
  62. package/lib/device/switch-single.js +37 -11
  63. package/lib/device/thermostat.js +15 -5
  64. package/lib/device/virtual.js +5 -1
  65. package/lib/device/zigbee/light-rgb-cct.js +6 -2
  66. package/lib/device/zigbee/motor.js +17 -5
  67. package/lib/device/zigbee/sensor-ambient.js +9 -3
  68. package/lib/device/zigbee/sensor-contact.js +9 -3
  69. package/lib/device/zigbee/sensor-leak.js +6 -2
  70. package/lib/device/zigbee/sensor-motion.js +9 -3
  71. package/lib/device/zigbee/sensor-occupancy.js +11 -5
  72. package/lib/device/zigbee/sensor-smoke.js +9 -3
  73. package/lib/device/zigbee/siren.js +7 -2
  74. package/lib/device/zigbee/switch-stateless.js +9 -3
  75. package/lib/device/zigbee/thermostat.js +11 -3
  76. package/lib/device/zigbee/zigbee-water-valve.js +129 -101
  77. package/lib/fakegato/fakegato-history.js +9 -3
  78. package/lib/fakegato/fakegato-storage.js +6 -2
  79. package/lib/node-dns-sd/lib/dns-sd-parser.js +6 -1
  80. package/lib/node-dns-sd/lib/dns-sd.js +39 -13
  81. package/lib/platform.js +21 -7
  82. package/lib/utils/colour.js +18 -4
  83. package/lib/utils/constants.js +112 -13
  84. package/lib/utils/lang-en.js +2 -0
  85. package/lib/utils/lang-fr.js +2 -0
  86. package/lib/utils/lang-th.js +2 -0
  87. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -14,6 +14,19 @@ All notable changes to `@homebridge-plugins/homebridge-ewelink` will be document
14
14
  - fix(zigbee): read the curtain motor's position, so home stops showing it opening (#810)
15
15
  - fix(zigbee): keep a curtain motor shown as a garage door in step with its door
16
16
  - fix(zigbee): flip the zbu-curt-7006 position, which counts 0 as open (#810)
17
+ - chore(deps): dependency updates
18
+ - fix: stop live updates dropping readings like light level, child lock and fan oscillation
19
+ - fix: show power readings on the 226 and 7032 when they are shown as an outlet
20
+ - fix: read inched power devices in hundredths, so a powr316 or s61 no longer shows 5500w for 55w
21
+ - fix: log in again when the cloud reports an expired token, so group commands keep working
22
+ - feat(zigbee): add the snzb-02b and snzb-02m temperature and humidity sensors
23
+ - feat(zigbee): add the snzb-06p24 presence sensor, with occupancy and light level
24
+ - feat(zigbee): add the mini-zb1gp switch, with power readings
25
+ - feat: add the mini-1gsp switch, with power readings
26
+ - feat: add the nspanel86pb relay, as a two-channel switch
27
+ - feat(zigbee): add the second generation trvzb radiator valve, on the existing thermostat
28
+ - feat(zigbee): add the swv-zf2e two-zone irrigation valve, with a valve for each zone
29
+ - feat: show pm2.5 and pm10 on the air quality sensors that measure them
17
30
 
18
31
  ## v12.19.0 (2026-10-18)
19
32
 
package/eslint.config.js CHANGED
@@ -32,10 +32,17 @@ export default antfu(
32
32
  'perfectionist/sort-named-imports': 'error',
33
33
  'quotes': ['error', 'single'],
34
34
  'sort-imports': 0,
35
- 'style/brace-style': ['error', '1tbs', { allowSingleLine: true }],
35
+ 'style/brace-style': [
36
+ 'error',
37
+ '1tbs',
38
+ { allowSingleLine: true },
39
+ ],
36
40
  'style/quote-props': ['error', 'consistent-as-needed'],
37
41
  'test/no-only-tests': 'error',
38
- 'unused-imports/no-unused-vars': ['error', { caughtErrors: 'none' }],
42
+ 'unused-imports/no-unused-vars': [
43
+ 'error',
44
+ { caughtErrors: 'none' },
45
+ ],
39
46
  },
40
47
  typescript: false,
41
48
  },
@@ -364,7 +364,9 @@ export default class {
364
364
  : false
365
365
  break
366
366
  case 'hue':
367
- charName = accServ.testCharacteristic(this.hapChar.Hue) ? this.hapChar.Hue : false
367
+ charName = accServ.testCharacteristic(this.hapChar.Hue)
368
+ ? this.hapChar.Hue
369
+ : false
368
370
  break
369
371
  case 'speed':
370
372
  charName = accServ.testCharacteristic(this.hapChar.RotationSpeed)
@@ -372,7 +374,9 @@ export default class {
372
374
  : false
373
375
  break
374
376
  case 'state':
375
- charName = accServ.testCharacteristic(this.hapChar.On) ? this.hapChar.On : false
377
+ charName = accServ.testCharacteristic(this.hapChar.On)
378
+ ? this.hapChar.On
379
+ : false
376
380
  break
377
381
  default:
378
382
  throw new Error(`Invalid characteristic specified for service:${servToUpdate}`)
@@ -455,7 +459,9 @@ export default class {
455
459
  throw new Error('Value must be \'low\', \'medium\' or \'high\' for characteristic:speed')
456
460
  }
457
461
  const inLevels = accServ.getCharacteristic(this.hapChar.RotationSpeed).props.maxValue <= 3
458
- newHKStatus = inLevels ? levels[newValue] : levels[newValue] * 33
462
+ newHKStatus = inLevels
463
+ ? levels[newValue]
464
+ : levels[newValue] * 33
459
465
 
460
466
  // Check the accessory has a correct set handler for speed
461
467
  if (!accessory.control.internalSpeedUpdate) {
@@ -34,15 +34,22 @@ export default class {
34
34
  // A timeout surfaces as ECONNABORTED/ETIMEDOUT, which the retry logic handles.
35
35
  this.axiosClient = axios.create({ timeout: 30000 })
36
36
  this.axiosClient.interceptors.response.use(
37
- res => res,
37
+ async (res) => {
38
+ // eWeLink normally reports an expired token inside an ordinary response,
39
+ // as error 401 or 402, rather than as an http 401
40
+ if ([401, 402].includes(res.data?.error) && !res.config._retried) {
41
+ try {
42
+ return await this.retryWithNewToken(res.config)
43
+ } catch (loginErr) {
44
+ return res
45
+ }
46
+ }
47
+ return res
48
+ },
38
49
  async (err) => {
39
50
  if (err.response?.status === 401 && !err.config._retried) {
40
- err.config._retried = true
41
51
  try {
42
- const authData = await this.login()
43
- this.aToken = authData.aToken
44
- err.config.headers.Authorization = `Bearer ${this.aToken}`
45
- return this.axiosClient(err.config)
52
+ return await this.retryWithNewToken(err.config)
46
53
  } catch (loginErr) {
47
54
  throw err
48
55
  }
@@ -52,6 +59,15 @@ export default class {
52
59
  )
53
60
  }
54
61
 
62
+ async retryWithNewToken(config) {
63
+ // Log in again for a fresh token, then send the request once more
64
+ config._retried = true
65
+ const authData = await this.login()
66
+ this.aToken = authData.aToken
67
+ config.headers.Authorization = `Bearer ${this.aToken}`
68
+ return this.axiosClient(config)
69
+ }
70
+
55
71
  async login() {
56
72
  try {
57
73
  // Used to log the user in and obtain the user api key and token
@@ -141,7 +157,9 @@ export default class {
141
157
  return await this.login()
142
158
  }
143
159
  if (body.msg) {
144
- throw new Error(body.msg + (body.error ? ` [${body.error}]` : ''))
160
+ throw new Error(body.msg + (body.error
161
+ ? ` [${body.error}]`
162
+ : ''))
145
163
  } else {
146
164
  throw new Error(`${this.lang.noAuthRec}.\n${JSON.stringify(body, null, 2)}`)
147
165
  }
@@ -161,7 +161,9 @@ export default class {
161
161
  // Log LAN discovery summary after 10 seconds
162
162
  setTimeout(() => {
163
163
  const total = this.deviceMap.size
164
- const withIp = [...this.deviceMap.values()].filter(d => d.ip).length
164
+ const withIp = [
165
+ ...this.deviceMap.values(),
166
+ ].filter(d => d.ip).length
165
167
  this.log('LAN discovery: %s/%s devices found locally.', withIp, total)
166
168
  }, 10000)
167
169
  }
@@ -284,7 +286,10 @@ export default class {
284
286
  const iv = randomBytes(16)
285
287
  const enc = createCipheriv('aes-128-cbc', key, iv)
286
288
  const data = {
287
- data: Buffer.concat([enc.update(JSON.stringify(params)), enc.final()]).toString('base64'),
289
+ data: Buffer.concat([
290
+ enc.update(JSON.stringify(params)),
291
+ enc.final(),
292
+ ]).toString('base64'),
288
293
  deviceid: json.deviceid,
289
294
  encrypt: true,
290
295
  iv: iv.toString('base64'),
@@ -301,7 +306,9 @@ export default class {
301
306
  'Content-Type': 'application/json',
302
307
  },
303
308
  data,
304
- timeout: this.mode === 'lan' ? 9000 : 3000,
309
+ timeout: this.mode === 'lan'
310
+ ? 9000
311
+ : 3000,
305
312
  })
306
313
 
307
314
  // Check for any errors in the response
@@ -70,7 +70,9 @@ export default class {
70
70
 
71
71
  // Fall back to static pconnect hosts
72
72
  const region = this.httpHost.split('-')[0]
73
- const suffix = region === 'cn' ? 'coolkit.cn' : 'coolkit.cc'
73
+ const suffix = region === 'cn'
74
+ ? 'coolkit.cn'
75
+ : 'coolkit.cc'
74
76
  const fallback = `${region}-pconnect3.${suffix}`
75
77
  this.log.warn('%s [%s].', this.lang.errGetHost, fallback)
76
78
  return fallback
@@ -104,7 +106,9 @@ export default class {
104
106
  packMessage: data => JSON.stringify(data),
105
107
  unpackMessage: (data) => {
106
108
  data = data.toString()
107
- return data === 'pong' ? data : JSON.parse(data)
109
+ return data === 'pong'
110
+ ? data
111
+ : JSON.parse(data)
108
112
  },
109
113
  timeout: 20000,
110
114
  })
@@ -341,7 +345,9 @@ export default class {
341
345
  })
342
346
 
343
347
  // Parse the response and see if any error has been reported back
344
- res.error = hasProperty(res, 'error') ? res.error : -1
348
+ res.error = hasProperty(res, 'error')
349
+ ? res.error
350
+ : -1
345
351
 
346
352
  // Check if and which error has been reported back
347
353
  switch (res.error) {
@@ -166,10 +166,14 @@ export default class {
166
166
 
167
167
  async internalActiveUpdate(value) {
168
168
  try {
169
- const newValue = value === 1 ? 'on' : 'off'
169
+ const newValue = value === 1
170
+ ? 'on'
171
+ : 'off'
170
172
 
171
173
  // Don't continue if the value is the same as before
172
- const prevState = this.service.getCharacteristic(this.hapChar.Active).value === 1 ? 'on' : 'off'
174
+ const prevState = this.service.getCharacteristic(this.hapChar.Active).value === 1
175
+ ? 'on'
176
+ : 'off'
173
177
  if (prevState === newValue) {
174
178
  return
175
179
  }
@@ -258,7 +262,11 @@ export default class {
258
262
 
259
263
  // Throw a 'no response' error and set a timeout to revert this after 2 seconds
260
264
  setTimeout(() => {
261
- const prevValue = this.cacheMode === 'heat' ? 1 : this.cacheMode === 'cool' ? 2 : 0
265
+ const prevValue = this.cacheMode === 'heat'
266
+ ? 1
267
+ : this.cacheMode === 'cool'
268
+ ? 2
269
+ : 0
262
270
  this.service.updateCharacteristic(this.hapChar.TargetHeaterCoolerState, prevValue)
263
271
  }, 2000)
264
272
  throw new this.hapErr(-70402)
@@ -372,7 +380,9 @@ export default class {
372
380
 
373
381
  // Update the active characteristic
374
382
  if (hasProperty(params, 'power')) {
375
- const newState = params.power === 'on' ? 1 : 0
383
+ const newState = params.power === 'on'
384
+ ? 1
385
+ : 0
376
386
  this.service.updateCharacteristic(this.hapChar.Active, newState)
377
387
 
378
388
  // Update the current state
@@ -498,7 +508,9 @@ export default class {
498
508
  const toReturn = {}
499
509
  toReturn.services = ['heater-cooler']
500
510
  toReturn.heater_cooler = {
501
- state: this.service.getCharacteristic(this.hapChar.Active).value === 1 ? 'on' : 'off',
511
+ state: this.service.getCharacteristic(this.hapChar.Active).value === 1
512
+ ? 'on'
513
+ : 'off',
502
514
  mode: this.cacheMode,
503
515
  target_temp: this.cacheTarg,
504
516
  current_temp: this.cacheTemp,
@@ -191,7 +191,9 @@ export default class {
191
191
  // If we are to fully open/close the curtain we can use the switch param
192
192
  if ([0, 100].includes(value)) {
193
193
  // 'on' for fully open and 'off' for fully close
194
- params.switch = value === 100 ? 'on' : 'off'
194
+ params.switch = value === 100
195
+ ? 'on'
196
+ : 'off'
195
197
  } else {
196
198
  // Otherwise, for a %-point we can use the 'setclose' param
197
199
  params.setclose = Math.abs(100 - value)
@@ -231,10 +233,14 @@ export default class {
231
233
  const params = {}
232
234
  switch (this.accessory.context.eweUIID) {
233
235
  case 11:
234
- params.switch = value === 0 ? 'on' : 'off'
236
+ params.switch = value === 0
237
+ ? 'on'
238
+ : 'off'
235
239
  break
236
240
  case 67:
237
- params.op = value === 0 ? 1 : 3
241
+ params.op = value === 0
242
+ ? 1
243
+ : 3
238
244
  break
239
245
  default:
240
246
  return
@@ -298,7 +304,9 @@ export default class {
298
304
  if (hasProperty(params, 'setclose')) {
299
305
  newPos = Math.abs(100 - params.setclose)
300
306
  } else if (params.switch) {
301
- newPos = params.switch === 'on' ? 100 : 0
307
+ newPos = params.switch === 'on'
308
+ ? 100
309
+ : 0
302
310
  } else {
303
311
  return
304
312
  }
@@ -165,7 +165,9 @@ export default class {
165
165
  }
166
166
 
167
167
  // The new speed can be {50, 100} so use rounding on the new value
168
- const newValue = value <= 50 ? 50 : 100
168
+ const newValue = value <= 50
169
+ ? 50
170
+ : 100
169
171
 
170
172
  // Check the rounded speed against the current cache value
171
173
  if (newValue === this.cacheSpeed) {
@@ -239,7 +241,9 @@ export default class {
239
241
 
240
242
  // Log the update if appropriate
241
243
  if (this.enableLogging) {
242
- this.log('[%s] %s [%s%].', this.name, this.lang.curLight, value === 1 ? 'on' : 'off')
244
+ this.log('[%s] %s [%s%].', this.name, this.lang.curLight, value === 1
245
+ ? 'on'
246
+ : 'off')
243
247
  }
244
248
  } catch (err) {
245
249
  // Catch any errors and let the platform display them
@@ -409,7 +413,9 @@ export default class {
409
413
  '[%s] %s [%s%].',
410
414
  this.name,
411
415
  this.lang.curLight,
412
- params.lightswitch === 1 ? 'on' : 'off',
416
+ params.lightswitch === 1
417
+ ? 'on'
418
+ : 'off',
413
419
  )
414
420
  }
415
421
  }
@@ -175,7 +175,9 @@ export default class {
175
175
 
176
176
  async internalShakeUpdate(value) {
177
177
  try {
178
- const newShake = value === this.hapChar.SwingMode.SWING_ENABLED ? 'on' : 'off'
178
+ const newShake = value === this.hapChar.SwingMode.SWING_ENABLED
179
+ ? 'on'
180
+ : 'off'
179
181
  if (newShake === this.cacheShake) {
180
182
  return
181
183
  }
package/lib/device/fan.js CHANGED
@@ -66,7 +66,12 @@ export default class {
66
66
  this.service
67
67
  .getCharacteristic(this.hapChar.RotationSpeed)
68
68
  .setProps(this.speedAsPercent
69
- ? { maxValue: 100, minStep: 33, minValue: 0, unit: 'percentage' }
69
+ ? {
70
+ maxValue: 100,
71
+ minStep: 33,
72
+ minValue: 0,
73
+ unit: 'percentage',
74
+ }
70
75
  : {
71
76
  maxValue: 3,
72
77
  minStep: 1,
@@ -151,11 +156,15 @@ export default class {
151
156
  })
152
157
  if (newState === 'on') {
153
158
  params.switches.push({
154
- switch: this.cacheSpeed === 2 ? 'on' : 'off',
159
+ switch: this.cacheSpeed === 2
160
+ ? 'on'
161
+ : 'off',
155
162
  outlet: 2,
156
163
  })
157
164
  params.switches.push({
158
- switch: this.cacheSpeed === 3 ? 'on' : 'off',
165
+ switch: this.cacheSpeed === 3
166
+ ? 'on'
167
+ : 'off',
159
168
  outlet: 3,
160
169
  })
161
170
  }
@@ -185,21 +194,29 @@ export default class {
185
194
  const params = {
186
195
  switches: [],
187
196
  }
188
- const newState = value >= 1 ? 'on' : 'off'
197
+ const newState = value >= 1
198
+ ? 'on'
199
+ : 'off'
189
200
  const newSpeed = this.levelFromHK(value)
190
201
  if (newSpeed === this.cacheSpeed) {
191
202
  return
192
203
  }
193
204
  params.switches.push({
194
- switch: newState === 'on' && newSpeed >= 1 ? 'on' : 'off',
205
+ switch: newState === 'on' && newSpeed >= 1
206
+ ? 'on'
207
+ : 'off',
195
208
  outlet: 1,
196
209
  })
197
210
  params.switches.push({
198
- switch: newState === 'on' && newSpeed === 2 ? 'on' : 'off',
211
+ switch: newState === 'on' && newSpeed === 2
212
+ ? 'on'
213
+ : 'off',
199
214
  outlet: 2,
200
215
  })
201
216
  params.switches.push({
202
- switch: newState === 'on' && newSpeed === 3 ? 'on' : 'off',
217
+ switch: newState === 'on' && newSpeed === 3
218
+ ? 'on'
219
+ : 'off',
203
220
  outlet: 3,
204
221
  })
205
222
  await this.platform.sendDeviceUpdate(this.accessory, params)
@@ -329,16 +346,22 @@ export default class {
329
346
  currentState() {
330
347
  const toReturn = {}
331
348
  const level = this.levelFromHK(this.service.getCharacteristic(this.hapChar.RotationSpeed).value)
332
- const speedLabel = level === 0 ? 'off' : this.speed2label[level]
349
+ const speedLabel = level === 0
350
+ ? 'off'
351
+ : this.speed2label[level]
333
352
  toReturn.services = ['fan']
334
353
  toReturn.fan = {
335
- state: this.service.getCharacteristic(this.hapChar.On).value ? 'on' : 'off',
354
+ state: this.service.getCharacteristic(this.hapChar.On).value
355
+ ? 'on'
356
+ : 'off',
336
357
  speed: speedLabel,
337
358
  }
338
359
  if (!this.hideLight) {
339
360
  toReturn.services.push('light')
340
361
  toReturn.light = {
341
- state: this.lightService.getCharacteristic(this.hapChar.On).value ? 'on' : 'off',
362
+ state: this.lightService.getCharacteristic(this.hapChar.On).value
363
+ ? 'on'
364
+ : 'off',
342
365
  }
343
366
  }
344
367
  return toReturn
@@ -348,17 +371,25 @@ export default class {
348
371
  // scale 1-33 is low, 34-66 medium and 67-100 high
349
372
  levelFromHK(value) {
350
373
  if (!this.speedAsPercent) {
351
- return value < 0 || value > 3 ? 0 : value
374
+ return value < 0 || value > 3
375
+ ? 0
376
+ : value
352
377
  }
353
378
  if (value <= 0) {
354
379
  return 0
355
380
  }
356
- return value <= 33 ? 1 : value <= 66 ? 2 : 3
381
+ return value <= 33
382
+ ? 1
383
+ : value <= 66
384
+ ? 2
385
+ : 3
357
386
  }
358
387
 
359
388
  // A fan level as a HomeKit rotation speed, on whichever scale is in use
360
389
  levelToHK(level) {
361
- return this.speedAsPercent && level ? level * 33 : level
390
+ return this.speedAsPercent && level
391
+ ? level * 33
392
+ : level
362
393
  }
363
394
 
364
395
  markStatus(isOnline) {
@@ -72,13 +72,17 @@ export default class {
72
72
  }
73
73
  const params = {}
74
74
  if (this.isSCM) {
75
- params.switches = [{ switch: newValue, outlet: 0 }]
75
+ params.switches = [
76
+ { switch: newValue, outlet: 0 },
77
+ ]
76
78
  } else {
77
79
  params.switch = newValue
78
80
  }
79
81
  await this.platform.sendGroupUpdate(this.accessory, params)
80
82
  this.cacheState = newValue
81
- this.accessory.eveService.addEntry({ status: value ? 1 : 0 })
83
+ this.accessory.eveService.addEntry({
84
+ status: value ? 1 : 0,
85
+ })
82
86
  if (this.enableLogging) {
83
87
  this.log('[%s] %s [%s].', this.name, this.lang.curState, this.cacheState)
84
88
  }
@@ -96,7 +100,11 @@ export default class {
96
100
  if (!this.isSCM && params.switch && params.switch !== this.cacheState) {
97
101
  this.cacheState = params.switch
98
102
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
99
- this.accessory.eveService.addEntry({ status: this.cacheState === 'on' ? 1 : 0 })
103
+ this.accessory.eveService.addEntry({
104
+ status: this.cacheState === 'on'
105
+ ? 1
106
+ : 0,
107
+ })
100
108
  if (params.updateSource && this.enableLogging) {
101
109
  this.log('[%s] %s [%s].', this.name, this.lang.curState, this.cacheState)
102
110
  }
@@ -104,7 +112,11 @@ export default class {
104
112
  if (this.isSCM && params.switches?.[0] && params.switches[0].switch !== this.cacheState) {
105
113
  this.cacheState = params.switches[0].switch
106
114
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
107
- this.accessory.eveService.addEntry({ status: this.cacheState === 'on' ? 1 : 0 })
115
+ this.accessory.eveService.addEntry({
116
+ status: this.cacheState === 'on'
117
+ ? 1
118
+ : 0,
119
+ })
108
120
  if (params.updateSource && this.enableLogging) {
109
121
  this.log('[%s] %s [%s].', this.name, this.lang.curState, this.cacheState)
110
122
  }
@@ -118,7 +130,9 @@ export default class {
118
130
  const toReturn = {}
119
131
  toReturn.services = ['switch']
120
132
  toReturn.switch = {
121
- state: this.service.getCharacteristic(this.hapChar.On).value ? 'on' : 'off',
133
+ state: this.service.getCharacteristic(this.hapChar.On).value
134
+ ? 'on'
135
+ : 'off',
122
136
  }
123
137
  return toReturn
124
138
  }
@@ -124,7 +124,9 @@ export default class {
124
124
  return
125
125
  }
126
126
  const params = {}
127
- const newState = value >= 1 ? 'on' : 'off'
127
+ const newState = value >= 1
128
+ ? 'on'
129
+ : 'off'
128
130
  params.switch = newState
129
131
  let newMode
130
132
  if (value > 0) {
@@ -336,7 +336,9 @@ export default class {
336
336
  const toReturn = {}
337
337
  toReturn.services = ['light']
338
338
  toReturn.light = {
339
- state: this.service.getCharacteristic(this.hapChar.On).value ? 'on' : 'off',
339
+ state: this.service.getCharacteristic(this.hapChar.On).value
340
+ ? 'on'
341
+ : 'off',
340
342
  brightness: this.service.getCharacteristic(this.hapChar.Brightness).value,
341
343
  colourtemperature: this.service.getCharacteristic(this.hapChar.ColorTemperature).value,
342
344
  adaptivelighting:
@@ -272,9 +272,15 @@ export default class {
272
272
  this.log(
273
273
  '[%s] %s%s%s.',
274
274
  this.name,
275
- power !== undefined ? `${this.lang.curPower} [${power}W]` : '',
276
- voltage !== undefined ? ` ${this.lang.curVolt} [${voltage}V]` : '',
277
- current !== undefined ? ` ${this.lang.curCurr} [${current}A]` : '',
275
+ power !== undefined
276
+ ? `${this.lang.curPower} [${power}W]`
277
+ : '',
278
+ voltage !== undefined
279
+ ? ` ${this.lang.curVolt} [${voltage}V]`
280
+ : '',
281
+ current !== undefined
282
+ ? ` ${this.lang.curCurr} [${current}A]`
283
+ : '',
278
284
  )
279
285
  }
280
286
  }
@@ -300,7 +306,9 @@ export default class {
300
306
  const toReturn = {}
301
307
  toReturn.services = ['light']
302
308
  toReturn.light = {
303
- state: this.service.getCharacteristic(this.hapChar.On).value ? 'on' : 'off',
309
+ state: this.service.getCharacteristic(this.hapChar.On).value
310
+ ? 'on'
311
+ : 'off',
304
312
  brightness: this.service.getCharacteristic(this.hapChar.Brightness).value,
305
313
  }
306
314
  return toReturn
@@ -840,9 +840,13 @@ export default class {
840
840
  const toReturn = {}
841
841
  toReturn.services = ['light']
842
842
  toReturn.light = {
843
- state: this.service.getCharacteristic(this.hapChar.On).value ? 'on' : 'off',
843
+ state: this.service.getCharacteristic(this.hapChar.On).value
844
+ ? 'on'
845
+ : 'off',
844
846
  brightness: this.service.getCharacteristic(this.hapChar.Brightness).value,
845
- colourmode: this.cacheMode === 'white' ? 'colourtemperature' : 'hue',
847
+ colourmode: this.cacheMode === 'white'
848
+ ? 'colourtemperature'
849
+ : 'hue',
846
850
  hue: this.service.getCharacteristic(this.hapChar.Hue).value,
847
851
  saturation: this.service.getCharacteristic(this.hapChar.Saturation).value,
848
852
  colourtemperature: this.service.getCharacteristic(this.hapChar.ColorTemperature).value,
@@ -210,7 +210,9 @@ export default class {
210
210
  this.service.updateCharacteristic(this.hapChar.On, this.cacheState === 'on')
211
211
  this.service.updateCharacteristic(
212
212
  this.hapChar.Brightness,
213
- this.cacheState === 'on' ? 100 : 0,
213
+ this.cacheState === 'on'
214
+ ? 100
215
+ : 0,
214
216
  )
215
217
  if (params.updateSource && this.enableLogging) {
216
218
  this.log('[%s] %s [%s].', this.name, this.lang.curState, this.cacheState)
@@ -278,7 +280,9 @@ export default class {
278
280
  const toReturn = {}
279
281
  toReturn.services = ['light']
280
282
  toReturn.light = {
281
- state: this.service.getCharacteristic(this.hapChar.On).value ? 'on' : 'off',
283
+ state: this.service.getCharacteristic(this.hapChar.On).value
284
+ ? 'on'
285
+ : 'off',
282
286
  brightness: this.service.getCharacteristic(this.hapChar.Brightness).value,
283
287
  hue: this.service.getCharacteristic(this.hapChar.Hue).value,
284
288
  saturation: this.service.getCharacteristic(this.hapChar.Saturation).value,
@@ -211,10 +211,20 @@ export default class {
211
211
  // this.cachePos is 0 for closed and >0 for open
212
212
 
213
213
  const params = this.accessory.context.eweUIID === 211
214
- ? { electromotor: value === 1 ? 2 : 0 }
215
- : { location: value === 1 ? 0 : 100 }
214
+ ? {
215
+ electromotor: value === 1
216
+ ? 2
217
+ : 0,
218
+ }
219
+ : {
220
+ location: value === 1
221
+ ? 0
222
+ : 100,
223
+ }
216
224
  await this.platform.sendDeviceUpdate(this.accessory, params)
217
- this.cacheTarg = value === 1 ? 0 : 100
225
+ this.cacheTarg = value === 1
226
+ ? 0
227
+ : 100
218
228
  if (this.enableLogging) {
219
229
  this.log('[%s] %s [%s%].', this.name, this.lang.curTarg, this.cacheTarg)
220
230
  }
@@ -236,7 +246,9 @@ export default class {
236
246
  }
237
247
 
238
248
  // Send the params to request the updates
239
- await this.platform.sendDeviceUpdate(this.accessory, { uiActive: { outlet: 0, time: 120 } })
249
+ await this.platform.sendDeviceUpdate(this.accessory, {
250
+ uiActive: { outlet: 0, time: 120 },
251
+ })
240
252
  } catch (err) {
241
253
  this.log.error(err)
242
254
  }
@@ -363,9 +375,15 @@ export default class {
363
375
  this.log(
364
376
  '[%s] %s%s%s.',
365
377
  this.name,
366
- power !== undefined ? `${this.lang.curPower} [${power}W]` : '',
367
- voltage !== undefined ? ` ${this.lang.curVolt} [${voltage}V]` : '',
368
- current !== undefined ? ` ${this.lang.curCurr} [${current}A]` : '',
378
+ power !== undefined
379
+ ? `${this.lang.curPower} [${power}W]`
380
+ : '',
381
+ voltage !== undefined
382
+ ? ` ${this.lang.curVolt} [${voltage}V]`
383
+ : '',
384
+ current !== undefined
385
+ ? ` ${this.lang.curCurr} [${current}A]`
386
+ : '',
369
387
  )
370
388
  }
371
389
  } catch (err) {