homebridge-deconz 0.0.26 → 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 (41) hide show
  1. package/config.schema.json +0 -7
  2. package/lib/Deconz/ApiError.js +12 -5
  3. package/lib/Deconz/ApiResponse.js +10 -7
  4. package/lib/Deconz/Resource.js +27 -4
  5. package/lib/DeconzAccessory/AirPurifier.js +0 -2
  6. package/lib/DeconzAccessory/Gateway.js +297 -147
  7. package/lib/DeconzAccessory/Light.js +32 -61
  8. package/lib/DeconzAccessory/Sensor.js +89 -1
  9. package/lib/DeconzAccessory/Thermostat.js +5 -8
  10. package/lib/DeconzAccessory/WarningDevice.js +2 -13
  11. package/lib/DeconzAccessory/WindowCovering.js +0 -2
  12. package/lib/DeconzAccessory/index.js +123 -13
  13. package/lib/DeconzPlatform.js +12 -20
  14. package/lib/DeconzService/AirPressure.js +8 -1
  15. package/lib/DeconzService/AirPurifier.js +2 -2
  16. package/lib/DeconzService/AirQuality.js +1 -1
  17. package/lib/DeconzService/Alarm.js +1 -1
  18. package/lib/DeconzService/Battery.js +21 -10
  19. package/lib/DeconzService/Button.js +1 -0
  20. package/lib/DeconzService/CarbonMonoxide.js +1 -1
  21. package/lib/DeconzService/Consumption.js +3 -1
  22. package/lib/DeconzService/Contact.js +1 -25
  23. package/lib/DeconzService/Daylight.js +22 -19
  24. package/lib/DeconzService/Flag.js +1 -1
  25. package/lib/DeconzService/Gateway.js +48 -0
  26. package/lib/DeconzService/Humidity.js +1 -1
  27. package/lib/DeconzService/Leak.js +1 -1
  28. package/lib/DeconzService/Light.js +121 -74
  29. package/lib/DeconzService/LightLevel.js +3 -3
  30. package/lib/DeconzService/LightsResource.js +24 -18
  31. package/lib/DeconzService/Motion.js +3 -9
  32. package/lib/DeconzService/Power.js +2 -1
  33. package/lib/DeconzService/Status.js +1 -1
  34. package/lib/DeconzService/WindowCovering.js +14 -4
  35. package/lib/DeconzService/index.js +14 -3
  36. package/package.json +6 -6
  37. package/lib/DeconzAccessory/Contact.js +0 -54
  38. package/lib/DeconzAccessory/Motion.js +0 -54
  39. package/lib/DeconzAccessory/Temperature.js +0 -63
  40. package/lib/DeconzService/DeviceSettings.js +0 -56
  41. package/lib/DeconzService/GatewaySettings.js +0 -175
@@ -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') }
@@ -50,7 +49,8 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
50
49
  name: resource.body.name,
51
50
  Service: params.Service,
52
51
  subtype: resource.subtype,
53
- primaryService: params.primaryService
52
+ primaryService: params.primaryService,
53
+ exposeConfiguredName: true
54
54
  })
55
55
  this.id = resource.id
56
56
  this.gateway = accessory.gateway
@@ -62,6 +62,14 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
62
62
  this.capabilities = resource.capabilities
63
63
 
64
64
  this.serviceNameByRpath = {}
65
+
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
+ // })
65
73
  }
66
74
 
67
75
  addResource (resource) {
@@ -80,6 +88,9 @@ class DeconzService extends homebridgeLib.ServiceDelegate {
80
88
  }
81
89
  return
82
90
  }
91
+ // if (body.name != null) {
92
+ // this.values.configuredName = body.name.slice(0, 31).trim()
93
+ // }
83
94
  if (body.lastseen != null && this.rtype === 'lights') {
84
95
  this.values.lastSeen = dateToString(body.lastseen)
85
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.26",
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.0"
23
+ "deCONZ": "2.19.3",
24
+ "homebridge": "^1.6.0",
25
+ "node": "^18.13.0"
26
26
  },
