forked from zwave-js/node-zwave-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_config.js
79 lines (78 loc) · 1.91 KB
/
server_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// @ts-check
const { CommandClasses, ConfigValueFormat, SupervisionStatus } = require(
"@zwave-js/core",
);
const { ccCaps, MockZWaveFrameType, createMockZWaveRequestFrame } = require(
"@zwave-js/testing",
);
const { wait } = require("alcalzone-shared/async");
const { SupervisionCCGet, SupervisionCCReport, ConfigurationCCSet } = require(
"zwave-js",
);
/** @type {import("zwave-js/Testing").MockServerOptions["config"]} */
module.exports.default = {
nodes: [
{
id: 2,
capabilities: {
commandClasses: [
CommandClasses.Version,
CommandClasses.Supervision,
ccCaps({
ccId: CommandClasses.Configuration,
isSupported: true,
version: 4,
parameters: [
{
"#": 10,
valueSize: 1,
format: ConfigValueFormat.SignedInteger,
minValue: -128,
maxValue: 0,
defaultValue: 0,
name: "Test Param 1",
},
{
"#": 255,
valueSize: 1,
format: ConfigValueFormat.BitField,
minValue: new Set([]),
maxValue: new Set([1, 4, 7]),
defaultValue: new Set([1]),
name: "Test Param 2",
info: "This is a description",
},
],
}),
],
},
behaviors: [
{
async onControllerFrame(controller, self, frame) {
if (
frame.type === MockZWaveFrameType.Request
&& frame.payload instanceof SupervisionCCGet
&& frame.payload.encapsulated
instanceof ConfigurationCCSet
) {
const cc = new SupervisionCCReport(self.host, {
nodeId: controller.host.ownNodeId,
sessionId: frame.payload.sessionId,
moreUpdatesFollow: false,
status: SupervisionStatus.Fail,
});
// await wait(500);
await self.sendToController(
createMockZWaveRequestFrame(cc, {
ackRequested: false,
}),
);
return true;
}
return false;
},
},
],
},
],
};