Node-RED/CheatSheet: Difference between revisions

From Wiki
(Created page with "== Global variables == <pre> var labelmode = global.get("labelmode") </pre> == Node Status == <pre> node.status({fill:"gray",shape:"dot",text:msg.serialnumber + " = " + msg.pclass + "W"}); </pre> == Stop messages == <pre> if ( ...)) { return null; } else { return msg; } </pre> == InfluxDB == * write data with custom timestamp <pre> var timestamp = new Date(date + 'Z').getTime() * 1e6 msg = { payload : { value: value, time: timestamp },...")
 
mNo edit summary
Line 2: Line 2:
<pre>
<pre>
var labelmode = global.get("labelmode")
var labelmode = global.get("labelmode")
global.set("labelmode", 123)
</pre>
</pre>


Line 8: Line 9:
node.status({fill:"gray",shape:"dot",text:msg.serialnumber + " = " + msg.pclass + "W"});
node.status({fill:"gray",shape:"dot",text:msg.serialnumber + " = " + msg.pclass + "W"});
</pre>
</pre>
== Stop messages ==
== Stop messages ==
<pre>
<pre>

Revision as of 11:43, 18 May 2024

Global variables

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

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 }