27
27
  "dependencies": {
28
- "homebridge-lib": "~5.7.2",
29
- "ws": "^8.10.0",
28
+ "homebridge-lib": "~6.3.4",
29
+ "ws": "^8.12.0",
30
30
  "xml2js": "~0.4.23"
31
31
  },
32
32
  "scripts": {
@@ -1,54 +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(
39
- this, {},
40
- this.service.characteristicDelegate('contact'),
41
- this.service.characteristicDelegate('timesOpened'),
42
- this.service.characteristicDelegate('lastActivation')
43
- )
44
-
45
- this.createSettingsService()
46
-
47
- setImmediate(() => {
48
- this.debug('initialised')
49
- this.emit('initialised')
50
- })
51
- }
52
- }
53
-
54
- module.exports = Contact
@@ -1,54 +0,0 @@
1
- // homebridge-deconz/lib/DeconzAccessory/Motion.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
- class Motion extends DeconzAccessory {
14
- /** Instantiate a delegate for an accessory corresponding to a device.
15
- * @param {DeconzAccessory.Gateway} gateway - The gateway.
16
- * @param {Deconz.Device} device - The device.
17
- */
18
- constructor (gateway, device) {
19
- super(gateway, device, gateway.Accessory.Categories.SENSOR)
20
-
21
- this.identify()
22
-
23
- this.service = this.createService(device.resource, { primaryService: true })
24
-
25
- for (const subtype in device.resourceBySubtype) {
26
- const resource = device.resourceBySubtype[subtype]
27
- if (subtype === device.primary) {
28
- continue
29
- }
30
- this.createService(resource)
31
- }
32
-
33
- this.historyService = new History.Motion(
34
- this, {},
35
- this.service.characteristicDelegate('motion'),
36
- this.service.characteristicDelegate('lastActivation'),
37
- this.serviceByServiceName.LightLevel == null
38
- ? null
39
- : this.serviceByServiceName.LightLevel.characteristicDelegate('lightlevel'),
40
- this.serviceByServiceName.Temperature == null
41
- ? null
42
- : this.serviceByServiceName.Temperature.characteristicDelegate('temperature')
43
- )
44
-
45
- this.createSettingsService()
46
-
47
- setImmediate(() => {
48
- this.debug('initialised')
49
- this.emit('initialised')
50
- })
51
- }
52
- }
53
-
54
- module.exports = Motion
@@ -1,63 +0,0 @@
1
- // homebridge-deconz/lib/DeconzAccessory/Temperature.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
- class Temperature extends DeconzAccessory {
14
- /** Instantiate a delegate for an accessory corresponding to a device.
15
- * @param {DeconzAccessory.Gateway} gateway - The gateway.
16
- * @param {Deconz.Device} device - The device.
17
- */
18
- constructor (gateway, device, settings = {}) {
19
- super(gateway, device, gateway.Accessory.Categories.SENSOR)
20
- this.identify()
21
-
22
- this.service = this.createService(device.resource, { primaryService: true })
23
-
24
- for (const subtype in device.resourceBySubtype) {
25
- const resource = device.resourceBySubtype[subtype]
26
- if (subtype === device.primary) {
27
- continue
28
- }
29
- this.createService(resource)
30
- }
31
-
32
- if (this.serviceByServiceName.AirQuality == null) {
33
- this.historyService = new History.Weather(
34
- this, {},
35
- this.service.characteristicDelegate('temperature'),
36
- this.serviceByServiceName.Humidity == null
37
- ? null
38
- : this.serviceByServiceName.Humidity.characteristicDelegate('humidity'),
39
- this.serviceByServiceName.AirPressure == null
40
- ? null
41
- : this.serviceByServiceName.AirPressure.characteristicDelegate('airPressure')
42
- )
43
- } else {
44
- this.historyService = new History.Room(
45
- this, {},
46
- this.service.characteristicDelegate('temperature'),
47
- this.serviceByServiceName.Humidity == null
48
- ? null
49
- : this.serviceByServiceName.Humidity.characteristicDelegate('humidity'),
50
- this.serviceByServiceName.AirQuality.characteristicDelegate('vocDensity')
51
- )
52
- }
53
-
54
- this.createSettingsService()
55
-
56
- setImmediate(() => {
57
- this.debug('initialised')
58
- this.emit('initialised')
59
- })
60
- }
61
- }
62
-
63
- module.exports = Temperature
@@ -1,56 +0,0 @@
1
- // homebridge-deconz/lib/DeconzService/DeviceSettings.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 DeconzDevice service.
11
- * @extends ServiceDelegate
12
- * @memberof DeconzService
13
- */
14
- class DeviceSettings extends homebridgeLib.ServiceDelegate {
15
- constructor (accessory, params = {}) {
16
- params.Service = accessory.Services.my.DeconzDevice
17
- super(accessory, params)
18
-
19
- this.debug('settings: %j', params)
20
-
21
- this.addCharacteristicDelegate({
22
- key: 'expose',
23
- Characteristic: this.Characteristics.my.Expose,
24
- value: params.expose,
25
- silent: true
26
- }).on('didSet', (value) => {
27
- accessory.gateway.exposeDevice(params.subtype, value)
28
- })
29
-
30
- if (params.hasRepeat != null) {
31
- this.addCharacteristicDelegate({
32
- key: 'repeat',
33
- Characteristic: this.Characteristics.my.Repeat,
34
- props: { minValue: 0, maxValue: 1, minStep: 1 },
35
- value: 0
36
- })
37
- }
38
-
39
- if (params.logLevel != null) {
40
- this.addCharacteristicDelegate({
41
- key: 'logLevel',
42
- Characteristic: this.Characteristics.my.LogLevel,
43
- value: params.logLevel
44
- })
45
- }
46
-
47
- this.addCharacteristicDelegate({
48
- key: 'resource',
49
- Characteristic: this.Characteristics.my.Resource,
50
- value: params.resource,
51
- silent: true
52
- })
53
- }
54
- }
55
-
56
- module.exports = DeviceSettings
@@ -1,175 +0,0 @@
1
- // homebridge-deconz/lib/DeconzService/GatewaySettings.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 GatewaySettings extends homebridgeLib.ServiceDelegate {
15
- constructor (gateway, params = {}) {
16
- params.Service = gateway.Services.my.DeconzGateway
17
- super(gateway, params)
18
- this.gateway = gateway
19
-
20
- this.addCharacteristicDelegate({
21
- key: 'expose',
22
- Characteristic: this.Characteristics.my.Expose,
23
- value: true
24
- }).on('didSet', async (value, fromHomeKit) => {
25
- try {
26
- this.values.statusActve = value
27
- if (value) {
28
- await gateway.connect()
29
- } else if (fromHomeKit) {
30
- await gateway.reset()
31
- }
32
- } catch (error) { this.error(error) }
33
- })
34
-
35
- this.addCharacteristicDelegate({
36
- key: 'lights',
37
- Characteristic: this.Characteristics.my.ExposeLights,
38
- value: false
39
- }).on('didSet', (value) => { this.updateRtypes('lights', value) })
40
-
41
- this.addCharacteristicDelegate({
42
- key: 'sensors',
43
- Characteristic: this.Characteristics.my.ExposeSensors,
44
- value: false
45
- }).on('didSet', (value) => { this.updateRtypes('sensors', value) })
46
-
47
- this.addCharacteristicDelegate({
48
- key: 'groups',
49
- Characteristic: this.Characteristics.my.ExposeGroups,
50
- value: false
51
- }).on('didSet', (value) => { this.updateRtypes('groups', value) })
52
-
53
- this.addCharacteristicDelegate({
54
- key: 'schedules',
55
- Characteristic: this.Characteristics.my.ExposeSchedules,
56
- value: false
57
- })
58
-
59
- this.addCharacteristicDelegate({
60
- key: 'heartrate',
61
- Characteristic: this.Characteristics.my.Heartrate,
62
- value: 30
63
- })
64
-
65
- this.addCharacteristicDelegate({
66
- key: 'lastUpdated',
67
- Characteristic: this.Characteristics.my.LastUpdated,
68
- silent: true
69
- })
70
-
71
- this.addCharacteristicDelegate({
72
- key: 'logLevel',
73
- Characteristic: this.Characteristics.my.LogLevel,
74
- value: this.accessoryDelegate.logLevel
75
- })
76
-
77
- this.addCharacteristicDelegate({
78
- key: 'restart',
79
- Characteristic: this.Characteristics.my.Restart,
80
- value: false
81
- }).on('didSet', async (value, fromHomeKit) => {
82
- try {
83
- if (value) {
84
- try {
85
- await gateway.client.restart()
86
- this.values.search = false
87
- this.values.unlock = false
88
- return
89
- } catch (error) { this.warn(error) }
90
- }
91
- if (fromHomeKit) {
92
- await homebridgeLib.timeout(this.platform.config.waitTimeReset)
93
- this.values.restart = !value
94
- }
95
- } catch (error) { this.error(error) }
96
- })
97
- this.values.restart = false
98
-
99
- this.addCharacteristicDelegate({
100
- key: 'search',
101
- Characteristic: this.Characteristics.my.Search,
102
- value: false
103
- }).on('didSet', async (value, fromHomeKit) => {
104
- try {
105
- if (value) {
106
- try {
107
- await gateway.client.search()
108
- await homebridgeLib.timeout(120000)
109
- this.values.search = false
110
- return
111
- } catch (error) { this.warn(error) }
112
- }
113
- if (fromHomeKit) {
114
- await homebridgeLib.timeout(this.platform.config.waitTimeReset)
115
- this.values.search = !value
116
- }
117
- } catch (error) { this.error(error) }
118
- })
119
- this.values.search = false
120
-
121
- this.addCharacteristicDelegate({
122
- key: 'statusActve',
123
- Characteristic: this.Characteristics.hap.StatusActive,
124
- value: true,
125
- silent: true
126
- })
127
-
128
- this.addCharacteristicDelegate({
129
- key: 'transitionTime',
130
- Characteristic: this.Characteristics.my.TransitionTime,
131
- value: this.gateway.defaultTransitionTime
132
- })
133
- this.values.transitionTime = this.gateway.defaultTransitionTime
134
-
135
- this.addCharacteristicDelegate({
136
- key: 'unlock',
137
- Characteristic: this.Characteristics.my.Unlock,
138
- value: false
139
- }).on('didSet', async (value, fromHomeKit) => {
140
- try {
141
- if (value) {
142
- try {
143
- await gateway.client.unlock()
144
- await homebridgeLib.timeout(60000)
145
- this.values.unlock = false
146
- return
147
- } catch (error) { this.warn(error) }
148
- }
149
- if (fromHomeKit) {
150
- await homebridgeLib.timeout(this.platform.config.waitTimeReset)
151
- this.values.unlock = !value
152
- }
153
- } catch (error) { this.error(error) }
154
- })
155
- this.values.unlock = false
156
- }
157
-
158
- async updateRtypes (rtype, value) {
159
- const rtypes = this.gateway.values.rtypes.slice()
160
- if (value) {
161
- rtypes.push(rtype)
162
- } else {
163
- rtypes.splice(rtypes.indexOf(rtype), 1)
164
- }
165
- this.gateway.values.rtypes = rtypes
166
- }
167
-
168
- update (config) {
169
- this.values.expose = true
170
- this.values.lastUpdated = new Date().toString().slice(0, 24)
171
- this.values.restart = false
172
- }
173
- }
174
-
175
- module.exports = GatewaySettings