This is from the API
If the value is 0.432, i want the final value to be 043
If the value is 1.234, the final value needs to be 123
This is from the API
If the value is 0.432, i want the final value to be 043
If the value is 1.234, the final value needs to be 123
This worked. I had to round to 1 to make it work correctly.
Thanks!
[
{
"id": "a3a21d2e40b021ad",
"type": "tab",
"label": "Temp Data",
"disabled": false,
"info": "",
"env": []
},
{
"id": "27970f52a4908ad1",
"type": "function",
"z": "a3a21d2e40b021ad",
"name": "Remove Decimal",
"func": "var conversion = msg.payload / 2.237\n\n\n\n\nvar d = Math.pow(10,2)\nvar dec = (parseInt(conversion*d)/d).toFixed(2)\n\nvar value = dec.toString().replace(\".\",\"\")\nif (parseInt(value) > 600) {\n msg.payload = 600\n} else {\n msg.payload = value\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 80,
"wires": [
[
"4c3a5cc7f43e0519"
]
]
},
{
"id": "4c3a5cc7f43e0519",
"type": "debug",
"z": "a3a21d2e40b021ad",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 530,
"y": 80,
"wires": []
},
{
"id": "0eaf5607dfe56699",
"type": "inject",
"z": "a3a21d2e40b021ad",
"name": "Injects 1.2 MPH",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "1.2",
"payloadType": "num",
"x": 120,
"y": 80,
"wires": [
[
"27970f52a4908ad1"
]
]
}
]
Thx, works great for me,
i have changed the 1 to 0 for the best result
Before it was for example 64.0 now itβs 64