@mschaeffler/node-red-logic 3.12.0 → 3.14.1

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/logic_bool.html CHANGED
@@ -4,6 +4,7 @@
4
4
  color: "#C0DEED",
5
5
  defaults: {
6
6
  name:{value:""},
7
+ topic:{value:""},
7
8
  property:{value:"payload",required:true},
8
9
  showState:{value:false},
9
10
  filter:{value:false}
@@ -12,7 +13,7 @@
12
13
  outputs:1,
13
14
  icon: "font-awesome/fa-check-square-o",
14
15
  label: function() {
15
- return this.name||"to bool";
16
+ return this.name||this.topic||"to bool";
16
17
  },
17
18
  labelStyle: function() {
18
19
  return this.name?"node_label_italic":"";
@@ -35,6 +36,10 @@
35
36
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
36
37
  <input type="text" id="node-input-name" placeholder="Name">
37
38
  </div>
39
+ <div class="form-row">
40
+ <label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
41
+ <input type="text" id="node-input-topic" placeholder="Topic">
42
+ </div>
38
43
  <div class="form-row">
39
44
  <label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
40
45
  <input type="text" id="node-input-property">
@@ -88,6 +93,8 @@
88
93
  <h3>Parameter</h3>
89
94
 
90
95
  <dl class="message-properties">
96
+ <dt>Topic <span class="property-type">string</span></dt>
97
+ <dd> defines the topic for the output message.</dd>
91
98
  <dt>Property <span class="property-type">string</span></dt>
92
99
  <dd> defines the message property to be used as payload.</dd>
93
100
  <dt>Status <span class="property-type">boolean</span></dt>
package/logic_bool.js CHANGED
@@ -5,6 +5,7 @@ module.exports = function(RED) {
5
5
  RED.nodes.createNode(this,config);
6
6
  //this.config = config;
7
7
  var node = this;
8
+ this.topic = config.topic ?? "";
8
9
  this.property = config.property || "payload";
9
10
  this.showState = Boolean( config.showState );
10
11
  this.filter = Boolean( config.filter );
@@ -21,6 +22,10 @@ module.exports = function(RED) {
21
22
  let status = { text:msg.payload ?? "error" };
22
23
  if( msg.payload !== null )
23
24
  {
25
+ if( node.topic )
26
+ {
27
+ msg.topic = node.topic;
28
+ }
24
29
  if( node.filter )
25
30
  {
26
31
  status.shape = "dot";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "3.12.0",
3
+ "version": "3.14.1",
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",
package/tools.js CHANGED
@@ -1,25 +1,28 @@
1
- // general functions
1
+ // general functions
2
2
 
3
3
  exports.property2boolean = function(input)
4
4
  {
5
- switch( input )
5
+ switch( typeof input )
6
6
  {
7
- case true:
8
- case 1:
9
- case "1":
10
- case "true":
11
- case "on":
12
- return true;
13
- case false:
14
- case 0:
15
- case "0":
16
- case "false":
17
- case "off":
18
- case "overpower":
19
- return false;
20
- default:
21
- return null;
7
+ case "boolean":
8
+ return input;
9
+ case "number":
10
+ return Number.isNaN( input ) ? null : Boolean( input );
11
+ case "string":
12
+ switch( input )
13
+ {
14
+ case "1":
15
+ case "true":
16
+ case "on":
17
+ return true;
18
+ case "0":
19
+ case "false":
20
+ case "off":
21
+ case "overpower":
22
+ return false;
23
+ }
22
24
  }
25
+ return null;
23
26
  }
24
27
 
25
28
  exports.prepareProperty = function(node)