smart-nodes 0.4.0 → 0.4.2

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/CHANGELOG.md CHANGED
@@ -80,3 +80,13 @@
80
80
 
81
81
  After saving the nodes, the values are automatically converted to the new one.
82
82
  This conversion will be removed in version 0.5.0.
83
+
84
+ ## Version 0.4.1:
85
+
86
+ - Show only up to 2 decimal places in node status text.
87
+ - Improved warn messages shown in console.
88
+
89
+ ## Version 0.4.2:
90
+
91
+ - Fixed design of property page of forwarder node.
92
+ - Corrected hysteresis to send original message.
@@ -50,7 +50,7 @@ module.exports = function (RED)
50
50
  {
51
51
  if (typeof msg.source == "undefined" || typeof msg.state == "undefined")
52
52
  {
53
- console.warn("Unknown message received in smart_node central.", msg);
53
+ helper.warn(this, "Unknown message received in smart_node central.", msg);
54
54
  return;
55
55
  }
56
56
 
@@ -85,7 +85,7 @@ module.exports = function (RED)
85
85
  let real_topic_number = helper.getTopicNumber(msg.topic);
86
86
  if (real_topic_number == null || real_topic_number < 1 || real_topic_number > 2)
87
87
  {
88
- console.warn("Topic has to be 1 or 2, sended: " + msg.topic);
88
+ helper.warn(this, "Topic has to be 1 or 2, sended: " + msg.topic);
89
89
  return;
90
90
  }
91
91
 
@@ -93,7 +93,7 @@ module.exports = function (RED)
93
93
  let num = parseFloat(msg.payload);
94
94
  if (Number.isNaN(num))
95
95
  {
96
- console.warn("Payload has to be numeric: " + msg.payload);
96
+ helper.warn(this, "Payload has to be numeric: " + msg.payload);
97
97
  return;
98
98
  }
99
99
 
@@ -46,15 +46,15 @@
46
46
  </div>
47
47
  <div class="form-row">
48
48
  <input type="checkbox" id="node-input-forward_last_on_enable" style="width: 20px;" />
49
- <label for="node-input-forward_last_on_enable" data-i18n="forwarder.ui.forward_last_on_enable"></label>
49
+ <label for="node-input-forward_last_on_enable" style="width: calc(100% - 30px);" data-i18n="forwarder.ui.forward_last_on_enable"></label>
50
50
  </div>
51
51
  <div class="form-row">
52
52
  <input type="checkbox" id="node-input-always_forward_true" style="width: 20px;" />
53
- <label for="node-input-always_forward_true" data-i18n="[html]forwarder.ui.always_forward_true"></label>
53
+ <label for="node-input-always_forward_true" style="width: calc(100% - 30px);" data-i18n="[html]forwarder.ui.always_forward_true"></label>
54
54
  </div>
55
55
  <div class="form-row">
56
56
  <input type="checkbox" id="node-input-always_forward_false" style="width: 20px;" />
57
- <label for="node-input-always_forward_false" data-i18n="[html]forwarder.ui.always_forward_false"></label>
57
+ <label for="node-input-always_forward_false" style="width: calc(100% - 30px);" data-i18n="[html]forwarder.ui.always_forward_false"></label>
58
58
  </div>
59
59
  <hr/>
60
60
  <h4 style="margin: 0.5rem 0;" data-i18n="forwarder.ui.system_start"></h4>
@@ -75,7 +75,7 @@ module.exports = function (RED)
75
75
  let new_setpoint = parseFloat(msg.payload);
76
76
  if (isNaN(new_setpoint) && !isFinite(new_setpoint))
77
77
  {
78
- console.warn("Invalid payload: " + msg.payload);
78
+ // helper.warn(this, "Invalid payload: " + msg.payload);
79
79
  return;
80
80
  }
81
81
 
@@ -86,7 +86,7 @@ module.exports = function (RED)
86
86
  let new_temp = parseFloat(msg.payload);
87
87
  if (isNaN(new_temp) && !isFinite(new_temp))
88
88
  {
89
- console.warn("Invalid payload: " + msg.payload);
89
+ // helper.warn(this, "Invalid payload: " + msg.payload);
90
90
  return;
91
91
  }
92
92
 
@@ -97,7 +97,7 @@ module.exports = function (RED)
97
97
  let new_flow_min = parseFloat(msg.payload);
98
98
  if (isNaN(new_flow_min) && !isFinite(new_flow_min))
99
99
  {
100
- console.warn("Invalid payload: " + msg.payload);
100
+ // helper.warn(this, "Invalid payload: " + msg.payload);
101
101
  return;
102
102
  }
103
103
 
@@ -108,7 +108,7 @@ module.exports = function (RED)
108
108
  let new_flow_max = parseFloat(msg.payload);
109
109
  if (isNaN(new_flow_max) && !isFinite(new_flow_max))
110
110
  {
111
- console.warn("Invalid payload: " + msg.payload);
111
+ // helper.warn(this, "Invalid payload: " + msg.payload);
112
112
  return;
113
113
  }
114
114
 
@@ -146,7 +146,7 @@ module.exports = function (RED)
146
146
 
147
147
  let setStatus = () =>
148
148
  {
149
- node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Out: " + node_settings.temperature_outside.toFixed(1) + "°C, Flow: " + node_settings.last_flow_temperature?.toFixed(1) + "°C" });
149
+ node.status({ fill: "green", shape: "dot", text: helper.getCurrentTimeForStatus() + ": Out: " + node_settings.temperature_outside?.toFixed(1) + "°C, Flow: " + node_settings.last_flow_temperature?.toFixed(1) + "°C" });
150
150
  }
151
151
 
152
152
  if (node_settings.last_flow_temperature !== null)
@@ -54,7 +54,6 @@ module.exports = function (RED)
54
54
  else
55
55
  {
56
56
  // delete old saved values
57
- node.status({});
58
57
  smart_context.del(node.id);
59
58
  }
60
59
 
@@ -103,7 +102,7 @@ module.exports = function (RED)
103
102
 
104
103
  if (isNaN(value))
105
104
  {
106
- console.warn("Invalid payload: " + msg.payload);
105
+ // helper.warn(this, "Invalid payload: " + msg.payload);
107
106
  return;
108
107
  }
109
108
 
@@ -176,12 +175,12 @@ module.exports = function (RED)
176
175
  if (node_settings.last_result == null)
177
176
  node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": ❓ S: " + node_settings.setpoint + " - H: " + node_settings.hysteresis + " - V: null" });
