homebridge-lib 5.5.0 → 5.6.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.
|
@@ -48,6 +48,10 @@ class Motion extends History {
|
|
|
48
48
|
* @param {!CharacteristicDelegate} lastActivationDelegate - A reference to the
|
|
49
49
|
* delegate of the associated `Characteristics.eve.LastActivation`
|
|
50
50
|
* characteristic.
|
|
51
|
+
* @param {?CharacteristicDelegate} lightLevelDelegate - A reference to the
|
|
52
|
+
* delegate of the associated `Characteristics.hap.CurrentAmbientLightLevel`
|
|
53
|
+
* characteristic. For PIR sensors (like the Hue motion sensor) that report
|
|
54
|
+
* light level in addition to motion.
|
|
51
55
|
* @param {?CharacteristicDelegate} temperatureDelegate - A reference to the
|
|
52
56
|
* delegate of the associated `Characteristics.hap.CurrentTemperature`
|
|
53
57
|
* characteristic. For PIR sensors (like the Hue motion sensor) that report
|
|
@@ -55,7 +59,8 @@ class Motion extends History {
|
|
|
55
59
|
*/
|
|
56
60
|
constructor (
|
|
57
61
|
accessoryDelegate, params,
|
|
58
|
-
motionDelegate, lastActivationDelegate,
|
|
62
|
+
motionDelegate, lastActivationDelegate,
|
|
63
|
+
lightLevelDelegate, temperatureDelegate
|
|
59
64
|
) {
|
|
60
65
|
super(accessoryDelegate, params)
|
|
61
66
|
if (!(motionDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
@@ -64,6 +69,12 @@ class Motion extends History {
|
|
|
64
69
|
if (!(lastActivationDelegate instanceof homebridgeLib.CharacteristicDelegate)) {
|
|
65
70
|
throw new TypeError('lastActivationDelegate: not a CharacteristicDelegate')
|
|
66
71
|
}
|
|
72
|
+
if (
|
|
73
|
+
lightLevelDelegate != null &&
|
|
74
|
+
!(lightLevelDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
75
|
+
) {
|
|
76
|
+
throw new TypeError('lightLevelDelegate: not a CharacteristicDelegate')
|
|
77
|
+
}
|
|
67
78
|
if (
|
|
68
79
|
temperatureDelegate != null &&
|
|
69
80
|
!(temperatureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
@@ -76,14 +87,23 @@ class Motion extends History {
|
|
|
76
87
|
lastActivationDelegate.value = now - this._h.initialTime
|
|
77
88
|
this._entry.status = value
|
|
78
89
|
if (this._entry.temp != null) {
|
|
90
|
+
const lightlevel = this._entry.lightlevel
|
|
79
91
|
const temp = this._entry.temp
|
|
92
|
+
this._entry.lightlevel = null
|
|
80
93
|
this._entry.temp = null
|
|
81
94
|
this._addEntry(now)
|
|
95
|
+
this._entry.lightlevel = lightlevel
|
|
82
96
|
this._entry.temp = temp
|
|
83
97
|
} else {
|
|
84
98
|
this._addEntry(now)
|
|
85
99
|
}
|
|
86
100
|
})
|
|
101
|
+
if (lightLevelDelegate != null) {
|
|
102
|
+
this._entry.lightlevel = lightLevelDelegate.value
|
|
103
|
+
lightLevelDelegate.on('didSet', (value) => {
|
|
104
|
+
this._entry.lightlevel = value
|
|
105
|
+
})
|
|
106
|
+
}
|
|
87
107
|
if (temperatureDelegate != null) {
|
|
88
108
|
this._entry.temp = temperatureDelegate.value
|
|
89
109
|
temperatureDelegate.on('didSet', (value) => {
|
|
@@ -93,23 +113,42 @@ class Motion extends History {
|
|
|
93
113
|
}
|
|
94
114
|
|
|
95
115
|
get _fingerPrint () {
|
|
96
|
-
return '
|
|
116
|
+
return '03 1c01 3002 0102'
|
|
97
117
|
}
|
|
98
118
|
|
|
99
119
|
_entryStream (entry) {
|
|
100
120
|
if (entry.temp == null) {
|
|
121
|
+
if (entry.lightlevel == null) {
|
|
122
|
+
return util.format(
|
|
123
|
+
'|0b %s %s 01 %s',
|
|
124
|
+
numToHex(swap32(this._h.currentEntry), 8),
|
|
125
|
+
numToHex(swap32(entry.time - this._h.initialTime), 8),
|
|
126
|
+
numToHex(entry.status, 2)
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
return util.format(
|
|
130
|
+
'|0d %s %s 03 %s %s',
|
|
131
|
+
numToHex(swap32(this._h.currentEntry), 8),
|
|
132
|
+
numToHex(swap32(entry.time - this._h.initialTime), 8),
|
|
133
|
+
numToHex(entry.status, 2),
|
|
134
|
+
numToHex(swap16(entry.lightlevel), 4)
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
if (entry.lightlevel == null) {
|
|
101
138
|
return util.format(
|
|
102
|
-
'|
|
|
139
|
+
'|0d %s %s 05 %s %s',
|
|
103
140
|
numToHex(swap32(this._h.currentEntry), 8),
|
|
104
141
|
numToHex(swap32(entry.time - this._h.initialTime), 8),
|
|
105
|
-
numToHex(entry.status, 2)
|
|
142
|
+
numToHex(entry.status, 2),
|
|
143
|
+
numToHex(swap16(entry.temp * 100), 4)
|
|
106
144
|
)
|
|
107
145
|
}
|
|
108
146
|
return util.format(
|
|
109
|
-
'|
|
|
147
|
+
'|0f %s %s 07 %s %s %s',
|
|
110
148
|
numToHex(swap32(this._h.currentEntry), 8),
|
|
111
149
|
numToHex(swap32(entry.time - this._h.initialTime), 8),
|
|
112
150
|
numToHex(entry.status, 2),
|
|
151
|
+
numToHex(swap16(entry.lightlevel), 4),
|
|
113
152
|
numToHex(swap16(entry.temp * 100), 4)
|
|
114
153
|
)
|
|
115
154
|
}
|
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.6.0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"homekit",
|
|
9
9
|
"homebridge"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"homebridge": "^1.4.1",
|
|
25
|
-
"node": "^16.15.
|
|
25
|
+
"node": "^16.15.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@homebridge/plugin-ui-utils": "~0.0.19",
|