homebridge-deconz 0.0.25 → 0.0.27

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/cli/deconz.js CHANGED
@@ -711,12 +711,15 @@ class Main extends homebridgeLib.CommandLineTool {
711
711
  .on('changed', (rtype, rid, body) => {
712
712
  let resource = '/' + rtype + '/' + rid
713
713
  if (Object.keys(body).length === 1) {
714
- if (body.state != null) {
715
- resource += '/state'
716
- body = body.state
714
+ if (body.capabilities != null) {
715
+ resource += '/capabilities'
716
+ body = body.capabilities
717
717
  } else if (body.config != null) {
718
718
  resource += '/config'
719
719
  body = body.config
720
+ } else if (body.state != null) {
721
+ resource += '/state'
722
+ body = body.state
720
723
  }
721
724
  }
722
725
  this.log('%s: %s', resource, this.jsonFormatter.stringify(body))
@@ -21,21 +21,28 @@ const nonCriticalApiErrorTypes = [
21
21
  * @memberof Deconz
22
22
  */
23
23
  class ApiError extends homebridgeLib.HttpClient.HttpError {
24
- constructor (message, response, type, description) {
25
- super(message, response.request, response.statusCode, response.statusMessage)
24
+ constructor (e, response) {
25
+ super(
26
+ `${e.address}: api error ${e.type}: ${e.description}`,
27
+ response.request, response.statusCode, response.statusMessage
28
+ )
26
29
 
27
30
  /** @member {integer} - The API error type.
28
31
  */
29
- this.type = type
32
+ this.type = e.type
33
+
34
+ /** @member {string} - The address causing the error.
35
+ */
36
+ this.address = e.address
30
37
 
31
38
  /** @member {string} - The API error description.
32
39
  */
33
- this.description = description
40
+ this.description = e.description
34
41
 
35
42
  /** @member {boolean} - Indication that the request might still succeed
36
43
  * for other attributes.
37
44
  */
38
- this.nonCritical = nonCriticalApiErrorTypes.includes(type)
45
+ this.nonCritical = nonCriticalApiErrorTypes.includes(e.type)
39
46
  }
40
47
  }
41
48
 
@@ -33,17 +33,20 @@ class ApiResponse extends homebridgeLib.HttpClient.HttpResponse {
33
33
  for (const id in response.body) {
34
34
  const e = response.body[id].error
35
35
  if (e != null && typeof e === 'object') {
36
- this.errors.push(new Deconz.ApiError(
37
- `api error ${e.type}: ${e.description}`,
38
- response, e.type, e.description
39
- ))
36
+ this.errors.push(new Deconz.ApiError(e, response))
40
37
  }
41
38
  const s = response.body[id].success
42
39
  if (s != null && typeof s === 'object') {
43
40
  for (const path of Object.keys(s)) {
44
- const a = path.split('/')
45
- const key = a[a.length - 1]
46
- this.success[key] = s[path]
41
+ const keys = path.split('/')
42
+ let obj = this.success
43
+ for (let i = 1; i < keys.length - 1; i++) {
44
+ if (obj[keys[i]] == null) {
45
+ obj[keys[i]] = {}
46
+ }
47
+ obj = obj[keys[i]]
48
+ }
49
+ obj[keys[keys.length - 1]] = s[path]
47
50
  }
48
51
  }
49
52
  }
@@ -91,12 +91,14 @@ class WsClient extends events.EventEmitter {
91
91
  case 'changed':
92
92
  if (obj.r !== null && obj.id !== null) {
93
93
  let body
94
- if (obj.state != null) {
95
- body = { state: obj.state }
94
+ if (obj.attr != null) {
95
+ body = obj.attr
96
+ } else if (obj.capabilities != null) {
97
+ body = { capabilities: obj.capabilities }
96
98
  } else if (obj.config != null) {
97
99
  body = { config: obj.config }
98
- } else if (obj.attr != null) {
99
- body = obj.attr
100
+ } else if (obj.state != null) {
101
+ body = { state: obj.state }
100
102
  }
101
103
  /** Emitted when a `changed` notification has been received.
102
104
  *
@@ -35,12 +35,11 @@ class Contact extends DeconzAccessory {
35
35
  this.createService(resource)
36
36
  }
37
37
 
38
- this.historyService = new History.Contact(
39
- this, {},
40
- this.service.characteristicDelegate('contact'),
41
- this.service.characteristicDelegate('timesOpened'),
42
- this.service.characteristicDelegate('lastActivation')
43
- )
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
+ })
44
43
 
45
44
  this.createSettingsService()
46
45
 
@@ -164,7 +164,8 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
164
164
  name: this.name + ' Button',
165
165
  button: 1,
166
166
  events: DeconzService.Button.SINGLE | DeconzService.Button.DOUBLE |
167
- DeconzService.Button.LONG
167
+ DeconzService.Button.LONG,
168
+ exposeConfiguredName: true
168
169
  })
169
170
 
170
171
  this.createClient()
@@ -21,8 +21,6 @@ class Light extends DeconzAccessory {
21
21
  * @param {Deconz.Device} device - The device.
22
22
  */
23
23
  constructor (gateway, device, settings = {}) {
24
- // settings.forceEveEnergy = true
25
-
26
24
  super(gateway, device, gateway.Accessory.Categories.LIGHTBULB)
27
25
 
28
26
  this.identify()
@@ -37,14 +35,12 @@ class Light extends DeconzAccessory {
37
35
  serviceName: this.values.serviceName
38
36
  })
39
37
 
40
- let nLights = 1
41
38
  for (const subtype in device.resourceBySubtype) {
42
39
  const resource = device.resourceBySubtype[subtype]
43
40
  if (subtype === device.primary) {
44
41
  continue
45
42
  }
46
43
  if (resource.rtype === 'lights') {
47
- nLights++
48
44
  this.createService(resource, { serviceName: this.values.serviceName })
49
45
  } else {
50
46
  this.createService(resource)
@@ -61,12 +57,15 @@ class Light extends DeconzAccessory {
61
57
  unit: ' W'
62
58
  })
63
59
  : null
64
- this.historyService = new History.Consumption(
65
- this, {},
66
- this.service.characteristicDelegate('totalConsumption'),
67
- currentConsumption,
68
- this.service.characteristicDelegate('on')
69
- )
60
+ this.service.addCharacteristicDelegate({
61
+ key: 'lockPhysicalControls',
62
+ Characteristic: this.Characteristics.hap.LockPhysicalControls
63
+ })
64
+ this.historyService = new History.Consumption(this, {
65
+ consumptionDelegate: this.service.characteristicDelegate('totalConsumption'),
66
+ powerDelegate: currentConsumption,
67
+ onDelegate: this.service.characteristicDelegate('on')
68
+ })
70
69
  } else if (this.serviceByServiceName.Power != null) {
71
70
  // Total Consumption to be computed by history
72
71
  const TotalConsumption = this.service.addCharacteristicDelegate({
@@ -75,43 +74,25 @@ class Light extends DeconzAccessory {
75
74
  unit: ' kWh',
76
75
  value: 0
77
76
  })
78
- this.historyService = new History.Power(
79
- this, {},
80
- this.service.characteristicDelegate('currentConsumption'),
81
- TotalConsumption,
82
- this.service.characteristicDelegate('on')
83
- )
84
- } else if (this.values.serviceName === 'Outlet' && settings.forceEveEnergy) {
85
- if (nLights > 1) {
86
- // Eve would recognise device as Eve Energy Strip.
87
- } else if (this.serviceByServiceName.Switch != null) {
88
- // Eve would recognise device as Eve Button.
89
- } else {
90
- // Needed for Eve to recognise device as Eve Energy.
91
- this.service.addCharacteristicDelegate({
92
- key: 'totalConsumption',
93
- Characteristic: this.Characteristics.eve.TotalConsumption,
94
- unit: ' kWh'
95
- })
96
- this.historyService = new History.On(
97
- this, {},
98
- this.service.characteristicDelegate('on')
99
- )
100
- }
101
- }
102
-
103
- if (this.values.serviceName === 'Outlet' && this.historyService != null) {
104
- if (nLights > 1) {
105
- // Eve would recognise device as Eve Energy Strip.
106
- } else if (this.serviceByServiceName.Switch != null) {
107
- // Eve would recognise device as Eve Button.
108
- } else {
109
- // Needed for Eve to show history for On.
110
- this.service.addCharacteristicDelegate({
111
- key: 'lockPhysicalControls',
112
- Characteristic: this.Characteristics.hap.LockPhysicalControls
113
- })
114
- }
77
+ this.service.addCharacteristicDelegate({
78
+ key: 'lockPhysicalControls',
79
+ Characteristic: this.Characteristics.hap.LockPhysicalControls
80
+ })
81
+ this.historyService = new History.Power(this, {
82
+ powerDelegate: this.service.characteristicDelegate('currentConsumption'),
83
+ consumptionDelegate: TotalConsumption,
84
+ onDelegate: this.service.characteristicDelegate('on')
85
+ })
86
+ } else {
87
+ const lastActivation = this.service.addCharacteristicDelegate({
88
+ key: 'lastActivation',
89
+ Characteristic: this.Characteristics.eve.LastActivation,
90
+ silent: true
91
+ })
92
+ this.historyService = new History.Light(this, {
93
+ onDelegate: this.service.characteristicDelegate('on'),
94
+ lastActivationDelegate: lastActivation
95
+ })
115
96
  }
116
97
 
117
98
  this.createSettingsService()
@@ -30,17 +30,16 @@ class Motion extends DeconzAccessory {
30
30
  this.createService(resource)
31
31
  }
32
32
 
33
- this.historyService = new History.Motion(
34
- this, {},
35
- this.service.characteristicDelegate('motion'),
36
- this.service.characteristicDelegate('lastActivation'),
37
- this.serviceByServiceName.LightLevel == null
33
+ this.historyService = new History.Motion(this, {
34
+ motionDelegate: this.service.characteristicDelegate('motion'),
35
+ lastActivationDelegate: this.service.characteristicDelegate('lastActivation'),
36
+ lightLevelDelegate: this.serviceByServiceName.LightLevel == null
38
37
  ? null
39
38
  : this.serviceByServiceName.LightLevel.characteristicDelegate('lightlevel'),
40
- this.serviceByServiceName.Temperature == null
39
+ temperatureDelegate: this.serviceByServiceName.Temperature == null
41
40
  ? null
42
41
  : this.serviceByServiceName.Temperature.characteristicDelegate('temperature')
43
- )
42
+ })
44
43
 
45
44
  this.createSettingsService()
46
45
 
@@ -30,25 +30,23 @@ class Temperature extends DeconzAccessory {
30
30
  }
31
31
 
32
32
  if (this.serviceByServiceName.AirQuality == null) {
33
- this.historyService = new History.Weather(
34
- this, {},
35
- this.service.characteristicDelegate('temperature'),
36
- this.serviceByServiceName.Humidity == null
33
+ this.historyService = new History.Weather(this, {
34
+ temperatureDelegate: this.service.characteristicDelegate('temperature'),
35
+ humidityDelegate: this.serviceByServiceName.Humidity == null
37
36
  ? null
38
37
  : this.serviceByServiceName.Humidity.characteristicDelegate('humidity'),
39
- this.serviceByServiceName.AirPressure == null
38
+ airPressureDelegate: this.serviceByServiceName.AirPressure == null
40
39
  ? null
41
40
  : this.serviceByServiceName.AirPressure.characteristicDelegate('airPressure')
42
- )
41
+ })
43
42
  } else {
44
- this.historyService = new History.Room(
45
- this, {},
46
- this.service.characteristicDelegate('temperature'),
47
- this.serviceByServiceName.Humidity == null
43
+ this.historyService = new History.Room(this, {
44
+ temperatureDelegate: this.service.characteristicDelegate('temperature'),
45
+ humidityDelegate: this.serviceByServiceName.Humidity == null
48
46
  ? null
49
47
  : this.serviceByServiceName.Humidity.characteristicDelegate('humidity'),
50
- this.serviceByServiceName.AirQuality.characteristicDelegate('vocDensity')
51
- )
48
+ airQualityDelegate: this.serviceByServiceName.AirQuality.characteristicDelegate('vocDensity')
49
+ })
52
50
  }
53
51
 
54
52
  this.createSettingsService()
@@ -30,12 +30,11 @@ class Thermostat extends DeconzAccessory {
30
30
  }
31
31
 
32
32
  if (device.resource.body.state.valve !== undefined) {
33
- this.historyService = new History.Thermo(
34
- this, {},
35
- this.service.characteristicDelegate('currentTemperature'),
36
- this.service.characteristicDelegate('targetTemperature'),
37
- this.service.characteristicDelegate('valvePosition')
38
- )
33
+ this.historyService = new History.Thermo(this, {
34
+ temperatureDelegate: this.service.characteristicDelegate('currentTemperature'),
35
+ targetTemperatureDelegate: this.service.characteristicDelegate('targetTemperature'),
36
+ valvePositionDelegate: this.service.characteristicDelegate('valvePosition')
37
+ })
39
38
  }
40
39
 
41
40
  this.createSettingsService()
@@ -5,10 +5,10 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- const homebridgeLib = require('homebridge-lib')
8
+ // const homebridgeLib = require('homebridge-lib')
9
9
  const DeconzAccessory = require('../DeconzAccessory')
10
10
 
11
- const { History } = homebridgeLib.ServiceDelegate
11
+ // const { History } = homebridgeLib.ServiceDelegate
12
12
 
13
13
  /** Delegate class for a HomeKit accessory, corresponding to a light device
14
14
  * or groups resource.
@@ -35,14 +35,11 @@ class WarningDevice extends DeconzAccessory {
35
35
  this.createService(resource)
36
36
  }
37
37
 
38
- if (this.serviceByServiceName.Temperature != null) {
39
- this.historyService = new History.Weather(
40
- this, {},
41
- this.serviceByServiceName.Temperature.characteristicDelegate('temperature'),
42
- null,
43
- null
44
- )
45
- }
38
+ // if (this.serviceByServiceName.Temperature != null) {
39
+ // this.historyService = new History.Weather(this, {
40
+ // temperatureDelegate: this.serviceByServiceName.Temperature.characteristicDelegate('temperature')
41
+ // })
42
+ // }
46
43
 
47
44
  this.createSettingsService()
48
45
 
@@ -27,6 +27,12 @@ class AirPressure extends DeconzService.SensorsResource {
27
27
  value: 0
28
28
  })
29
29
 
30
+ // this.addCharacteristicDelegate({
31
+ // key: 'trend',
32
+ // Characteristic: this.Characteristics.eve.WeatherTrend,
33
+ // value: 0
34
+ // })
35
+
30
36
  this.addCharacteristicDelegates()
31
37
 
32
38
  this.update(resource.body)
@@ -36,6 +42,7 @@ class AirPressure extends DeconzService.SensorsResource {
36
42
  if (state.pressure != null) {
37
43
  this.values.airPressure = Math.round(state.pressure * 10) / 10
38
44
  }
45
+ // this.values.trend = Math.round(new Date().valueOf() / 60000) % 16
39
46
  super.updateState(state)
40
47
  }
41
48
  }
@@ -16,7 +16,8 @@ const homebridgeLib = require('homebridge-lib')
16
16
  class Battery extends homebridgeLib.ServiceDelegate.Battery {
17
17
  constructor (accessory, resource, params = {}) {
18
18
  super(accessory, {
19
- name: accessory.name + ' Battery'
19
+ name: accessory.name + ' Battery',
20
+ exposeConfiguredName: true
20
21
  })
21
22
  }
22
23
 
@@ -6,6 +6,7 @@
6
6
  'use strict'
7
7
 
8
8
  const homebridgeLib = require('homebridge-lib')
9
+ const DeconzAccessory = require('../DeconzAccessory')
9
10
 
10
11
  /** Delegate class for a DeconzDevice service.
11
12
  * @extends ServiceDelegate
@@ -14,6 +15,7 @@ const homebridgeLib = require('homebridge-lib')
14
15
  class DeviceSettings extends homebridgeLib.ServiceDelegate {
15
16
  constructor (accessory, params = {}) {
16
17
  params.Service = accessory.Services.my.DeconzDevice
18
+ params.exposeConfiguredName = true
17
19
  super(accessory, params)
18
20
 
19
21
  this.debug('settings: %j', params)
@@ -27,7 +29,7 @@ class DeviceSettings extends homebridgeLib.ServiceDelegate {
27
29
  accessory.gateway.exposeDevice(params.subtype, value)
28
30
  })
29
31
 
30
- if (params.hasRepeat != null) {
32
+ if (params.hasRepeat) {
31
33
  this.addCharacteristicDelegate({
32
34
  key: 'repeat',
33
35
  Characteristic: this.Characteristics.my.Repeat,
@@ -50,6 +52,13 @@ class DeviceSettings extends homebridgeLib.ServiceDelegate {
50
52
  value: params.resource,
51
53
  silent: true
52
54
  })
55
+
56
+ if (!(accessory instanceof DeconzAccessory.Gateway)) {
57
+ accessory.propertyDelegate('name')
58
+ .on('didSet', (name) => {
59
+ this.values.configuredName = name + ' Settings'
60
+ })
61
+ }
53
62
  }
54
63
  }
55
64
 
@@ -14,6 +14,7 @@ const homebridgeLib = require('homebridge-lib')
14
14
  class GatewaySettings extends homebridgeLib.ServiceDelegate {
15
15
  constructor (gateway, params = {}) {
16
16
  params.Service = gateway.Services.my.DeconzGateway
17
+ params.exposeConfiguredName = true
17
18
  super(gateway, params)
18
19
  this.gateway = gateway
19
20
 
@@ -243,7 +243,7 @@ class Light extends DeconzService.LightsResource {
243
243
  }
244
244
 
245
245
  if (this.capabilities.effects != null) {
246
- this.effectServices = []
246
+ this.effectServices = {}
247
247
  this.addCharacteristicDelegate({
248
248
  key: 'effect',
249
249
  value: -1,
@@ -253,12 +253,13 @@ class Light extends DeconzService.LightsResource {
253
253
  this.effectServices[i].values.on = value === i
254
254
  }
255
255
  })
256
- for (const i in this.capabilities.effects) {
257
- const effect = this.capabilities.effects[i]
256
+ for (const id in this.capabilities.effects) {
257
+ const effect = this.capabilities.effects[id]
258
258
  const service = new homebridgeLib.ServiceDelegate(accessory, {
259
259
  name: this.resource.body.name + ' ' + effect,
260
- Service: this.Services.hap.Switch,
261
- subtype: this.subtype + '-E' + i
260
+ Service: this.Services.hap.Lightbulb,
261
+ subtype: this.subtype + '-E' + id,
262
+ exposeConfiguredName: true
262
263
  })
263
264
  service.addCharacteristicDelegate({
264
265
  key: 'on',
@@ -266,14 +267,27 @@ class Light extends DeconzService.LightsResource {
266
267
  }).on('didSet', (value, fromHomeKit) => {
267
268
  if (fromHomeKit) {
268
269
  this.checkAdaptiveLighting()
269
- this.values.effect = value ? i : -1
270
+ this.values.effect = value ? id : -1
270
271
  const newEffect = value
271
272
  ? effect.toLowerCase()
272
273
  : 'none'
273
274
  this.put({ effect: newEffect })
274
275
  }
275
276
  })
276
- this.effectServices.push(service)
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
+ })
277
291
  }
278
292
  // if (this.capabilities.effectSpeed) {
279
293
  // this.addCharacteristicDelegate({
@@ -399,8 +413,9 @@ class Light extends DeconzService.LightsResource {
399
413
  if (this.sceneServices[scene.id] == null) {
400
414
  const service = new homebridgeLib.ServiceDelegate(this.accessoryDelegate, {
401
415
  name: this.resource.body.name + ' ' + scene.name,
402
- Service: this.Services.hap.Switch,
403
- subtype: this.subtype + '-S' + scene.id
416
+ Service: this.Services.hap.Lightbulb,
417
+ subtype: this.subtype + '-S' + scene.id,
418
+ exposeConfiguredName: true
404
419
  })
405
420
  service.addCharacteristicDelegate({
406
421
  key: 'on',
@@ -418,8 +433,15 @@ class Light extends DeconzService.LightsResource {
418
433
  service.values.on = false
419
434
  }
420
435
  })
436
+ service.addCharacteristicDelegate({
437
+ key: 'index',
438
+ Characteristic: this.Characteristics.hap.ServiceLabelIndex,
439
+ value: Number(scene.id) + 1
440
+ })
421
441
  this.sceneServices[scene.id] = service
422
442
  }
443
+ this.sceneServices[scene.id].values.configuredName =
444
+ this.resource.body.name + ' ' + scene.name
423
445
  }
424
446
  for (const id in this.scenesServices) {
425
447
  if (sceneById[id] == null) {
@@ -15,7 +15,7 @@ const { timeout } = homebridgeLib
15
15
  class LightsResource extends DeconzService {
16
16
  constructor (accessory, resource, params) {
17
17
  super(accessory, resource, params)
18
- this.rpath += resource.rtype === 'groups' ? '/action' : '/state'
18
+ this.rpathState = this.rpath + (resource.rtype === 'groups' ? '/action' : '/state')
19
19
 
20
20
  this.updating = 0
21
21
  this.targetState = {}
@@ -23,16 +23,18 @@ class LightsResource extends DeconzService {
23
23
  }
24
24
 
25
25
  addCharacteristicDelegates (params = {}) {
26
- this.addCharacteristicDelegate({
27
- key: 'lastSeen',
28
- Characteristic: this.Characteristics.my.LastSeen,
29
- silent: true
30
- })
26
+ if (this.resource.rtype !== 'groups') {
27
+ this.addCharacteristicDelegate({
28
+ key: 'lastSeen',
29
+ Characteristic: this.Characteristics.my.LastSeen,
30
+ silent: true
31
+ })
31
32
 
32
- this.addCharacteristicDelegate({
33
- key: 'statusFault',
34
- Characteristic: this.Characteristics.hap.StatusFault
35
- })
33
+ this.addCharacteristicDelegate({
34
+ key: 'statusFault',
35
+ Characteristic: this.Characteristics.hap.StatusFault
36
+ })
37
+ }
36
38
  }
37
39
 
38
40
  updateState (state) {
@@ -43,24 +45,28 @@ class LightsResource extends DeconzService {
43
45
  }
44
46
  }
45
47
 
48
+ updateConfig (config) {
49
+ }
50
+
46
51
  async identify () {
47
52
  if (this.capabilities.alert) {
48
53
  if (this.capabilities.breathe) {
49
- await this.client.put(this.rpath, { alert: 'breathe' })
50
- await timeout(1500)
51
- await this.client.put(this.rpath, { alert: 'stop' })
54
+ await this.put({ alert: 'breathe' })
55
+ await timeout(1000)
56
+ await this.put({ alert: 'stop' })
57
+ } else {
58
+ await this.put({ alert: 'select' })
52
59
  }
53
- await this.put(this.rpath, { alert: 'select' })
54
60
  }
55
61
  }
56
62
 
57
63
  // Collect changes into a combined request.
58
- put (state) {
64
+ async put (state) {
59
65
  for (const key in state) {
60
66
  this.resource.body.state[key] = state[key]
61
67
  this.targetState[key] = state[key]
62
68
  }
63
- this._put()
69
+ return this._put()
64
70
  }
65
71
 
66
72
  // Send the request (for the combined changes) to the gateway.
@@ -96,8 +102,8 @@ class LightsResource extends DeconzService {
96
102
  targetState.transitiontime = 0
97
103
  }
98
104
  }
99
- this.debug('PUT %s %j', this.rpath, targetState)
100
- await this.client.put(this.rpath, targetState)
105
+ this.debug('PUT %s %j', this.rpathState, targetState)
106
+ await this.client.put(this.rpathState, targetState)
101
107
  this.recentlyUpdated = true
102
108
  await timeout(500)
103
109
  this.recentlyUpdated = false
@@ -50,7 +50,8 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
50
50
  name: resource.body.name,
51
51
  Service: params.Service,
52
52
  subtype: resource.subtype,
53
- primaryService: params.primaryService
53
+ primaryService: params.primaryService,
54
+ exposeConfiguredName: true
54
55
  })
55
56
  this.id = resource.id
56
57
  this.gateway = accessory.gateway
@@ -62,6 +63,14 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
62
63
  this.capabilities = resource.capabilities
63
64
 
64
65
  this.serviceNameByRpath = {}
66
+
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
+ })
65
74
  }
66
75
 
67
76
  addResource (resource) {
@@ -80,6 +89,9 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
80
89
  }
81
90
  return
82
91
  }
92
+ if (body.name != null) {
93
+ this.values.configuredName = body.name
94
+ }
83
95
  if (body.lastseen != null && this.rtype === 'lights') {
84
96
  this.values.lastSeen = dateToString(body.lastseen)
85
97
  }
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.25",
7
+ "version": "0.0.27",
8
8
  "keywords": [
9
9
  "homebridge-plugin",
10
10
  "homekit",
@@ -22,11 +22,11 @@
22
22
  "engines": {
23
23
  "deCONZ": "2.19.1",
24
24
  "homebridge": "^1.5.1",
25
- "node": "^18.12.0"
25
+ "node": "^18.12.1"
26
26
  },
27
27
  "dependencies": {
28
- "homebridge-lib": "~5.7.1",
29
- "ws": "^8.10.0",
28
+ "homebridge-lib": "~6.0.1",
29
+ "ws": "^8.11.0",
30
30
  "xml2js": "~0.4.23"
31
31
  },
32
32
  "scripts": {