homebridge-deconz 0.0.27 → 0.1.0

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 (38) hide show
  1. package/config.schema.json +0 -7
  2. package/lib/Deconz/Resource.js +27 -4
  3. package/lib/DeconzAccessory/AirPurifier.js +0 -2
  4. package/lib/DeconzAccessory/Gateway.js +298 -149
  5. package/lib/DeconzAccessory/Light.js +27 -37
  6. package/lib/DeconzAccessory/Sensor.js +89 -1
  7. package/lib/DeconzAccessory/Thermostat.js +1 -3
  8. package/lib/DeconzAccessory/WarningDevice.js +0 -8
  9. package/lib/DeconzAccessory/WindowCovering.js +0 -2
  10. package/lib/DeconzAccessory/index.js +123 -13
  11. package/lib/DeconzPlatform.js +12 -20
  12. package/lib/DeconzService/AirPressure.js +1 -1
  13. package/lib/DeconzService/AirPurifier.js +2 -2
  14. package/lib/DeconzService/AirQuality.js +1 -1
  15. package/lib/DeconzService/Alarm.js +1 -1
  16. package/lib/DeconzService/Battery.js +19 -9
  17. package/lib/DeconzService/Button.js +1 -0
  18. package/lib/DeconzService/CarbonMonoxide.js +1 -1
  19. package/lib/DeconzService/Consumption.js +3 -1
  20. package/lib/DeconzService/Contact.js +1 -25
  21. package/lib/DeconzService/Daylight.js +22 -19
  22. package/lib/DeconzService/Flag.js +1 -1
  23. package/lib/DeconzService/Gateway.js +48 -0
  24. package/lib/DeconzService/Humidity.js +1 -1
  25. package/lib/DeconzService/Leak.js +1 -1
  26. package/lib/DeconzService/Light.js +111 -86
  27. package/lib/DeconzService/LightLevel.js +3 -3
  28. package/lib/DeconzService/Motion.js +3 -9
  29. package/lib/DeconzService/Power.js +2 -1
  30. package/lib/DeconzService/Status.js +1 -1
  31. package/lib/DeconzService/WindowCovering.js +14 -4
  32. package/lib/DeconzService/index.js +11 -12
  33. package/package.json +6 -6
  34. package/lib/DeconzAccessory/Contact.js +0 -53
  35. package/lib/DeconzAccessory/Motion.js +0 -53
  36. package/lib/DeconzAccessory/Temperature.js +0 -61
  37. package/lib/DeconzService/DeviceSettings.js +0 -65
  38. package/lib/DeconzService/GatewaySettings.js +0 -176
@@ -8,7 +8,7 @@
8
8
  const DeconzService = require('../DeconzService')
9
9
  const Deconz = require('../Deconz')
10
10
 
11
- const { dateToString, lightLevelToLux } = Deconz.ApiClient
11
+ const { dateToString } = Deconz.ApiClient
12
12
 
