@bldgblocks/node-red-contrib-control 0.1.4

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.
Files changed (98) hide show
  1. package/README.md +43 -0
  2. package/nodes/accumulate-block.html +71 -0
  3. package/nodes/accumulate-block.js +104 -0
  4. package/nodes/add-block.html +67 -0
  5. package/nodes/add-block.js +97 -0
  6. package/nodes/analog-switch-block.html +65 -0
  7. package/nodes/analog-switch-block.js +129 -0
  8. package/nodes/and-block.html +64 -0
  9. package/nodes/and-block.js +73 -0
  10. package/nodes/average-block.html +97 -0
  11. package/nodes/average-block.js +137 -0
  12. package/nodes/boolean-switch-block.html +59 -0
  13. package/nodes/boolean-switch-block.js +88 -0
  14. package/nodes/boolean-to-number-block.html +59 -0
  15. package/nodes/boolean-to-number-block.js +45 -0
  16. package/nodes/cache-block.html +69 -0
  17. package/nodes/cache-block.js +106 -0
  18. package/nodes/call-status-block.html +111 -0
  19. package/nodes/call-status-block.js +274 -0
  20. package/nodes/changeover-block.html +234 -0
  21. package/nodes/changeover-block.js +392 -0
  22. package/nodes/comment-block.html +83 -0
  23. package/nodes/comment-block.js +53 -0
  24. package/nodes/compare-block.html +64 -0
  25. package/nodes/compare-block.js +84 -0
  26. package/nodes/contextual-label-block.html +67 -0
  27. package/nodes/contextual-label-block.js +52 -0
  28. package/nodes/convert-block.html +179 -0
  29. package/nodes/convert-block.js +289 -0
  30. package/nodes/count-block.html +57 -0
  31. package/nodes/count-block.js +92 -0
  32. package/nodes/debounce-block.html +64 -0
  33. package/nodes/debounce-block.js +140 -0
  34. package/nodes/delay-block.html +104 -0
  35. package/nodes/delay-block.js +180 -0
  36. package/nodes/divide-block.html +65 -0
  37. package/nodes/divide-block.js +123 -0
  38. package/nodes/edge-block.html +71 -0
  39. package/nodes/edge-block.js +120 -0
  40. package/nodes/frequency-block.html +55 -0
  41. package/nodes/frequency-block.js +140 -0
  42. package/nodes/hysteresis-block.html +131 -0
  43. package/nodes/hysteresis-block.js +142 -0
  44. package/nodes/interpolate-block.html +74 -0
  45. package/nodes/interpolate-block.js +141 -0
  46. package/nodes/load-sequence-block.html +134 -0
  47. package/nodes/load-sequence-block.js +272 -0
  48. package/nodes/max-block.html +76 -0
  49. package/nodes/max-block.js +103 -0
  50. package/nodes/memory-block.html +90 -0
  51. package/nodes/memory-block.js +241 -0
  52. package/nodes/min-block.html +77 -0
  53. package/nodes/min-block.js +106 -0
  54. package/nodes/minmax-block.html +89 -0
  55. package/nodes/minmax-block.js +119 -0
  56. package/nodes/modulo-block.html +73 -0
  57. package/nodes/modulo-block.js +126 -0
  58. package/nodes/multiply-block.html +63 -0
  59. package/nodes/multiply-block.js +115 -0
  60. package/nodes/negate-block.html +55 -0
  61. package/nodes/negate-block.js +91 -0
  62. package/nodes/nullify-block.html +111 -0
  63. package/nodes/nullify-block.js +78 -0
  64. package/nodes/on-change-block.html +79 -0
  65. package/nodes/on-change-block.js +191 -0
  66. package/nodes/oneshot-block.html +96 -0
  67. package/nodes/oneshot-block.js +169 -0
  68. package/nodes/or-block.html +64 -0
  69. package/nodes/or-block.js +73 -0
  70. package/nodes/pid-block.html +205 -0
  71. package/nodes/pid-block.js +407 -0
  72. package/nodes/priority-block.html +66 -0
  73. package/nodes/priority-block.js +239 -0
  74. package/nodes/rate-limit-block.html +99 -0
  75. package/nodes/rate-limit-block.js +221 -0
  76. package/nodes/round-block.html +73 -0
  77. package/nodes/round-block.js +89 -0
  78. package/nodes/saw-tooth-wave-block.html +87 -0
  79. package/nodes/saw-tooth-wave-block.js +161 -0
  80. package/nodes/scale-range-block.html +90 -0
  81. package/nodes/scale-range-block.js +137 -0
  82. package/nodes/sine-wave-block.html +88 -0
  83. package/nodes/sine-wave-block.js +142 -0
  84. package/nodes/subtract-block.html +64 -0
  85. package/nodes/subtract-block.js +103 -0
  86. package/nodes/thermistor-block.html +81 -0
  87. package/nodes/thermistor-block.js +146 -0
  88. package/nodes/tick-tock-block.html +66 -0
  89. package/nodes/tick-tock-block.js +110 -0
  90. package/nodes/time-sequence-block.html +67 -0
  91. package/nodes/time-sequence-block.js +144 -0
  92. package/nodes/triangle-wave-block.html +86 -0
  93. package/nodes/triangle-wave-block.js +154 -0
  94. package/nodes/tstat-block.html +311 -0
  95. package/nodes/tstat-block.js +499 -0
  96. package/nodes/units-block.html +150 -0
  97. package/nodes/units-block.js +106 -0
  98. package/package.json +73 -0
