homebridge-deconz 1.2.7 → 1.2.9

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.
@@ -410,15 +410,24 @@ class Resource {
410
410
  case 'LIDL Livarno Lux':
411
411
  this.capabilities.ctMax = 454 // 2200 K
412
412
  this.capabilities.ctMin = 153 // 6500 K
413
- if (this.model === 'HG06467') { // Xmas light strip
414
- this.capabilities.colorLoop = false
415
- this.capabilities.hs = true
416
- this.capabilities.effects = [
417
- 'Steady', 'Snow', 'Rainbow', 'Snake',
418
- 'Twinkle', 'Fireworks', 'Flag', 'Waves',
419
- 'Updown', 'Vintage', 'Fading', 'Collide',
420
- 'Strobe', 'Sparkles', 'Carnival', 'Glow'
421
- ]
413
+ break
414
+ case '_TZE200_s8gkrkxk': // LIDL Xmas light strip
415
+ if (this.model === 'TS0601') { // Xmas light strip
416
+ this.manufacturer = 'LIDL Livarno Lux'
417
+ this.model = 'HG06467'
418
+ this.body.capabilities.bri = {
419
+ no_bri_inc: true
420
+ }
421
+ this.body.capabilities.color = {
422
+ effects: [
423
+ 'steady', 'snow', 'rainbow', 'snake',
424
+ 'twinkle', 'fireworks', 'flag', 'waves',
425
+ 'updown', 'vintage', 'fading', 'collide',
426
+ 'strobe', 'sparkles', 'carnival', 'glow'
427
+ ],
428
+ effect_colors: 6,
429
+ effect_speed: true
430
+ }
422
431
  }
423
432
  break
424
433
  default:
@@ -11,7 +11,7 @@ import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
11
11
  import { DeconzService } from '../DeconzService/index.js'
12
12
  import '../DeconzService/LightsResource.js'
13
13
 
14
- const { defaultGamut, xyToHsv, hsvToXy, ctToXy } = Colour
14
+ const { defaultGamut, xyToHsv, hsvToXy, ctToXy, hsvToRgb } = Colour
15
15
 
16
16
  class Light extends DeconzService.LightsResource {
17
17
  constructor (accessory, resource, params = {}) {
@@ -26,7 +26,7 @@ class Light extends DeconzService.LightsResource {
26
26
  this.resource.body[this.stateKey].hue !== undefined,
27
27
  xy: this.resource.body[this.stateKey].xy !== undefined
28
28
  }
29
- if (this.resource.body.action?.effect !== undefined) {
29
+ if (this.resource.body?.action?.effect !== undefined) {
30
30
  this.capabilities.colorLoop = true
31
31
  } else if (this.resource.body?.capabilities?.color?.effects != null) {
32
32
  const effects = this.resource.body.capabilities.color.effects
@@ -78,16 +78,18 @@ class Light extends DeconzService.LightsResource {
78
78
  }
79
79
  })
80
80
 
81
- this.addCharacteristicDelegate({
82
- key: 'brightnessChange',
83
- Characteristic: this.Characteristics.my.BrightnessChange,
84
- value: 0
85
- }).on('didSet', async (value) => {
86
- this.putState({ bri_inc: Math.round(value * 254.0 / 100.0) })
87
- await timeout(this.platform.config.waitTimeReset)
81
+ if (!this.resource.body?.capabilities?.bri?.no_bri_inc) {
82
+ this.addCharacteristicDelegate({
83
+ key: 'brightnessChange',
84
+ Characteristic: this.Characteristics.my.BrightnessChange,
85
+ value: 0
86
+ }).on('didSet', async (value) => {
87
+ this.putState({ bri_inc: Math.round(value * 254.0 / 100.0) })
88
+ await timeout(this.platform.config.waitTimeReset)
89
+ this.values.brightnessChange = 0
90
+ })
88
91
  this.values.brightnessChange = 0
89
- })
90
- this.values.brightnessChange = 0
92
+ }
91
93
  }
92
94
 
93
95
  if (this.capabilities.ct || this.capabilities.xy || this.capabilities.hs) {
@@ -338,8 +340,8 @@ class Light extends DeconzService.LightsResource {
338
340
  }).on('didSet', (value, fromHomeKit) => {
339
341
  if (fromHomeKit) {
340
342
  this.checkAdaptiveLighting()
341
- this.putState({ effect: value ? effect : 'none' })
342
343
  this.values.effectString = value ? effect : 'none'
344
+ this.putEffect()
343
345
  }
344
346
  })
345
347
  effectString.on('didSet', (value) => {
@@ -347,44 +349,95 @@ class Light extends DeconzService.LightsResource {
347
349
  })
348
350
  }
349
351
  }
350
- // if (this.capabilities.effectSpeed) {
351
- // this.addCharacteristicDelegate({
352
- // key: 'effectSpeed',
353
- // Characteristic: this.Characteristics.my.EffectSpeed,
354
- // value: 50
355
- // }).on('didSet', (value) => {
356
- // this.setEffectSpeed(value)
357
- // })
358
- // this.hk.effectColours = []
359
- // for (let i = 0; i <= 5; i++) {
360
- // const service = new this.Service.Lightbulb(
361
- // this.name + ' Effect Color ' + (i + 1), this.subtype + '-C' + i
362
- // )
363
- // service.addCharacteristicDelegate({
364
- // key: 'on',
365
- // Characteristic: this.Characteristics.hap.On,
366
- // value: true
367
- // }).on('didSet', (value) => {
368
- // this.setEffectOn(i, value)
369
- // })
370
- // service.addCharacteristicDelegate({
371
- // key: 'hue',
372
- // Characteristic: this.Characteristics.hap.Hue,
373
- // value: i * 60
374
- // }).on('didSet', (value) => {
375
- // this.setEffectHue(i, value)
376
- // })
377
- // service.addCharacteristicDelegate({
378
- // key: 'saturation',
379
- // Characteristic: this.Characteristics.hap.Saturation,
380
- // value: 100
381
- // }).on('didSet', (value) => {
382
- // this.setEffectSat(i, value)
383
- // })
384
- // this.effectServices.push(service)
385
- // }
386
- // }
387
- // this.checkEffect(this.obj.state.effect)
352
+ if (this.resource.body.capabilities.color.effect_speed) {
353
+ this.addCharacteristicDelegate({
354
+ key: 'effectSpeed',
355
+ Characteristic: this.Characteristics.my.EffectSpeed,
356
+ unit: '%',
357
+ value: 50
358
+ }).on('didSet', (value, fromHomeKit) => {
359
+ if (fromHomeKit) {
360
+ this.checkAdaptiveLighting()
361
+ this.putEffect()
362
+ }
363
+ })
364
+ }
365
+ if (this.resource.body.capabilities.color.effect_colors != null) {
366
+ this.effectServices = []
367
+ for (let i = 0; i < this.resource.body.capabilities.color.effect_colors; i++) {
368
+ const service = new ServiceDelegate(this.accessory, {
369
+ name: this.name + ' Effect Color ' + (i + 1),
370
+ Service: this.Services.hap.Lightbulb,
371
+ subtype: this.subtype + '-C' + i
372
+ })
373
+ service.addCharacteristicDelegate({
374
+ key: 'on',
375
+ Characteristic: this.Characteristics.hap.On,
376
+ value: true
377
+ }).on('didSet', (value, fromHomeKit) => {
378
+ if (fromHomeKit) {
379
+ if (value) {
380
+ for (let j = 0; j < i; j++) {
381
+ this.effectServices[j].values.on = true
382
+ }
383
+ } else {
384
+ for (let j = i + 1; j < this.resource.body.capabilities.color.effect_colors; j++) {
385
+ this.effectServices[j].values.on = false
386
+ }
387
+ }
388
+ this.checkAdaptiveLighting()
389
+ this.putEffect()
390
+ }
391
+ })
392
+ service.addCharacteristicDelegate({
393
+ key: 'hue',
394
+ Characteristic: this.Characteristics.hap.Hue,
395
+ unit: '°',
396
+ value: i * 60
397
+ }).on('didSet', (value, fromHomeKit) => {
398
+ if (fromHomeKit) {
399
+ this.checkAdaptiveLighting()
400
+ this.putEffect()
401
+ }
402
+ })
403
+ service.addCharacteristicDelegate({
404
+ key: 'saturation',
405
+ Characteristic: this.Characteristics.hap.Saturation,
406
+ unit: '%',
407
+ value: 100
408
+ }).on('didSet', (value, fromHomeKit) => {
409
+ if (fromHomeKit) {
410
+ this.checkAdaptiveLighting()
411
+ this.putEffect()
412
+ }
413
+ })
414
+ this.effectServices.push(service)
415
+ }
416
+ }
417
+ }
418
+
419
+ putEffect () {
420
+ this.putState({ effect: this.values.effectString })
421
+ if (this.values.effectString === 'none') {
422
+ return
423
+ }
424
+ if (this.resource.body.capabilities.color.effect_speed) {
425
+ this.putState({ effectSpeed: this.values.effectSpeed })
426
+ }
427
+ if (this.resource.body.capabilities.color.effect_colors != null) {
428
+ const effectColours = []
429
+ for (let i = 0; i < this.resource.body.capabilities.color.effect_colors; i++) {
430
+ const service = this.effectServices[i]
431
+ if (!service.values.on) {
432
+ break
433
+ }
434
+ const { r, g, b } = hsvToRgb(service.values.hue, service.values.saturation)
435
+ effectColours.push([Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)])
436
+ }
437
+ if (effectColours.length > 0) {
438
+ this.putState({ effectColours })
439
+ }
440
+ }
388
441
  }
