homebridge-deconz 1.0.12 → 1.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.
- package/cli/deconz.js +6 -4
- package/cli/otau.js +6 -4
- package/cli/ui.js +10 -7
- package/homebridge-ui/server.js +2 -4
- package/index.js +7 -3
- package/lib/Deconz/Device.js +10 -2
- package/lib/Deconz/Resource.js +19 -12
- package/lib/Deconz/index.js +2 -7
- package/lib/DeconzAccessory/AirPurifier.js +2 -4
- package/lib/DeconzAccessory/Gateway.js +68 -12
- package/lib/DeconzAccessory/Light.js +30 -21
- package/lib/DeconzAccessory/Sensor.js +4 -4
- package/lib/DeconzAccessory/Thermostat.js +4 -4
- package/lib/DeconzAccessory/WarningDevice.js +4 -4
- package/lib/DeconzAccessory/WindowCovering.js +2 -4
- package/lib/DeconzAccessory/index.js +7 -13
- package/lib/DeconzPlatform.js +14 -9
- package/lib/DeconzService/AirPressure.js +3 -4
- package/lib/DeconzService/AirPurifier.js +3 -4
- package/lib/DeconzService/AirQuality.js +4 -4
- package/lib/DeconzService/Alarm.js +3 -4
- package/lib/DeconzService/Battery.js +7 -4
- package/lib/DeconzService/Button.js +3 -3
- package/lib/DeconzService/CarbonMonoxide.js +3 -4
- package/lib/DeconzService/Consumption.js +4 -4
- package/lib/DeconzService/Contact.js +3 -4
- package/lib/DeconzService/Daylight.js +4 -4
- package/lib/DeconzService/Flag.js +3 -4
- package/lib/DeconzService/Gateway.js +3 -3
- package/lib/DeconzService/Humidity.js +3 -4
- package/lib/DeconzService/Label.js +3 -4
- package/lib/DeconzService/Leak.js +3 -4
- package/lib/DeconzService/Light.js +7 -4
- package/lib/DeconzService/LightLevel.js +4 -4
- package/lib/DeconzService/LightsResource.js +3 -4
- package/lib/DeconzService/Motion.js +3 -4
- package/lib/DeconzService/Outlet.js +3 -4
- package/lib/DeconzService/Power.js +4 -4
- package/lib/DeconzService/Schedule.js +5 -4
- package/lib/DeconzService/SensorsResource.js +3 -4
- package/lib/DeconzService/Smoke.js +3 -4
- package/lib/DeconzService/Status.js +3 -4
- package/lib/DeconzService/Switch.js +3 -4
- package/lib/DeconzService/Temperature.js +3 -4
- package/lib/DeconzService/Thermostat.js +3 -4
- package/lib/DeconzService/Valve.js +4 -6
- package/lib/DeconzService/WarningDevice.js +4 -4
- package/lib/DeconzService/WindowCovering.js +4 -4
- package/lib/DeconzService/index.js +3 -36
- package/package.json +9 -5
package/cli/deconz.js
CHANGED
@@ -5,9 +5,11 @@
|
|
5
5
|
//
|
6
6
|
// Command line interface to deCONZ gateway.
|
7
7
|
|
8
|
-
|
8
|
+
import { createRequire } from 'node:module'
|
9
9
|
|
10
|
-
|
11
|
-
const pkgJson = require('../package.json')
|
10
|
+
import { DeconzTool } from 'hb-deconz-tools/DeconzTool'
|
12
11
|
|
13
|
-
|
12
|
+
const require = createRequire(import.meta.url)
|
13
|
+
const packageJson = require('../package.json')
|
14
|
+
|
15
|
+
new DeconzTool(packageJson).main()
|
package/cli/otau.js
CHANGED
@@ -5,9 +5,11 @@
|
|
5
5
|
//
|
6
6
|
// Command line interface to deCONZ gateway.
|
7
7
|
|
8
|
-
|
8
|
+
import { createRequire } from 'node:module'
|
9
9
|
|
10
|
-
|
11
|
-
const pkgJson = require('../package.json')
|
10
|
+
import { OtauTool } from 'hb-deconz-tools/OtauTool'
|
12
11
|
|
13
|
-
|
12
|
+
const require = createRequire(import.meta.url)
|
13
|
+
const packageJson = require('../package.json')
|
14
|
+
|
15
|
+
new OtauTool(packageJson).main()
|
package/cli/ui.js
CHANGED
@@ -5,13 +5,16 @@
|
|
5
5
|
//
|
6
6
|
// Command line interface to Homebridge deCONZ UI Server.
|
7
7
|
|
8
|
-
|
8
|
+
import { readFile } from 'node:fs/promises'
|
9
|
+
import { createRequire } from 'node:module'
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
11
|
+
import { CommandLineParser } from 'hb-lib-tools/CommandLineParser'
|
12
|
+
import { CommandLineTool } from 'hb-lib-tools/CommandLineTool'
|
13
|
+
import { HttpClient } from 'hb-lib-tools/HttpClient'
|
14
|
+
import { JsonFormatter } from 'hb-lib-tools/JsonFormatter'
|
15
|
+
import { OptionParser } from 'hb-lib-tools/OptionParser'
|
16
|
+
|
17
|
+
const require = createRequire(import.meta.url)
|
15
18
|
const packageJson = require('../package.json')
|
16
19
|
|
17
20
|
const { b, u } = CommandLineTool
|
@@ -247,7 +250,7 @@ class Main extends CommandLineTool {
|
|
247
250
|
*/
|
248
251
|
async readJsonFile (filename) {
|
249
252
|
this.vdebug('reading %s', filename)
|
250
|
-
const text = await
|
253
|
+
const text = await readFile(filename)
|
251
254
|
this.debug('%s: %d bytes', filename, text.length)
|
252
255
|
const body = JSON.parse(text)
|
253
256
|
this.vdebug('%s: %j', filename, body)
|
package/homebridge-ui/server.js
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
// Homebridge plug-in for deCONZ.
|
4
4
|
// Copyright © 2022-2024 Erik Baauw. All rights reserved.
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
const { UiServer } = require('homebridge-lib')
|
9
|
-
const { Discovery } = require('hb-deconz-tools')
|
6
|
+
import { UiServer } from 'hb-lib-tools/UiServer'
|
7
|
+
import { Discovery } from 'hb-deconz-tools/Discovery'
|
10
8
|
|
11
9
|
class DeconzUiServer extends UiServer {
|
12
10
|
constructor () {
|
package/index.js
CHANGED
@@ -3,11 +3,15 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { createRequire } from 'node:module'
|
7
7
|
|
8
|
-
|
8
|
+
import { DeconzPlatform } from './lib/DeconzPlatform.js'
|
9
|
+
|
10
|
+
const require = createRequire(import.meta.url)
|
9
11
|
const packageJson = require('./package.json')
|
10
12
|
|
11
|
-
|
13
|
+
function main (homebridge) {
|
12
14
|
DeconzPlatform.loadPlatform(homebridge, packageJson, 'deCONZ', DeconzPlatform)
|
13
15
|
}
|
16
|
+
|
17
|
+
export { main as default }
|
package/lib/Deconz/Device.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { Deconz } from './index.js'
|
7
7
|
|
8
8
|
/** Delegate class for a Zigbee or virtual device on a deCONZ gateway.
|
9
9
|
*
|
@@ -61,6 +61,11 @@ class Device {
|
|
61
61
|
* @type {boolean}
|
62
62
|
*/
|
63
63
|
this.zigbee = resource.zigbee
|
64
|
+
|
65
|
+
/** Device has a resource with `config.battery` in their `body`.
|
66
|
+
* @type {boolean}
|
67
|
+
*/
|
68
|
+
this.hasBattery = resource.body.config?.battery !== undefined
|
64
69
|
}
|
65
70
|
|
66
71
|
/** The delegate of the primary resource of the device.
|
@@ -105,6 +110,9 @@ class Device {
|
|
105
110
|
this.subtypesByServiceName[resource.serviceName].push(resource.subtype)
|
106
111
|
}
|
107
112
|
this.resourceBySubtype[subtype] = resource
|
113
|
+
if (resource.body.config?.battery !== undefined) {
|
114
|
+
this.hasBattery = true
|
115
|
+
}
|
108
116
|
const p = this.resourceBySubtype[this.primary]
|
109
117
|
if (p.rtype === rtype && p.prio < prio) {
|
110
118
|
this.primary = resource.subtype
|
@@ -112,4 +120,4 @@ class Device {
|
|
112
120
|
}
|
113
121
|
}
|
114
122
|
|
115
|
-
|
123
|
+
Deconz.Device = Device
|
package/lib/Deconz/Resource.js
CHANGED
@@ -3,12 +3,15 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { OptionParser } from 'homebridge-lib/OptionParser'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
import { ApiClient } from 'hb-deconz-tools/ApiClient'
|
9
|
+
|
10
|
+
import { Deconz } from './index.js'
|
11
|
+
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
12
|
+
import '../DeconzAccessory/Gateway.js'
|
13
|
+
import { DeconzService } from '../DeconzService/index.js'
|
14
|
+
import '../DeconzService/Button.js'
|
12
15
|
|
13
16
|
const { toInstance, toInt, toObject, toString } = OptionParser
|
14
17
|
const { buttonEvent } = ApiClient
|
@@ -109,6 +112,9 @@ class Resource {
|
|
109
112
|
*/
|
110
113
|
this.body = toObject('body', body)
|
111
114
|
toString('body.name', body.name, true)
|
115
|
+
body.name = body.name.replace(/[^\p{L}\p{N} ']/ug, ' ')
|
116
|
+
.replace(/^[ ']*/, '')
|
117
|
+
.replace(/[ ']*$/, '')
|
112
118
|
toString('body.type', body.type, true)
|
113
119
|
|
114
120
|
let realDevice = false
|
@@ -299,6 +305,7 @@ class Resource {
|
|
299
305
|
case 'Consumption': return 'Consumption'
|
300
306
|
// case 'DoorLock': return null
|
301
307
|
case 'Daylight': return 'Daylight'
|
308
|
+
case 'DaylightOffset': return ''
|
302
309
|
case 'Fire': return 'Smoke'
|
303
310
|
case 'GenericFlag': return 'Flag'
|
304
311
|
case 'GenericStatus': return 'Status'
|
@@ -533,7 +540,7 @@ class Resource {
|
|
533
540
|
buttons.push([2, 'Close', SINGLE | LONG])
|
534
541
|
break
|
535
542
|
case 'TRADFRI remote control':
|
536
|
-
buttons.push([1, '
|
543
|
+
buttons.push([1, 'Power', SINGLE])
|
537
544
|
buttons.push([2, 'Dim Up', SINGLE | LONG])
|
538
545
|
buttons.push([3, 'Dim Down', SINGLE | LONG])
|
539
546
|
buttons.push([4, 'Previous', SINGLE | LONG])
|
@@ -577,7 +584,7 @@ class Resource {
|
|
577
584
|
case 'LDS':
|
578
585
|
switch (this.model) {
|
579
586
|
case 'ZBT-DIMController-D0800':
|
580
|
-
buttons.push([1, '
|
587
|
+
buttons.push([1, 'Power', SINGLE])
|
581
588
|
buttons.push([2, 'Dim Up', SINGLE | LONG])
|
582
589
|
buttons.push([3, 'Dim Down', SINGLE | LONG])
|
583
590
|
buttons.push([4, 'Scene', SINGLE | LONG])
|
@@ -716,7 +723,7 @@ class Resource {
|
|
716
723
|
case 'MLI':
|
717
724
|
switch (this.model) {
|
718
725
|
case 'ZBT-Remote-ALL-RGBW': // Tint remote control by Müller-Licht see deconz-rest-plugin#1209
|
719
|
-
buttons.push([1, '
|
726
|
+
buttons.push([1, 'Power', SINGLE])
|
720
727
|
buttons.push([2, 'Dim Up', SINGLE | LONG])
|
721
728
|
buttons.push([3, 'Dim Down', SINGLE | LONG])
|
722
729
|
buttons.push([4, 'Warm', SINGLE])
|
@@ -799,7 +806,7 @@ class Resource {
|
|
799
806
|
buttons.push([4, 'Off', SINGLE | LONG])
|
800
807
|
break
|
801
808
|
case 'RWL022': // Hue dimmer switch (2021)
|
802
|
-
buttons.push([1, '
|
809
|
+
buttons.push([1, 'Power', SINGLE | LONG])
|
803
810
|
buttons.push([2, 'Dim Up', SINGLE | LONG, true])
|
804
811
|
buttons.push([3, 'Dim Down', SINGLE | LONG, true])
|
805
812
|
buttons.push([4, 'Hue', SINGLE | LONG])
|
@@ -1052,7 +1059,7 @@ class Resource {
|
|
1052
1059
|
switch (this.model) {
|
1053
1060
|
case 'RC 110':
|
1054
1061
|
if (this.endpoint === '01') {
|
1055
|
-
buttons.push([1, '
|
1062
|
+
buttons.push([1, 'Power', SINGLE])
|
1056
1063
|
buttons.push([2, 'Dim Up', SINGLE | LONG])
|
1057
1064
|
buttons.push([3, 'Dim Down', SINGLE | LONG])
|
1058
1065
|
buttons.push([4, '1', SINGLE])
|
@@ -1063,7 +1070,7 @@ class Resource {
|
|
1063
1070
|
buttons.push([9, '6', SINGLE])
|
1064
1071
|
for (let i = 1; i <= 6; i++) {
|
1065
1072
|
const button = 7 + i * 3
|
1066
|
-
buttons.push([button, `
|
1073
|
+
buttons.push([button, `Power ${i}`, SINGLE])
|
1067
1074
|
buttons.push([button + 1, `Dim Up ${i}`, SINGLE | LONG])
|
1068
1075
|
buttons.push([button + 2, `Dim Down ${i}`, SINGLE | LONG])
|
1069
1076
|
}
|
@@ -1157,4 +1164,4 @@ class Resource {
|
|
1157
1164
|
}
|
1158
1165
|
}
|
1159
1166
|
|
1160
|
-
|
1167
|
+
Deconz.Resource = Resource
|
package/lib/Deconz/index.js
CHANGED
@@ -3,14 +3,9 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
'use strict'
|
7
|
-
|
8
6
|
/** Library to discover, monitor, and interact with a deCONZ gateway.
|
9
7
|
* @hideconstructor
|
10
8
|
*/
|
11
|
-
class Deconz {
|
12
|
-
static get Device () { return require('./Device') }
|
13
|
-
static get Resource () { return require('./Resource') }
|
14
|
-
}
|
9
|
+
class Deconz {}
|
15
10
|
|
16
|
-
|
11
|
+
export { Deconz }
|
@@ -3,9 +3,7 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
6
|
+
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
9
7
|
|
10
8
|
class AirPurifier extends DeconzAccessory {
|
11
9
|
/** Instantiate a delegate for an accessory corresponding to a device.
|
@@ -33,4 +31,4 @@ class AirPurifier extends DeconzAccessory {
|
|
33
31
|
}
|
34
32
|
}
|
35
33
|
|
36
|
-
|
34
|
+
DeconzAccessory.AirPurifier = AirPurifier
|
@@ -3,14 +3,25 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { timeout } from 'homebridge-lib'
|
7
|
+
import { AccessoryDelegate } from 'homebridge-lib/AccessoryDelegate'
|
8
|
+
import { OptionParser } from 'homebridge-lib/OptionParser'
|
9
|
+
|
10
|
+
import { ApiClient } from 'hb-deconz-tools/ApiClient'
|
11
|
+
import { ApiError } from 'hb-deconz-tools/ApiError'
|
12
|
+
import { WsClient } from 'hb-deconz-tools/WsClient'
|
13
|
+
|
14
|
+
import { Deconz } from '../Deconz/index.js'
|
15
|
+
import '../Deconz/Resource.js'
|
16
|
+
import '../Deconz/Device.js'
|
17
|
+
|
18
|
+
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
19
|
+
|
20
|
+
import { DeconzService } from '../DeconzService/index.js'
|
21
|
+
import '../DeconzService/Button.js'
|
22
|
+
import '../DeconzService/Gateway.js'
|
7
23
|
|
8
|
-
const { AccessoryDelegate, OptionParser, timeout } = require('homebridge-lib')
|
9
|
-
const { ApiClient, ApiError, WsClient } = require('hb-deconz-tools')
|
10
24
|
const { HttpError } = ApiClient
|
11
|
-
const Deconz = require('../Deconz')
|
12
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
13
|
-
const DeconzService = require('../DeconzService')
|
14
25
|
|
15
26
|
const migration = {
|
16
27
|
name: 'homebridge-deconz',
|
@@ -138,7 +149,7 @@ class Gateway extends AccessoryDelegate {
|
|
138
149
|
|
139
150
|
this.addPropertyDelegate({
|
140
151
|
key: 'periodicEvents',
|
141
|
-
value:
|
152
|
+
value: false,
|
142
153
|
silent: true
|
143
154
|
})
|
144
155
|
|
@@ -225,7 +236,7 @@ class Gateway extends AccessoryDelegate {
|
|
225
236
|
this.exposeErrorById = {}
|
226
237
|
|
227
238
|
/** The service delegate for the Gateway Settings settings.
|
228
|
-
* @type {DeconzService.
|
239
|
+
* @type {DeconzService.Gateway}
|
229
240
|
*/
|
230
241
|
this.service = new DeconzService.Gateway(this, {
|
231
242
|
name: this.name + ' Gateway',
|
@@ -556,7 +567,6 @@ class Gateway extends AccessoryDelegate {
|
|
556
567
|
this.exposeErrors = {}
|
557
568
|
this.context.settingsById = {}
|
558
569
|
this.context.fullState = null
|
559
|
-
this.values.logLevel = 2
|
560
570
|
} catch (error) { this.error(error) }
|
561
571
|
}
|
562
572
|
|
@@ -600,11 +610,47 @@ class Gateway extends AccessoryDelegate {
|
|
600
610
|
this.pollNext = true
|
601
611
|
}
|
602
612
|
|
613
|
+
/** On-demand import of a DeconzAccessory subclass.
|
614
|
+
* @params {string} type - The name of the class.
|
615
|
+
*/
|
616
|
+
async importAccessoryType (type) {
|
617
|
+
switch (type) {
|
618
|
+
case 'AirPurifier':
|
619
|
+
case 'Light':
|
620
|
+
case 'Sensor':
|
621
|
+
case 'Thermostat':
|
622
|
+
case 'WarningDevice':
|
623
|
+
case 'WindowCovering':
|
624
|
+
break
|
625
|
+
case 'Outlet':
|
626
|
+
case 'Switch':
|
627
|
+
type = 'Light'
|
628
|
+
break
|
629
|
+
default:
|
630
|
+
type = 'Sensor'
|
631
|
+
break
|
632
|
+
}
|
633
|
+
if (DeconzAccessory[type] == null) {
|
634
|
+
this.vdebug('importing DeconzAccessory.%s', type)
|
635
|
+
await import('../DeconzAccessory/' + type + '.js')
|
636
|
+
}
|
637
|
+
}
|
638
|
+
|
639
|
+
/** On-demand import of a a DeconzService subclass.
|
640
|
+
* @params {string} type - The name of the class.
|
641
|
+
*/
|
642
|
+
async importServiceType (type) {
|
643
|
+
if (DeconzService[type] == null) {
|
644
|
+
this.vdebug('importing DeconzService.%s', type)
|
645
|
+
await import('../DeconzService/' + type + '.js')
|
646
|
+
}
|
647
|
+
}
|
648
|
+
|
603
649
|
/** Add the accessory for the device.
|
604
650
|
* @params {string} id - The device ID.
|
605
651
|
* @return {?DeconzAccessory} - The accessory delegate.
|
606
652
|
*/
|
607
|
-
addAccessory (id) {
|
653
|
+
async addAccessory (id) {
|
608
654
|
if (id === this.id) {
|
609
655
|
throw new RangeError(`${id}: gateway ID`)
|
610
656
|
}
|
@@ -617,10 +663,17 @@ class Gateway extends AccessoryDelegate {
|
|
617
663
|
const { body } = device.resource
|
618
664
|
this.log('%s: add accessory', body.name)
|
619
665
|
let { serviceName } = device.resource
|
666
|
+
await this.importAccessoryType(serviceName)
|
620
667
|
if (DeconzAccessory[serviceName] == null) {
|
621
668
|
// this.warn('%s: %s: not yet supported %s type', body.name, body.type, rtype)
|
622
669
|
serviceName = 'Sensor'
|
623
670
|
}
|
671
|
+
for (const resourceServiceName of Object.keys(device.subtypesByServiceName)) {
|
672
|
+
await this.importServiceType(resourceServiceName)
|
673
|
+
}
|
674
|
+
if (device.hasBattery) {
|
675
|
+
await this.importServiceType('Battery')
|
676
|
+
}
|
624
677
|
const accessory = new DeconzAccessory[serviceName](this, device)
|
625
678
|
this.accessoryById[id] = accessory
|
626
679
|
this.monitorResources(accessory, true)
|
@@ -1134,7 +1187,7 @@ class Gateway extends AccessoryDelegate {
|
|
1134
1187
|
} else {
|
1135
1188
|
this.debug('%s: exposed by legacy code', name)
|
1136
1189
|
}
|
1137
|
-
this.addAccessory(id)
|
1190
|
+
await this.addAccessory(id)
|
1138
1191
|
changed = true
|
1139
1192
|
}
|
1140
1193
|
} else {
|
@@ -1160,6 +1213,9 @@ class Gateway extends AccessoryDelegate {
|
|
1160
1213
|
|
1161
1214
|
this.vdebug('analysing schedules...')
|
1162
1215
|
if (this.values.exposeSchedules) {
|
1216
|
+
if (DeconzService.Schedule == null) {
|
1217
|
+
await import('../DeconzService/Schedule.js')
|
1218
|
+
}
|
1163
1219
|
for (const rid in fullState.schedules) {
|
1164
1220
|
if (this.scheduleServicesByRid[rid] == null) {
|
1165
1221
|
this.scheduleServicesByRid[rid] = new DeconzService.Schedule(
|
@@ -1225,4 +1281,4 @@ class Gateway extends AccessoryDelegate {
|
|
1225
1281
|
}
|
1226
1282
|
}
|
1227
1283
|
|
1228
|
-
|
1284
|
+
DeconzAccessory.Gateway = Gateway
|
@@ -3,10 +3,10 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
|
7
|
+
import 'homebridge-lib/ServiceDelegate/History'
|
7
8
|
|
8
|
-
|
9
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
9
|
+
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
10
10
|
|
11
11
|
/** Delegate class for a HomeKit accessory, corresponding to a light device
|
12
12
|
* or groups resource.
|
@@ -127,26 +127,33 @@ class Light extends DeconzAccessory {
|
|
127
127
|
})
|
128
128
|
}
|
129
129
|
} else {
|
130
|
+
this.debug('servicesByServiceName: %j', Object.keys(this.servicesByServiceName))
|
131
|
+
this.debug('servicesByServiceName[%s]: %j', this.values.serviceName, Object.keys(this.servicesByServiceName[this.values.serviceName]))
|
130
132
|
for (const i in this.servicesByServiceName[this.values.serviceName]) {
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
Characteristic: this.Characteristics.hap.ServiceLabelIndex,
|
135
|
-
silent: true,
|
136
|
-
value: Number(i) + 1
|
137
|
-
})
|
138
|
-
service.values.index = Number(i) + 1
|
139
|
-
if (i === '0') {
|
140
|
-
continue
|
141
|
-
}
|
142
|
-
this.historyService?.addLastOnDelegate(
|
143
|
-
service.characteristicDelegate('on'),
|
133
|
+
try {
|
134
|
+
const service = this.servicesByServiceName[this.values.serviceName][i]
|
135
|
+
this.debug('service %d: %j', i, service.rpath)
|
144
136
|
service.addCharacteristicDelegate({
|
145
|
-
key: '
|
146
|
-
Characteristic: this.Characteristics.
|
147
|
-
silent: true
|
137
|
+
key: 'index',
|
138
|
+
Characteristic: this.Characteristics.hap.ServiceLabelIndex,
|
139
|
+
silent: true,
|
140
|
+
value: Number(i) + 1
|
148
141
|
})
|
149
|
-
|
142
|
+
service.values.index = Number(i) + 1
|
143
|
+
if (i === '0') {
|
144
|
+
continue
|
145
|
+
}
|
146
|
+
this.historyService?.addLastOnDelegate(
|
147
|
+
service.characteristicDelegate('on'),
|
148
|
+
service.addCharacteristicDelegate({
|
149
|
+
key: 'lastActivation',
|
150
|
+
Characteristic: this.Characteristics.eve.LastActivation,
|
151
|
+
silent: true
|
152
|
+
})
|
153
|
+
)
|
154
|
+
} catch (error) {
|
155
|
+
this.warn(error)
|
156
|
+
}
|
150
157
|
}
|
151
158
|
}
|
152
159
|
|
@@ -157,4 +164,6 @@ class Light extends DeconzAccessory {
|
|
157
164
|
}
|
158
165
|
}
|
159
166
|
|
160
|
-
|
167
|
+
DeconzAccessory.Light = Light
|
168
|
+
DeconzAccessory.Outlet = Light
|
169
|
+
DeconzAccessory.Switch = Light
|
@@ -8,10 +8,10 @@
|
|
8
8
|
// Stateless Programmable Switch (Eve button)
|
9
9
|
// Sensors
|
10
10
|
|
11
|
-
|
11
|
+
import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
|
12
|
+
import 'homebridge-lib/ServiceDelegate/History'
|
12
13
|
|
13
|
-
|
14
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
14
|
+
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
15
15
|
|
16
16
|
class Sensor extends DeconzAccessory {
|
17
17
|
constructor (gateway, device) {
|
@@ -150,4 +150,4 @@ class Sensor extends DeconzAccessory {
|
|
150
150
|
}
|
151
151
|
}
|
152
152
|
|
153
|
-
|
153
|
+
DeconzAccessory.Sensor = Sensor
|
@@ -3,10 +3,10 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
|
7
|
+
import 'homebridge-lib/ServiceDelegate/History'
|
7
8
|
|
8
|
-
|
9
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
9
|
+
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
10
10
|
|
11
11
|
class Thermostat extends DeconzAccessory {
|
12
12
|
/** Instantiate a delegate for an accessory corresponding to a device.
|
@@ -42,4 +42,4 @@ class Thermostat extends DeconzAccessory {
|
|
42
42
|
}
|
43
43
|
}
|
44
44
|
|
45
|
-
|
45
|
+
DeconzAccessory.Thermostat = Thermostat
|
@@ -3,10 +3,10 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
|
7
|
+
import 'homebridge-lib/ServiceDelegate/History'
|
7
8
|
|
8
|
-
|
9
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
9
|
+
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
10
10
|
|
11
11
|
/** Delegate class for a HomeKit accessory, corresponding to a light device
|
12
12
|
* or groups resource.
|
@@ -57,4 +57,4 @@ class WarningDevice extends DeconzAccessory {
|
|
57
57
|
}
|
58
58
|
}
|
59
59
|
|
60
|
-
|
60
|
+
DeconzAccessory.WarningDevice = WarningDevice
|
@@ -3,9 +3,7 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
6
|
+
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
9
7
|
|
10
8
|
/** Delegate class for a HomeKit accessory, corresponding to a light device
|
11
9
|
* or groups resource.
|
@@ -42,4 +40,4 @@ class WindowCovering extends DeconzAccessory {
|
|
42
40
|
}
|
43
41
|
}
|
44
42
|
|
45
|
-
|
43
|
+
DeconzAccessory.WindowCovering = WindowCovering
|
@@ -3,11 +3,13 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { AccessoryDelegate } from 'homebridge-lib/AccessoryDelegate'
|
7
|
+
import { OptionParser } from 'homebridge-lib/OptionParser'
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
import { ApiClient } from 'hb-deconz-tools/ApiClient'
|
10
|
+
|
11
|
+
import { DeconzService } from '../DeconzService/index.js'
|
12
|
+
import '../DeconzService/Button.js'
|
11
13
|
|
12
14
|
const { HttpError } = ApiClient
|
13
15
|
const { SINGLE, DOUBLE, LONG } = DeconzService.Button
|
@@ -17,14 +19,6 @@ const { SINGLE, DOUBLE, LONG } = DeconzService.Button
|
|
17
19
|
* @extends AccessoryDelegate
|
18
20
|
*/
|
19
21
|
class DeconzAccessory extends AccessoryDelegate {
|
20
|
-
static get Light () { return require('./Light') }
|
21
|
-
static get Gateway () { return require('./Gateway') }
|
22
|
-
static get Outlet () { return DeconzAccessory.Light }
|
23
|
-
static get Sensor () { return require('./Sensor') }
|
24
|
-
static get Switch () { return DeconzAccessory.Light }
|
25
|
-
static get WarningDevice () { return require('./WarningDevice') }
|
26
|
-
static get WindowCovering () { return require('./WindowCovering') }
|
27
|
-
|
28
22
|
/** Instantiate a delegate for an accessory corresponding to a device.
|
29
23
|
* @param {DeconzAccessory.Gateway} gateway - The gateway.
|
30
24
|
* @param {Deconz.Device} device - The device.
|
@@ -330,4 +324,4 @@ class DeconzAccessory extends AccessoryDelegate {
|
|
330
324
|
}
|
331
325
|
}
|
332
326
|
|
333
|
-
|
327
|
+
export { DeconzAccessory }
|
package/lib/DeconzPlatform.js
CHANGED
@@ -3,12 +3,17 @@
|
|
3
3
|
//
|
4
4
|
// Homebridge plugin for deCONZ.
|
5
5
|
|
6
|
-
|
6
|
+
import { once } from 'node:events'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
import { timeout } from 'homebridge-lib'
|
9
|
+
import { HttpClient } from 'homebridge-lib/HttpClient'
|
10
|
+
import { OptionParser } from 'homebridge-lib/OptionParser'
|
11
|
+
import { Platform } from 'homebridge-lib/Platform'
|
12
|
+
|
13
|
+
import { Discovery } from 'hb-deconz-tools/Discovery'
|
14
|
+
|
15
|
+
import { DeconzAccessory } from './DeconzAccessory/index.js'
|
16
|
+
import './DeconzAccessory/Gateway.js'
|
12
17
|
|
13
18
|
class DeconzPlatform extends Platform {
|
14
19
|
constructor (log, configJson, homebridge, bridge) {
|
@@ -112,7 +117,7 @@ class DeconzPlatform extends Platform {
|
|
112
117
|
this.gatewayMap[id] = new DeconzAccessory.Gateway(this, { config, host })
|
113
118
|
}
|
114
119
|
await this.gatewayMap[id].found(host, config)
|
115
|
-
await
|
120
|
+
await once(this.gatewayMap[id], 'initialised')
|
116
121
|
this.emit('found')
|
117
122
|
}
|
118
123
|
|
@@ -137,12 +142,12 @@ class DeconzPlatform extends Platform {
|
|
137
142
|
}
|
138
143
|
} else {
|
139
144
|
this.debug('job %d: find at least one gateway', jobs.length)
|
140
|
-
jobs.push(
|
145
|
+
jobs.push(once(this, 'found'))
|
141
146
|
for (const id in this.gatewayMap) {
|
142
147
|
const gateway = this.gatewayMap[id]
|
143
148
|
const host = gateway.values.host
|
144
149
|
this.debug('job %d: find gateway %s', jobs.length, id)
|
145
|
-
jobs.push(
|
150
|
+
jobs.push(once(gateway, 'initialised'))
|
146
151
|
try {
|
147
152
|
const config = await this.discovery.config(host)
|
148
153
|
await this.foundGateway(host, config)
|
@@ -259,4 +264,4 @@ class DeconzPlatform extends Platform {
|
|
259
264
|
}
|
260
265
|
}
|
261
266
|
|
262
|
-
|
267
|
+
export { DeconzPlatform }
|