var data = msg.payload;msg.measurement = global.get ("temp");msg.payload = [{sensor: parseFloat(data),}];return msg;
Thanks Dave,I dont know not working :-(
var data = msg.payload;var data1 = global.get ("variable1");msg.measurement = global.get ("variable2");
msg.payload = []; // create an empty arraymsg.payload[0] = {}; // create an empty object as first item
msg.payload[0][global.get ("casevariable")] = parseFloat(data);return msg;
and try
var data = msg.payload;var data1 = global.get ("casevariable");msg.measurement = global.get ("prodvariable1");
msg.payload = []; // create an empty arraymsg.payload[0] = {}; // create an empty object as first item
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/c5453089-322f-47f9-8c26-472cc1dc3938%40googlegroups.com.
What are you seeing in the payload for the first case? It is no good saying it is not working unless you tell us what you are seeing and what you want it to be.Colin
The second one doesn't work because you need a string, so msg.payload[0]["data1"].
Colin
On 1 January 2018 at 16:52, Colin Law <cla...@gmail.com> wrote:
What are you seeing in the payload for the first case? It is no good saying it is not working unless you tell us what you are seeing and what you want it to be.Colin
I have global variables declared as text (to all Node-red) and payload input in to node function as value
var data = msg.payload;var data1 = global.get ("variable1");msg.measurement = global.get ("variable2");msg.payload = []; // create an empty arraymsg.payload[0] = {}; // create an empty object as first item
msg.payload[0][(data1)] = parseFloat(data);return msg;
msg.payload[0][data1] = parseFloat(data);
Put a line in above that with
node.warn("data1 is " + data1 + " type is " + typeof data1);
It will print that in the debug window so you can see what it says
Colin
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/7858dedb-23e9-40b4-87f7-7697970b048e%40googlegroups.com.
Thank you for professional help
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/f9d98674-8b0a-4d3a-a683-f68186ef0b7c%40googlegroups.com.
I have to admit there was something wrong with my variable declaration :-(
but it's ok with
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/50b6eec6-3284-4add-936a-28a52aefecf3%40googlegroups.com.