homebridge-deconz 1.3.0 → 1.3.1

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/ui.js CHANGED
@@ -344,58 +344,10 @@ class Main extends CommandLineTool {
344
344
  const client = new HttpClient({
345
345
  host,
346
346
  json: true,
347
+ logger: this,
347
348
  name: host,
348
349
  timeout: this.clargs.options.timeout
349
350
  })
350
- client
351
- .on('error', (error) => {
352
- if (error.request.id !== this.requestId) {
353
- if (error.request.body == null) {
354
- this.log(
355
- '%s: request %d: %s %s', error.request.name, error.request.id,
356
- error.request.method, error.request.resource
357
- )
358
- } else {
359
- this.log(
360
- '%s: request %d: %s %s %s', error.request.name, error.request.id,
361
- error.request.method, error.request.resource, error.request.body
362
- )
363
- }
364
- this.requestId = error.request.id
365
- }
366
- this.error('%s: request %d: %s', error.request.name, error.request.id, error)
367
- })
368
- .on('request', (request) => {
369
- if (request.body == null) {
370
- this.debug(
371
- '%s: request %d: %s %s', request.name, request.id,
372
- request.method, request.resource
373
- )
374
- this.vdebug(
375
- '%s: request %d: %s %s', request.name, request.id,
376
- request.method, request.url
377
- )
378
- } else {
379
- this.debug(
380
- '%s: request %d: %s %s %s', request.name, request.id,
381
- request.method, request.resource, request.body
382
- )
383
- this.vdebug(
384
- '%s: request %d: %s %s %s', request.name, request.id,
385
- request.method, request.url, request.body
386
- )
387
- }
388
- })
389
- .on('response', (response) => {
390
- this.vdebug(
391
- '%s: request %d: response: %j', response.request.name, response.request.id,
392
- response.body
393
- )
394
- this.debug(
395
- '%s: request %d: %d %s', response.request.name, response.request.id,
396
- response.statusCode, response.statusMessage
397
- )
398
- })
399
351
  const response = await client.get('/ping')
400
352
  if (response.body !== 'pong') {
401
353
  throw new Error(`${host}: cannot ping`)
@@ -1159,22 +1159,6 @@ class Resource {
1159
1159
  break
1160
1160
  case 'icasa':
1161
1161
  switch (this.model) {
1162
- case 'ICZB-KPD12':
1163
- case 'ICZB-KPD14S':
1164
- case 'ICZB-KPD18S':
1165
- buttons.push([1, 'Off', SINGLE | LONG])
1166
- buttons.push([2, 'On', SINGLE | LONG])
1167
- if (this.model !== 'ICZB-KPD12') {
1168
- buttons.push([3, 'S1', SINGLE])
1169
- buttons.push([4, 'S2', SINGLE])
1170
- if (this.model === 'ICZB-KPD18S') {
1171
- buttons.push([5, 'S3', SINGLE])
1172
- buttons.push([6, 'S4', SINGLE])
1173
- buttons.push([7, 'S5', SINGLE])
1174
- buttons.push([8, 'S6', SINGLE])
1175
- }
1176
- }
1177
- break
1178
1162
  case 'ICZB-RM11S':
1179
1163
  buttons.push([1, '1 Off', SINGLE | LONG])
1180
1164
  buttons.push([2, '1 On', SINGLE | LONG])
@@ -21,8 +21,6 @@ import { DeconzService } from '../DeconzService/index.js'
21
21
  import '../DeconzService/Button.js'
22
22
  import '../DeconzService/Gateway.js'
23
23
 
24
- const { HttpError } = ApiClient
25
-
26
24
  const migration = {
27
25
  name: 'homebridge-deconz',
28
26
  description: 'migration',
@@ -275,12 +273,8 @@ class Gateway extends AccessoryDelegate {
275
273
  .on('identify', this.identify)
276
274
  .once('heartbeat', async (beat) => {
277
275
  this.initialBeat = beat
278
- try {
279
- await this.createClient()
280
- } catch (error) { this.warn(error) }
281
276
  })
282
277
  .on('heartbeat', this.heartbeat)
283
- .on('shutdown', this.shutdown)
284
278
  }
285
279
 
286
280
  get transitionTime () { return this.service.values.transitionTime }
@@ -352,10 +346,6 @@ class Gateway extends AccessoryDelegate {
352
346
  this.values.https = config.https
353
347
  this.values.software = config.swversion
354
348
  this.values.url = 'http' + (config.https ? 's' : '') + '://' + host
355
- if (!this.initialised) {
356
- this.debug('initialising...')
357
- await this.connect()
358
- }
359
349
  } catch (error) {
360
350
  this.error(error)
361
351
  }
@@ -419,53 +409,16 @@ class Gateway extends AccessoryDelegate {
419
409
  this.client = new ApiClient({
420
410
  apiKey: this.values.apiKey,
421
411
  config: this.context.config,
422
- https: this.values.https,
423
412
  fingerprint: this.values.fingerprint,
424
413
  host: this.values.host,
414
+ https: this.values.https,
415
+ logger: this,
425
416
  maxSockets: this.platform.config.parallelRequests,
426
417
  timeout: this.platform.config.timeout,
427
418
  waitTimePut: this.platform.config.waitTimePut,
428
419
  waitTimePutGroup: this.platform.config.waitTimePutGroup,
429
420
  waitTimeResend: this.platform.config.waitTimeResend
430
421
  })
431
- this.client
432
- .on('error', (error) => {
433
- if (error instanceof HttpError) {
434
- if (error.request.id !== this.requestId) {
435
- this.log(
436
- 'request %d: %s %s%s', error.request.id,
437
- error.request.method, error.request.resource,
438
- error.request.body == null ? '' : ' ' + error.request.body
439
- )
440
- this.requestId = error.request.id
441
- }
442
- this.warn('request %s: %s', error.request.id, error)
443
- return
444
- }
445
- this.warn(error)
446
- })
447
- .on('request', (request) => {
448
- this.debug(
449
- 'request %d: %s %s%s', request.id,
450
- request.method, request.resource,
451
- request.body == null ? '' : ' ' + request.body
452
- )
453
- this.vdebug(
454
- 'request %s: %s %s%s', request.id,
455
- request.method, request.url,
456
- request.body == null ? '' : ' ' + request.body
457
- )
458
- })
459
- .on('response', (response) => {
460
- this.vdebug(
461
- 'request %d: response: %j', response.request.id,
462
- response.body
463
- )
464
- this.debug(
465
- 'request %s: %d %s', response.request.id,
466
- response.statusCode, response.statusMessage
467
- )
468
- })
469
422
  return this.connect()
470
423
  }
471
424
 
@@ -1378,25 +1331,26 @@ class Gateway extends AccessoryDelegate {
1378
1331
  const resource = new Deconz.Resource(this, rtype, rid, body)
1379
1332
  const { id, serviceName } = resource
1380
1333
  // FIX_ME: check introspect against whitelist
1381
- if (logUnsupported && resource.body.type === 'ZHASwitch') {
1334
+ if (resource.body.type === 'ZHASwitch') {
1382
1335
  if (!resource.capabilities._introspect) {
1383
- this.warn(
1336
+ warn(
1384
1337
  '%s: /sensors/%d: %s by %s: no introspect',
1385
1338
  id, rid, resource.model, resource.manufacturer
1386
1339
  )
1387
1340
  }
1388
- } else if (resource.capabilities._buttons != null) {
1341
+ }
1342
+ if (resource.capabilities._buttons != null) {
1389
1343
  if (
1390
1344
  JSON.stringify(resource.capabilities._buttons) !==
1391
1345
  JSON.stringify(resource.capabilities.buttons) ||
1392
1346
  resource.capabilities._namespace !== resource.capabilities.namespace
1393
1347
  ) {
1394
- this.debug(
1348
+ debug(
1395
1349
  '%s: /sensors/%d: %s by %s: whitelist vs introspect mismatch: %j',
1396
1350
  id, rid, resource.model, resource.manufacturer, resource.capabilities
1397
1351
  )
1398
1352
  } else {
1399
- this.warn(
1353
+ warn(
1400
1354
  '%s: /sensors/%d: %s by %s: whitelist matches introspect',
1401
1355
  id, rid, resource.model, resource.manufacturer
1402
1356
  )
@@ -6,7 +6,6 @@
6
6
  import { once } from 'node:events'
7
7
 
8
8
  import { timeout } from 'homebridge-lib'
9
- import { HttpClient } from 'homebridge-lib/HttpClient'
10
9
  import { OptionParser } from 'homebridge-lib/OptionParser'
11
10
  import { Platform } from 'homebridge-lib/Platform'
12
11
 
@@ -67,41 +66,9 @@ class DeconzPlatform extends Platform {
67
66
  this.config.hosts.push(this.config.host)
68
67
  }
69
68
  this.discovery = new Discovery({
69
+ logger: this,
70
70
  timeout: this.config.timeout
71
71
  })
72
- this.discovery
73
- .on('error', (error) => {
74
- if (error instanceof HttpClient.HttpError) {
75
- this.log(
76
- '%s: request %d: %s %s', error.request.name,
77
- error.request.id, error.request.method, error.request.resource
78
- )
79
- this.warn(
80
- '%s: request %d: %s', error.request.name, error.request.id, error
81
- )
82
- return
83
- }
84
- this.warn(error)
85
- })
86
- .on('request', (request) => {
87
- this.debug(
88
- '%s: request %d: %s %s', request.name,
89
- request.id, request.method, request.resource
90
- )
91
- })
92
- .on('response', (response) => {
93
- this.debug(
94
- '%s: request %d: %d %s', response.request.name,
95
- response.request.id, response.statusCode, response.statusMessage
96
- )
97
- })
98
- .on('found', (name, id, address) => {
99
- this.debug('%s: found %s at %s', name, id, address)
100
- })
101
- .on('searching', (host) => {
102
- this.debug('upnp: listening on %s', host)
103
- })
104
- .on('searchDone', () => { this.debug('upnp: search done') })
105
72
  } catch (error) {
106
73
  this.error(error)
107
74
  }
@@ -111,10 +78,10 @@ class DeconzPlatform extends Platform {
111
78
  const id = config.bridgeid
112
79
  if (this.gatewayMap[id] == null) {
113
80
  this.gatewayMap[id] = new DeconzAccessory.Gateway(this, { config, host })
114
- }
115
- await this.gatewayMap[id].found(host, config)
116
- if (!this.gatewayMap[id].initialised) {
81
+ await this.gatewayMap[id].found(host, config)
117
82
  await once(this.gatewayMap[id], 'initialised')
83
+ } else {
84
+ await this.gatewayMap[id].found(host, config)
118
85
  }
119
86
  this.emit('found')
120
87
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "ebaauw"
8
8
  ],
9
9
  "license": "Apache-2.0",
10
- "version": "1.3.0",
10
+ "version": "1.3.1",
11
11
  "keywords": [
12
12
  "homebridge-plugin",
13
13
  "homekit",
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "engines": {
29
29
  "deCONZ": "2.32.5",
30
- "homebridge": "^1.11.2||^2.0.0-beta",
31
- "node": "^24||^22||^20"
30
+ "homebridge": "^2.0.1",
31
+ "node": "^24||^22"
32
32
  },
33
33
  "dependencies": {
34
- "hb-deconz-tools": "~3.0.0",
35
- "homebridge-lib": "~7.3.2"
34
+ "hb-deconz-tools": "~3.0.3",
35
+ "homebridge-lib": "~8.1.0"
36
36
  },
37
37
  "scripts": {
38
38
  "prepare": "standard && rm -rf out && jsdoc -c jsdoc.json",