homebridge-deconz 1.0.1 → 1.0.2

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.
@@ -33,19 +33,8 @@ class Light extends DeconzAccessory {
33
33
  serviceName: this.values.serviceName
34
34
  })
35
35
 
36
- for (const subtype in device.resourceBySubtype) {
37
- const resource = device.resourceBySubtype[subtype]
38
- if (subtype === device.primary) {
39
- continue
40
- }
41
- if (resource.rtype === 'lights') {
42
- this.createService(resource, { serviceName: this.values.serviceName })
43
- } else {
44
- this.createService(resource)
45
- }
46
- }
47
-
48
36
  const params = {}
37
+
49
38
  if (this.values.serviceName === 'Outlet') {
50
39
  this.service.addCharacteristicDelegate({
51
40
  key: 'lockPhysicalControls',
@@ -57,7 +46,14 @@ class Light extends DeconzAccessory {
57
46
  Characteristic: this.Characteristics.eve.LastActivation,
58
47
  silent: true
59
48
  })
60
- } else if (this.values.serviceName !== 'Valve') {
49
+ } else if (this.values.serviceName === 'Switch') {
50
+ params.onDelegate = this.service.characteristicDelegate('on')
51
+ params.lastOnDelegate = this.service.addCharacteristicDelegate({
52
+ key: 'lastActivation',
53
+ Characteristic: this.Characteristics.eve.LastActivation,
54
+ silent: true
55
+ })
56
+ } else if (this.values.serviceName === 'Light') {
61
57
  params.lightOnDelegate = this.service.characteristicDelegate('on')
62
58
  params.lastLightOnDelegate = this.service.addCharacteristicDelegate({
63
59
  key: 'lastActivation',
@@ -65,6 +61,7 @@ class Light extends DeconzAccessory {
65
61
  silent: true
66
62
  })
67
63
  }
64
+
68
65
  if (this.service.characteristicDelegate('totalConsumption') != null) {
69
66
  params.totalConsumptionDelegate = this.service.characteristicDelegate('totalConsumption')
70
67
  if (this.service.values.consumption === undefined) {
@@ -86,6 +83,51 @@ class Light extends DeconzAccessory {
86
83
  }
87
84
  this.historyService = new ServiceDelegate.History(this, params)
88
85
 
86
+ for (const subtype in device.resourceBySubtype) {
87
+ const resource = device.resourceBySubtype[subtype]
88
+ if (subtype === device.primary) {
89
+ continue
90
+ }
91
+ if (resource.rtype === 'lights') {
92
+ const service = this.createService(resource, { serviceName: this.values.serviceName })
93
+ if (this.values.serviceName !== 'Valve') {
94
+ this.historyService.addLastOnDelegate(
95
+ service.characteristicDelegate('on'),
96
+ service.addCharacteristicDelegate({
97
+ key: 'lastActivation',
98
+ Characteristic: this.Characteristics.eve.LastActivation,
99
+ silent: true
100
+ })
101
+ )
102
+ }
103
+ } else {
104
+ this.createService(resource)
105
+ }
106
+ }
107
+
108
+ if (
109
+ this.values.serviceName === 'Outlet' &&
110
+ this.service.characteristicDelegate('totalConsumption') == null &&
111
+ this.service.characteristicDelegate('consumption') == null &&
112
+ this.servicesByServiceName.Outlet?.length === 1
113
+ ) {
114
+ // Dumb Outlet
115
+ this.warn('dumb outlet')
116
+ this.service.addCharacteristicDelegate({
117
+ key: 'dummyTotalConsumption',
118
+ Characteristic: this.Characteristics.eve.TotalConsumption,
119
+ props: {
120
+ perms: [
121
+ this.Characteristic.Perms.PAIRED_READ,
122
+ this.Characteristic.Perms.NOTIFY,
123
+ this.Characteristic.Perms.HIDDEN
124
+ ]
125
+ },
126
+ silent: true,
127
+ value: 0
128
+ })
129
+ }
130
+
89
131
  setImmediate(() => {
90
132
  this.debug('initialised')
91
133
  this.emit('initialised')
@@ -106,10 +106,10 @@ class Sensor extends DeconzAccessory {
106
106
  params.vocDensityDelegate = service.characteristicDelegate('vocDensity')
107
107
  }
108
108
  }
109
- if (this.servicesByServiceName.Flag != null) {
109
+ if (this.servicesByServiceName.Flag?.length === 1) {
110
110
  const service = this.servicesByServiceName.Flag[0]
111
- params.switchOnDelegate = service.characteristicDelegate('on')
112
- params.lastSwitchOnDelegate = service.addCharacteristicDelegate({
111
+ params.onDelegate = service.characteristicDelegate('on')
112
+ params.lastOnDelegate = service.addCharacteristicDelegate({
113
113
  key: 'lastActivation',
114
114
  Characteristic: this.Characteristics.eve.LastActivation,
115
115
  silent: true
@@ -35,8 +35,8 @@ class WarningDevice extends DeconzAccessory {
35
35
 
36
36
  const params = {}
37
37
  if (this.servicesByServiceName.WarningDevice?.length === 1) {
38
- params.switchOnDelegate = this.service.characteristicDelegate('on')
39
- params.lastSwitchOnDelegate = this.service.addCharacteristicDelegate({
38
+ params.onDelegate = this.service.characteristicDelegate('on')
39
+ params.lastOnDelegate = this.service.addCharacteristicDelegate({
40
40
  key: 'lastActivation',
41
41
  Characteristic: this.Characteristics.eve.LastActivation,
42
42
  silent: true
@@ -6,6 +6,7 @@
6
6
  'use strict'
7
7
 
8
8
  const DeconzService = require('../DeconzService')
9
+ const { timeout } = require('homebridge-lib')
9
10
 
10
11
  class WarningDevice extends DeconzService.LightsResource {
11
12
  constructor (accessory, resource, params = {}) {
@@ -33,11 +34,10 @@ class WarningDevice extends DeconzService.LightsResource {
33
34
  body = { alert: 'lselect', ontime: onTime }
34
35
  }
35
36
  }
36
- this.put(body)
37
+ await this.put(this.statePath, body)
37
38
  if (value) {
38
- this.timer = setTimeout(() => {
39
- this.values.on = false
40
- }, onTime * 1000)
39
+ await timeout(onTime * 1000)
40
+ this.values.on = false
41
41
  }
42
42
  }
43
43
  })
@@ -5,8 +5,8 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- const { timeout } = require('homebridge-lib')
9
8
  const DeconzService = require('../DeconzService')
9
+ const { timeout } = require('homebridge-lib')
10
10
 
11
11
  class WindowCovering extends DeconzService.LightsResource {
12
12
  constructor (accessory, resource, params = {}) {
@@ -34,7 +34,7 @@ class WindowCovering extends DeconzService.LightsResource {
34
34
  return
35
35
  }
36
36
  this.values.targetPosition = Math.round(this.values.targetPosition / 5) * 5
37
- await this.setPosition()
37
+ return this.setPosition()
38
38
  })
39
39
 
40
40
  this.addCharacteristicDelegate({
@@ -46,8 +46,8 @@ class WindowCovering extends DeconzService.LightsResource {
46
46
  this.addCharacteristicDelegate({
47
47
  key: 'holdPosition',
48
48
  Characteristic: this.Characteristics.hap.HoldPosition
49
- }).on('didSet', () => {
50
- this.put({ stop: true })
49
+ }).on('didSet', async () => {
50
+ await this.put(this.statePath, { stop: true })
51
51
  this.values.positionState = this.Characteristics.hap.PositionState.STOPPED
52
52
  })
53
53
 
@@ -60,7 +60,7 @@ class WindowCovering extends DeconzService.LightsResource {
60
60
  return
61
61
  }
62
62
  if (this.values.currentPosition !== 100) {
63
- await this.setPosition()
63
+ return this.setPosition()
64
64
  }
65
65
  })
66
66
  }
@@ -80,7 +80,7 @@ class WindowCovering extends DeconzService.LightsResource {
80
80
  if (!fromHomeKit) {
81
81
  return
82
82
  }
83
- await this.put({ speed: value })
83
+ await this.put('/config', { speed: value })
84
84
  })
85
85
  }
86
86
 
@@ -90,7 +90,7 @@ class WindowCovering extends DeconzService.LightsResource {
90
90
  Characteristic: this.Characteristics.my.PositionChange
91
91
  }).on('didSet', async (value) => {
92
92
  if (value !== 0) {
93
- this.put({ lift_inc: -value })
93
+ await this.put(this.statePath, { lift_inc: -value })
94
94
  await timeout(this.platform.config.waitTimeReset)
95
95
  this.values.positionChange = 0
96
96
  }
@@ -120,7 +120,7 @@ class WindowCovering extends DeconzService.LightsResource {
120
120
  ? this.Characteristics.hap.PositionState.INCREASING
121
121
  : this.Characteristics.hap.PositionState.DECREASING
122
122
  this.moving = new Date()
123
- await this.put({ lift })
123
+ return this.put(this.statePath, { lift })
124
124
  }
125
125
 
126
126
  updateState (state) {
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": "1.0.1",
7
+ "version": "1.0.2",
8
8
  "keywords": [
9
9
  "homebridge-plugin",
10
10
  "homekit",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "hb-deconz-tools": "~1.0.7",
31
- "homebridge-lib": "~6.5.1"
31
+ "homebridge-lib": "~6.6.0"
32
32
  },
33
33
  "scripts": {
34
34
  "prepare": "standard && rm -rf out && jsdoc -c jsdoc.json",