178
177
  else
179
- node.status({ fill: node_settings.last_result ? "green" : "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": " + (node_settings.last_result ? "⬆️" : "⬇️") + " S: " + node_settings.setpoint + " - H: " + node_settings.hysteresis + " - V: " + node_settings.last_value.toFixed(2) });
178
+ node.status({ fill: node_settings.last_result ? "green" : "red", shape: "dot", text: helper.getCurrentTimeForStatus() + ": " + (node_settings.last_result ? "⬆️" : "⬇️") + " S: " + node_settings.setpoint + " - H: " + node_settings.hysteresis + " - V: " + node_settings.last_value?.toFixed(2) });
180
179
  }
181
180
 
182
181
  let createMessage = (out_msg, out_type, msg, value) =>
183
182
  {
184
- return helper.cloneObject(out_type == "ORIGINAL" ? msg : out_msg, {
183
+ return helper.cloneObject(out_type == "NOTHING" ? msg : out_msg, {
185
184
  smart_info: {
186
185
  last_result: node_settings.last_result,
187
186
  hysteresis: node_settings.hysteresis,
package/light/light.js CHANGED
@@ -287,7 +287,7 @@ module.exports = function (RED)
287
287
 
288
288
  if (isNaN(timeMs))
289
289
  {
290
- console.warn("Invalid time_on value send: " + origTimeMs);
290
+ helper.warn(this, "Invalid time_on value send: " + origTimeMs);
291
291
  timeMs = max_time_on;
292
292
  }
293
293
 
@@ -124,7 +124,7 @@ module.exports = function (RED)
124
124
  let new_setpoint = parseFloat(msg.payload);
125
125
  if (isNaN(new_setpoint) && !isFinite(new_setpoint))
126
126
  {
127
- console.warn("Invalid payload: " + msg.payload);
127
+ // helper.warn(this, "Invalid payload: " + msg.payload);
128
128
  return;
129
129
  }
130
130
 
@@ -144,7 +144,7 @@ module.exports = function (RED)
144
144
  break;
145
145
 
146
146
  default:
147
- console.warn("Invalid off_mode: " + msg.payload);
147
+ helper.warn(this, "Invalid off_mode: " + msg.payload);
148
148
  return;
149
149
  }
150
150
  break;
@@ -159,7 +159,7 @@ module.exports = function (RED)
159
159
  break;
160
160
 
161
161
  default:
162
- console.warn("Invalid valve_mode: " + msg.payload);
162
+ helper.warn(this, "Invalid valve_mode: " + msg.payload);
163
163
  return;
164
164
  }
165
165
 
@@ -170,7 +170,7 @@ module.exports = function (RED)
170
170
  let new_temp = parseFloat(msg.payload);
171
171
  if (isNaN(new_temp) && !isFinite(new_temp))
172
172
  {
173
- console.warn("Invalid payload for current_temperature: " + msg.payload);
173
+ // helper.warn(this, "Invalid payload for current_temperature: " + msg.payload);
174
174
  return;
175
175
  }
176
176
  current_temperature = new_temp;
@@ -181,7 +181,7 @@ module.exports = function (RED)
181
181
  break;
182
182
 
183
183
  default:
184
- console.warn("Invalid topic: " + real_topic);
184
+ helper.warn(this, "Invalid topic: " + real_topic);
185
185
  return;
186
186
  }
187
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-nodes",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Smart Nodes",
5
5
  "keywords": [
6
6
  "node-red",
@@ -206,7 +206,7 @@ module.exports = function (RED)
206
206
  let timeMs = helper.getTimeInMsFromString(msg.time_on);
207
207
  if (isNaN(timeMs) || timeMs <= 0)
208
208
  {
209
- console.warn("Invalid msg.time_on value was sent.", msg);
209
+ helper.warn(this, "Invalid msg.time_on value was sent.", msg);
210
210
  return;
211
211
  }
212
212
 
@@ -354,7 +354,7 @@ module.exports = function (RED)
354
354
  // data is the position in percent
355
355
  if (data == null)
356
356
  {
357
- console.warn("WARN: Try to set position without giving a new position");
357
+ helper.warn(this, "Try to set position without giving a new position");
358
358
  return;
359
359
  }
360
360
 
package/smart_helper.js CHANGED
@@ -348,5 +348,14 @@ module.exports = {
348
348
  {
349
349
  // uncomment to see all log values
350
350
  // console.log(...arguments);
351
+ },
352
+
353
+ /**
354
+ * Forward all arguments to the console if it is enabled
355
+ */
356
+ warn(node, ...args)
357
+ {
358
+ // uncomment to see all warn values
359
+ console.warn(typeof node + " (" + node.id + "):", ...args);
351
360
  }
352
361
  };
@@ -64,7 +64,7 @@
64
64
  $("#node-input-out_message").typedInput({
65
65
  type: "json",
66
66
  types: ["json", {
67
- value: "DEFAULT",
67
+ value: "NOTHING",
68
68
  label: node._("statistic.ui.default"),
69
69
  icon: "fa fa-times",
70
70
  hasValue: false,
@@ -83,10 +83,10 @@
83
83
 
84
84
 
85
85
  // Backward compatibility
86
- if (this.out_message_type == "null")
86
+ if (this.out_message_type == "null" || this.out_message_type == "DEFAULT")
87
87
  {
88
- this.out_message_type = "DEFAULT";
89
- $("#node-input-out_message_type").val("DEFAULT");
88
+ this.out_message_type = "NOTHING";
89
+ $("#node-input-out_message_type").val("NOTHING");
90
90
  }
91
91
 
92
92
  }
@@ -73,7 +73,7 @@ module.exports = function (RED)
73
73
  {
74
74
  if (isNaN(parseFloat(msg.payload)))
75
75
  {
76
- console.warn("Invalid payload: " + msg.payload);
76
+ // helper.warn(this, "Invalid payload: " + msg.payload);
77
77
  return;
78
78
  }
79
79
 
@@ -214,7 +214,7 @@ module.exports = function (RED)
214
214
  if (operation === "ABS")
215
215
  node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": " + operation + " => " + msg.payload });
216
216
  else
217
- node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": " + operation + "(" + Object.entries(node_settings.values).map(v => v[1]).join(", ") + ") => " + msg.payload });
217
+ node.status({ fill: "yellow", shape: "ring", text: helper.getCurrentTimeForStatus() + ": " + operation + "(" + Object.entries(node_settings.values).map(v => v[1]).join(", ") + ") => " + msg.payload?.toFixed(2) });
218
218
  }
219
219
 
220
220
  if (config.save_state && config.resend_on_start && node_settings.last_message != null)