@@ -0,0 +1,106 @@
1
+ const validUnits = [
2
+ // Temperature
3
+ "°C", "°F", "K", "°R",
4
+
5
+ // Humidity/Pressure
6
+ "%RH", "Pa", "kPa", "bar", "mbar", "psi", "atm", "inH₂O", "mmH₂O", "inHg",
7
+
8
+ // Flow
9
+ "CFM", "m³/h", "L/s",
10
+
11
+ // Electrical
12
+ "V", "mV", "A", "mA", "W", "kW", "hp", "Ω",
13
+
14
+ // General/Math
15
+ "%",
16
+
17
+ // Length
18
+ "m", "cm", "mm", "km", "ft", "in",
19
+
20
+ // Mass
21
+ "kg", "g", "lb",
22
+
23
+ // Time
24
+ "s", "min", "h",
25
+
26
+ // Volume
27
+ "L", "mL", "gal",
28
+
29
+ // Other
30
+ "lx", "cd", "B", "T"
31
+ ];
32
+
33
+ module.exports = function(RED) {
34
+ function UnitsBlockNode(config) {
35
+ RED.nodes.createNode(this, config);
36
+ const node = this;
37
+
38
+ // Initialize runtime state
39
+ node.runtime = {
40
+ name: config.name,
41
+ unit: config.unit
42
+ };
43
+
44
+ // Validate configuration (Req 8)
45
+ if (!validUnits.includes(node.runtime.unit)) {
46
+ node.runtime.unit = "°F";
47
+ node.status({ fill: "red", shape: "ring", text: "invalid unit, using °F" });
48
+ } else {
49
+ node.status({ fill: "green", shape: "dot", text: `in: unit: ${node.runtime.unit}` });
50
+ }
51
+
52
+ node.on("input", function(msg, send, done) {
53
+ send = send || function() { node.send.apply(node, arguments); };
54
+
55
+ // Validate input
56
+ if (!msg || typeof msg !== "object") {
57
+ node.status({ fill: "red", shape: "ring", text: "invalid message" });
58
+
59
+ if (done) done();
60
+ return;
61
+ }
62
+
63
+ try {
64
+ // Handle configuration messages
65
+ if (msg.hasOwnProperty("context")) {
66
+ // Configuration handling
67
+ if (msg.context === "unit") {
68
+ if (typeof msg.payload === "string" && VALID_UNITS.includes(msg.payload)) {
69
+ node.runtime.unit = msg.payload;
70
+ node.status({ fill: "green", shape: "dot", text: `unit: ${node.runtime.unit}` });
71
+ } else {
72
+ node.status({ fill: "red", shape: "ring", text: "invalid unit" });
73
+ }
74
+ if (done) done();
75
+ return;
76
+ }
77
+
78
+ // Handle unknown context
79
+ if (msg.context && msg.context !== "unit") {
80
+ node.status({ fill: "yellow", shape: "ring", text: "unknown context" });
81
+ // Continue processing as passthrough
82
+ }
83
+ }
84
+
85
+ // Process input
86
+ const outputMsg = RED.util.cloneMessage(msg);
87
+ const payloadPreview = msg.payload !== null ? (typeof msg.payload === "number" ? msg.payload.toFixed(2) : JSON.stringify(msg.payload).slice(0, 20)) : "none";
88
+
89
+ node.status({ fill: "blue", shape: "dot", text: `in: ${payloadPreview} unit: ${node.runtime.unit}` });
90
+ send(outputMsg);
91
+ if (done) done();
92
+ } catch (error) {
93
+ node.status({ fill: "red", shape: "ring", text: "processing error" });
94
+
95
+ if (done) done(error);
96
+ return;
97
+ }
98
+ });
99
+
100
+ node.on("close", function(done) {
101
+ done();
102
+ });
103
+ }
104
+
105
+ RED.nodes.registerType("units-block", UnitsBlockNode);
106
+ };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@bldgblocks/node-red-contrib-control",
3
+ "version": "0.1.4",
4
+ "description": "Sedona-inspired control nodes for Node-RED",
5
+ "keywords": [ "node-red", "sedona", "control", "hvac" ],
6
+ "files": ["nodes/*.js", "nodes/*.html"],
7
+ "engines": {
8
+ "node": ">=20.0.0",
9
+ "npm": ">=8.0.0"
10
+ },
11
+ "node-red": {
12
+ "nodes": {
13
+ "accumulate-block": "nodes/accumulate-block.js",
14
+ "add-block": "nodes/add-block.js",
15
+ "analog-switch-block": "nodes/analog-switch-block.js",
16
+ "and-block": "nodes/and-block.js",
17
+ "average-block": "nodes/average-block.js",
18
+ "boolean-switch-block": "nodes/boolean-switch-block.js",
19
+ "boolean-to-number-block": "nodes/boolean-to-number-block.js",
20
+ "cache-block": "nodes/cache-block.js",
21
+ "call-status-block": "nodes/call-status-block.js",
22
+ "changeover-block": "nodes/changeover-block.js",
23
+ "comment-block": "nodes/comment-block.js",
24
+ "compare-block": "nodes/compare-block.js",
25
+ "contextual-label-block": "nodes/contextual-label-block.js",
26
+ "convert-block": "nodes/convert-block.js",
27
+ "count-block": "nodes/count-block.js",
28
+ "debounce-block": "nodes/debounce-block.js",
29
+ "delay-block": "nodes/delay-block.js",
30
+ "divide-block": "nodes/divide-block.js",
31
+ "edge-block": "nodes/edge-block.js",
32
+ "frequency-block": "nodes/frequency-block.js",
33
+ "hysteresis-block": "nodes/hysteresis-block.js",
34
+ "interpolate-block": "nodes/interpolate-block.js",
35
+ "load-sequence-block": "nodes/load-sequence-block.js",
36
+ "max-block": "nodes/max-block.js",
37
+ "memory-block": "nodes/memory-block.js",
38
+ "min-block": "nodes/min-block.js",
39
+ "minmax-block": "nodes/minmax-block.js",
40
+ "modulo-block": "nodes/modulo-block.js",
41
+ "multiply-block": "nodes/multiply-block.js",
42
+ "negate-block": "nodes/negate-block.js",
43
+ "nullify-block": "nodes/nullify-block.js",
44
+ "on-change-block": "nodes/on-change-block.js",
45
+ "oneshot-block": "nodes/oneshot-block.js",
46
+ "or-block": "nodes/or-block.js",
47
+ "pid-block": "nodes/pid-block.js",
48
+ "priority-block": "nodes/priority-block.js",
49
+ "rate-limit-block": "nodes/rate-limit-block.js",
50
+ "round-block": "nodes/round-block.js",
51
+ "saw-tooth-wave-block": "nodes/saw-tooth-wave-block.js",
52
+ "scale-range-block": "nodes/scale-range-block.js",
53
+ "sine-wave-block": "nodes/sine-wave-block.js",
54
+ "subtract-block": "nodes/subtract-block.js",
55
+ "thermistor-block": "nodes/thermistor-block.js",
56
+ "tick-tock-block": "nodes/tick-tock-block.js",
57
+ "time-sequence-block": "nodes/time-sequence-block.js",
58
+ "triangle-wave-block": "nodes/triangle-wave-block.js",
59
+ "tstat-block": "nodes/tstat-block.js",
60
+ "units-block": "nodes/units-block.js"
61
+ }
62
+ },
63
+ "author": "buildingblocks",
64
+ "license": "MIT",
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "git+https://github.com/BldgBlocks/node-red-contrib-buildingblocks-control.git"
68
+ },
69
+ "homepage": "https://github.com/BldgBlocks/node-red-contrib-buildingblocks-control#readme",
70
+ "bugs": {
71
+ "url": "https://github.com/BldgBlocks/node-red-contrib-buildingblocks-control/issues"
72
+ }
73
+ }