389
442
 
390
443
  updateState (state, rpath, stateKey = 'state') {
@@ -426,7 +479,7 @@ class Light extends DeconzService.LightsResource {
426
479
  break
427
480
  case 'hue':
428
481
  if (!this.capabilities.xy) {
429
- this.values.hue = value
482
+ this.values.hue = Math.round(value * 360.0 / 65535.0)
430
483
  }
431
484
  break
432
485
  case 'on':
@@ -444,7 +497,7 @@ class Light extends DeconzService.LightsResource {
444
497
  break
445
498
  case 'sat':
446
499
  if (!this.capabilities.xy) {
447
- this.values.hue = value
500
+ this.values.saturation = Math.round(value / 2.54)
448
501
  }
449
502
  break
450
503
  case 'xy':
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "ebaauw"
8
8
  ],
9
9
  "license": "Apache-2.0",
10
- "version": "1.2.7",
10
+ "version": "1.2.9",
11
11
  "keywords": [
12
12
  "homebridge-plugin",
13
13
  "homekit",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "hb-deconz-tools": "~2.0.19",
35
- "homebridge-lib": "~7.1.13"
35
+ "homebridge-lib": "~7.2.0"
36
36
  },
37
37
  "scripts": {
38
38
  "prepare": "standard && rm -rf out && jsdoc -c jsdoc.json",