homebridge-lib 5.7.1 → 5.8.0
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/AccessoryDelegate.js +5 -18
- package/lib/CharacteristicDelegate.js +1 -1
- package/lib/EveHomeKitTypes.js +41 -15
- package/lib/MyHomeKitTypes.js +10 -0
- package/lib/ServiceDelegate/AccessoryInformation.js +5 -0
- package/lib/ServiceDelegate/Battery.js +5 -0
- package/lib/ServiceDelegate/Dummy.js +9 -4
- package/lib/ServiceDelegate/History/Consumption.js +38 -26
- package/lib/ServiceDelegate/History/Contact.js +21 -25
- package/lib/ServiceDelegate/History/Light.js +82 -0
- package/lib/ServiceDelegate/History/Motion.js +34 -36
- package/lib/ServiceDelegate/History/On.js +29 -13
- package/lib/ServiceDelegate/History/Power.js +34 -33
- package/lib/ServiceDelegate/History/Room.js +24 -27
- package/lib/ServiceDelegate/History/Thermo.js +27 -27
- package/lib/ServiceDelegate/History/Weather.js +22 -25
- package/lib/ServiceDelegate/History/index.js +10 -2
- package/lib/ServiceDelegate/ServiceLabel.js +6 -1
- package/lib/ServiceDelegate/index.js +25 -33
- package/package.json +2 -2
package/lib/AccessoryDelegate.js
CHANGED
|
@@ -63,8 +63,9 @@ class AccessoryDelegate extends homebridgeLib.Delegate {
|
|
|
63
63
|
// Setup shortcut for property values and values of the characteristics
|
|
64
64
|
// of the _Accessory Information_ service.
|
|
65
65
|
this._values = {} // by key
|
|
66
|
-
|
|
67
66
|
this._propertyDelegates = {}
|
|
67
|
+
this.addPropertyDelegate({ key: 'name', value: this.name, silent: true })
|
|
68
|
+
.on('didSet', (name) => { this.name = name })
|
|
68
69
|
|
|
69
70
|
// Create delegate for AccessoryInformation service.
|
|
70
71
|
this._serviceDelegates = {}
|
|
@@ -124,20 +125,6 @@ class AccessoryDelegate extends homebridgeLib.Delegate {
|
|
|
124
125
|
delete this._context[key]
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
get name () {
|
|
128
|
-
return super.name
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
set name (name) {
|
|
132
|
-
super.name = name
|
|
133
|
-
if (this._accessory != null) {
|
|
134
|
-
this._accessory.displayName = name
|
|
135
|
-
}
|
|
136
|
-
if (this._accessoryInformationDelegate != null) {
|
|
137
|
-
this._accessoryInformationDelegate.values.name = name
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
128
|
/** Creates a new {@link PropertyDelegate} instance, for a property of the
|
|
142
129
|
* associated HomeKit accessory.
|
|
143
130
|
*
|
|
@@ -173,7 +160,7 @@ class AccessoryDelegate extends homebridgeLib.Delegate {
|
|
|
173
160
|
throw new RangeError(`params.key: ${params.key}: invalid key`)
|
|
174
161
|
}
|
|
175
162
|
const key = params.key
|
|
176
|
-
if (this.
|
|
163
|
+
if (this._values[key] !== undefined) {
|
|
177
164
|
throw new SyntaxError(`${key}: duplicate key`)
|
|
178
165
|
}
|
|
179
166
|
|
|
@@ -181,7 +168,7 @@ class AccessoryDelegate extends homebridgeLib.Delegate {
|
|
|
181
168
|
this._propertyDelegates[key] = delegate
|
|
182
169
|
|
|
183
170
|
// Create shortcut for characteristic value.
|
|
184
|
-
Object.defineProperty(this.
|
|
171
|
+
Object.defineProperty(this._values, key, {
|
|
185
172
|
configurable: true, // make sure we can delete it again
|
|
186
173
|
writeable: true,
|
|
187
174
|
get () { return delegate.value },
|
|
@@ -195,7 +182,7 @@ class AccessoryDelegate extends homebridgeLib.Delegate {
|
|
|
195
182
|
if (this._accessoryInformationDelegate.values[key] != null) {
|
|
196
183
|
throw new RangeError('%s: invalid key')
|
|
197
184
|
}
|
|
198
|
-
delete this.
|
|
185
|
+
delete this._values[key]
|
|
199
186
|
const delegate = this._propertyDelegates[key]
|
|
200
187
|
delegate._destroy()
|
|
201
188
|
delete this._propertyDelegates[key]
|
|
@@ -415,7 +415,7 @@ class CharacteristicDelegate extends homebridgeLib.Delegate {
|
|
|
415
415
|
result = await this._setter(value)
|
|
416
416
|
} catch (error) {
|
|
417
417
|
clearTimeout(timeout)
|
|
418
|
-
this.
|
|
418
|
+
this.warn('set %s: %s', this.displayName, error)
|
|
419
419
|
if (!timedOut) {
|
|
420
420
|
callback(error)
|
|
421
421
|
}
|
package/lib/EveHomeKitTypes.js
CHANGED
|
@@ -159,8 +159,8 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
159
159
|
this.createCharacteristicClass('Voltage', uuid('10A'), {
|
|
160
160
|
format: this.Formats.FLOAT,
|
|
161
161
|
unit: 'V',
|
|
162
|
-
minValue:
|
|
163
|
-
maxValue:
|
|
162
|
+
minValue: 0,
|
|
163
|
+
maxValue: 380,
|
|
164
164
|
minStep: 0.1,
|
|
165
165
|
perms: [this.Perms.READ, this.Perms.NOTIFY]
|
|
166
166
|
})
|
|
@@ -188,7 +188,7 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
188
188
|
unit: 'kWh',
|
|
189
189
|
minValue: 0,
|
|
190
190
|
maxValue: 1000000,
|
|
191
|
-
minStep: 0.
|
|
191
|
+
minStep: 0.01,
|
|
192
192
|
perms: [this.Perms.READ, this.Perms.NOTIFY]
|
|
193
193
|
}, 'Total Consumption')
|
|
194
194
|
|
|
@@ -255,6 +255,12 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
255
255
|
perms: [this.Perms.WRITE, this.Perms.HIDDEN]
|
|
256
256
|
}, 'Config Command')
|
|
257
257
|
|
|
258
|
+
// On various Eve devices - presumably for firmware upgrade.
|
|
259
|
+
this.createCharacteristicClass('Char11E', uuid('11E'), {
|
|
260
|
+
format: this.Formats.DATA,
|
|
261
|
+
perms: [this.Perms.READ, this.Perms.WRITE, this.Perms.HIDDEN]
|
|
262
|
+
}, 'Eve 11E')
|
|
263
|
+
|
|
258
264
|
this.createCharacteristicClass('Sensitivity', uuid('120'), {
|
|
259
265
|
format: this.Formats.UINT8,
|
|
260
266
|
minValue: 0,
|
|
@@ -277,7 +283,7 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
277
283
|
unit: 'A',
|
|
278
284
|
minValue: 0,
|
|
279
285
|
maxValue: 48,
|
|
280
|
-
minStep: 0.
|
|
286
|
+
minStep: 0.01,
|
|
281
287
|
perms: [this.Perms.READ, this.Perms.NOTIFY]
|
|
282
288
|
}, 'Electric Current')
|
|
283
289
|
|
|
@@ -326,9 +332,9 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
326
332
|
this.createCharacteristicClass('Elevation', uuid('130'), {
|
|
327
333
|
format: this.Formats.INT,
|
|
328
334
|
unit: 'm',
|
|
329
|
-
minValue: -
|
|
330
|
-
maxValue:
|
|
331
|
-
minStep:
|
|
335
|
+
minValue: -450,
|
|
336
|
+
maxValue: 9000,
|
|
337
|
+
minStep: 1,
|
|
332
338
|
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE],
|
|
333
339
|
adminOnlyAccess: [this.Access.WRITE]
|
|
334
340
|
})
|
|
@@ -338,6 +344,25 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
338
344
|
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.HIDDEN]
|
|
339
345
|
}, 'Config Data')
|
|
340
346
|
|
|
347
|
+
this.createCharacteristicClass('WeatherTrend', uuid('136'), {
|
|
348
|
+
format: this.Formats.UINT8,
|
|
349
|
+
minValue: 0,
|
|
350
|
+
maxValue: 15,
|
|
351
|
+
minStep: 1,
|
|
352
|
+
perms: [this.Perms.READ, this.Perms.NOTIFY]
|
|
353
|
+
}, 'Weather Trend')
|
|
354
|
+
this.Characteristics.WeatherTrend.BLANK = 0 // also: 2, 8, 10
|
|
355
|
+
this.Characteristics.WeatherTrend.SUN = 1 // also: 9
|
|
356
|
+
this.Characteristics.WeatherTrend.CLOUDS_SUN = 3 // also: 11
|
|
357
|
+
this.Characteristics.WeatherTrend.RAIN = 4 // also: 5, 6, 7
|
|
358
|
+
this.Characteristics.WeatherTrend.RAIN_WIND = 12 // also: 13, 14, 15
|
|
359
|
+
|
|
360
|
+
// On various Eve devices - presumably for firmware upgrade.
|
|
361
|
+
this.createCharacteristicClass('Char158', uuid('158'), {
|
|
362
|
+
format: this.Formats.DATA,
|
|
363
|
+
perms: [this.Perms.READ, this.Perms.WRITE, this.Perms.HIDDEN]
|
|
364
|
+
}, 'Eve 158')
|
|
365
|
+
|
|
341
366
|
// =========================================================================
|
|
342
367
|
|
|
343
368
|
// The following custom characteristics are supported by the Eve app.
|
|
@@ -560,15 +585,16 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
560
585
|
])
|
|
561
586
|
|
|
562
587
|
this.createServiceClass('History', uuid('007'), [
|
|
563
|
-
this.Characteristics.HistoryRequest,
|
|
564
|
-
this.Characteristics.SetTime,
|
|
565
|
-
this.Characteristics.HistoryStatus,
|
|
566
|
-
this.Characteristics.HistoryEntries
|
|
588
|
+
this.Characteristics.HistoryRequest, // 11C
|
|
589
|
+
this.Characteristics.SetTime, // 121
|
|
590
|
+
this.Characteristics.HistoryStatus, // 116
|
|
591
|
+
this.Characteristics.HistoryEntries // 117
|
|
567
592
|
], [
|
|
568
|
-
|
|
569
|
-
this.Characteristics.
|
|
570
|
-
// this.Characteristics.
|
|
571
|
-
// this.Characteristics.
|
|
593
|
+
this.Characteristics.ResetTotal // 112
|
|
594
|
+
// this.Characteristics.ConfigCommand, // 11D
|
|
595
|
+
// this.Characteristics.ConfigData, // 131
|
|
596
|
+
// this.Characteristics.Char11E, // presumably for firmware upgrade
|
|
597
|
+
// this.Characteristics.Char158, // presumably for firmware upgrade
|
|
572
598
|
])
|
|
573
599
|
|
|
574
600
|
this.createServiceClass('AirPressureSensor', uuid('00A'), [
|
package/lib/MyHomeKitTypes.js
CHANGED
|
@@ -168,6 +168,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
168
168
|
* <br>Used by: homebridge-hue for Hue Entertainment groups.
|
|
169
169
|
* @property {Class} SubEnabled - Enabled/disable Sub.
|
|
170
170
|
* <br>Used by: homebridge-zp in Speaker service.
|
|
171
|
+
* @property {Class} SubLevel - Level for the Sub.
|
|
172
|
+
* <br>Used by: homebridge-zp in Speaker service.
|
|
171
173
|
* @property {Class} Sunrise - Date/time of today's sun rise.
|
|
172
174
|
* <br>Used by: homebridge-hue, homebridge-ws.
|
|
173
175
|
* @property {Class} Sunset - Date/time of today's sun set.
|
|
@@ -749,6 +751,14 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
749
751
|
adminOnlyAccess: [this.Access.WRITE]
|
|
750
752
|
}, 'Expose Schedules')
|
|
751
753
|
|
|
754
|
+
this.createCharacteristicClass('SubLevel', uuid('07D'), {
|
|
755
|
+
format: this.Formats.INT,
|
|
756
|
+
minValue: -15,
|
|
757
|
+
maxValue: 15,
|
|
758
|
+
minStep: 1,
|
|
759
|
+
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
760
|
+
}, 'Sub Level')
|
|
761
|
+
|
|
752
762
|
// Characteristic for Unique ID, used by homebridge-hue.
|
|
753
763
|
// Source: as exposed by the Philips Hue bridge. This characteristic is
|
|
754
764
|
// used by the Hue app to select the accessories when syncing Hue bridge
|
|
@@ -89,6 +89,11 @@ class AccessoryInformation extends ServiceDelegate {
|
|
|
89
89
|
value: params.software
|
|
90
90
|
})
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
accessoryDelegate.propertyDelegate('name')
|
|
94
|
+
.on('didSet', (value) => {
|
|
95
|
+
this.values.configuredName = value
|
|
96
|
+
})
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
addCharacteristicDelegate (params = {}) {
|
|
@@ -74,6 +74,11 @@ class Battery extends ServiceDelegate {
|
|
|
74
74
|
}).on('didSet', (value) => {
|
|
75
75
|
this.updateStatusLowBattery()
|
|
76
76
|
})
|
|
77
|
+
|
|
78
|
+
accessoryDelegate.propertyDelegate('name')
|
|
79
|
+
.on('didSet', (value) => {
|
|
80
|
+
this.values.configuredName = value + ' Battery'
|
|
81
|
+
})
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
updateStatusLowBattery () {
|
|
@@ -25,10 +25,10 @@ const { ServiceDelegate } = homebridgeLib
|
|
|
25
25
|
* @memberof ServiceDelegate
|
|
26
26
|
*/
|
|
27
27
|
class Dummy extends ServiceDelegate {
|
|
28
|
-
constructor (
|
|
29
|
-
params.name =
|
|
30
|
-
params.Service =
|
|
31
|
-
super(
|
|
28
|
+
constructor (accessoryDelegate, params = {}) {
|
|
29
|
+
params.name = accessoryDelegate.name
|
|
30
|
+
params.Service = accessoryDelegate.Services.hap.StatelessProgrammableSwitch
|
|
31
|
+
super(accessoryDelegate, params)
|
|
32
32
|
|
|
33
33
|
this.addCharacteristicDelegate({
|
|
34
34
|
key: 'programmableSwitchEvent',
|
|
@@ -38,6 +38,11 @@ class Dummy extends ServiceDelegate {
|
|
|
38
38
|
maxValue: this.Characteristics.hap.ProgrammableSwitchEvent.SINGLE_PRESS
|
|
39
39
|
}
|
|
40
40
|
})
|
|
41
|
+
|
|
42
|
+
accessoryDelegate.propertyDelegate('name')
|
|
43
|
+
.on('didSet', (value) => {
|
|
44
|
+
this.values.configuredName = value
|
|
45
|
+
})
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -47,44 +47,56 @@ class Consumption extends History {
|
|
|
47
47
|
* corresponding HomeKit accessory.
|
|
48
48
|
* @param {!object} params - The parameters for the
|
|
49
49
|
* _History_ HomeKit service.
|
|
50
|
-
* @param {!CharacteristicDelegate} consumptionDelegate - A reference
|
|
51
|
-
* delegate of the associated `Characteristics.eve.TotalConsumption`
|
|
50
|
+
* @param {!CharacteristicDelegate} params.consumptionDelegate - A reference
|
|
51
|
+
* to the delegate of the associated `Characteristics.eve.TotalConsumption`
|
|
52
52
|
* characteristic.
|
|
53
|
-
* @param {?CharacteristicDelegate} powerDelegate - A reference to the
|
|
53
|
+
* @param {?CharacteristicDelegate} params.powerDelegate - A reference to the
|
|
54
54
|
* delegate of the associated `Characteristics.eve.CurrentConsumption`
|
|
55
55
|
* characteristic.
|
|
56
|
-
* @param {!CharacteristicDelegate} onDelegate - A reference to the
|
|
56
|
+
* @param {!CharacteristicDelegate} params.onDelegate - A reference to the
|
|
57
57
|
* delegate of the associated `Characteristics.hap.On` characteristic.
|
|
58
|
+
* @param {!CharacteristicDelegate} params.lastActivationDelegate - A
|
|
59
|
+
* reference to the delegate of the associated
|
|
60
|
+
* `Characteristics.eve.LastActivation` characteristic.
|
|
58
61
|
*/
|
|
59
|
-
constructor (
|
|
60
|
-
accessoryDelegate, params, consumptionDelegate, powerDelegate, onDelegate
|
|
61
|
-
) {
|
|
62
|
+
constructor (accessoryDelegate, params = {}) {
|
|
62
63
|
super(accessoryDelegate, params)
|
|
63
|
-
if (!(consumptionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
64
|
-
throw new TypeError('consumptionDelegate: not a CharacteristicDelegate')
|
|
64
|
+
if (!(params.consumptionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
65
|
+
throw new TypeError('params.consumptionDelegate: not a CharacteristicDelegate')
|
|
65
66
|
}
|
|
66
67
|
if (
|
|
67
|
-
powerDelegate != null &&
|
|
68
|
-
!(powerDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
68
|
+
params.powerDelegate != null &&
|
|
69
|
+
!(params.powerDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
69
70
|
) {
|
|
70
|
-
throw new TypeError('powerDelegate: not a CharacteristicDelegate')
|
|
71
|
+
throw new TypeError('params.powerDelegate: not a CharacteristicDelegate')
|
|
71
72
|
}
|
|
72
73
|
if (
|
|
73
|
-
onDelegate != null &&
|
|
74
|
-
!(onDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
74
|
+
params.onDelegate != null &&
|
|
75
|
+
!(params.onDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
75
76
|
) {
|
|
76
|
-
throw new TypeError('
|
|
77
|
+
throw new TypeError('params.onDelegate: not a CharacteristicDelegate')
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
if (
|
|
80
|
+
params.lastActivationDelegate != null &&
|
|
81
|
+
!(params.lastActivationDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
82
|
+
) {
|
|
83
|
+
throw new TypeError('params.lastActivationDelegate: not a CharacteristicDelegate')
|
|
84
|
+
}
|
|
85
|
+
this._consumptionDelegate = params.consumptionDelegate
|
|
86
|
+
this._powerDelegate = params.powerDelegate
|
|
87
|
+
|
|
80
88
|
this._entry = { time: 0, power: 0 }
|
|
81
|
-
if (onDelegate != null) {
|
|
82
|
-
this._entry.on = onDelegate.value ? 1 : 0
|
|
83
|
-
onDelegate.on('didSet', (value) => {
|
|
89
|
+
if (params.onDelegate != null) {
|
|
90
|
+
this._entry.on = params.onDelegate.value ? 1 : 0
|
|
91
|
+
params.onDelegate.on('didSet', (value) => {
|
|
92
|
+
const now = Math.round(new Date().valueOf() / 1000)
|
|
93
|
+
if (params.lastActivationDelegate != null) {
|
|
94
|
+
params.lastActivationDelegate.value = now - this._h.initialTime
|
|
95
|
+
}
|
|
84
96
|
this._entry.on = value ? 1 : 0
|
|
85
97
|
const power = this._entry.power
|
|
86
98
|
this._entry.power = null
|
|
87
|
-
super._addEntry()
|
|
99
|
+
super._addEntry(now)
|
|
88
100
|
this._entry.power = power
|
|
89
101
|
})
|
|
90
102
|
}
|
|
@@ -96,11 +108,11 @@ class Consumption extends History {
|
|
|
96
108
|
if (this._consumption != null && this._time != null) {
|
|
97
109
|
const delta = this._consumptionDelegate.value - this._consumption // kWh
|
|
98
110
|
const period = now - this._time // s
|
|
99
|
-
const power =
|
|
111
|
+
const power = 1000 * 3600 * delta / period // W
|
|
100
112
|
if (this._powerDelegate != null) {
|
|
101
|
-
this._powerDelegate.value = power
|
|
113
|
+
this._powerDelegate.value = Math.round(power) // W
|
|
102
114
|
}
|
|
103
|
-
this._entry.power = power
|
|
115
|
+
this._entry.power = Math.round(power * 10) // 0.1 W * 10 min
|
|
104
116
|
super._addEntry(now)
|
|
105
117
|
}
|
|
106
118
|
this._consumption = this._consumptionDelegate.value
|
|
@@ -115,7 +127,7 @@ class Consumption extends History {
|
|
|
115
127
|
'|0c %s %s 01 %s',
|
|
116
128
|
numToHex(swap32(this._h.currentEntry), 8),
|
|
117
129
|
numToHex(swap32(entry.time - this._h.initialTime), 8),
|
|
118
|
-
numToHex(swap16(entry.power
|
|
130
|
+
numToHex(swap16(entry.power), 4)
|
|
119
131
|
)
|
|
120
132
|
}
|
|
121
133
|
if (entry.power == null) {
|
|
@@ -130,7 +142,7 @@ class Consumption extends History {
|
|
|
130
142
|
'|0d %s %s 03 %s %s',
|
|
131
143
|
numToHex(swap32(this._h.currentEntry), 8),
|
|
132
144
|
numToHex(swap32(entry.time - this._h.initialTime), 8),
|
|
133
|
-
numToHex(swap16(entry.power
|
|
145
|
+
numToHex(swap16(entry.power), 4),
|
|
134
146
|
numToHex(entry.on, 2)
|
|
135
147
|
)
|
|
136
148
|
}
|
|
@@ -38,40 +38,37 @@ const { swap32, numToHex } = History
|
|
|
38
38
|
* @memberof ServiceDelegate.History
|
|
39
39
|
*/
|
|
40
40
|
class Contact extends History {
|
|
41
|
-
/** Create a new instance of an Eve Door _History_ service delegate.
|
|
41
|
+
/** Create a new instance of an Eve Door & Window _History_ service delegate.
|
|
42
42
|
* @param {!AccessoryDelegate} accessoryDelegate - The delegate of the
|
|
43
43
|
* corresponding HomeKit accessory.
|
|
44
44
|
* @param {!object} params - The parameters for the
|
|
45
45
|
* _History_ HomeKit service.
|
|
46
|
-
* @param {!CharacteristicDelegate} contactDelegate - A reference to
|
|
47
|
-
*
|
|
46
|
+
* @param {!CharacteristicDelegate} params.contactDelegate - A reference to
|
|
47
|
+
* thedelegate of the associated `Characteristics.hap.ContactSensorState`
|
|
48
48
|
* characteristic.
|
|
49
|
-
* @param {!CharacteristicDelegate} timesOpenedDelegate - A reference
|
|
50
|
-
* delegate of the associated `Characteristics.eve.TimesOpened`
|
|
51
|
-
* characteristic.
|
|
52
|
-
* @param {!CharacteristicDelegate} lastActivationDelegate - A reference to the
|
|
53
|
-
* delegate of the associated `Characteristics.eve.LastActivation`
|
|
49
|
+
* @param {!CharacteristicDelegate} params.timesOpenedDelegate - A reference
|
|
50
|
+
* to the delegate of the associated `Characteristics.eve.TimesOpened`
|
|
54
51
|
* characteristic.
|
|
52
|
+
* @param {!CharacteristicDelegate} params.lastActivationDelegate - A
|
|
53
|
+
* reference to the delegate of the associated
|
|
54
|
+
* `Characteristics.eve.LastActivation` characteristic.
|
|
55
55
|
*/
|
|
56
|
-
constructor (
|
|
57
|
-
accessoryDelegate, params,
|
|
58
|
-
contactDelegate, timesOpenedDelegate, lastActivationDelegate
|
|
59
|
-
) {
|
|
56
|
+
constructor (accessoryDelegate, params) {
|
|
60
57
|
super(accessoryDelegate, params)
|
|
61
|
-
if (!(contactDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
62
|
-
throw new TypeError('contactDelegate: not a CharacteristicDelegate')
|
|
58
|
+
if (!(params.contactDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
59
|
+
throw new TypeError('params.contactDelegate: not a CharacteristicDelegate')
|
|
63
60
|
}
|
|
64
|
-
if (!(timesOpenedDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
65
|
-
throw new TypeError('timesOpenedDelegate: not a CharacteristicDelegate')
|
|
61
|
+
if (!(params.timesOpenedDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
62
|
+
throw new TypeError('params.timesOpenedDelegate: not a CharacteristicDelegate')
|
|
66
63
|
}
|
|
67
|
-
if (!(lastActivationDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
68
|
-
throw new TypeError('lastActivationDelegate: not a CharacteristicDelegate')
|
|
64
|
+
if (!(params.lastActivationDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
65
|
+
throw new TypeError('params.lastActivationDelegate: not a CharacteristicDelegate')
|
|
69
66
|
}
|
|
70
|
-
this._entry = { time: 0, status: contactDelegate.value }
|
|
71
|
-
contactDelegate.on('didSet', (value) => {
|
|
67
|
+
this._entry = { time: 0, status: params.contactDelegate.value }
|
|
68
|
+
params.contactDelegate.on('didSet', (value) => {
|
|
72
69
|
const now = Math.round(new Date().valueOf() / 1000)
|
|
73
|
-
timesOpenedDelegate.value += value
|
|
74
|
-
lastActivationDelegate.value = now - this._h.initialTime
|
|
70
|
+
params.timesOpenedDelegate.value += value
|
|
71
|
+
params.lastActivationDelegate.value = now - this._h.initialTime
|
|
75
72
|
this._entry.status = value
|
|
76
73
|
this._addEntry(now)
|
|
77
74
|
})
|
|
@@ -79,9 +76,8 @@ class Contact extends History {
|
|
|
79
76
|
key: 'resetTotal',
|
|
80
77
|
Characteristic: this.Characteristics.eve.ResetTotal,
|
|
81
78
|
value: params.resetTotal
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
timesOpenedDelegate.value = 0
|
|
79
|
+
}).on('didSet', (value) => {
|
|
80
|
+
params.timesOpenedDelegate.value = 0
|
|
85
81
|
})
|
|
86
82
|
}
|
|
87
83
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// homebridge-lib/lib/ServiceDelegate/History/On.js
|
|
2
|
+
//
|
|
3
|
+
// Library for Homebridge plugins.
|
|
4
|
+
// Copyright © 2017-2022 Erik Baauw. All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
// The logic for handling Eve history was copied from Simone Tisa's
|
|
7
|
+
// fakagato-history repository, copyright © 2017 simont77.
|
|
8
|
+
// See https://github.com/simont77/fakegato-history.
|
|
9
|
+
|
|
10
|
+
'use strict'
|
|
11
|
+
|
|
12
|
+
const homebridgeLib = require('../../../index')
|
|
13
|
+
|
|
14
|
+
const { ServiceDelegate } = homebridgeLib
|
|
15
|
+
const { History } = ServiceDelegate
|
|
16
|
+
|
|
17
|
+
/** Class for an Eve Light Strip _History_ service delegate.
|
|
18
|
+
*
|
|
19
|
+
* This delegate sets up a `Services.eve.History` HomeKit service
|
|
20
|
+
* with keys for the following HomeKit characteristics:
|
|
21
|
+
*
|
|
22
|
+
* key | Characteristic
|
|
23
|
+
* ---------------- | ----------------------------------
|
|
24
|
+
* `name` | `Characteristics.hap.Name`
|
|
25
|
+
* `historyRequest` | `Characteristics.eve.HistoryRequest`
|
|
26
|
+
* `setTime` | `Characteristics.eve.SetTime`
|
|
27
|
+
* `historyStatus` | `Characteristics.eve.HistoryStatus`
|
|
28
|
+
* `historyEntries` | `Characteristics.eve.HistoryEntries`
|
|
29
|
+
*
|
|
30
|
+
* This delegate creates the history from the associated
|
|
31
|
+
* `Characteristics.hap.On` characteristic.
|
|
32
|
+
* @extends ServiceDelegate.History
|
|
33
|
+
* @memberof ServiceDelegate.History
|
|
34
|
+
*/
|
|
35
|
+
class Light extends History {
|
|
36
|
+
/** Create a new instance of a Raspberry Pi _History_ service delegate.
|
|
37
|
+
* @param {!AccessoryDelegate} accessoryDelegate - The delegate of the
|
|
38
|
+
* corresponding HomeKit accessory.
|
|
39
|
+
* @param {!object} params - The parameters for the
|
|
40
|
+
* _History_ HomeKit service.
|
|
41
|
+
* @param {!CharacteristicDelegate} params.onDelegate - A reference to the
|
|
42
|
+
* delegate of the associated `Characteristics.hap.On`
|
|
43
|
+
* characteristic.
|
|
44
|
+
* @param {!CharacteristicDelegate} params.lastActivationDelegate - A
|
|
45
|
+
* reference to the delegate of the associated
|
|
46
|
+
* `Characteristics.eve.LastActivation` characteristic.
|
|
47
|
+
*/
|
|
48
|
+
constructor (accessoryDelegate, params) {
|
|
49
|
+
params.memorySize = 0
|
|
50
|
+
super(accessoryDelegate, params)
|
|
51
|
+
if (!(params.onDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
52
|
+
throw new TypeError('params.onDelegate: not a CharacteristicDelegate')
|
|
53
|
+
}
|
|
54
|
+
if (!(params.lastActivationDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
55
|
+
throw new TypeError('params.lastActivationDelegate: not a CharacteristicDelegate')
|
|
56
|
+
}
|
|
57
|
+
if (
|
|
58
|
+
params.temperatureDelegate != null &&
|
|
59
|
+
!(params.temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
60
|
+
) {
|
|
61
|
+
throw new TypeError('params.temperatureDelegate: not a CharacteristicDelegate')
|
|
62
|
+
}
|
|
63
|
+
this._entry = {
|
|
64
|
+
time: 0
|
|
65
|
+
}
|
|
66
|
+
params.onDelegate.on('didSet', (value) => {
|
|
67
|
+
const now = Math.round(new Date().valueOf() / 1000)
|
|
68
|
+
if (params.lastActivationDelegate != null) {
|
|
69
|
+
params.lastActivationDelegate.value = now - this._h.initialTime
|
|
70
|
+
}
|
|
71
|
+
this._addEntry(now)
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get _fingerPrint () { return '00' }
|
|
76
|
+
|
|
77
|
+
_entryStream (entry) {
|
|
78
|
+
return ''
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = Light
|
|
@@ -42,49 +42,47 @@ class Motion extends History {
|
|
|
42
42
|
* corresponding HomeKit accessory.
|
|
43
43
|
* @param {!object} params - The parameters for the
|
|
44
44
|
* _History_ HomeKit service.
|
|
45
|
-
* @param {!CharacteristicDelegate} motionDelegate - A reference to
|
|
46
|
-
* delegate of the associated `Characteristics.hap.MotionDetected`
|
|
45
|
+
* @param {!CharacteristicDelegate} params.motionDelegate - A reference to
|
|
46
|
+
* the delegate of the associated `Characteristics.hap.MotionDetected`
|
|
47
47
|
* characteristic.
|
|
48
|
-
* @param {!CharacteristicDelegate} lastActivationDelegate - A
|
|
49
|
-
* delegate of the associated
|
|
48
|
+
* @param {!CharacteristicDelegate} params.lastActivationDelegate - A
|
|
49
|
+
* reference to the delegate of the associated
|
|
50
|
+
* `Characteristics.eve.LastActivation` characteristic.
|
|
51
|
+
* @param {?CharacteristicDelegate} params.lightLevelDelegate - A reference
|
|
52
|
+
* to the delegate of the associated
|
|
53
|
+
* `Characteristics.hap.CurrentAmbientLightLevel` characteristic.
|
|
54
|
+
* For PIR sensors (like the Hue motion sensor) that report light level in
|
|
55
|
+
* addition to motion.
|
|
56
|
+
* @param {?CharacteristicDelegate} params.temperatureDelegate - A reference
|
|
57
|
+
* to the delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
50
58
|
* characteristic.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* characteristic. For PIR sensors (like the Hue motion sensor) that report
|
|
54
|
-
* light level in addition to motion.
|
|
55
|
-
* @param {?CharacteristicDelegate} temperatureDelegate - A reference to the
|
|
56
|
-
* delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
57
|
-
* characteristic. For PIR sensors (like the Hue motion sensor) that report
|
|
58
|
-
* temperature in addition to motion.
|
|
59
|
+
* For PIR sensors (like the Hue motion sensor) that report temperature in
|
|
60
|
+
* addition to motion.
|
|
59
61
|
*/
|
|
60
|
-
constructor (
|
|
61
|
-
accessoryDelegate, params,
|
|
62
|
-
motionDelegate, lastActivationDelegate,
|
|
63
|
-
lightLevelDelegate, temperatureDelegate
|
|
64
|
-
) {
|
|
62
|
+
constructor (accessoryDelegate, params) {
|
|
65
63
|
super(accessoryDelegate, params)
|
|
66
|
-
if (!(motionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
67
|
-
throw new TypeError('motionDelegate: not a CharacteristicDelegate')
|
|
64
|
+
if (!(params.motionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
65
|
+
throw new TypeError('params.motionDelegate: not a CharacteristicDelegate')
|
|
68
66
|
}
|
|
69
|
-
if (!(lastActivationDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
70
|
-
throw new TypeError('lastActivationDelegate: not a CharacteristicDelegate')
|
|
67
|
+
if (!(params.lastActivationDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
68
|
+
throw new TypeError('params.lastActivationDelegate: not a CharacteristicDelegate')
|
|
71
69
|
}
|
|
72
70
|
if (
|
|
73
|
-
lightLevelDelegate != null &&
|
|
74
|
-
!(lightLevelDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
71
|
+
params.lightLevelDelegate != null &&
|
|
72
|
+
!(params.lightLevelDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
75
73
|
) {
|
|
76
|
-
throw new TypeError('lightLevelDelegate: not a CharacteristicDelegate')
|
|
74
|
+
throw new TypeError('params.lightLevelDelegate: not a CharacteristicDelegate')
|
|
77
75
|
}
|
|
78
76
|
if (
|
|
79
|
-
temperatureDelegate != null &&
|
|
80
|
-
!(temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
77
|
+
params.temperatureDelegate != null &&
|
|
78
|
+
!(params.temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
81
79
|
) {
|
|
82
|
-
throw new TypeError('temperatureDelegate: not a CharacteristicDelegate')
|
|
80
|
+
throw new TypeError('params.temperatureDelegate: not a CharacteristicDelegate')
|
|
83
81
|
}
|
|
84
|
-
this._entry = { time: 0, status: motionDelegate.value }
|
|
85
|
-
motionDelegate.on('didSet', (value) => {
|
|
82
|
+
this._entry = { time: 0, status: params.motionDelegate.value }
|
|
83
|
+
params.motionDelegate.on('didSet', (value) => {
|
|
86
84
|
const now = Math.round(new Date().valueOf() / 1000)
|
|
87
|
-
lastActivationDelegate.value = now - this._h.initialTime
|
|
85
|
+
params.lastActivationDelegate.value = now - this._h.initialTime
|
|
88
86
|
this._entry.status = value
|
|
89
87
|
if (this._entry.temp != null) {
|
|
90
88
|
const lightlevel = this._entry.lightlevel
|
|
@@ -98,15 +96,15 @@ class Motion extends History {
|
|
|
98
96
|
this._addEntry(now)
|
|
99
97
|
}
|
|
100
98
|
})
|
|
101
|
-
if (lightLevelDelegate != null) {
|
|
102
|
-
this._entry.lightlevel = lightLevelDelegate.value
|
|
103
|
-
lightLevelDelegate.on('didSet', (value) => {
|
|
99
|
+
if (params.lightLevelDelegate != null) {
|
|
100
|
+
this._entry.lightlevel = params.lightLevelDelegate.value
|
|
101
|
+
params.lightLevelDelegate.on('didSet', (value) => {
|
|
104
102
|
this._entry.lightlevel = value
|
|
105
103
|
})
|
|
106
104
|
}
|
|
107
|
-
if (temperatureDelegate != null) {
|
|
108
|
-
this._entry.temp = temperatureDelegate.value
|
|
109
|
-
temperatureDelegate.on('didSet', (value) => {
|
|
105
|
+
if (params.temperatureDelegate != null) {
|
|
106
|
+
this._entry.temp = params.temperatureDelegate.value
|
|
107
|
+
params.temperatureDelegate.on('didSet', (value) => {
|
|
110
108
|
this._entry.temp = value
|
|
111
109
|
})
|
|
112
110
|
}
|
|
@@ -40,32 +40,48 @@ class On extends History {
|
|
|
40
40
|
* corresponding HomeKit accessory.
|
|
41
41
|
* @param {!object} params - The parameters for the
|
|
42
42
|
* _History_ HomeKit service.
|
|
43
|
-
* @param {!CharacteristicDelegate} onDelegate - A reference to the
|
|
43
|
+
* @param {!CharacteristicDelegate} params.onDelegate - A reference to the
|
|
44
44
|
* delegate of the associated `Characteristics.hap.On`
|
|
45
45
|
* characteristic.
|
|
46
|
+
* @param {?CharacteristicDelegate} params.lastActivationDelegate - A
|
|
47
|
+
* reference to the delegate of the associated
|
|
48
|
+
* `Characteristics.eve.LastActivation` characteristic.
|
|
49
|
+
* @param {?CharacteristicDelegate} params.temperatureDelegate - A reference
|
|
50
|
+
* to the delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
51
|
+
* characteristic.
|
|
46
52
|
*/
|
|
47
|
-
constructor (accessoryDelegate, params
|
|
53
|
+
constructor (accessoryDelegate, params) {
|
|
48
54
|
super(accessoryDelegate, params)
|
|
49
|
-
if (!(onDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
50
|
-
throw new TypeError('onDelegate: not a CharacteristicDelegate')
|
|
55
|
+
if (!(params.onDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
56
|
+
throw new TypeError('params.onDelegate: not a CharacteristicDelegate')
|
|
57
|
+
}
|
|
58
|
+
if (
|
|
59
|
+
params.lastActivationDelegate != null &&
|
|
60
|
+
!(params.lastActivationDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
61
|
+
) {
|
|
62
|
+
throw new TypeError('params.lastActivationDelegate: not a CharacteristicDelegate')
|
|
51
63
|
}
|
|
52
64
|
if (
|
|
53
|
-
temperatureDelegate != null &&
|
|
54
|
-
!(temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
65
|
+
params.temperatureDelegate != null &&
|
|
66
|
+
!(params.temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
55
67
|
) {
|
|
56
|
-
throw new TypeError('temperatureDelegate: not a CharacteristicDelegate')
|
|
68
|
+
throw new TypeError('params.temperatureDelegate: not a CharacteristicDelegate')
|
|
57
69
|
}
|
|
58
70
|
this._entry = {
|
|
59
71
|
time: 0,
|
|
60
|
-
on: onDelegate.value ? 1 : 0
|
|
72
|
+
on: params.onDelegate.value ? 1 : 0
|
|
61
73
|
}
|
|
62
|
-
onDelegate.on('didSet', (value) => {
|
|
74
|
+
params.onDelegate.on('didSet', (value) => {
|
|
75
|
+
const now = Math.round(new Date().valueOf() / 1000)
|
|
76
|
+
if (params.lastActivationDelegate != null) {
|
|
77
|
+
params.lastActivationDelegate.value = now - this._h.initialTime
|
|
78
|
+
}
|
|
63
79
|
this._entry.on = value ? 1 : 0
|
|
64
|
-
this._addEntry()
|
|
80
|
+
this._addEntry(now)
|
|
65
81
|
})
|
|
66
|
-
if (temperatureDelegate != null) {
|
|
67
|
-
this._entry.temp = temperatureDelegate.value
|
|
68
|
-
temperatureDelegate.on('didSet', (value) => {
|
|
82
|
+
if (params.temperatureDelegate != null) {
|
|
83
|
+
this._entry.temp = params.temperatureDelegate.value
|
|
84
|
+
params.temperatureDelegate.on('didSet', (value) => {
|
|
69
85
|
this._entry.temp = value
|
|
70
86
|
})
|
|
71
87
|
}
|
|
@@ -43,42 +43,40 @@ class Power extends History {
|
|
|
43
43
|
* corresponding HomeKit accessory.
|
|
44
44
|
* @param {!object} params - The parameters for the
|
|
45
45
|
* _History_ HomeKit service.
|
|
46
|
-
* @param {!CharacteristicDelegate} powerDelegate - A reference to the
|
|
46
|
+
* @param {!CharacteristicDelegate} params.powerDelegate - A reference to the
|
|
47
47
|
* delegate of the associated `Characteristics.eve.CurrentConsumption`
|
|
48
48
|
* characteristic.
|
|
49
|
-
* @param {!CharacteristicDelegate} consumptionDelegate - A reference
|
|
50
|
-
* delegate of the associated `Characteristics.eve.TotalConsumption`
|
|
49
|
+
* @param {!CharacteristicDelegate} params.consumptionDelegate - A reference
|
|
50
|
+
* to the delegate of the associated `Characteristics.eve.TotalConsumption`
|
|
51
51
|
* characteristic.
|
|
52
|
-
* @param {!CharacteristicDelegate} onDelegate - A reference to the
|
|
52
|
+
* @param {!CharacteristicDelegate} params.onDelegate - A reference to the
|
|
53
53
|
* delegate of the associated `Characteristics.hap.On` characteristic.
|
|
54
54
|
*/
|
|
55
|
-
constructor (
|
|
56
|
-
accessoryDelegate, params, powerDelegate, consumptionDelegate, onDelegate
|
|
57
|
-
) {
|
|
55
|
+
constructor (accessoryDelegate, params) {
|
|
58
56
|
super(accessoryDelegate, params)
|
|
59
|
-
if (!(powerDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
60
|
-
throw new TypeError('powerDelegate: not a CharacteristicDelegate')
|
|
57
|
+
if (!(params.powerDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
58
|
+
throw new TypeError('params.powerDelegate: not a CharacteristicDelegate')
|
|
61
59
|
}
|
|
62
|
-
if (!(consumptionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
63
|
-
throw new TypeError('consumptionDelegate: not a CharacteristicDelegate')
|
|
60
|
+
if (!(params.consumptionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
61
|
+
throw new TypeError('params.consumptionDelegate: not a CharacteristicDelegate')
|
|
64
62
|
}
|
|
65
63
|
if (
|
|
66
|
-
onDelegate != null &&
|
|
67
|
-
!(onDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
64
|
+
params.onDelegate != null &&
|
|
65
|
+
!(params.onDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
68
66
|
) {
|
|
69
|
-
throw new TypeError('temperatureDelegate: not a CharacteristicDelegate')
|
|
67
|
+
throw new TypeError('params.temperatureDelegate: not a CharacteristicDelegate')
|
|
70
68
|
}
|
|
71
|
-
this._powerDelegate = powerDelegate
|
|
72
|
-
this._consumptionDelegate = consumptionDelegate
|
|
69
|
+
this._powerDelegate = params.powerDelegate
|
|
70
|
+
this._consumptionDelegate = params.consumptionDelegate
|
|
73
71
|
this._entry = { time: 0, power: 0 }
|
|
74
72
|
this._runningConsumption = 0 // 10-min-interval running value
|
|
75
|
-
this._totalConsumption = consumptionDelegate.value // life-time value
|
|
76
|
-
powerDelegate.on('didSet', (value) => {
|
|
73
|
+
this._totalConsumption = params.consumptionDelegate.value // life-time value
|
|
74
|
+
params.powerDelegate.on('didSet', (value) => {
|
|
77
75
|
const now = Math.round(new Date().valueOf() / 1000)
|
|
78
76
|
if (this._time != null) {
|
|
79
77
|
const delta = this._power * (now - this._time) // Ws
|
|
80
|
-
this._runningConsumption += Math.round(delta /
|
|
81
|
-
this._totalConsumption +=
|
|
78
|
+
this._runningConsumption += Math.round(delta / 60.0) // 0.1W * 10 min
|
|
79
|
+
this._totalConsumption += delta / 36000.0 // 0.01 kWh
|
|
82
80
|
}
|
|
83
81
|
this._power = value
|
|
84
82
|
this._time = now
|
|
@@ -87,33 +85,36 @@ class Power extends History {
|
|
|
87
85
|
key: 'resetTotal',
|
|
88
86
|
Characteristic: this.Characteristics.eve.ResetTotal,
|
|
89
87
|
value: params.resetTotal
|
|
90
|
-
})
|
|
91
|
-
this._characteristicDelegates.resetTotal.on('didSet', (value) => {
|
|
88
|
+
}).on('didSet', (value) => {
|
|
92
89
|
this._runningConsumption = 0
|
|
93
90
|
this._totalConsumption = 0
|
|
94
91
|
this._consumptionDelegate.value = this._totalConsumption
|
|
95
92
|
})
|
|
96
|
-
if (onDelegate != null) {
|
|
97
|
-
this._entry.on = onDelegate.value ? 1 : 0
|
|
98
|
-
onDelegate.on('didSet', (value) => {
|
|
93
|
+
if (params.onDelegate != null) {
|
|
94
|
+
this._entry.on = params.onDelegate.value ? 1 : 0
|
|
95
|
+
params.onDelegate.on('didSet', (value) => {
|
|
96
|
+
const now = Math.round(new Date().valueOf() / 1000)
|
|
97
|
+
if (params.lastActivationDelegate != null) {
|
|
98
|
+
params.lastActivationDelegate.value = now - this._h.initialTime
|
|
99
|
+
}
|
|
99
100
|
this._entry.on = value ? 1 : 0
|
|
100
101
|
const power = this._entry.power
|
|
101
102
|
this._entry.power = null
|
|
102
|
-
super._addEntry()
|
|
103
|
+
super._addEntry(now)
|
|
103
104
|
this._entry.power = power
|
|
104
105
|
})
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
_addEntry () {
|
|
109
|
-
// Sensor delivers currentConsumption, compute totalConsumption
|
|
110
110
|
const now = Math.round(new Date().valueOf() / 1000)
|
|
111
|
+
// Sensor delivers currentConsumption, compute totalConsumption
|
|
111
112
|
if (this._time != null) {
|
|
112
113
|
const delta = this._power * (now - this._time) // Ws
|
|
113
|
-
this._runningConsumption +=
|
|
114
|
-
this._totalConsumption +=
|
|
115
|
-
this._consumptionDelegate.value = this._totalConsumption
|
|
116
|
-
this._entry.power = this._runningConsumption
|
|
114
|
+
this._runningConsumption += delta / 60.0 // 0.1 W * 10 min
|
|
115
|
+
this._totalConsumption += delta / 36000.0 // 0.01 kWh
|
|
116
|
+
this._consumptionDelegate.value = Math.round(this._totalConsumption) / 100.0 // kWh
|
|
117
|
+
this._entry.power = Math.round(this._runningConsumption) // 0.1 W * 10 min
|
|
117
118
|
super._addEntry(now)
|
|
118
119
|
} else if (this._entry.on != null) {
|
|
119
120
|
super._addEntry(now)
|
|
@@ -131,7 +132,7 @@ class Power extends History {
|
|
|
131
132
|
'|0c %s %s 01 %s',
|
|
132
133
|
numToHex(swap32(this._h.currentEntry), 8),
|
|
133
134
|
numToHex(swap32(entry.time - this._h.initialTime), 8),
|
|
134
|
-
numToHex(swap16(entry.power
|
|
135
|
+
numToHex(swap16(entry.power), 4)
|
|
135
136
|
)
|
|
136
137
|
}
|
|
137
138
|
if (entry.power == null) {
|
|
@@ -146,7 +147,7 @@ class Power extends History {
|
|
|
146
147
|
'|0d %s %s 03 %s %s',
|
|
147
148
|
numToHex(swap32(this._h.currentEntry), 8),
|
|
148
149
|
numToHex(swap32(entry.time - this._h.initialTime), 8),
|
|
149
|
-
numToHex(swap16(entry.power
|
|
150
|
+
numToHex(swap16(entry.power), 4),
|
|
150
151
|
numToHex(entry.on, 2)
|
|
151
152
|
)
|
|
152
153
|
}
|
|
@@ -42,53 +42,50 @@ class Room extends ServiceDelegate.History {
|
|
|
42
42
|
* corresponding HomeKit accessory.
|
|
43
43
|
* @param {!object} params - The parameters for the
|
|
44
44
|
* _History_ HomeKit service.
|
|
45
|
-
* @param {!CharacteristicDelegate} temperatureDelegate - A reference
|
|
46
|
-
* delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
45
|
+
* @param {!CharacteristicDelegate} params.temperatureDelegate - A reference
|
|
46
|
+
* to the delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
47
47
|
* characteristic.
|
|
48
|
-
* @param {?CharacteristicDelegate} humidityDelegate - A reference to
|
|
49
|
-
* delegate of the associated
|
|
50
|
-
* characteristic.
|
|
51
|
-
* @param {?CharacteristicDelegate} vocDensityDelegate - A reference
|
|
52
|
-
* delegate of the associated `Characteristics.eve.AirPressure`
|
|
48
|
+
* @param {?CharacteristicDelegate} params.humidityDelegate - A reference to
|
|
49
|
+
* the delegate of the associated
|
|
50
|
+
* `Characteristics.hap.CurrentRelativeHumidity` characteristic.
|
|
51
|
+
* @param {?CharacteristicDelegate} params.vocDensityDelegate - A reference
|
|
52
|
+
* to the delegate of the associated `Characteristics.eve.AirPressure`
|
|
53
53
|
* characteristic.
|
|
54
54
|
*/
|
|
55
|
-
constructor (
|
|
56
|
-
accessoryDelegate, params,
|
|
57
|
-
temperatureDelegate, humidityDelegate, vocDensityDelegate
|
|
58
|
-
) {
|
|
55
|
+
constructor (accessoryDelegate, params) {
|
|
59
56
|
super(accessoryDelegate, params)
|
|
60
|
-
if (!(temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
61
|
-
throw new TypeError('temperatureDelegate: not a CharacteristicDelegate')
|
|
57
|
+
if (!(params.temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
58
|
+
throw new TypeError('params.temperatureDelegate: not a CharacteristicDelegate')
|
|
62
59
|
}
|
|
63
60
|
if (
|
|
64
|
-
humidityDelegate != null &&
|
|
65
|
-
!(humidityDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
61
|
+
params.humidityDelegate != null &&
|
|
62
|
+
!(params.humidityDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
66
63
|
) {
|
|
67
|
-
throw new TypeError('humidityDelegate: not a CharacteristicDelegate')
|
|
64
|
+
throw new TypeError('params.humidityDelegate: not a CharacteristicDelegate')
|
|
68
65
|
}
|
|
69
66
|
if (
|
|
70
|
-
vocDensityDelegate != null &&
|
|
71
|
-
!(vocDensityDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
67
|
+
params.vocDensityDelegate != null &&
|
|
68
|
+
!(params.vocDensityDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
72
69
|
) {
|
|
73
|
-
throw new TypeError('vocDensityDelegate: not a CharacteristicDelegate')
|
|
70
|
+
throw new TypeError('params.vocDensityDelegate: not a CharacteristicDelegate')
|
|
74
71
|
}
|
|
75
72
|
this._entry = {
|
|
76
73
|
time: 0,
|
|
77
|
-
temp: temperatureDelegate.value,
|
|
74
|
+
temp: params.temperatureDelegate.value,
|
|
78
75
|
humidity: 0,
|
|
79
76
|
voc: 0
|
|
80
77
|
}
|
|
81
|
-
temperatureDelegate.on('didSet', (value) => {
|
|
78
|
+
params.temperatureDelegate.on('didSet', (value) => {
|
|
82
79
|
this._entry.temp = value
|
|
83
80
|
})
|
|
84
|
-
if (humidityDelegate != null) {
|
|
85
|
-
this._entry.humidity = humidityDelegate.value
|
|
86
|
-
humidityDelegate.on('didSet', (value) => {
|
|
81
|
+
if (params.humidityDelegate != null) {
|
|
82
|
+
this._entry.humidity = params.humidityDelegate.value
|
|
83
|
+
params.humidityDelegate.on('didSet', (value) => {
|
|
87
84
|
this._entry.humidity = value
|
|
88
85
|
})
|
|
89
|
-
if (vocDensityDelegate != null) {
|
|
90
|
-
this._entry.voc = vocDensityDelegate.value
|
|
91
|
-
vocDensityDelegate.on('didSet', (value) => {
|
|
86
|
+
if (params.vocDensityDelegate != null) {
|
|
87
|
+
this._entry.voc = params.vocDensityDelegate.value
|
|
88
|
+
params.vocDensityDelegate.on('didSet', (value) => {
|
|
92
89
|
this._entry.voc = value
|
|
93
90
|
})
|
|
94
91
|
}
|
|
@@ -42,42 +42,42 @@ class Thermo extends ServiceDelegate.History {
|
|
|
42
42
|
* corresponding HomeKit accessory.
|
|
43
43
|
* @param {!object} params - The parameters for the
|
|
44
44
|
* _History_ HomeKit service.
|
|
45
|
-
* @param {!CharacteristicDelegate} temperatureDelegate - A reference
|
|
46
|
-
* delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
47
|
-
* characteristic.
|
|
48
|
-
* @param {!CharacteristicDelegate} targetTemperatureDelegate - A reference
|
|
49
|
-
* to the delegate of the associated `Characteristics.hap.TargetTemperature`
|
|
50
|
-
* characteristic.
|
|
51
|
-
* @param {!CharacteristicDelegate} valvePositionDelegate - A reference to
|
|
52
|
-
* the delegate of the associated `Characteristics.eve.ValvePosition`
|
|
45
|
+
* @param {!CharacteristicDelegate} params.temperatureDelegate - A reference
|
|
46
|
+
* to the delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
53
47
|
* characteristic.
|
|
48
|
+
* @param {!CharacteristicDelegate} params.targetTemperatureDelegate - A
|
|
49
|
+
* reference to the delegate of the associated
|
|
50
|
+
* `Characteristics.hap.TargetTemperature` characteristic.
|
|
51
|
+
* @param {!CharacteristicDelegate} params.valvePositionDelegate - A
|
|
52
|
+
* reference to the delegate of the associated
|
|
53
|
+
* `Characteristics.eve.ValvePosition` characteristic.
|
|
54
54
|
*/
|
|
55
|
-
constructor (
|
|
56
|
-
accessoryDelegate, params,
|
|
57
|
-
temperatureDelegate, targetTemperatureDelegate, valvePositionDelegate
|
|
58
|
-
) {
|
|
55
|
+
constructor (accessoryDelegate, params) {
|
|
59
56
|
super(accessoryDelegate, params)
|
|
60
|
-
if (!(temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
61
|
-
throw new TypeError('temperatureDelegate: not a CharacteristicDelegate')
|
|
57
|
+
if (!(params.temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
58
|
+
throw new TypeError('params.temperatureDelegate: not a CharacteristicDelegate')
|
|
62
59
|
}
|
|
63
|
-
if (!(targetTemperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
64
|
-
throw new TypeError('targetTemperatureDelegate: not a CharacteristicDelegate')
|
|
60
|
+
if (!(params.targetTemperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
61
|
+
throw new TypeError('params.targetTemperatureDelegate: not a CharacteristicDelegate')
|
|
65
62
|
}
|
|
66
|
-
if (!(valvePositionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
67
|
-
throw new TypeError('valvePositionDelegate: not a CharacteristicDelegate')
|
|
63
|
+
if (!(params.valvePositionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
64
|
+
throw new TypeError('params.valvePositionDelegate: not a CharacteristicDelegate')
|
|
68
65
|
}
|
|
69
66
|
this._entry = {
|
|
70
67
|
time: 0,
|
|
71
|
-
currentTemp: temperatureDelegate.value,
|
|
72
|
-
setTemp: targetTemperatureDelegate.value,
|
|
73
|
-
valvePosition: valvePositionDelegate.value
|
|
68
|
+
currentTemp: params.temperatureDelegate.value,
|
|
69
|
+
setTemp: params.targetTemperatureDelegate.value,
|
|
70
|
+
valvePosition: params.valvePositionDelegate.value
|
|
74
71
|
}
|
|
75
|
-
temperatureDelegate
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
params.temperatureDelegate.on('didSet', (value) => {
|
|
73
|
+
this._entry.currentTemp = value
|
|
74
|
+
})
|
|
75
|
+
params.targetTemperatureDelegate.on('didSet', (value) => {
|
|
76
|
+
this._entry.setTemp = value
|
|
77
|
+
})
|
|
78
|
+
params.valvePositionDelegate.on('didSet', (value) => {
|
|
79
|
+
this._entry.valvePosition = value
|
|
80
|
+
})
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// I think 1201 and 1d01 are for current mode and target more, but it doesn't
|
|
@@ -42,51 +42,48 @@ class Weather extends ServiceDelegate.History {
|
|
|
42
42
|
* corresponding HomeKit accessory.
|
|
43
43
|
* @param {!object} params - The parameters for the
|
|
44
44
|
* _History_ HomeKit service.
|
|
45
|
-
* @param {!CharacteristicDelegate} temperatureDelegate - A reference
|
|
46
|
-
* delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
45
|
+
* @param {!CharacteristicDelegate} params.temperatureDelegate - A reference
|
|
46
|
+
* to the delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
47
47
|
* characteristic.
|
|
48
|
-
* @param {?CharacteristicDelegate} humidityDelegate - A reference
|
|
49
|
-
* delegate of the associated
|
|
50
|
-
* characteristic.
|
|
51
|
-
* @param {?CharacteristicDelegate} pressureDelegate - A reference to
|
|
52
|
-
* delegate of the associated `Characteristics.eve.AirPressure`
|
|
48
|
+
* @param {?CharacteristicDelegate} params.humidityDelegate - A reference
|
|
49
|
+
* to the delegate of the associated
|
|
50
|
+
* `Characteristics.hap.CurrentRelativeHumidity` characteristic.
|
|
51
|
+
* @param {?CharacteristicDelegate} params.pressureDelegate - A reference to
|
|
52
|
+
* the delegate of the associated `Characteristics.eve.AirPressure`
|
|
53
53
|
* characteristic.
|
|
54
54
|
*/
|
|
55
|
-
constructor (
|
|
56
|
-
accessoryDelegate, params,
|
|
57
|
-
temperatureDelegate, humidityDelegate, pressureDelegate
|
|
58
|
-
) {
|
|
55
|
+
constructor (accessoryDelegate, params) {
|
|
59
56
|
super(accessoryDelegate, params)
|
|
60
|
-
if (!(temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
61
|
-
throw new TypeError('temperatureDelegate: not a CharacteristicDelegate')
|
|
57
|
+
if (!(params.temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
58
|
+
throw new TypeError('params.temperatureDelegate: not a CharacteristicDelegate')
|
|
62
59
|
}
|
|
63
60
|
if (
|
|
64
|
-
humidityDelegate != null &&
|
|
65
|
-
!(humidityDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
61
|
+
params.humidityDelegate != null &&
|
|
62
|
+
!(params.humidityDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
66
63
|
) {
|
|
67
64
|
throw new TypeError('humidityDelegate: not a CharacteristicDelegate')
|
|
68
65
|
}
|
|
69
66
|
if (
|
|
70
|
-
pressureDelegate != null &&
|
|
71
|
-
!(pressureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
67
|
+
params.pressureDelegate != null &&
|
|
68
|
+
!(params.pressureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
72
69
|
) {
|
|
73
70
|
throw new TypeError('pressureDelegate: not a CharacteristicDelegate')
|
|
74
71
|
}
|
|
75
72
|
this._entry = {
|
|
76
73
|
time: 0,
|
|
77
|
-
temp: temperatureDelegate.value
|
|
74
|
+
temp: params.temperatureDelegate.value
|
|
78
75
|
}
|
|
79
|
-
temperatureDelegate.on('didSet', (value) => {
|
|
76
|
+
params.temperatureDelegate.on('didSet', (value) => {
|
|
80
77
|
this._entry.temp = value
|
|
81
78
|
})
|
|
82
|
-
if (humidityDelegate != null) {
|
|
83
|
-
this._entry.humidity = humidityDelegate.value
|
|
84
|
-
humidityDelegate.on('didSet', (value) => {
|
|
79
|
+
if (params.humidityDelegate != null) {
|
|
80
|
+
this._entry.humidity = params.humidityDelegate.value
|
|
81
|
+
params.humidityDelegate.on('didSet', (value) => {
|
|
85
82
|
this._entry.humidity = value
|
|
86
83
|
})
|
|
87
|
-
if (pressureDelegate != null) {
|
|
88
|
-
this._entry.pressure = pressureDelegate.value
|
|
89
|
-
pressureDelegate.on('didSet', (value) => {
|
|
84
|
+
if (params.pressureDelegate != null) {
|
|
85
|
+
this._entry.pressure = params.pressureDelegate.value
|
|
86
|
+
params.pressureDelegate.on('didSet', (value) => {
|
|
90
87
|
this._entry.pressure = value
|
|
91
88
|
})
|
|
92
89
|
}
|
|
@@ -82,6 +82,7 @@ function numToHex (value, length) {
|
|
|
82
82
|
class History extends ServiceDelegate {
|
|
83
83
|
static get Consumption () { return require('./Consumption') }
|
|
84
84
|
static get Contact () { return require('./Contact') }
|
|
85
|
+
static get Light () { return require('./Light') }
|
|
85
86
|
static get Motion () { return require('./Motion') }
|
|
86
87
|
static get On () { return require('./On') }
|
|
87
88
|
static get Power () { return require('./Power') }
|
|
@@ -100,13 +101,15 @@ class History extends ServiceDelegate {
|
|
|
100
101
|
* corresponding HomeKit accessory.
|
|
101
102
|
* @param {!object} params - The parameters for the
|
|
102
103
|
* _History_ HomeKit service.
|
|
104
|
+
* @param {integer} [params.memorySize=2304] - The memory size, in number of
|
|
105
|
+
* history entries. The default is 4 weeks of 6 entries per hour.
|
|
103
106
|
*/
|
|
104
107
|
constructor (accessoryDelegate, params = {}) {
|
|
105
108
|
params.name = accessoryDelegate.name + ' History'
|
|
106
109
|
params.Service = accessoryDelegate.Services.eve.History
|
|
107
110
|
params.hidden = true
|
|
108
111
|
super(accessoryDelegate, params)
|
|
109
|
-
this._memorySize =
|
|
112
|
+
this._memorySize = params.memorySize == null ? 4032 : params.memorySize
|
|
110
113
|
this._transfer = false
|
|
111
114
|
this._restarted = true
|
|
112
115
|
|
|
@@ -186,6 +189,11 @@ class History extends ServiceDelegate {
|
|
|
186
189
|
// // silent: true
|
|
187
190
|
// })
|
|
188
191
|
|
|
192
|
+
accessoryDelegate.propertyDelegate('name')
|
|
193
|
+
.on('didSet', (value) => {
|
|
194
|
+
this.values.configuredName = value + ' History'
|
|
195
|
+
})
|
|
196
|
+
|
|
189
197
|
this._accessoryDelegate.heartbeatEnabled = true
|
|
190
198
|
this._accessoryDelegate
|
|
191
199
|
.once('heartbeat', (beat) => {
|
|
@@ -259,7 +267,7 @@ class History extends ServiceDelegate {
|
|
|
259
267
|
// offset += 1
|
|
260
268
|
|
|
261
269
|
const value = util.format(
|
|
262
|
-
'%s 00000000 %s [%s] %s %s %s
|
|
270
|
+
'%s 00000000 %s [%s] %s %s %s 00000000 0101',
|
|
263
271
|
numToHex(swap32(this._entry.time - this._h.initialTime), 8),
|
|
264
272
|
numToHex(swap32(this._h.initialTime - epoch), 8),
|
|
265
273
|
this._fingerPrint,
|
|
@@ -33,7 +33,7 @@ class ServiceLabel extends ServiceDelegate {
|
|
|
33
33
|
* `Characteristics.hap.ServiceLabelNamespace`.
|
|
34
34
|
*/
|
|
35
35
|
constructor (accessoryDelegate, params = {}) {
|
|
36
|
-
params.name = accessoryDelegate.name
|
|
36
|
+
params.name = accessoryDelegate.name + ' Label'
|
|
37
37
|
params.Service = accessoryDelegate.Services.hap.ServiceLabel
|
|
38
38
|
super(accessoryDelegate, params)
|
|
39
39
|
this.addCharacteristicDelegate({
|
|
@@ -41,6 +41,11 @@ class ServiceLabel extends ServiceDelegate {
|
|
|
41
41
|
Characteristic: this.Characteristics.hap.ServiceLabelNamespace,
|
|
42
42
|
value: params.namespace
|
|
43
43
|
})
|
|
44
|
+
|
|
45
|
+
accessoryDelegate.propertyDelegate('name')
|
|
46
|
+
.on('didSet', (value) => {
|
|
47
|
+
this.values.configuredName = value + ' Label'
|
|
48
|
+
})
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
|
|
@@ -47,9 +47,6 @@ class ServiceDelegate extends homebridgeLib.Delegate {
|
|
|
47
47
|
* @params {?ServiceDelegate} params.linkedServiceDelegate - The delegate
|
|
48
48
|
* of the service this service links to.
|
|
49
49
|
* @params {?boolean} params.hidden - Hidden service.
|
|
50
|
-
* @params {?boolean} params.exposeConfiguredName - Expose
|
|
51
|
-
* `Characteristics.hap.ConfiguredName`, so device name can be synced with
|
|
52
|
-
* HomeKit service name.
|
|
53
50
|
*/
|
|
54
51
|
constructor (accessoryDelegate, params = {}) {
|
|
55
52
|
if (!(accessoryDelegate instanceof homebridgeLib.AccessoryDelegate)) {
|
|
@@ -80,7 +77,6 @@ class ServiceDelegate extends homebridgeLib.Delegate {
|
|
|
80
77
|
this._service = this._accessory.addService(
|
|
81
78
|
new params.Service(this.name, params.subtype)
|
|
82
79
|
)
|
|
83
|
-
this._service.displayName = this.name
|
|
84
80
|
}
|
|
85
81
|
this._accessoryDelegate._linkServiceDelegate(this)
|
|
86
82
|
this._service.setPrimaryService(!!params.primaryService)
|
|
@@ -114,38 +110,34 @@ class ServiceDelegate extends homebridgeLib.Delegate {
|
|
|
114
110
|
this._characteristicDelegates = {} // by key
|
|
115
111
|
this._characteristics = {} // by uuid
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
]
|
|
133
|
-
},
|
|
134
|
-
value: params.name
|
|
135
|
-
}).on('didSet', (value) => {
|
|
136
|
-
if (value.trim() !== '') {
|
|
137
|
-
this.name = value
|
|
138
|
-
this._service.displayName = value
|
|
139
|
-
this.values.name = value
|
|
140
|
-
for (const key in this._characteristicDelegates) {
|
|
141
|
-
this._characteristicDelegates[key].name = value
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
})
|
|
113
|
+
this.addCharacteristicDelegate({
|
|
114
|
+
key: 'name',
|
|
115
|
+
Characteristic: this.Characteristics.hap.Name,
|
|
116
|
+
silent: true,
|
|
117
|
+
value: params.name
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
this.addCharacteristicDelegate({
|
|
121
|
+
key: 'configuredName',
|
|
122
|
+
Characteristic: this.Characteristics.hap.ConfiguredName,
|
|
123
|
+
value: params.name,
|
|
124
|
+
setter: (value) => {
|
|
125
|
+
if (value == null || value === '') {
|
|
126
|
+
throw new Error('cannot be empty')
|
|
127
|
+
}
|
|
145
128
|
}
|
|
146
|
-
}
|
|
129
|
+
}).on('didSet', (value) => {
|
|
130
|
+
this.name = value
|
|
131
|
+
for (const key in this._characteristicDelegates) {
|
|
132
|
+
this._characteristicDelegates[key].name = value
|
|
133
|
+
}
|
|
134
|
+
if (params.primaryService) {
|
|
135
|
+
accessoryDelegate.values.name = value
|
|
136
|
+
}
|
|
137
|
+
})
|
|
147
138
|
|
|
148
139
|
this.once('initialised', () => {
|
|
140
|
+
this.values.configuredName = this.name
|
|
149
141
|
const staleCharacteristics = []
|
|
150
142
|
for (const uuid in this._service.characteristics) {
|
|
151
143
|
const characteristic = this._service.characteristics[uuid]
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Library for homebridge plugins",
|
|
4
4
|
"author": "Erik Baauw",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "5.
|
|
6
|
+
"version": "5.8.0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"homekit",
|
|
9
9
|
"homebridge"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"homebridge": "^1.5.1",
|
|
25
|
-
"node": "^18.12.
|
|
25
|
+
"node": "^18.12.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@homebridge/plugin-ui-utils": "~0.0.19",
|