@mschaeffler/node-red-logic 3.4.0 → 3.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.
@@ -17,6 +17,7 @@
17
17
  outputRiseType:{value:"bool"},
18
18
  outputFall:{value:false,required:true},
19
19
  outputFallType:{value:"bool"},
20
+ noInit:{value:false},
20
21
  showState:{value:false}
21
22
  },
22
23
  inputs:1,
@@ -87,6 +88,10 @@
87
88
  <input type="text" id="node-input-outputFall">
88
89
  <input type="hidden" id="node-input-outputFallType">
89
90
  </div>
91
+ <div class="form-row">
92
+ <label for="node-input-noInit"><i class="fa fa-play"></i> no inits</label>
93
+ <input type="checkbox" id="node-input-noInit" style="display:inline-block; width:20px; vertical-align:baseline;">
94
+ </div>
90
95
  <div class="form-row">
91
96
  <label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
92
97
  <input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
@@ -146,6 +151,8 @@
146
151
  <dd> Value to be sent in case of a rising edge.</dd>
147
152
  <dt>fall Output <span class="property-type">multi</span></dt>
148
153
  <dd> Value to be sent in case of a falling edge.</dd>
154
+ <dt>no init <span class="property-type">boolean</span></dt>
155
+ <dd> does not send init messages.</dd>
149
156
  <dt>Status <span class="property-type">boolean</span></dt>
150
157
  <dd> shows the actual value as a node status.</dd>
151
158
  </dl>
@@ -14,6 +14,7 @@ module.exports = function(RED) {
14
14
  this.consecutiveFall= Number( config.consecutiveFall ?? 1 );
15
15
  this.outputRise = tools.convertTypedInput( config.outputRise ?? "true", config.outputRiseType ?? "bool" );
16
16
  this.outputFall = tools.convertTypedInput( config.outputFall ?? "false",config.outputFallType ?? "bool" );
17
+ this.noInit = Boolean( config.noInit );
17
18
  this.showState = Boolean( config.showState );
18
19
  if( this.propertyType === "jsonata" )
19
20
  {
@@ -94,9 +95,12 @@ module.exports = function(RED) {
94
95
  status.fill = edge ? "red" : "blue";
95
96
  data[msg.topic] = { edge:edge, status:status.fill };
96
97
  context.set( "data", data );
97
- msgSetEdge( msg, edge );
98
- msg.init = last === undefined;
99
- send( msg );
98
+ if( last !== undefined || ! node.noInit )
99
+ {
100
+ msgSetEdge( msg, edge );
101
+ msg.init = last === undefined;
102
+ send( msg );
103
+ }
100
104
  }
101
105
 
102
106
  if( msg.value > node.threshold_rise && last !== true )
@@ -12,6 +12,7 @@
12
12
  minData:{value:"1", required:true, validate:function(v){
13
13
  return v!=='' && !isNaN(v) && Number(v)>0;}
14
14
  },
15
+ contextStore:{value:"",required:true},
15
16
  showState:{value:false}
16
17
  },
17
18
  inputs:1,
@@ -26,11 +27,25 @@
26
27
  inputLabels: 'input',
27
28
  outputLabels: 'output',
28
29
  oneditprepare: function() {
30
+ const node = this;
29
31
  $("#node-input-property").typedInput({
30
32
  type:"msg",
31
33
  types:["msg","jsonata"],
32
34
  typeField: "#node-input-propertyType"
33
35
  });
36
+ // populate store names
37
+ $("#node-input-contextStore").empty();
38
+ $("#node-input-contextStore").append(`<option value="none">None</option>`);
39
+ const defaultStore = RED.settings.hasOwnProperty('context') ? RED.settings.context.default : ''
40
+ RED.settings.context.stores.forEach(function(item){
41
+ if( item ) {
42
+ const opt = $(`<option value="${item}">${item}${item===defaultStore?" (default)":""}</option>`);
43
+ $("#node-input-contextStore").append(opt);
44
+ }
45
+ });
46
+ const currentStore = node.contextStore || '';
47
+ // select the current option
48
+ $("#node-input-contextStore").val(currentStore);
34
49
  }
35
50
  });
36
51
  </script>
@@ -53,6 +68,10 @@
53
68
  <label for="node-input-minData"><i class="fa fa-check-square-o "></i> min. Data</label>
54
69
  <input type="text" id="node-input-minData">
55
70
  </div>
71
+ <div class="form-row">
72
+ <label for="node-input-contextStore"><i class="fa fa-database"></i> Contextstore</label>
73
+ <select type="text" id="node-input-contextStore"></select>
74
+ </div>
56
75
  <div class="form-row">
57
76
  <label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
58
77
  <input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
@@ -109,6 +128,8 @@
109
128
  <dd> time frame to collect the data for the analysis.</dd>
110
129
  <dt>min. Data <span class="property-type">number</span></dt>
111
130
  <dd> min. amount of data points to generate an output.</dd>
131
+ <dt>Contextstore <span class="property-type">context store</span></dt>
132
+ <dd> context store for storing the values; <code>none</code> is no storage.</dd>
112
133
  <dt>Status <span class="property-type">boolean</span></dt>
113
134
  <dd> shows the actual value as a node status.</dd>
114
135
  </dl>
@@ -9,6 +9,7 @@ module.exports = function(RED) {
9
9
  this.propertyType = config.propertyType ?? "msg";
10
10
  this.deltaTime = Number( config.deltaTime ?? 60 )*1000;
11
11
  this.minData = Number( config.minData ?? 1 );
12
+ this.contextStore = config.contextStore ?? "none";
12
13
  this.showState = Boolean( config.showState );
13
14
  if( this.propertyType === "jsonata" )
14
15
  {
@@ -61,7 +62,7 @@ module.exports = function(RED) {
61
62
  const payload = Number( value );
62
63
  if( ! isNaN( payload ) )
63
64
  {
64
- let data = context.get( "data" ) ?? {};
65
+ let data = context.get( "data", node.contextStore ) ?? {};
65
66
  let item = data[msg.topic] ?? [];
66
67
  item.push( { time:now, value:payload } );
67
68
  while( item[0].time < now - node.deltaTime )
@@ -69,7 +70,7 @@ module.exports = function(RED) {
69
70
  item.shift();
70
71
  }
71
72
  data[msg.topic] = item;
72
- context.set( "data", data );
73
+ context.set( "data", data, node.contextStore );
73
74
 
74
75
  if( item.length >= node.minData )
75
76
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "3.4.0",
3
+ "version": "3.6.0",
4
4
  "description": "nodes for simple operations.",
5
5
  "license": "LGPL-2.1",
6
6
  "homepage": "https://github.com/m-schaeffler/node-red-my-nodes/tree/main/node-red-logic",