@mschaeffler/node-red-logic 3.1.7 → 3.2.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.
package/README.md CHANGED
@@ -309,6 +309,8 @@ Each `topic` is treated seperatly.
309
309
 
310
310
  The message property to be used as payload can be defined with the `Property` property.
311
311
 
312
+ With a input message with `msg.topic=="query"` or `msg.query=true`, you can query the latest states of all topics.
313
+
312
314
  |msg. | type | description |
313
315
  |:-------|:-------|:----------------------------------|
314
316
  |topic | string | name of the input channel. |
@@ -102,6 +102,8 @@
102
102
  <h3>Input</h3>
103
103
 
104
104
  <p>The message property to be used as payload can be defined with the <code>Property</code> property.</p>
105
+
106
+ <p>With a input message with <code>msg.topic=="query"</code> or <code>msg.query=true</code>, you can query the latest states of all topics.</p>
105
107
 
106
108
  <dl class="message-properties">
107
109
  <dt>topic <span class="property-type">string</span></dt>
@@ -29,7 +29,14 @@ module.exports = function(RED) {
29
29
  node.cntFall = 0;
30
30
  node.status( "" );
31
31
 
32
+ function msgSetEdge(msg,edge)
33
+ {
34
+ msg.payload = edge ? node.outputRise : node.outputFall;
35
+ msg.edge = edge ? "rising" : 'falling';
36
+ }
37
+
32
38
  node.on('input', function(msg,send,done) {
39
+ let data = context.get( "data" ) ?? {};
33
40
  if( msg.invalid )
34
41
  {
35
42
  done();
@@ -40,6 +47,16 @@ module.exports = function(RED) {
40
47
  node.status( "" );
41
48
  done();
42
49
  }
50
+ else if( msg.querry || msg.topic==="query" )
51
+ {
52
+ for( const i in data )
53
+ {
54
+ let help ={ topic: i, query: true };
55
+ msgSetEdge( help, data[i].edge );
56
+ send( help );
57
+ }
58
+ done();
59
+ }
43
60
  else
44
61
  {
45
62
  function getPayload(callback)
@@ -65,8 +82,7 @@ module.exports = function(RED) {
65
82
  }
66
83
  getPayload( function(value)
67
84
  {
68
- msg.value = Number( value );
69
- let data = context.get( "data" ) ?? {};
85
+ msg.value = Number( value );
70
86
  let status = { fill:data[msg.topic]?.status??"gray", shape:"dot", text:msg.value.toPrecision(4) };
71
87
 
72
88
  if( ! isNaN( msg.value ) )
@@ -78,9 +94,8 @@ module.exports = function(RED) {
78
94
  status.fill = edge ? "red" : "blue";
79
95
  data[msg.topic] = { edge:edge, status:status.fill };
80
96
  context.set( "data", data );
81
- msg.payload = edge ? node.outputRise : node.outputFall;
82
- msg.edge = edge ? "rising" : 'falling';
83
- msg.init = last === undefined;
97
+ msgSetEdge( msg, edge );
98
+ msg.init = last === undefined;
84
99
  send( msg );
85
100
  }
86
101
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "3.1.7",
3
+ "version": "3.2.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",