node-red-contrib-homebridge-automation 0.1.12-beta.41 → 0.1.12-beta.43
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/package.json +8 -8
- package/src/HAP-NodeRed.js +1 -5
- package/src/hbBaseNode.js +2 -2
- package/src/hbConfigNode.js +2 -1
- package/src/hbControlNode.js +1 -1
- package/src/hbResumeNode.js +15 -5
- package/test/node-red/.config.users.json +3 -0
- package/test/node-red/.config.users.json.backup +3 -0
- package/test/node-red/.flows.json.backup +1629 -16
- package/test/node-red/flows.json +1626 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-homebridge-automation",
|
|
3
|
-
"version": "0.1.12-beta.
|
|
3
|
+
"version": "0.1.12-beta.43",
|
|
4
4
|
"description": "NodeRED Automation for HomeBridge",
|
|
5
5
|
"main": "src/HAP-NodeRed.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,23 +26,23 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node-red": "^1.3.5",
|
|
29
|
-
"@types/jest": "^29.5.
|
|
30
|
-
"@eslint/js": "^9.
|
|
29
|
+
"@types/jest": "^29.5.14",
|
|
30
|
+
"@eslint/js": "^9.16.0",
|
|
31
31
|
"eslint": "^8.57.1",
|
|
32
32
|
"eslint-plugin-format": "^0.1.2",
|
|
33
33
|
"eslint-plugin-jest": "^28.8.3",
|
|
34
|
-
"globals": "^15.
|
|
34
|
+
"globals": "^15.13.0",
|
|
35
35
|
"jest": "^29.7.0",
|
|
36
36
|
"node-red": "^4.0.2",
|
|
37
37
|
"node-red-node-test-helper": "^0.3.4",
|
|
38
|
-
"nodemon": "^3.1.
|
|
38
|
+
"nodemon": "^3.1.7",
|
|
39
39
|
"rimraf": "^6.0.1",
|
|
40
|
-
"semver": "^7.6.
|
|
40
|
+
"semver": "^7.6.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"better-queue": ">=3.8.12",
|
|
44
|
-
"debug": "^4.3.
|
|
45
|
-
"@homebridge/hap-client": "2.0.5
|
|
44
|
+
"debug": "^4.3.7",
|
|
45
|
+
"@homebridge/hap-client": "^2.0.5"
|
|
46
46
|
},
|
|
47
47
|
"author": "NorthernMan54",
|
|
48
48
|
"license": "ISC",
|
package/src/HAP-NodeRed.js
CHANGED
|
@@ -13,7 +13,7 @@ module.exports = function (RED) {
|
|
|
13
13
|
|
|
14
14
|
class hbConfigNode extends HBConfigNode {
|
|
15
15
|
constructor(config) {
|
|
16
|
-
debug('hbConfigNode', config);
|
|
16
|
+
debug('hbConfigNode', JSON.stringify(config));
|
|
17
17
|
super(config, RED);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -28,7 +28,6 @@ module.exports = function (RED) {
|
|
|
28
28
|
|
|
29
29
|
class hbEventNode extends HbEventNode {
|
|
30
30
|
constructor(config) {
|
|
31
|
-
debug('hbEventNode', config);
|
|
32
31
|
super(config, RED);
|
|
33
32
|
}
|
|
34
33
|
}
|
|
@@ -37,7 +36,6 @@ module.exports = function (RED) {
|
|
|
37
36
|
|
|
38
37
|
class hbResumeNode extends HbResumeNode {
|
|
39
38
|
constructor(config) {
|
|
40
|
-
debug('hbResumeNode', config);
|
|
41
39
|
super(config, RED);
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -46,7 +44,6 @@ module.exports = function (RED) {
|
|
|
46
44
|
|
|
47
45
|
class hbControlNode extends HbControlNode {
|
|
48
46
|
constructor(config) {
|
|
49
|
-
debug('hbControlNode', config);
|
|
50
47
|
super(config, RED);
|
|
51
48
|
}
|
|
52
49
|
}
|
|
@@ -55,7 +52,6 @@ module.exports = function (RED) {
|
|
|
55
52
|
|
|
56
53
|
class hbStatusNode extends HbStatusNode {
|
|
57
54
|
constructor(config) {
|
|
58
|
-
debug('hbStatusNode', config);
|
|
59
55
|
super(config, RED);
|
|
60
56
|
}
|
|
61
57
|
}
|
package/src/hbBaseNode.js
CHANGED
|
@@ -2,7 +2,7 @@ const debug = require('debug')('hapNodeRed:hbBaseNode');
|
|
|
2
2
|
|
|
3
3
|
class HbBaseNode {
|
|
4
4
|
constructor(config, RED) {
|
|
5
|
-
debug("Constructor:", config);
|
|
5
|
+
debug("Constructor:", config.type, JSON.stringify(config));
|
|
6
6
|
RED.nodes.createNode(this, config);
|
|
7
7
|
|
|
8
8
|
if (!config.conf) {
|
|
@@ -31,7 +31,7 @@ class HbBaseNode {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
handleHBEventMessage(service) {
|
|
34
|
-
debug('hbEvent for', this.id, service.serviceName, service.values);
|
|
34
|
+
debug('hbEvent for', this.id, this.type, service.serviceName, JSON.stringify(service.values));
|
|
35
35
|
|
|
36
36
|
this.status({
|
|
37
37
|
text: JSON.stringify(service.values),
|
package/src/hbConfigNode.js
CHANGED
|
@@ -142,7 +142,7 @@ class HBConfigNode {
|
|
|
142
142
|
clientNode.hbDevice = matchedDevice;
|
|
143
143
|
clientNode.status({ fill: 'green', shape: 'dot', text: 'connected' });
|
|
144
144
|
clientNode.emit('hbReady', matchedDevice);
|
|
145
|
-
debug('_Registered: %s type: %s',
|
|
145
|
+
debug('_Registered: %s type: %s', clientNode.type, matchedDevice.type, matchedDevice.serviceName);
|
|
146
146
|
} else {
|
|
147
147
|
this.error(`ERROR: Device registration failed ${clientNode.name}`);
|
|
148
148
|
}
|
|
@@ -174,6 +174,7 @@ class HBConfigNode {
|
|
|
174
174
|
const eventNodes = Object.values(this.clientNodes).filter(clientNode =>
|
|
175
175
|
clientNode.config.device === `${service.instance.name}${service.instance.username}${service.accessoryInformation.Manufacturer}${service.serviceName}${service.uuid.slice(0, 8)}`
|
|
176
176
|
);
|
|
177
|
+
// debug('service-update', service.serviceName, eventNodes);
|
|
177
178
|
eventNodes.forEach(eventNode => eventNode.emit('hbEvent', service));
|
|
178
179
|
});
|
|
179
180
|
});
|
package/src/hbControlNode.js
CHANGED
|
@@ -7,7 +7,7 @@ class HbControlNode extends hbBaseNode {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async handleInput(message, send, done) {
|
|
10
|
-
debug('handleInput',
|
|
10
|
+
debug('handleInput', this.name, JSON.stringify(message.payload));
|
|
11
11
|
|
|
12
12
|
if (!this.hbDevice) {
|
|
13
13
|
this.handleWarning('HB not initialized');
|
package/src/hbResumeNode.js
CHANGED
|
@@ -4,12 +4,21 @@ const debug = require('debug')('hapNodeRed:hbResumeNode');
|
|
|
4
4
|
class HbResumeNode extends HbBaseNode {
|
|
5
5
|
constructor(config, RED) {
|
|
6
6
|
super(config, RED);
|
|
7
|
-
|
|
7
|
+
this.lastOutputTime = Date.now();
|
|
8
8
|
this.storedState = null;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
handleHBEventMessage(service) {
|
|
12
|
+
debug('hbEvent for', this.id, service.serviceName, JSON.stringify(service.values));
|
|
13
|
+
|
|
14
|
+
if (service.values && Date.now() - this.lastOutputTime > 1000) { // Ignore messages within 1 second of last output
|
|
15
|
+
this.storedState = JSON.parse(JSON.stringify(this.hbDevice.values));
|
|
16
|
+
debug('Storing state', this.name, JSON.stringify(this.storedState));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
handleInput(message, send) {
|
|
12
|
-
debug('handleInput', message.payload, this.name);
|
|
21
|
+
debug('handleInput', this.id, message.payload, this.name);
|
|
13
22
|
|
|
14
23
|
if (!this.hbDevice) {
|
|
15
24
|
this.handleWarning('HB not initialized');
|
|
@@ -32,10 +41,10 @@ class HbResumeNode extends HbBaseNode {
|
|
|
32
41
|
|
|
33
42
|
if (message.payload.On) {
|
|
34
43
|
this.storedState = JSON.parse(JSON.stringify(this.hbDevice.values));
|
|
35
|
-
debug('Storing state', this.storedState);
|
|
44
|
+
debug('Storing state', this.name, JSON.stringify(this.storedState));
|
|
36
45
|
} else if (this.storedState) {
|
|
37
|
-
debug('Restoring state', this.storedState);
|
|
38
|
-
message.payload = { ...
|
|
46
|
+
debug('Restoring state', this.name, JSON.stringify(this.storedState));
|
|
47
|
+
message.payload = { ...message.payload, ...this.storedState };
|
|
39
48
|
this.storedState = null;
|
|
40
49
|
}
|
|
41
50
|
|
|
@@ -45,6 +54,7 @@ class HbResumeNode extends HbBaseNode {
|
|
|
45
54
|
fill: 'green',
|
|
46
55
|
});
|
|
47
56
|
|
|
57
|
+
this.lastOutputTime = Date.now();;
|
|
48
58
|
send(message);
|
|
49
59
|
}
|
|
50
60
|
|