@switchbot/homebridge-switchbot 4.1.8-beta.4 → 4.1.8-beta.6
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/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +17 -6
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +17 -6
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +17 -6
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +62 -36
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +17 -6
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +17 -6
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +17 -6
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +17 -6
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +17 -6
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +17 -6
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +62 -36
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +17 -6
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +17 -6
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +17 -6
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/meterpro.d.ts.map +1 -1
- package/dist/device/meterpro.js +17 -6
- package/dist/device/meterpro.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +17 -6
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +17 -6
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +17 -6
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +17 -6
- package/dist/device/waterdetector.js.map +1 -1
- package/docs/assets/dmt/dmt-component-data.js +1 -0
- package/docs/assets/dmt/dmt-components.css +20 -0
- package/docs/assets/dmt/dmt-components.js +67 -0
- package/docs/assets/dmt/dmt-search.cmp +0 -0
- package/docs/assets/dmt/dmt-theme.css +1 -0
- package/docs/assets/main.js +1 -1
- package/docs/functions/default.html +2 -1
- package/docs/index.html +7 -6
- package/docs/modules.html +2 -1
- package/package.json +5 -3
- package/src/device/blindtilt.ts +15 -6
- package/src/device/bot.ts +15 -6
- package/src/device/ceilinglight.ts +15 -6
- package/src/device/colorbulb.ts +57 -36
- package/src/device/contact.ts +15 -6
- package/src/device/curtain.ts +15 -6
- package/src/device/fan.ts +15 -6
- package/src/device/hub.ts +15 -6
- package/src/device/humidifier.ts +15 -6
- package/src/device/iosensor.ts +15 -6
- package/src/device/lightstrip.ts +61 -42
- package/src/device/lock.ts +15 -6
- package/src/device/meter.ts +15 -6
- package/src/device/meterplus.ts +15 -6
- package/src/device/meterpro.ts +15 -6
- package/src/device/motion.ts +15 -6
- package/src/device/plug.ts +15 -6
- package/src/device/robotvacuumcleaner.ts +15 -6
- package/src/device/waterdetector.ts +15 -6
- package/typedoc.json +4 -0
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
package/src/device/colorbulb.ts
CHANGED
|
@@ -203,14 +203,18 @@ export class ColorBulb extends deviceBase {
|
|
|
203
203
|
this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
|
|
204
204
|
// Color, Hue & Brightness
|
|
205
205
|
this.debugLog(`red: ${this.serviceData.red}, green: ${this.serviceData.green}, blue: ${this.serviceData.blue}`)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
206
|
+
if (this.serviceData.red !== undefined && this.serviceData.green !== undefined && this.serviceData.blue !== undefined) {
|
|
207
|
+
const [hue, saturation] = rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue)
|
|
208
|
+
this.debugLog(`hs: ${JSON.stringify(rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue))}`)
|
|
209
|
+
// Hue
|
|
210
|
+
this.LightBulb.Hue = hue
|
|
211
|
+
this.debugLog(`Hue: ${this.LightBulb.Hue}`)
|
|
212
|
+
// Saturation
|
|
213
|
+
this.LightBulb.Saturation = saturation
|
|
214
|
+
this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
|
|
215
|
+
} else {
|
|
216
|
+
this.errorLog(`Invalid color data: red=${this.serviceData.red}, green=${this.serviceData.green}, blue=${this.serviceData.blue}`)
|
|
217
|
+
}
|
|
214
218
|
// ColorTemperature
|
|
215
219
|
const miredColorTemperature = Math.round(1000000 / this.serviceData.color_temperature)
|
|
216
220
|
this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140)
|
|
@@ -229,17 +233,21 @@ export class ColorBulb extends deviceBase {
|
|
|
229
233
|
this.LightBulb.Brightness = this.deviceStatus.brightness
|
|
230
234
|
this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
|
|
231
235
|
// Color, Hue & Brightness
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
if (typeof this.deviceStatus.color === 'string') {
|
|
237
|
+
this.debugLog(`color: ${JSON.stringify(this.deviceStatus.color)}`)
|
|
238
|
+
const [red, green, blue] = this.deviceStatus.color.split(':')
|
|
239
|
+
this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`)
|
|
240
|
+
const [hue, saturation] = rgb2hs(red, green, blue)
|
|
241
|
+
this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`)
|
|
242
|
+
// Hue
|
|
243
|
+
this.LightBulb.Hue = hue
|
|
244
|
+
this.debugLog(`Hue: ${this.LightBulb.Hue}`)
|
|
245
|
+
// Saturation
|
|
246
|
+
this.LightBulb.Saturation = saturation
|
|
247
|
+
this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
|
|
248
|
+
} else {
|
|
249
|
+
this.errorLog(`Invalid color format: ${JSON.stringify(this.deviceStatus.color)}`)
|
|
250
|
+
}
|
|
243
251
|
// ColorTemperature
|
|
244
252
|
const miredColorTemperature = Math.round(1000000 / this.deviceStatus.colorTemperature)
|
|
245
253
|
this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140)
|
|
@@ -270,17 +278,21 @@ export class ColorBulb extends deviceBase {
|
|
|
270
278
|
this.LightBulb.Brightness = this.webhookContext.brightness
|
|
271
279
|
this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
|
|
272
280
|
// Color, Hue & Brightness
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
if (typeof this.webhookContext.color === 'string') {
|
|
282
|
+
this.debugLog(`color: ${JSON.stringify(this.webhookContext.color)}`)
|
|
283
|
+
const [red, green, blue] = this.webhookContext.color.split(':')
|
|
284
|
+
this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`)
|
|
285
|
+
const [hue, saturation] = rgb2hs(red, green, blue)
|
|
286
|
+
this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`)
|
|
287
|
+
// Hue
|
|
288
|
+
this.LightBulb.Hue = hue
|
|
289
|
+
this.debugLog(`Hue: ${this.LightBulb.Hue}`)
|
|
290
|
+
// Saturation
|
|
291
|
+
this.LightBulb.Saturation = saturation
|
|
292
|
+
this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
|
|
293
|
+
} else {
|
|
294
|
+
this.errorLog(`Invalid color format: ${JSON.stringify(this.webhookContext.color)}`)
|
|
295
|
+
}
|
|
284
296
|
// ColorTemperature
|
|
285
297
|
const miredColorTemperature = Math.round(1000000 / this.webhookContext.colorTemperature)
|
|
286
298
|
this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140)
|
|
@@ -341,10 +353,15 @@ export class ColorBulb extends deviceBase {
|
|
|
341
353
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
342
354
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: colorBulbServiceData) => {
|
|
343
355
|
try {
|
|
344
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
345
356
|
this.serviceData = context
|
|
346
|
-
|
|
347
|
-
|
|
357
|
+
if (context !== undefined || context !== null) {
|
|
358
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
359
|
+
await this.BLEparseStatus()
|
|
360
|
+
await this.updateHomeKitCharacteristics()
|
|
361
|
+
} else {
|
|
362
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
363
|
+
await this.BLERefreshConnection(context)
|
|
364
|
+
}
|
|
348
365
|
} catch (e: any) {
|
|
349
366
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
350
367
|
}
|
|
@@ -382,10 +399,14 @@ export class ColorBulb extends deviceBase {
|
|
|
382
399
|
this.debugLog('is listening webhook.')
|
|
383
400
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: colorBulbWebhookContext) => {
|
|
384
401
|
try {
|
|
385
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
386
402
|
this.webhookContext = context
|
|
387
|
-
|
|
388
|
-
|
|
403
|
+
if (context !== undefined || context !== null) {
|
|
404
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
405
|
+
await this.parseStatusWebhook()
|
|
406
|
+
await this.updateHomeKitCharacteristics()
|
|
407
|
+
} else {
|
|
408
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
409
|
+
}
|
|
389
410
|
} catch (e: any) {
|
|
390
411
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
391
412
|
}
|
package/src/device/contact.ts
CHANGED
|
@@ -334,10 +334,15 @@ export class Contact extends deviceBase {
|
|
|
334
334
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
335
335
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: contactSensorServiceData) => {
|
|
336
336
|
try {
|
|
337
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
338
337
|
this.serviceData = context
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
if (context !== undefined || context !== null) {
|
|
339
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
340
|
+
await this.BLEparseStatus()
|
|
341
|
+
await this.updateHomeKitCharacteristics()
|
|
342
|
+
} else {
|
|
343
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
344
|
+
await this.BLERefreshConnection(context)
|
|
345
|
+
}
|
|
341
346
|
} catch (e: any) {
|
|
342
347
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
343
348
|
}
|
|
@@ -375,10 +380,14 @@ export class Contact extends deviceBase {
|
|
|
375
380
|
this.debugLog('is listening webhook.')
|
|
376
381
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: contactSensorWebhookContext) => {
|
|
377
382
|
try {
|
|
378
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
379
383
|
this.webhookContext = context
|
|
380
|
-
|
|
381
|
-
|
|
384
|
+
if (context !== undefined || context !== null) {
|
|
385
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
386
|
+
await this.parseStatusWebhook()
|
|
387
|
+
await this.updateHomeKitCharacteristics()
|
|
388
|
+
} else {
|
|
389
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
390
|
+
}
|
|
382
391
|
} catch (e: any) {
|
|
383
392
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
384
393
|
}
|
package/src/device/curtain.ts
CHANGED
|
@@ -534,10 +534,14 @@ export class Curtain extends deviceBase {
|
|
|
534
534
|
this.debugLog('is listening webhook.')
|
|
535
535
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: curtainWebhookContext | curtain3WebhookContext) => {
|
|
536
536
|
try {
|
|
537
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
538
537
|
this.webhookContext = context
|
|
539
|
-
|
|
540
|
-
|
|
538
|
+
if (context !== undefined || context !== null) {
|
|
539
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
540
|
+
await this.parseStatusWebhook()
|
|
541
|
+
await this.updateHomeKitCharacteristics()
|
|
542
|
+
} else {
|
|
543
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
544
|
+
}
|
|
541
545
|
} catch (e: any) {
|
|
542
546
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
543
547
|
}
|
|
@@ -557,10 +561,15 @@ export class Curtain extends deviceBase {
|
|
|
557
561
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
558
562
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: curtainServiceData | curtain3ServiceData) => {
|
|
559
563
|
try {
|
|
560
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
561
564
|
this.serviceData = context
|
|
562
|
-
|
|
563
|
-
|
|
565
|
+
if (context !== undefined || context !== null) {
|
|
566
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
567
|
+
await this.BLEparseStatus()
|
|
568
|
+
await this.updateHomeKitCharacteristics()
|
|
569
|
+
} else {
|
|
570
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
571
|
+
await this.BLERefreshConnection(context)
|
|
572
|
+
}
|
|
564
573
|
} catch (e: any) {
|
|
565
574
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
566
575
|
}
|
package/src/device/fan.ts
CHANGED
|
@@ -356,10 +356,15 @@ export class Fan extends deviceBase {
|
|
|
356
356
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
357
357
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: batteryCirculatorFanServiceData) => {
|
|
358
358
|
try {
|
|
359
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
360
359
|
this.serviceData = context
|
|
361
|
-
|
|
362
|
-
|
|
360
|
+
if (context !== undefined || context !== null) {
|
|
361
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
362
|
+
await this.BLEparseStatus()
|
|
363
|
+
await this.updateHomeKitCharacteristics()
|
|
364
|
+
} else {
|
|
365
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
366
|
+
await this.BLERefreshConnection(context)
|
|
367
|
+
}
|
|
363
368
|
} catch (e: any) {
|
|
364
369
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
365
370
|
}
|
|
@@ -397,10 +402,14 @@ export class Fan extends deviceBase {
|
|
|
397
402
|
this.debugLog('is listening webhook.')
|
|
398
403
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: batteryCirculatorFanWebhookContext) => {
|
|
399
404
|
try {
|
|
400
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
401
405
|
this.webhookContext = context
|
|
402
|
-
|
|
403
|
-
|
|
406
|
+
if (context !== undefined || context !== null) {
|
|
407
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
408
|
+
await this.parseStatusWebhook()
|
|
409
|
+
await this.updateHomeKitCharacteristics()
|
|
410
|
+
} else {
|
|
411
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
412
|
+
}
|
|
404
413
|
} catch (e: any) {
|
|
405
414
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
406
415
|
}
|
package/src/device/hub.ts
CHANGED
|
@@ -323,10 +323,15 @@ export class Hub extends deviceBase {
|
|
|
323
323
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
324
324
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: hub2ServiceData) => {
|
|
325
325
|
try {
|
|
326
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
327
326
|
this.serviceData = context
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
if (context !== undefined || context !== null) {
|
|
328
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
329
|
+
await this.BLEparseStatus()
|
|
330
|
+
await this.updateHomeKitCharacteristics()
|
|
331
|
+
} else {
|
|
332
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
333
|
+
await this.BLERefreshConnection(context)
|
|
334
|
+
}
|
|
330
335
|
} catch (e: any) {
|
|
331
336
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
332
337
|
}
|
|
@@ -364,10 +369,14 @@ export class Hub extends deviceBase {
|
|
|
364
369
|
this.debugLog('is listening webhook.')
|
|
365
370
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: hub2WebhookContext) => {
|
|
366
371
|
try {
|
|
367
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
368
372
|
this.webhookContext = context
|
|
369
|
-
|
|
370
|
-
|
|
373
|
+
if (context !== undefined || context !== null) {
|
|
374
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
375
|
+
await this.parseStatusWebhook()
|
|
376
|
+
await this.updateHomeKitCharacteristics()
|
|
377
|
+
} else {
|
|
378
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
379
|
+
}
|
|
371
380
|
} catch (e: any) {
|
|
372
381
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
373
382
|
}
|
package/src/device/humidifier.ts
CHANGED
|
@@ -353,10 +353,15 @@ export class Humidifier extends deviceBase {
|
|
|
353
353
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
354
354
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: humidifierServiceData | humidifier2ServiceData) => {
|
|
355
355
|
try {
|
|
356
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
357
356
|
this.serviceData = context
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
if (context !== undefined || context !== null) {
|
|
358
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
359
|
+
await this.BLEparseStatus()
|
|
360
|
+
await this.updateHomeKitCharacteristics()
|
|
361
|
+
} else {
|
|
362
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
363
|
+
await this.BLERefreshConnection(context)
|
|
364
|
+
}
|
|
360
365
|
} catch (e: any) {
|
|
361
366
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
362
367
|
}
|
|
@@ -394,10 +399,14 @@ export class Humidifier extends deviceBase {
|
|
|
394
399
|
this.debugLog('is listening webhook.')
|
|
395
400
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: humidifierWebhookContext | humidifier2WebhookContext) => {
|
|
396
401
|
try {
|
|
397
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
398
402
|
this.webhookContext = context
|
|
399
|
-
|
|
400
|
-
|
|
403
|
+
if (context !== undefined || context !== null) {
|
|
404
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
405
|
+
await this.parseStatusWebhook()
|
|
406
|
+
await this.updateHomeKitCharacteristics()
|
|
407
|
+
} else {
|
|
408
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
409
|
+
}
|
|
401
410
|
} catch (e: any) {
|
|
402
411
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
403
412
|
}
|
package/src/device/iosensor.ts
CHANGED
|
@@ -317,10 +317,15 @@ export class IOSensor extends deviceBase {
|
|
|
317
317
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
318
318
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: outdoorMeterServiceData) => {
|
|
319
319
|
try {
|
|
320
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
321
320
|
this.serviceData = context
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
if (context !== undefined || context !== null) {
|
|
322
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
323
|
+
await this.BLEparseStatus()
|
|
324
|
+
await this.updateHomeKitCharacteristics()
|
|
325
|
+
} else {
|
|
326
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
327
|
+
await this.BLERefreshConnection(context)
|
|
328
|
+
}
|
|
324
329
|
} catch (e: any) {
|
|
325
330
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
326
331
|
}
|
|
@@ -358,10 +363,14 @@ export class IOSensor extends deviceBase {
|
|
|
358
363
|
this.debugLog('is listening webhook.')
|
|
359
364
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: outdoorMeterWebhookContext) => {
|
|
360
365
|
try {
|
|
361
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
362
366
|
this.webhookContext = context
|
|
363
|
-
|
|
364
|
-
|
|
367
|
+
if (context !== undefined || context !== null) {
|
|
368
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
369
|
+
await this.parseStatusWebhook()
|
|
370
|
+
await this.updateHomeKitCharacteristics()
|
|
371
|
+
} else {
|
|
372
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
373
|
+
}
|
|
365
374
|
} catch (e: any) {
|
|
366
375
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
367
376
|
}
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -208,16 +208,18 @@ export class StripLight extends deviceBase {
|
|
|
208
208
|
|
|
209
209
|
// Color, Hue & Brightness
|
|
210
210
|
this.debugLog(`red: ${this.serviceData.red}, green: ${this.serviceData.green}, blue: ${this.serviceData.blue}`)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
211
|
+
if (this.serviceData.red !== undefined && this.serviceData.green !== undefined && this.serviceData.blue !== undefined) {
|
|
212
|
+
const [hue, saturation] = rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue)
|
|
213
|
+
this.debugLog(`hs: ${JSON.stringify(rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue))}`)
|
|
214
|
+
// Hue
|
|
215
|
+
this.LightBulb.Hue = hue
|
|
216
|
+
this.debugLog(`Hue: ${this.LightBulb.Hue}`)
|
|
217
|
+
// Saturation
|
|
218
|
+
this.LightBulb.Saturation = saturation
|
|
219
|
+
this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
|
|
220
|
+
} else {
|
|
221
|
+
this.errorLog(`Invalid color data: red=${this.serviceData.red}, green=${this.serviceData.green}, blue=${this.serviceData.blue}`)
|
|
222
|
+
}
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
async openAPIparseStatus(): Promise<void> {
|
|
@@ -233,19 +235,23 @@ export class StripLight extends deviceBase {
|
|
|
233
235
|
this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
|
|
234
236
|
|
|
235
237
|
// Color, Hue & Brightness
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
238
|
+
if (typeof this.deviceStatus.color === 'string') {
|
|
239
|
+
this.debugLog(`color: ${JSON.stringify(this.deviceStatus.color)}`)
|
|
240
|
+
const [red, green, blue] = this.deviceStatus.color.split(':')
|
|
241
|
+
this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`)
|
|
242
|
+
const [hue, saturation] = rgb2hs(red, green, blue)
|
|
243
|
+
this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`)
|
|
244
|
+
|
|
245
|
+
// Hue
|
|
246
|
+
this.LightBulb.Hue = hue
|
|
247
|
+
this.debugLog(`Hue: ${this.LightBulb.Hue}`)
|
|
248
|
+
|
|
249
|
+
// Saturation
|
|
250
|
+
this.LightBulb.Saturation = saturation
|
|
251
|
+
this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
|
|
252
|
+
} else {
|
|
253
|
+
this.errorLog(`Invalid color format: ${JSON.stringify(this.deviceStatus.color)}`)
|
|
254
|
+
}
|
|
249
255
|
|
|
250
256
|
// Firmware Version
|
|
251
257
|
if (this.deviceStatus.version) {
|
|
@@ -276,19 +282,23 @@ export class StripLight extends deviceBase {
|
|
|
276
282
|
this.debugLog(`Brightness: ${this.LightBulb.Brightness}`)
|
|
277
283
|
|
|
278
284
|
// Color, Hue & Brightness
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
285
|
+
if (typeof this.webhookContext.color === 'string') {
|
|
286
|
+
this.debugLog(`color: ${JSON.stringify(this.webhookContext.color)}`)
|
|
287
|
+
const [red, green, blue] = this.webhookContext.color.split(':')
|
|
288
|
+
this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`)
|
|
289
|
+
const [hue, saturation] = rgb2hs(red, green, blue)
|
|
290
|
+
this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`)
|
|
291
|
+
|
|
292
|
+
// Hue
|
|
293
|
+
this.LightBulb.Hue = hue
|
|
294
|
+
this.debugLog(`Hue: ${this.LightBulb.Hue}`)
|
|
295
|
+
|
|
296
|
+
// Saturation
|
|
297
|
+
this.LightBulb.Saturation = saturation
|
|
298
|
+
this.debugLog(`Saturation: ${this.LightBulb.Saturation}`)
|
|
299
|
+
} else {
|
|
300
|
+
this.errorLog(`Invalid color format: ${JSON.stringify(this.webhookContext.color)}`)
|
|
301
|
+
}
|
|
292
302
|
}
|
|
293
303
|
|
|
294
304
|
/**
|
|
@@ -345,10 +355,15 @@ export class StripLight extends deviceBase {
|
|
|
345
355
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
346
356
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: stripLightServiceData) => {
|
|
347
357
|
try {
|
|
348
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
349
358
|
this.serviceData = context
|
|
350
|
-
|
|
351
|
-
|
|
359
|
+
if (context !== undefined || context !== null) {
|
|
360
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
361
|
+
await this.BLEparseStatus()
|
|
362
|
+
await this.updateHomeKitCharacteristics()
|
|
363
|
+
} else {
|
|
364
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
365
|
+
await this.BLERefreshConnection(context)
|
|
366
|
+
}
|
|
352
367
|
} catch (e: any) {
|
|
353
368
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
354
369
|
}
|
|
@@ -386,10 +401,14 @@ export class StripLight extends deviceBase {
|
|
|
386
401
|
this.debugLog('is listening webhook.')
|
|
387
402
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: stripLightWebhookContext) => {
|
|
388
403
|
try {
|
|
389
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
390
404
|
this.webhookContext = context
|
|
391
|
-
|
|
392
|
-
|
|
405
|
+
if (context !== undefined || context !== null) {
|
|
406
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
407
|
+
await this.parseStatusWebhook()
|
|
408
|
+
await this.updateHomeKitCharacteristics()
|
|
409
|
+
} else {
|
|
410
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
411
|
+
}
|
|
393
412
|
} catch (e: any) {
|
|
394
413
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
395
414
|
}
|
package/src/device/lock.ts
CHANGED
|
@@ -359,10 +359,15 @@ export class Lock extends deviceBase {
|
|
|
359
359
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
360
360
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: lockServiceData | lockProServiceData) => {
|
|
361
361
|
try {
|
|
362
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
363
362
|
this.serviceData = context
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
if (context !== undefined || context !== null) {
|
|
364
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
365
|
+
await this.BLEparseStatus()
|
|
366
|
+
await this.updateHomeKitCharacteristics()
|
|
367
|
+
} else {
|
|
368
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
369
|
+
await this.BLERefreshConnection(context)
|
|
370
|
+
}
|
|
366
371
|
} catch (e: any) {
|
|
367
372
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
368
373
|
}
|
|
@@ -400,10 +405,14 @@ export class Lock extends deviceBase {
|
|
|
400
405
|
this.debugLog('is listening webhook.')
|
|
401
406
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: lockWebhookContext | lockProWebhookContext) => {
|
|
402
407
|
try {
|
|
403
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
404
408
|
this.webhookContext = context
|
|
405
|
-
|
|
406
|
-
|
|
409
|
+
if (context !== undefined || context !== null) {
|
|
410
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
411
|
+
await this.parseStatusWebhook()
|
|
412
|
+
await this.updateHomeKitCharacteristics()
|
|
413
|
+
} else {
|
|
414
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
415
|
+
}
|
|
407
416
|
} catch (e: any) {
|
|
408
417
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
409
418
|
}
|
package/src/device/meter.ts
CHANGED
|
@@ -314,10 +314,15 @@ export class Meter extends deviceBase {
|
|
|
314
314
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
315
315
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: meterServiceData) => {
|
|
316
316
|
try {
|
|
317
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
318
317
|
this.serviceData = context
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
if (context !== undefined || context !== null) {
|
|
319
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
320
|
+
await this.BLEparseStatus()
|
|
321
|
+
await this.updateHomeKitCharacteristics()
|
|
322
|
+
} else {
|
|
323
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
324
|
+
await this.BLERefreshConnection(context)
|
|
325
|
+
}
|
|
321
326
|
} catch (e: any) {
|
|
322
327
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
323
328
|
}
|
|
@@ -355,10 +360,14 @@ export class Meter extends deviceBase {
|
|
|
355
360
|
this.debugLog('is listening webhook.')
|
|
356
361
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: meterWebhookContext) => {
|
|
357
362
|
try {
|
|
358
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
359
363
|
this.webhookContext = context
|
|
360
|
-
|
|
361
|
-
|
|
364
|
+
if (context !== undefined || context !== null) {
|
|
365
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
366
|
+
await this.parseStatusWebhook()
|
|
367
|
+
await this.updateHomeKitCharacteristics()
|
|
368
|
+
} else {
|
|
369
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
370
|
+
}
|
|
362
371
|
} catch (e: any) {
|
|
363
372
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
364
373
|
}
|
package/src/device/meterplus.ts
CHANGED
|
@@ -318,10 +318,15 @@ export class MeterPlus extends deviceBase {
|
|
|
318
318
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
319
319
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: meterPlusServiceData) => {
|
|
320
320
|
try {
|
|
321
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
322
321
|
this.serviceData = context
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
if (context !== undefined || context !== null) {
|
|
323
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
324
|
+
await this.BLEparseStatus()
|
|
325
|
+
await this.updateHomeKitCharacteristics()
|
|
326
|
+
} else {
|
|
327
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
328
|
+
await this.BLERefreshConnection(context)
|
|
329
|
+
}
|
|
325
330
|
} catch (e: any) {
|
|
326
331
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
327
332
|
}
|
|
@@ -359,10 +364,14 @@ export class MeterPlus extends deviceBase {
|
|
|
359
364
|
this.debugLog('is listening webhook.')
|
|
360
365
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: meterPlusWebhookContext) => {
|
|
361
366
|
try {
|
|
362
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
363
367
|
this.webhookContext = context
|
|
364
|
-
|
|
365
|
-
|
|
368
|
+
if (context !== undefined || context !== null) {
|
|
369
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
370
|
+
await this.parseStatusWebhook()
|
|
371
|
+
await this.updateHomeKitCharacteristics()
|
|
372
|
+
} else {
|
|
373
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
374
|
+
}
|
|
366
375
|
} catch (e: any) {
|
|
367
376
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
368
377
|
}
|