How to change a temperature value?

2,139 views
Skip to first unread message

d...@dehcomputers.co.uk

unread,
Jun 8, 2016, 8:17:08 AM6/8/16
to Node-RED
Hi there

I have a flow set up with a temperature value, I would like to subtract 1 from each value to correct it for example 25.2 C would become 24.2 C could anyone explain how to do this?

Mark Setrem

unread,
Jun 8, 2016, 9:01:07 AM6/8/16
to Node-RED
Might be a little easier if you showed us some of your workings... 

But easy to do in a function window, you would need to either strip the " C" off or split on the space and just use the 1st value

take a look at 


Dom Holden

unread,
Jun 8, 2016, 10:04:41 AM6/8/16
to Node-RED
Thanks Mark for your reply. 

I worked out how to use the change node so can use that to remove the C so that the value is just a number.

I tried to use the change node to do the temp correction but got unexpected results!

I have also had a play with the range node but also not got anywhere.

Could you give me any pointers?



--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/J6WAf5cleEk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Nicholas O'Leary

unread,
Jun 8, 2016, 10:08:48 AM6/8/16
to Node-RED Mailing List
Hi Dom,

to do the sort of increment you want, you'll need to use the Function node - the Change/Range nodes can't do the sort of +1 operation you're looking for.

Nick

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+u...@googlegroups.com.

Ty George

unread,
Jun 8, 2016, 7:48:17 PM6/8/16
to Node-RED
[{"id":"64bb60d.c3f85a","type":"inject","z":"20b7876.4745d78","name":"Inject value as a string","topic":"","payload":"25.2","payloadType":"str","repeat":"","crontab":"","once":false,"x":220.5,"y":221.3333511352539,"wires":[["a86fe4cf.3cfb78","847f4b7d.ed1f78"]]},{"id":"a86fe4cf.3cfb78","type":"function","z":"20b7876.4745d78","name":"custom function","func":"// declare place holder variables\nvar originalval = msg.payload;\nvar temp = \"\";\n\n\n// convert string of originalval to float with 1 decimal place\n// run originalval thru a simple minus operation to form the 'temp' number\ntemp = parseFloat(originalval).toFixed(1) - 1;\n\n// output the originalval after deduction \nmsg.payload = temp;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":434.5000305175781,"y":221.6666488647461,"wires":[["ed4b60d1.09bc7"]]},{"id":"ed4b60d1.09bc7","type":"debug","z":"20b7876.4745d78","name":"after function debugger","active":true,"console":"false","complete":"payload","x":658.4999694824219,"y":222.66663360595703,"wires":[]},{"id":"847f4b7d.ed1f78","type":"debug","z":"20b7876.4745d78","name":"before function debugger","active":true,"console":"false","complete":"payload","x":464.5000305175781,"y":284.6666488647461,"wires":[]}]

Hopefully this helps you get past the hurdle :)

Ty

Dom Holden

unread,
Jun 9, 2016, 5:42:58 AM6/9/16
to Node-RED
Thats fantastic, thank you very much for your help!

--

Ty George

unread,
Jun 9, 2016, 1:03:04 PM6/9/16
to Node-RED
no problem, be sure to pay it forward some day to someone :)
Reply all
Reply to author
Forward
0 new messages