13
13
  const daylightEvents = {
14
14
  100: { name: 'Solar Midnight', period: 'Night' },
@@ -27,15 +27,22 @@ const daylightEvents = {
27
27
  230: { name: 'Astronomical Dusk', period: 'Night' }
28
28
  }
29
29
 
30
+ // Eve uses the following thresholds:
31
+ const VERY_BRIGHT = 1000
32
+ const BRIGHT = 300
33
+ const NORMAL = 100
34
+ const DIM = 10
35
+ const DARK = 0
36
+
30
37
  const daylightPeriods = {
31
- Night: { lightlevel: 0, daylight: false, dark: true },
32
- 'Astronomical Twilight': { lightlevel: 100, daylight: false, dark: true },
33
- 'Nautical Twilight': { lightlevel: 1000, daylight: false, dark: true },
34
- Twilight: { lightlevel: 10000, daylight: false, dark: false },
35
- Sunrise: { lightlevel: 15000, daylight: true, dark: false },
36
- Sunset: { lightlevel: 20000, daylight: true, dark: false },
37
- 'Golden Hour': { lightlevel: 40000, daylight: true, dark: false },
38
- Day: { lightlevel: 65535, daylight: true, dark: false }
38
+ Night: { lightLevel: DARK, dark: true, daylight: false },
39
+ 'Astronomical Twilight': { lightLevel: DIM, dark: true, daylight: false },
40
+ 'Nautical Twilight': { lightLevel: DIM, dark: true, daylight: false },
41
+ Twilight: { lightLevel: NORMAL, dark: false, daylight: false },
42
+ Sunrise: { lightLevel: BRIGHT, dark: false, daylight: true },
43
+ Sunset: { lightLevel: BRIGHT, dark: false, daylight: true },
44
+ 'Golden Hour': { lightLevel: BRIGHT, dark: false, daylight: true },
45
+ Day: { lightLevel: VERY_BRIGHT, dark: false, daylight: true }
39
46
  }
40
47
 
41
48
  /**
@@ -47,7 +54,7 @@ class Daylight extends DeconzService.SensorsResource {
47
54
  super(accessory, resource, params)
48
55
 
49
56
  this.addCharacteristicDelegate({
50
- key: 'lightlevel',
57
+ key: 'lightLevel',
51
58
  Characteristic: this.Characteristics.hap.CurrentAmbientLightLevel,
52
59
  unit: ' lux'
53
60
  })
@@ -101,7 +108,7 @@ class Daylight extends DeconzService.SensorsResource {
101
108
  this.warn('%s: %s not configured', resource.rpath, resource.body.type)
102
109
  }
103
110
 
104
- this.update(resource.body)
111
+ this.update(resource.body, resource.rpath)
105
112
  }
106
113
 
107
114
  updateState (state) {
@@ -110,14 +117,10 @@ class Daylight extends DeconzService.SensorsResource {
110
117
  const { name, period } = daylightEvents[state.status]
111
118
  this.values.lastEvent = name
112
119
  this.values.period = period
113
- const { lightlevel } = daylightPeriods[period]
114
- this.values.lightlevel = lightLevelToLux(lightlevel)
115
- }
116
- if (state.dark != null) {
117
- this.values.dark = state.dark
118
- }
119
- if (state.daylight != null) {
120
- this.values.daylight = state.daylight
120
+ const { lightLevel, dark, daylight } = daylightPeriods[period]
121
+ this.values.lightLevel = lightLevel
122
+ this.values.dark = dark
123
+ this.values.daylight = daylight
121
124
  }
122
125
  if (state.sunrise != null) {
123
126
  this.values.sunrise = dateToString(state.sunrise)
@@ -38,7 +38,7 @@ class Flag extends DeconzService.SensorsResource {
38
38
 
39
39
  this.addCharacteristicDelegates()
40
40
 
41
- this.update(resource.body)
41
+ this.update(resource.body, resource.rpath)
42
42
  }
43
43
 
44
44
  updateState (state) {
@@ -0,0 +1,48 @@
1
+ // homebridge-deconz/lib/DeconzService/Gateway.js
2
+ // Copyright © 2022 Erik Baauw. All rights reserved.
3
+ //
4
+ // Homebridge plugin for deCONZ.
5
+
6
+ 'use strict'
7
+
8
+ const homebridgeLib = require('homebridge-lib')
9
+
10
+ /** Delegate class for a DeconzGateway service.
11
+ * @extends ServiceDelegate
12
+ * @memberof DeconzService
13
+ */
14
+ class Gateway extends homebridgeLib.ServiceDelegate {
15
+ constructor (gateway, params = {}) {
16
+ params.Service = gateway.Services.my.DeconzGateway
17
+ params.exposeConfiguredName = true
18
+ super(gateway, params)
19
+ this.gateway = gateway
20
+
21
+ this.addCharacteristicDelegate({
22
+ key: 'lastUpdated',
23
+ Characteristic: this.Characteristics.my.LastUpdated,
24
+ silent: true
25
+ })
26
+
27
+ this.addCharacteristicDelegate({
28
+ key: 'statusActive',
29
+ Characteristic: this.Characteristics.hap.StatusActive,
30
+ value: true,
31
+ silent: true
32
+ })
33
+
34
+ this.addCharacteristicDelegate({
35
+ key: 'transitionTime',
36
+ Characteristic: this.Characteristics.my.TransitionTime,
37
+ value: this.gateway.defaultTransitionTime
38
+ })
39
+ this.values.transitionTime = this.gateway.defaultTransitionTime
40
+ }
41
+
42
+ update (config) {
43
+ this.values.expose = true
44
+ this.values.lastUpdated = new Date().toString().slice(0, 24)
45
+ }
46
+ }
47
+
48
+ module.exports = Gateway
@@ -23,7 +23,7 @@ class Humidity extends DeconzService.SensorsResource {
23
23
 
24
24
  this.addCharacteristicDelegates()
25
25
 
26
- this.update(resource.body)
26
+ this.update(resource.body, resource.rpath)
27
27
  }
28
28
 
29
29
  updateState (state) {
@@ -22,7 +22,7 @@ class Leak extends DeconzService.SensorsResource {
22
22
 
23
23
  super.addCharacteristicDelegates()
24
24
 
25
- this.update(resource.body)
25
+ this.update(resource.body, resource.rpath)
26
26
  }
27
27
 
28
28
  updateState (state) {
@@ -8,6 +8,7 @@
8
8
  const homebridgeLib = require('homebridge-lib')
9
9
  const DeconzService = require('../DeconzService')
10
10
 
11
+ const { History } = homebridgeLib.ServiceDelegate
11
12
  const { timeout } = homebridgeLib
12
13
  const { xyToHsv, hsvToXy, ctToXy } = homebridgeLib.Colour
13
14
 
@@ -207,6 +208,7 @@ class Light extends DeconzService.LightsResource {
207
208
  .CharacteristicValueTransitionControl,
208
209
  silent: true,
209
210
  getter: async () => {
211
+ this.initAdaptiveLighting()
210
212
  return this.adaptiveLighting.generateControl()
211
213
  },
212
214
  setter: async (value) => {
@@ -238,95 +240,24 @@ class Light extends DeconzService.LightsResource {
238
240
  }
239
241
 
240
242
  if (this.resource.rtype === 'groups') {
241
- this.sceneServices = {}
242
- this.updateScenes(this.resource.body.scenes)
243
+ this.addCharacteristicDelegate({
244
+ key: 'exposeScenes',
245
+ value: true
246
+ })
247
+ if (this.values.exposeScenes) {
248
+ this.sceneServices = {}
249
+ this.updateScenes(this.resource.body.scenes)
250
+ }
243
251
  }
244
252
 
245
253
  if (this.capabilities.effects != null) {
246
- this.effectServices = {}
247
254
  this.addCharacteristicDelegate({
248
- key: 'effect',
249
- value: -1,
250
- silent: true
251
- }).on('didSet', (value) => {
252
- for (const i in this.capabilities.effects) {
253
- this.effectServices[i].values.on = value === i
254
- }
255
+ key: 'exposeEffects',
256
+ value: true
255
257
  })
256
- for (const id in this.capabilities.effects) {
257
- const effect = this.capabilities.effects[id]
258
- const service = new homebridgeLib.ServiceDelegate(accessory, {
259
- name: this.resource.body.name + ' ' + effect,
260
- Service: this.Services.hap.Lightbulb,
261
- subtype: this.subtype + '-E' + id,
262
- exposeConfiguredName: true
263
- })
264
- service.addCharacteristicDelegate({
265
- key: 'on',
266
- Characteristic: this.Characteristics.hap.On
267
- }).on('didSet', (value, fromHomeKit) => {
268
- if (fromHomeKit) {
269
- this.checkAdaptiveLighting()
270
- this.values.effect = value ? id : -1
271
- const newEffect = value
272
- ? effect.toLowerCase()
273
- : 'none'
274
- this.put({ effect: newEffect })
275
- }
276
- })
277
- service.addCharacteristicDelegate({
278
- key: 'index',
279
- Characteristic: this.Characteristics.hap.ServiceLabelIndex,
280
- value: Number(id) + 1
281
- })
282
- this.effectServices[id] = service
283
-
284
- this.characteristicDelegate('configuredName')
285
- .on('didSet', (value) => {
286
- for (const id in this.capabilities.effects) {
287
- this.effectServices[id].values.configuredName = value +
288
- ' ' + this.capabilities.effects[id]
289
- }
290
- })
258
+ if (this.values.exposeEffects) {
259
+ this.exposeEffects()
291
260
  }
292
- // if (this.capabilities.effectSpeed) {
293
- // this.addCharacteristicDelegate({
294
- // key: 'effectSpeed',
295
- // Characteristic: this.Characteristics.my.EffectSpeed,
296
- // value: 50
297
- // }).on('didSet', (value) => {
298
- // this.setEffectSpeed(value)
299
- // })
300
- // this.hk.effectColours = []
301
- // for (let i = 0; i <= 5; i++) {
302
- // const service = new this.Service.Lightbulb(
303
- // this.name + ' Effect Color ' + (i + 1), this.subtype + '-C' + i
304
- // )
305
- // service.addCharacteristicDelegate({
306
- // key: 'on',
307
- // Characteristic: this.Characteristics.hap.On,
308
- // value: true
309
- // }).on('didSet', (value) => {
310
- // this.setEffectOn(i, value)
311
- // })
312
- // service.addCharacteristicDelegate({
313
- // key: 'hue',
314
- // Characteristic: this.Characteristics.hap.Hue,
315
- // value: i * 60
316
- // }).on('didSet', (value) => {
317
- // this.setEffectHue(i, value)
318
- // })
319
- // service.addCharacteristicDelegate({
320
- // key: 'saturation',
321
- // Characteristic: this.Characteristics.hap.Saturation,
322
- // value: 100
323
- // }).on('didSet', (value) => {
324
- // this.setEffectSat(i, value)
325
- // })
326
- // this.effectServices.push(service)
327
- // }
328
- // }
329
- // this.checkEffect(this.obj.state.effect)
330
261
  }
331
262
 
332
263
  this.settings = {
@@ -336,6 +267,100 @@ class Light extends DeconzService.LightsResource {
336
267
  }
337
268
  }
338
269
 
270
+ exposeEffects () {
271
+ this.effectServices = {}
272
+ this.addCharacteristicDelegate({
273
+ key: 'effect',
274
+ value: -1,
275
+ silent: true
276
+ }).on('didSet', (value) => {
277
+ for (const i in this.capabilities.effects) {
278
+ this.effectServices[i].values.on = value === i
279
+ }
280
+ })
281
+ for (const id in this.capabilities.effects) {
282
+ const effect = this.capabilities.effects[id]
283
+ const service = new homebridgeLib.ServiceDelegate(this.accessoryDelegate, {
284
+ name: this.resource.body.name + ' ' + effect,
285
+ Service: this.Services.hap.Lightbulb,
286
+ subtype: this.subtype + '-E' + id,
287
+ exposeConfiguredName: true
288
+ })
289
+ service.addCharacteristicDelegate({
290
+ key: 'on',
291
+ Characteristic: this.Characteristics.hap.On
292
+ }).on('didSet', (value, fromHomeKit) => {
293
+ service.values.lastActivation =
294
+ this.accessoryDelegate.historyService.lastActivationValue(History.now())
295
+ if (fromHomeKit) {
296
+ this.checkAdaptiveLighting()
297
+ this.values.effect = value ? id : -1
298
+ const newEffect = value
299
+ ? effect.toLowerCase()
300
+ : 'none'
301
+ this.put({ effect: newEffect })
302
+ }
303
+ })
304
+ service.addCharacteristicDelegate({
305
+ key: 'index',
306
+ Characteristic: this.Characteristics.hap.ServiceLabelIndex,
307
+ value: Number(id) + 1
308
+ })
309
+ service.addCharacteristicDelegate({
310
+ key: 'lastActivation',
311
+ Characteristic: this.Characteristics.eve.LastActivation,
312
+ silent: true
313
+ })
314
+ this.effectServices[id] = service
315
+
316
+ this.characteristicDelegate('configuredName')
317
+ .on('didSet', (value) => {
318
+ for (const id in this.capabilities.effects) {
319
+ this.effectServices[id].values.configuredName = value +
320
+ ' ' + this.capabilities.effects[id]
321
+ }
322
+ })
323
+ }
324
+ // if (this.capabilities.effectSpeed) {
325
+ // this.addCharacteristicDelegate({
326
+ // key: 'effectSpeed',
327
+ // Characteristic: this.Characteristics.my.EffectSpeed,
328
+ // value: 50
329
+ // }).on('didSet', (value) => {
330
+ // this.setEffectSpeed(value)
331
+ // })
332
+ // this.hk.effectColours = []
333
+ // for (let i = 0; i <= 5; i++) {
334
+ // const service = new this.Service.Lightbulb(
335
+ // this.name + ' Effect Color ' + (i + 1), this.subtype + '-C' + i
336
+ // )
337
+ // service.addCharacteristicDelegate({
338
+ // key: 'on',
339
+ // Characteristic: this.Characteristics.hap.On,
340
+ // value: true
341
+ // }).on('didSet', (value) => {
342
+ // this.setEffectOn(i, value)
343
+ // })
344
+ // service.addCharacteristicDelegate({
345
+ // key: 'hue',
346
+ // Characteristic: this.Characteristics.hap.Hue,
347
+ // value: i * 60
348
+ // }).on('didSet', (value) => {
349
+ // this.setEffectHue(i, value)
350
+ // })
351
+ // service.addCharacteristicDelegate({
352
+ // key: 'saturation',
353
+ // Characteristic: this.Characteristics.hap.Saturation,
354
+ // value: 100
355
+ // }).on('didSet', (value) => {
356
+ // this.setEffectSat(i, value)
357
+ // })
358
+ // this.effectServices.push(service)
359
+ // }
360
+ // }
361
+ // this.checkEffect(this.obj.state.effect)
362
+ }
363
+
339
364
  updateState (state) {
340
365
  this.initAdaptiveLighting()
341
366
  let updateAdaptiveLighting = false
@@ -474,13 +499,13 @@ class Light extends DeconzService.LightsResource {
474
499
  async updateAdaptiveLighting () {
475
500
  if (
476
501
  this.adaptiveLighting == null || // not supported
477
- this.values.activeTransitionCount === 0 || // disabled
478
- !this.values.on // light is off
502
+ this.values.activeTransitionCount === 0 // disabled
503
+ // !this.values.on // light is off
479
504
  ) {
480
505
  return
481
506
  }
482
507
  const ct = this.adaptiveLighting.getCt(
483
- this.values.brightness * this.platform.config.brightnessAdjustment
508
+ this.values.brightness * this.gateway.values.brightnessAdjustment
484
509
  )
485
510
  if (ct == null) {
486
511
  this.warn('adaptive lighting: cannot compute Color Temperature')
@@ -19,7 +19,7 @@ class LightLevel extends DeconzService.SensorsResource {
19
19
  super(accessory, resource, params)
20
20
 
21
21
  this.addCharacteristicDelegate({
22
- key: 'lightlevel',
22
+ key: 'lightLevel',
23
23
  Characteristic: this.Characteristics.hap.CurrentAmbientLightLevel,
24
24
  unit: ' lux'
25
25
  })
@@ -36,12 +36,12 @@ class LightLevel extends DeconzService.SensorsResource {
36
36
 
37
37
  this.addCharacteristicDelegates()
38
38
 
39
- this.update(resource.body)
39
+ this.update(resource.body, resource.rpath)
40
40
  }
41
41
 
42
42
  updateState (state) {
43
43
  if (state.lightlevel != null) {
44
- this.values.lightlevel = lightLevelToLux(state.lightlevel)
44
+ this.values.lightLevel = lightLevelToLux(state.lightlevel)
45
45
  }
46
46
  if (state.dark != null) {
47
47
  this.values.dark = state.dark
@@ -15,13 +15,13 @@ class Motion extends DeconzService.SensorsResource {
15
15
  params.Service = accessory.Services.hap.MotionSensor
16
16
  super(accessory, resource, params)
17
17
 
18
- this.durationKey = resource.body.config.delay !== null ? 'delay' : 'duration'
18
+ this.durationKey = resource.body.config.delay != null ? 'delay' : 'duration'
19
19
  this.sensitivitymax = resource.body.config.sensitivitymax
20
20
 
21
21
  this.addCharacteristicDelegate({
22
22
  key: 'motion',
23
23
  Characteristic: this.Characteristics.hap.MotionDetected,
24
- value: 0
24
+ value: false
25
25
  })
26
26
 
27
27
  this.addCharacteristicDelegate({
@@ -52,15 +52,9 @@ class Motion extends DeconzService.SensorsResource {
52
52
  }
53
53
  })
54
54
 
55
- this.addCharacteristicDelegate({
56
- key: 'lastActivation',
57
- Characteristic: this.Characteristics.eve.LastActivation,
58
- silent: true
59
- })
60
-
61
55
  this.addCharacteristicDelegates()
62
56
 
63
- this.update(resource.body)
57
+ this.update(resource.body, resource.rpath)
64
58
  }
65
59
 
66
60
  updateState (state) {
@@ -46,6 +46,7 @@ class Power extends DeconzService.SensorsResource {
46
46
  silent: true
47
47
  })
48
48
  }
49
+ service.update(resource.body, resource.rpath)
49
50
  }
50
51
 
51
52
  static updateResourceState (service, state) {
@@ -71,7 +72,7 @@ class Power extends DeconzService.SensorsResource {
71
72
 
72
73
  super.addCharacteristicDelegates({ noLastUpdated: true })
73
74
 
74
- this.update(resource.body)
75
+ this.update(resource.body, resource.rpath)
75
76
  }
76
77
 
77
78
  updateState (state) {
@@ -39,7 +39,7 @@ class Status extends DeconzService.SensorsResource {
39
39
 
40
40
  this.addCharacteristicDelegates()
41
41
 
42
- this.update(resource.body)
42
+ this.update(resource.body, resource.rpath)
43
43
  }
44
44
 
45
45
  updateState (state) {
@@ -15,6 +15,12 @@ class WindowCovering extends DeconzService.LightsResource {
15
15
  params.Service = accessory.Services.hap.WindowCovering
16
16
  super(accessory, resource, params)
17
17
 
18
+ this.addCharacteristicDelegate({
19
+ key: 'venetianBlind',
20
+ value: false,
21
+ silent: true
22
+ })
23
+
18
24
  this.addCharacteristicDelegate({
19
25
  key: 'currentPosition',
20
26
  Characteristic: this.Characteristics.hap.CurrentPosition,
@@ -47,7 +53,7 @@ class WindowCovering extends DeconzService.LightsResource {
47
53
  this.values.positionState = this.Characteristics.hap.PositionState.STOPPED
48
54
  })
49
55
 
50
- if (this.venetianBlind) {
56
+ if (this.values.venetianBlind) {
51
57
  this.addCharacteristicDelegate({
52
58
  key: 'closeUpwards',
53
59
  Characteristic: this.Characteristics.my.CloseUpwards
@@ -55,7 +61,9 @@ class WindowCovering extends DeconzService.LightsResource {
55
61
  if (!fromHomeKit) {
56
62
  return
57
63
  }
58
- await this.setPosition()
64
+ if (this.values.currentPosition !== 100) {
65
+ await this.setPosition()
66
+ }
59
67
  })
60
68
  }
61
69
 
@@ -100,7 +108,7 @@ class WindowCovering extends DeconzService.LightsResource {
100
108
 
101
109
  async setPosition () {
102
110
  let lift = 100 - this.values.targetPosition // % closed --> % open
103
- if (this.venetianBlind) {
111
+ if (this.values.venetianBlind) {
104
112
  if (this.values.closeUpwards) {
105
113
  lift *= -1
106
114
  }
@@ -121,7 +129,9 @@ class WindowCovering extends DeconzService.LightsResource {
121
129
  if (state.lift != null) {
122
130
  let position = Math.round(state.lift / 5) * 5
123
131
  let closeUpwards
124
- if (this.venetianBlind) {
132
+ if (this.values.venetianBlind) {
133
+ position *= 2
134
+ position -= 100
125
135
  if (position < 0) {
126
136
  position *= -1
127
137
  closeUpwards = true
@@ -24,9 +24,8 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
24
24
  static get Consumption () { return require('./Consumption') }
25
25
  static get Contact () { return require('./Contact') }
26
26
  static get Daylight () { return require('./Daylight') }
27
- static get DeviceSettings () { return require('./DeviceSettings') }
28
27
  static get Flag () { return require('./Flag') }
29
- static get GatewaySettings () { return require('./GatewaySettings') }
28
+ static get Gateway () { return require('./Gateway') }
30
29
  static get Humidity () { return require('./Humidity') }
31
30
  static get Leak () { return require('./Leak') }
32
31
  static get Light () { return require('./Light') }
@@ -64,13 +63,13 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
64
63
 
65
64
  this.serviceNameByRpath = {}
66
65
 
67
- this.characteristicDelegate('configuredName')
68
- .on('didSet', async (value, fromHomeKit) => {
69
- if (fromHomeKit && value != null && value !== '') {
70
- this.debug('PUT %s %j', this.rpath, { name: value })
71
- await this.client.put(this.rpath, { name: value })
72
- }
73
- })
66
+ // this.characteristicDelegate('configuredName')
67
+ // .on('didSet', async (value, fromHomeKit) => {
68
+ // if (fromHomeKit && value != null && value !== '') {
69
+ // this.debug('PUT %s %j', this.rpath, { name: value })
70
+ // await this.client.put(this.rpath, { name: value })
71
+ // }
72
+ // })
74
73
  }
75
74
 
76
75
  addResource (resource) {
@@ -89,9 +88,9 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
89
88
  }
90
89
  return
91
90
  }
92
- if (body.name != null) {
93
- this.values.configuredName = body.name
94
- }
91
+ // if (body.name != null) {
92
+ // this.values.configuredName = body.name.slice(0, 31).trim()
93
+ // }
95
94
  if (body.lastseen != null && this.rtype === 'lights') {
96
95
  this.values.lastSeen = dateToString(body.lastseen)
97
96
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName": "Homebridge deCONZ",
5
5
  "author": "Erik Baauw",
6
6
  "license": "Apache-2.0",
7
- "version": "0.0.27",
7
+ "version": "0.1.0",
8
8
  "keywords": [
9
9
  "homebridge-plugin",
10
10
  "homekit",
@@ -20,13 +20,13 @@
20
20
  "deconz": "cli/deconz.js"
21
21
  },
22
22
  "engines": {
23
- "deCONZ": "2.19.1",
24
- "homebridge": "^1.5.1",
25
- "node": "^18.12.1"
23
+ "deCONZ": "2.19.3",
24
+ "homebridge": "^1.6.0",
25
+ "node": "^18.13.0"
26
26
  },
27
27
  "dependencies": {
28
- "homebridge-lib": "~6.0.1",
29
- "ws": "^8.11.0",
28
+ "homebridge-lib": "~6.3.4",
29
+ "ws": "^8.12.0",
30
30
  "xml2js": "~0.4.23"
31
31
  },
32
32
  "scripts": {
@@ -1,53 +0,0 @@
1
- // homebridge-deconz/lib/DeconzAccessory/Contact.js
2
- // Copyright © 2022 Erik Baauw. All rights reserved.
3
- //
4
- // Homebridge plugin for deCONZ.
5
-
6
- 'use strict'
7
-
8
- const homebridgeLib = require('homebridge-lib')
9
- const DeconzAccessory = require('../DeconzAccessory')
10
-
11
- const { History } = homebridgeLib.ServiceDelegate
12
-
13
- /** Delegate class for a HomeKit accessory corresponding to a contact sensor,
14
- * with Eve Door & Window history.
15
- * @extends DeconzAccessory
16
- * @memberof DeconzAccessory
17
- */
18
- class Contact extends DeconzAccessory {
19
- /** Instantiate a contact sensor delegate.
20
- * @param {DeconzAccessory.Gateway} gateway - The gateway.
21
- * @param {Deconz.Device} device - The device.
22
- */
23
- constructor (gateway, device) {
24
- super(gateway, device, gateway.Accessory.Categories.SENSOR)
25
-
26
- this.identify()
27
-
28
- this.service = this.createService(device.resource, { primaryService: true })
29
-
30
- for (const subtype in device.resourceBySubtype) {
31
- const resource = device.resourceBySubtype[subtype]
32
- if (subtype === device.primary) {
33
- continue
34
- }
35
- this.createService(resource)
36
- }
37
-
38
- this.historyService = new History.Contact(this, {
39
- contactDelegate: this.service.characteristicDelegate('contact'),
40
- timesOpenedDelegate: this.service.characteristicDelegate('timesOpened'),
41
- lastActivationDelegate: this.service.characteristicDelegate('lastActivation')
42
- })
43
-
44
- this.createSettingsService()
45
-
46
- setImmediate(() => {
47
- this.debug('initialised')
48
- this.emit('initialised')
49
- })
50
- }
51
- }
52
-
53
- module.exports = Contact