Node-RED/CheatSheet: Difference between revisions

From Wiki
mNo edit summary
mNo edit summary
Line 4: Line 4:
global.set("labelmode", 123)
global.set("labelmode", 123)
</pre>
</pre>
== Convert string to number ==
* Change-node
* JSONata: $number(payload)


== Node Status ==
== Node Status ==

Revision as of 10:37, 19 May 2024

Global variables

var labelmode = global.get("labelmode")
global.set("labelmode", 123)

Convert string to number

  • Change-node
  • JSONata: $number(payload)

Node Status

node.status({fill:"gray",shape:"dot",text:msg.serialnumber + " = " + msg.pclass + "W"});

Stop messages

if ( ...)) { 
return null; 
} else {
return msg;
}

InfluxDB

  • write data with custom timestamp
var timestamp = new Date(date + 'Z').getTime() * 1e6

msg = { payload : { value: value,
                    time: timestamp },
        measurement: topic }