homebridge-deconz 0.0.17 → 0.0.21
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/README.md +4 -4
- package/config.schema.json +7 -0
- package/homebridge-ui/public/index.html +249 -460
- package/homebridge-ui/public/index.old.html +506 -0
- package/lib/Deconz/Discovery.js +5 -2
- package/lib/Deconz/Resource.js +14 -0
- package/lib/DeconzAccessory/Gateway.js +5 -2
- package/lib/DeconzAccessory/index.js +6 -4
- package/lib/DeconzPlatform.js +5 -1
- package/lib/DeconzService/AirPurifier.js +1 -11
- package/lib/DeconzService/Button.js +4 -0
- package/lib/DeconzService/Consumption.js +9 -1
- package/lib/DeconzService/Light.js +10 -12
- package/lib/DeconzService/LightsResource.js +5 -5
- package/lib/DeconzService/Outlet.js +1 -1
- package/lib/DeconzService/Power.js +1 -1
- package/lib/DeconzService/Switch.js +33 -21
- package/package.json +6 -6
@@ -31,6 +31,14 @@ class Consumption extends DeconzService.SensorsResource {
|
|
31
31
|
unit: ' W'
|
32
32
|
})
|
33
33
|
}
|
34
|
+
|
35
|
+
if (service.values.lastUpdated === undefined) {
|
36
|
+
service.addCharacteristicDelegate({
|
37
|
+
key: 'lastUpdated',
|
38
|
+
Characteristic: service.Characteristics.my.LastUpdated,
|
39
|
+
silent: true
|
40
|
+
})
|
41
|
+
}
|
34
42
|
}
|
35
43
|
|
36
44
|
static updateResourceState (service, state) {
|
@@ -51,7 +59,7 @@ class Consumption extends DeconzService.SensorsResource {
|
|
51
59
|
|
52
60
|
Consumption.addResource(this, resource)
|
53
61
|
|
54
|
-
super.addCharacteristicDelegates()
|
62
|
+
super.addCharacteristicDelegates({ noLastUpdated: true })
|
55
63
|
|
56
64
|
this.update(resource.body)
|
57
65
|
}
|
@@ -92,11 +92,11 @@ class Light extends DeconzService.LightsResource {
|
|
92
92
|
},
|
93
93
|
value: this.resource.body.state.ct
|
94
94
|
}).on('didSet', (value, fromHomeKit) => {
|
95
|
-
this.checkAdaptiveLighting()
|
96
95
|
const ct = Math.max(
|
97
96
|
this.capabilities.ctMin, Math.min(value, this.capabilities.ctMax)
|
98
97
|
)
|
99
98
|
if (fromHomeKit) {
|
99
|
+
this.checkAdaptiveLighting()
|
100
100
|
this.put({ ct })
|
101
101
|
this.values.colormode = 'ct'
|
102
102
|
}
|
@@ -214,7 +214,7 @@ class Light extends DeconzService.LightsResource {
|
|
214
214
|
const response = this.adaptiveLighting.generateControlResponse()
|
215
215
|
const parsedResponse = this.adaptiveLighting.parseControl(response)
|
216
216
|
this.vdebug(
|
217
|
-
'
|
217
|
+
'adaptive lighting: control update: %j => %j',
|
218
218
|
control, parsedResponse
|
219
219
|
)
|
220
220
|
this.values.activeTransitionCount = parsedResponse === '' ? 0 : 1
|
@@ -228,7 +228,7 @@ class Light extends DeconzService.LightsResource {
|
|
228
228
|
silent: true,
|
229
229
|
value: 0
|
230
230
|
}).on('didSet', (value) => {
|
231
|
-
this.log('
|
231
|
+
this.log('adaptive lighting: %sabled', value > 0 ? 'en' : 'dis')
|
232
232
|
if (value) {
|
233
233
|
this.updateAdaptiveLighting()
|
234
234
|
}
|
@@ -314,7 +314,6 @@ class Light extends DeconzService.LightsResource {
|
|
314
314
|
}
|
315
315
|
|
316
316
|
this.settings = {
|
317
|
-
brightnessAdjustment: 1,
|
318
317
|
resetTimeout: this.platform.config.resetTimeout,
|
319
318
|
waitTimeUpdate: this.platform.config.waitTimeUpdate,
|
320
319
|
wallSwitch: false
|
@@ -322,9 +321,11 @@ class Light extends DeconzService.LightsResource {
|
|
322
321
|
}
|
323
322
|
|
324
323
|
updateState (state) {
|
324
|
+
this.initAdaptiveLighting()
|
325
325
|
let updateAdaptiveLighting = false
|
326
326
|
for (const key in state) {
|
327
327
|
const value = state[key]
|
328
|
+
// const oldValue = this.resource.body.state[key]
|
328
329
|
this.resource.body.state[key] = value
|
329
330
|
switch (key) {
|
330
331
|
case 'all_on':
|
@@ -435,11 +436,11 @@ class Light extends DeconzService.LightsResource {
|
|
435
436
|
const control = this.adaptiveLighting.parseControl(
|
436
437
|
this.context.transitionControl
|
437
438
|
)
|
438
|
-
this.vdebug('
|
439
|
+
this.vdebug('adaptive lighting: restore control: %j', control)
|
439
440
|
this.adaptiveLighting.parseControl(this.context.transitionControl)
|
440
441
|
}
|
441
442
|
this.log(
|
442
|
-
'
|
443
|
+
'adaptive lighting: %sabled',
|
443
444
|
this.values.activeTransitionCount > 0 ? 'en' : 'dis'
|
444
445
|
)
|
445
446
|
}
|
@@ -454,24 +455,21 @@ class Light extends DeconzService.LightsResource {
|
|
454
455
|
return
|
455
456
|
}
|
456
457
|
const ct = this.adaptiveLighting.getCt(
|
457
|
-
this.values.brightness * this.
|
458
|
+
this.values.brightness * this.platform.config.brightnessAdjustment
|
458
459
|
)
|
459
460
|
if (ct == null) {
|
460
461
|
this.warn('assertion failed')
|
461
462
|
return
|
462
463
|
}
|
463
|
-
this.debug(
|
464
|
-
'/%s/%d: adaptive lighting: {"state":{"ct": %d}}',
|
465
|
-
this.rtype, this.rid, ct
|
466
|
-
)
|
467
464
|
if (this.values.colormode === 'ct' && ct === this.values.colorTemperature) {
|
468
465
|
return
|
469
466
|
}
|
467
|
+
this.debug('adaptive lighting: set Color Temperature to %d mired', ct)
|
470
468
|
this.put({ ct })
|
471
469
|
this.fromAdaptiveLighting = true
|
472
470
|
this.values.colormode = 'ct'
|
473
471
|
if (ct !== this.values.colorTemperature) {
|
474
|
-
this.values.colorTemperature = ct
|
472
|
+
this.values.colorTemperature = ct // should only do this when PUT succeeds
|
475
473
|
} else if (this.capabilities.xy) { // colormode changed
|
476
474
|
const { h, s } = xyToHsv(ctToXy(ct), this.capabilities.gamut)
|
477
475
|
this.values.hue = h
|
@@ -17,6 +17,7 @@ class LightsResource extends DeconzService {
|
|
17
17
|
super(accessory, resource, params)
|
18
18
|
this.rpath += resource.rtype === 'groups' ? '/action' : '/state'
|
19
19
|
|
20
|
+
this.updating = 0
|
20
21
|
this.targetState = {}
|
21
22
|
this.deferrals = []
|
22
23
|
}
|
@@ -65,16 +66,15 @@ class LightsResource extends DeconzService {
|
|
65
66
|
// Send the request (for the combined changes) to the gateway.
|
66
67
|
async _put () {
|
67
68
|
try {
|
68
|
-
if (this.updating) {
|
69
|
-
return
|
70
|
-
}
|
71
|
-
this.updating = true
|
72
69
|
if (this.platform.config.waitTimeUpdate > 0) {
|
70
|
+
this.updating++
|
73
71
|
await timeout(this.platform.config.waitTimeUpdate)
|
72
|
+
if (--this.updating > 0) {
|
73
|
+
return
|
74
|
+
}
|
74
75
|
}
|
75
76
|
const targetState = this.targetState
|
76
77
|
this.targetState = {}
|
77
|
-
this.updating = false
|
78
78
|
if (
|
79
79
|
this.gateway.transitionTime !== this.gateway.defaultTransitionTime &&
|
80
80
|
targetState.transitiontime === undefined
|
@@ -39,7 +39,7 @@ class Outlet extends DeconzService.LightsResource {
|
|
39
39
|
this.addCharacteristicDelegate({
|
40
40
|
key: 'outletInUse',
|
41
41
|
Characteristic: this.Characteristics.hap.OutletInUse,
|
42
|
-
value: 1
|
42
|
+
value: 1 // Eve interpretes OutletInUse as: device is physically plugged in.
|
43
43
|
})
|
44
44
|
|
45
45
|
this.addCharacteristicDelegates()
|
@@ -29,10 +29,19 @@ class Switch extends DeconzService.SensorsResource {
|
|
29
29
|
}
|
30
30
|
|
31
31
|
createButtonServices (resource) {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
if (resource.body.type.endsWith('Switch')) {
|
33
|
+
this.buttonResources[resource.rpath] = {
|
34
|
+
buttonEvent: resource.body.state.buttonevent,
|
35
|
+
lastUpdated: '',
|
36
|
+
toButtonEvent: resource.capabilities.toButtonEvent
|
37
|
+
}
|
38
|
+
} else if (resource.body.type.endsWith('RelativeRotary')) {
|
39
|
+
const keys = Object.keys(resource.capabilities.buttons)
|
40
|
+
this.buttonResources[resource.rpath] = {
|
41
|
+
lastUpdated: '',
|
42
|
+
right: keys[0],
|
43
|
+
left: keys[1]
|
44
|
+
}
|
36
45
|
}
|
37
46
|
for (const i in resource.capabilities.buttons) {
|
38
47
|
const { label, events, hasRepeat } = resource.capabilities.buttons[i]
|
@@ -57,17 +66,27 @@ class Switch extends DeconzService.SensorsResource {
|
|
57
66
|
state.lastupdated !== buttonResource.lastUpdated
|
58
67
|
) {
|
59
68
|
buttonResource.lastUpdated = state.lastupdated
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
69
|
+
if (buttonResource.buttonEvent !== undefined) {
|
70
|
+
const oldValue = buttonResource.buttonEvent
|
71
|
+
if (state.buttonevent != null) {
|
72
|
+
buttonResource.buttonEvent = buttonResource.toButtonEvent == null
|
73
|
+
? state.buttonevent
|
74
|
+
: buttonResource.toButtonEvent(state.buttonevent)
|
75
|
+
}
|
76
|
+
// TODO handle repeat
|
77
|
+
const i = Math.floor(buttonResource.buttonEvent / 1000)
|
78
|
+
if (this.buttonServices[i] != null) {
|
79
|
+
this.buttonServices[i].update(
|
80
|
+
buttonResource.buttonEvent, oldValue,
|
81
|
+
this.accessoryDelegate.settingsService.values.repeat
|
82
|
+
)
|
83
|
+
}
|
84
|
+
} else {
|
85
|
+
const i = state.expectedrotation >= 0
|
86
|
+
? buttonResource.right
|
87
|
+
: buttonResource.left
|
88
|
+
this.buttonServices[i].updateRotation()
|
65
89
|
}
|
66
|
-
// TODO handle repeat
|
67
|
-
this.updateButtonEvent(
|
68
|
-
buttonResource.buttonEvent, oldValue,
|
69
|
-
this.accessoryDelegate.settingsService.values.repeat
|
70
|
-
)
|
71
90
|
}
|
72
91
|
super.updateState(state)
|
73
92
|
}
|
@@ -77,13 +96,6 @@ class Switch extends DeconzService.SensorsResource {
|
|
77
96
|
super.updateConfig(config)
|
78
97
|
}
|
79
98
|
|
80
|
-
updateButtonEvent (value, oldValue, repeat) {
|
81
|
-
const i = Math.floor(value / 1000)
|
82
|
-
if (this.buttonServices[i] != null) {
|
83
|
-
this.buttonServices[i].update(value, oldValue, repeat)
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
99
|
async identify () {
|
88
100
|
this.debug('hasRepeat: %j', this.hasRepeat)
|
89
101
|
return super.identify()
|
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.21",
|
8
8
|
"keywords": [
|
9
9
|
"homebridge-plugin",
|
10
10
|
"homekit",
|
@@ -20,14 +20,14 @@
|
|
20
20
|
"deconz": "cli/deconz.js"
|
21
21
|
},
|
22
22
|
"engines": {
|
23
|
-
"deCONZ": "2.
|
24
|
-
"homebridge": "^1.
|
25
|
-
"node": "^16.
|
23
|
+
"deCONZ": "2.17.1",
|
24
|
+
"homebridge": "^1.5.0",
|
25
|
+
"node": "^16.17.0"
|
26
26
|
},
|
27
27
|
"dependencies": {
|
28
|
-
"homebridge-lib": "~5.6.
|
28
|
+
"homebridge-lib": "~5.6.5",
|
29
29
|
"semver": "^7.3.7",
|
30
|
-
"ws": "^8.8.
|
30
|
+
"ws": "^8.8.1",
|
31
31
|
"xml2js": "~0.4.23"
|
32
32
|
},
|
33
33
|
"scripts": {
|