homebridge-deconz 1.0.13 → 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/lib/Deconz/Device.js
CHANGED
@@ -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
|
package/lib/Deconz/Resource.js
CHANGED
@@ -112,6 +112,9 @@ class Resource {
|
|
112
112
|
*/
|
113
113
|
this.body = toObject('body', body)
|
114
114
|
toString('body.name', body.name, true)
|
115
|
+
body.name = body.name.replace(/[^\p{L}\p{N} ']/ug, ' ')
|
116
|
+
.replace(/^[ ']*/, '')
|
117
|
+
.replace(/[ ']*$/, '')
|
115
118
|
toString('body.type', body.type, true)
|
116
119
|
|
117
120
|
let realDevice = false
|
@@ -302,6 +305,7 @@ class Resource {
|
|
302
305
|
case 'Consumption': return 'Consumption'
|
303
306
|
// case 'DoorLock': return null
|
304
307
|
case 'Daylight': return 'Daylight'
|
308
|
+
case 'DaylightOffset': return ''
|
305
309
|
case 'Fire': return 'Smoke'
|
306
310
|
case 'GenericFlag': return 'Flag'
|
307
311
|
case 'GenericStatus': return 'Status'
|
@@ -536,7 +540,7 @@ class Resource {
|
|
536
540
|
buttons.push([2, 'Close', SINGLE | LONG])
|
537
541
|
break
|
538
542
|
case 'TRADFRI remote control':
|
539
|
-
buttons.push([1, '
|
543
|
+
buttons.push([1, 'Power', SINGLE])
|
540
544
|
buttons.push([2, 'Dim Up', SINGLE | LONG])
|
541
545
|
buttons.push([3, 'Dim Down', SINGLE | LONG])
|
542
546
|
buttons.push([4, 'Previous', SINGLE | LONG])
|
@@ -580,7 +584,7 @@ class Resource {
|
|
580
584
|
case 'LDS':
|
581
585
|
switch (this.model) {
|
582
586
|
case 'ZBT-DIMController-D0800':
|
583
|
-
buttons.push([1, '
|
587
|
+
buttons.push([1, 'Power', SINGLE])
|
584
588
|
buttons.push([2, 'Dim Up', SINGLE | LONG])
|
585
589
|
buttons.push([3, 'Dim Down', SINGLE | LONG])
|
586
590
|
buttons.push([4, 'Scene', SINGLE | LONG])
|
@@ -719,7 +723,7 @@ class Resource {
|
|
719
723
|
case 'MLI':
|
720
724
|
switch (this.model) {
|
721
725
|
case 'ZBT-Remote-ALL-RGBW': // Tint remote control by Müller-Licht see deconz-rest-plugin#1209
|
722
|
-
buttons.push([1, '
|
726
|
+
buttons.push([1, 'Power', SINGLE])
|
723
727
|
buttons.push([2, 'Dim Up', SINGLE | LONG])
|
724
728
|
buttons.push([3, 'Dim Down', SINGLE | LONG])
|
725
729
|
buttons.push([4, 'Warm', SINGLE])
|
@@ -802,7 +806,7 @@ class Resource {
|
|
802
806
|
buttons.push([4, 'Off', SINGLE | LONG])
|
803
807
|
break
|
804
808
|
case 'RWL022': // Hue dimmer switch (2021)
|
805
|
-
buttons.push([1, '
|
809
|
+
buttons.push([1, 'Power', SINGLE | LONG])
|
806
810
|
buttons.push([2, 'Dim Up', SINGLE | LONG, true])
|
807
811
|
buttons.push([3, 'Dim Down', SINGLE | LONG, true])
|
808
812
|
buttons.push([4, 'Hue', SINGLE | LONG])
|
@@ -1055,7 +1059,7 @@ class Resource {
|
|
1055
1059
|
switch (this.model) {
|
1056
1060
|
case 'RC 110':
|
1057
1061
|
if (this.endpoint === '01') {
|
1058
|
-
buttons.push([1, '
|
1062
|
+
buttons.push([1, 'Power', SINGLE])
|
1059
1063
|
buttons.push([2, 'Dim Up', SINGLE | LONG])
|
1060
1064
|
buttons.push([3, 'Dim Down', SINGLE | LONG])
|
1061
1065
|
buttons.push([4, '1', SINGLE])
|
@@ -1066,7 +1070,7 @@ class Resource {
|
|
1066
1070
|
buttons.push([9, '6', SINGLE])
|
1067
1071
|
for (let i = 1; i <= 6; i++) {
|
1068
1072
|
const button = 7 + i * 3
|
1069
|
-
buttons.push([button, `
|
1073
|
+
buttons.push([button, `Power ${i}`, SINGLE])
|
1070
1074
|
buttons.push([button + 1, `Dim Up ${i}`, SINGLE | LONG])
|
1071
1075
|
buttons.push([button + 2, `Dim Down ${i}`, SINGLE | LONG])
|
1072
1076
|
}
|
@@ -16,14 +16,10 @@ import '../Deconz/Resource.js'
|
|
16
16
|
import '../Deconz/Device.js'
|
17
17
|
|
18
18
|
import { DeconzAccessory } from '../DeconzAccessory/index.js'
|
19
|
-
import '../DeconzAccessory/AirPurifier.js'
|
20
|
-
import '../DeconzAccessory/Light.js'
|
21
|
-
import '../DeconzAccessory/Sensor.js'
|
22
|
-
import '../DeconzAccessory/Thermostat.js'
|
23
|
-
import '../DeconzAccessory/WarningDevice.js'
|
24
|
-
import '../DeconzAccessory/WindowCovering.js'
|
25
19
|
|
26
20
|
import { DeconzService } from '../DeconzService/index.js'
|
21
|
+
import '../DeconzService/Button.js'
|
22
|
+
import '../DeconzService/Gateway.js'
|
27
23
|
|
28
24
|
const { HttpError } = ApiClient
|
29
25
|
|
@@ -153,7 +149,7 @@ class Gateway extends AccessoryDelegate {
|
|
153
149
|
|
154
150
|
this.addPropertyDelegate({
|
155
151
|
key: 'periodicEvents',
|
156
|
-
value:
|
152
|
+
value: false,
|
157
153
|
silent: true
|
158
154
|
})
|
159
155
|
|
@@ -571,7 +567,6 @@ class Gateway extends AccessoryDelegate {
|
|
571
567
|
this.exposeErrors = {}
|
572
568
|
this.context.settingsById = {}
|
573
569
|
this.context.fullState = null
|
574
|
-
this.values.logLevel = 2
|
575
570
|
} catch (error) { this.error(error) }
|
576
571
|
}
|
577
572
|
|
@@ -615,11 +610,47 @@ class Gateway extends AccessoryDelegate {
|
|
615
610
|
this.pollNext = true
|
616
611
|
}
|
617
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
|
+
|
618
649
|
/** Add the accessory for the device.
|
619
650
|
* @params {string} id - The device ID.
|
620
651
|
* @return {?DeconzAccessory} - The accessory delegate.
|
621
652
|
*/
|
622
|
-
addAccessory (id) {
|
653
|
+
async addAccessory (id) {
|
623
654
|
if (id === this.id) {
|
624
655
|
throw new RangeError(`${id}: gateway ID`)
|
625
656
|
}
|
@@ -632,10 +663,17 @@ class Gateway extends AccessoryDelegate {
|
|
632
663
|
const { body } = device.resource
|
633
664
|
this.log('%s: add accessory', body.name)
|
634
665
|
let { serviceName } = device.resource
|
666
|
+
await this.importAccessoryType(serviceName)
|
635
667
|
if (DeconzAccessory[serviceName] == null) {
|
636
668
|
// this.warn('%s: %s: not yet supported %s type', body.name, body.type, rtype)
|
637
669
|
serviceName = 'Sensor'
|
638
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
|
+
}
|
639
677
|
const accessory = new DeconzAccessory[serviceName](this, device)
|
640
678
|
this.accessoryById[id] = accessory
|
641
679
|
this.monitorResources(accessory, true)
|
@@ -9,35 +9,7 @@ import { OptionParser } from 'homebridge-lib/OptionParser'
|
|
9
9
|
import { ApiClient } from 'hb-deconz-tools/ApiClient'
|
10
10
|
|
11
11
|
import { DeconzService } from '../DeconzService/index.js'
|
12
|
-
import '../DeconzService/AirPressure.js'
|
13
|
-
import '../DeconzService/AirPurifier.js'
|
14
|
-
import '../DeconzService/AirQuality.js'
|
15
|
-
import '../DeconzService/Alarm.js'
|
16
|
-
import '../DeconzService/Battery.js'
|
17
12
|
import '../DeconzService/Button.js'
|
18
|
-
import '../DeconzService/CarbonMonoxide.js'
|
19
|
-
import '../DeconzService/Consumption.js'
|
20
|
-
import '../DeconzService/Contact.js'
|
21
|
-
import '../DeconzService/Daylight.js'
|
22
|
-
import '../DeconzService/Flag.js'
|
23
|
-
import '../DeconzService/Gateway.js'
|
24
|
-
import '../DeconzService/Humidity.js'
|
25
|
-
import '../DeconzService/Label.js'
|
26
|
-
import '../DeconzService/Leak.js'
|
27
|
-
import '../DeconzService/Light.js'
|
28
|
-
import '../DeconzService/LightLevel.js'
|
29
|
-
import '../DeconzService/Motion.js'
|
30
|
-
import '../DeconzService/Outlet.js'
|
31
|
-
import '../DeconzService/Power.js'
|
32
|
-
import '../DeconzService/Schedule.js'
|
33
|
-
import '../DeconzService/Status.js'
|
34
|
-
import '../DeconzService/Smoke.js'
|
35
|
-
import '../DeconzService/Switch.js'
|
36
|
-
import '../DeconzService/Temperature.js'
|
37
|
-
import '../DeconzService/Thermostat.js'
|
38
|
-
import '../DeconzService/Valve.js'
|
39
|
-
import '../DeconzService/WarningDevice.js'
|
40
|
-
import '../DeconzService/WindowCovering.js'
|
41
13
|
|
42
14
|
const { HttpError } = ApiClient
|
43
15
|
const { SINGLE, DOUBLE, LONG } = DeconzService.Button
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
"ebaauw"
|
8
8
|
],
|
9
9
|
"license": "Apache-2.0",
|
10
|
-
"version": "1.0.
|
10
|
+
"version": "1.0.15",
|
11
11
|
"keywords": [
|
12
12
|
"homebridge-plugin",
|
13
13
|
"homekit",
|
@@ -32,7 +32,7 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"hb-deconz-tools": "~2.0.3",
|
35
|
-
"homebridge-lib": "~7.0.
|
35
|
+
"homebridge-lib": "~7.0.6"
|
36
36
|
},
|
37
37
|
"scripts": {
|
38
38
|
"prepare": "standard && rm -rf out && jsdoc -c jsdoc.json",
|