homebridge-deconz 0.0.14 → 0.0.15
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.
@@ -157,7 +157,7 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
157
157
|
this.heartbeatEnabled = true
|
158
158
|
this
|
159
159
|
.on('identify', this.identify)
|
160
|
-
.once('heartbeat', this.
|
160
|
+
.once('heartbeat', (beat) => { this.initialBeat = beat })
|
161
161
|
.on('heartbeat', this.heartbeat)
|
162
162
|
.on('shutdown', this.shutdown)
|
163
163
|
}
|
@@ -182,6 +182,12 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
182
182
|
this.values.manufacturer, this.values.model, this.values.software,
|
183
183
|
this.nAccessories, this.nDevices, this.nResourcesMonitored
|
184
184
|
)
|
185
|
+
if (this.context.migration != null) {
|
186
|
+
this.log(
|
187
|
+
'migration: %s: %d resources',
|
188
|
+
this.context.migration, this.nResourcesMonitored
|
189
|
+
)
|
190
|
+
}
|
185
191
|
if (this.logLevel > 2) {
|
186
192
|
this.vdebug(
|
187
193
|
'%d gateway resouces: %j', this.nResources,
|
@@ -210,28 +216,24 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
210
216
|
}
|
211
217
|
}
|
212
218
|
|
213
|
-
/** Initialise the gateway delegate.
|
214
|
-
*/
|
215
|
-
async init (beat) {
|
216
|
-
try {
|
217
|
-
this.debug('initialising...')
|
218
|
-
this.initialBeat = beat
|
219
|
-
await this.connect()
|
220
|
-
this.initialised = true
|
221
|
-
this.debug('initialised')
|
222
|
-
this.emit('initialised')
|
223
|
-
} catch (error) { this.error(error) }
|
224
|
-
}
|
225
|
-
|
226
219
|
/** Update properties from gateway announcement.
|
227
220
|
* @param {string} host - The gateway hostname or IP address and port.
|
228
221
|
* @param {Object} config - The response body of an unauthenticated
|
229
222
|
* GET `/config` (from {@link DeconzDiscovery#config config()}.
|
230
223
|
*/
|
231
|
-
found (host, config) {
|
232
|
-
|
233
|
-
|
234
|
-
|
224
|
+
async found (host, config) {
|
225
|
+
try {
|
226
|
+
this.context.host = host
|
227
|
+
this.values.host = host
|
228
|
+
this.context.config = config
|
229
|
+
this.values.software = config.swversion
|
230
|
+
if (!this.initialised) {
|
231
|
+
this.debug('initialising...')
|
232
|
+
await this.connect()
|
233
|
+
}
|
234
|
+
} catch (error) {
|
235
|
+
this.error(error)
|
236
|
+
}
|
235
237
|
}
|
236
238
|
|
237
239
|
async shutdown () {
|
@@ -412,8 +414,8 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
412
414
|
for (const id in this.exposeErrorById) {
|
413
415
|
this.resetExposeError(id)
|
414
416
|
}
|
415
|
-
this.context.fullState = null
|
416
417
|
this.pollNext = true
|
418
|
+
this.pollFullState = true
|
417
419
|
} catch (error) {
|
418
420
|
if (
|
419
421
|
error instanceof Deconz.ApiError && error.type === 101 && retry < 8
|
@@ -678,9 +680,11 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
678
680
|
try {
|
679
681
|
this.polling = true
|
680
682
|
this.vdebug('%spolling...', this.pollNext ? 'priority ' : '')
|
681
|
-
if (this.context.fullState == null) {
|
682
|
-
|
683
|
-
|
683
|
+
if (this.context.fullState == null || this.pollFullState) {
|
684
|
+
const fullState = await this.client.get('/')
|
685
|
+
fullState.groups[0] = await this.client.get('/groups/0')
|
686
|
+
this.context.fullState = fullState
|
687
|
+
this.pollFullState = false
|
684
688
|
} else {
|
685
689
|
const config = await this.client.get('/config')
|
686
690
|
if (config.bridgeid === this.id && config.UTC == null) {
|
@@ -712,6 +716,11 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
712
716
|
this.vdebug('polling done')
|
713
717
|
this.pollNext = false
|
714
718
|
this.polling = false
|
719
|
+
if (!this.initialised) {
|
720
|
+
this.initialised = true
|
721
|
+
this.debug('initialised')
|
722
|
+
this.emit('initialised')
|
723
|
+
}
|
715
724
|
}
|
716
725
|
}
|
717
726
|
|
@@ -896,6 +905,7 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
896
905
|
}
|
897
906
|
|
898
907
|
this.nAccessories = Object.keys(this.accessoryById).length
|
908
|
+
this.nResourcesMonitored = Object.keys(this.accessoryByRpath).length
|
899
909
|
this.nExposeErrors = Object.keys(this.exposeErrorById).length
|
900
910
|
if (this.nExposeErrors === 0) {
|
901
911
|
this.vdebug('%d accessories', this.nAccessories)
|
@@ -906,8 +916,6 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
906
916
|
}
|
907
917
|
|
908
918
|
if (changed) {
|
909
|
-
this.nResourcesMonitored = Object.keys(this.accessoryByRpath).length
|
910
|
-
this.identify()
|
911
919
|
if (this.context.migration == null) {
|
912
920
|
const response = await this.client.post('/resourcelinks', {
|
913
921
|
name: 'homebridge-deconz',
|
@@ -921,10 +929,7 @@ class Gateway extends homebridgeLib.AccessoryDelegate {
|
|
921
929
|
links: Object.keys(this.accessoryByRpath).sort()
|
922
930
|
})
|
923
931
|
}
|
924
|
-
this.
|
925
|
-
'migration: %s: %d resources',
|
926
|
-
this.context.migration, this.nResourcesMonitored
|
927
|
-
)
|
932
|
+
this.identify()
|
928
933
|
}
|
929
934
|
}
|
930
935
|
|
package/lib/DeconzPlatform.js
CHANGED
@@ -110,7 +110,8 @@ class DeconzPlatform extends homebridgeLib.Platform {
|
|
110
110
|
host: host
|
111
111
|
})
|
112
112
|
}
|
113
|
-
this.gatewayMap[id].found(host, config)
|
113
|
+
await this.gatewayMap[id].found(host, config)
|
114
|
+
await events.once(this.gatewayMap[id], 'initialised')
|
114
115
|
this.emit('found')
|
115
116
|
}
|
116
117
|
|
@@ -128,17 +129,25 @@ class DeconzPlatform extends homebridgeLib.Platform {
|
|
128
129
|
async init () {
|
129
130
|
try {
|
130
131
|
const jobs = []
|
131
|
-
this.debug('job %d: find at least one gateway', jobs.length)
|
132
|
-
jobs.push(events.once(this, 'found'))
|
133
132
|
if (this.config.hosts.length > 0) {
|
134
133
|
for (const host of this.config.hosts) {
|
135
134
|
this.debug('job %d: find gateway at %s', jobs.length, host)
|
136
135
|
jobs.push(this.findHost(host))
|
137
136
|
}
|
138
137
|
} else {
|
138
|
+
this.debug('job %d: find at least one gateway', jobs.length)
|
139
|
+
jobs.push(events.once(this, 'found'))
|
139
140
|
for (const id in this.gatewayMap) {
|
141
|
+
const gateway = this.gatewayMap[id]
|
142
|
+
const host = gateway.context.host
|
140
143
|
this.debug('job %d: find gateway %s', jobs.length, id)
|
141
|
-
jobs.push(
|
144
|
+
jobs.push(events.once(gateway, 'initialised'))
|
145
|
+
try {
|
146
|
+
const config = await this.discovery.config(host)
|
147
|
+
await this.foundGateway(host, config)
|
148
|
+
} catch (error) {
|
149
|
+
this.warn('%s: %s', id, error)
|
150
|
+
}
|
142
151
|
}
|
143
152
|
}
|
144
153
|
|
@@ -154,6 +163,15 @@ class DeconzPlatform extends homebridgeLib.Platform {
|
|
154
163
|
|
155
164
|
this.log('%d gateways', Object.keys(this.gatewayMap).length)
|
156
165
|
this.emit('initialised')
|
166
|
+
const dumpInfo = {
|
167
|
+
config: this.config,
|
168
|
+
gatewayMap: {}
|
169
|
+
}
|
170
|
+
for (const id in this.gatewayMap) {
|
171
|
+
const gateway = this.gatewayMap[id]
|
172
|
+
dumpInfo.gatewayMap[id] = gateway.context
|
173
|
+
}
|
174
|
+
await this.createDumpFile(dumpInfo)
|
157
175
|
} catch (error) { this.error(error) }
|
158
176
|
}
|
159
177
|
|
@@ -135,7 +135,7 @@ class WindowCovering extends DeconzService.LightsResource {
|
|
135
135
|
this.values.closeUpwards = closeUpwards
|
136
136
|
}
|
137
137
|
if (
|
138
|
-
this.moving == null || new Date() - this.moving >=
|
138
|
+
this.moving == null || new Date() - this.moving >= 30000 || (
|
139
139
|
position === this.values.targetPosition &&
|
140
140
|
(closeUpwards == null || closeUpwards === this.targetCloseUpwards)
|
141
141
|
)
|
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.
|
7
|
+
"version": "0.0.15",
|
8
8
|
"keywords": [
|
9
9
|
"homebridge-plugin",
|
10
10
|
"homekit",
|
@@ -22,11 +22,11 @@
|
|
22
22
|
"engines": {
|
23
23
|
"deCONZ": "2.14.1",
|
24
24
|
"homebridge": "^1.4.0",
|
25
|
-
"node": "^16.14.
|
25
|
+
"node": "^16.14.2"
|
26
26
|
},
|
27
27
|
"dependencies": {
|
28
|
-
"homebridge-lib": "~5.
|
29
|
-
"semver": "^7.3.
|
28
|
+
"homebridge-lib": "~5.4.0",
|
29
|
+
"semver": "^7.3.7",
|
30
30
|
"ws": "^8.5.0",
|
31
31
|
"xml2js": "~0.4.23"
|
32
32
|
},
|