Hi,
I have tried but cannot work this out, I am sure it is simple but i cannot find how.
A simple test example and flow ...
Insert a number, trim payload to fixed and the other is payload and is an electricity cost sum.
But I get 2 outputs because one is fractional slower than the other, somehow it needs to wait ?
Thanks
Flow ...
[
{
"id": "3593ba4fbc73c796",
"type": "function",
"z": "1f152ae0632b70bb",
"name": "to fixed",
"func": "msg.payload = Number(msg.payload.toFixed(3))\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 420,
"y": 320,
"wires": [
[
"2af008fd6fecd0d4"
]
]
},
{
"id": "7e6d8b9fef9b1119",
"type": "function",
"z": "1f152ae0632b70bb",
"name": "Cost 04-2024",
"func": "msg.payload = ((msg.payload) * 0.2884); // 1kw rate\nmsg.payload = (msg.payload + 0.4001); // Standing charge\nmsg.payload = (msg.payload * 1.05); // Adds 5% VAT\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 440,
"y": 360,
"wires": [
[
"c638a34eb22b0a85"
]
]
},
{
"id": "6077005b98249772",
"type": "inject",
"z": "1f152ae0632b70bb",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "3.35123",
"payloadType": "num",
"x": 260,
"y": 330,
"wires": [
[
"3593ba4fbc73c796",
"7e6d8b9fef9b1119"
]
]
},
{
"id": "2af008fd6fecd0d4",
"type": "change",
"z": "1f152ae0632b70bb",
"name": "",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "data",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 320,
"wires": [
[
"58510885dbc75e25"
]
]
},
{
"id": "c638a34eb22b0a85",
"type": "change",
"z": "1f152ae0632b70bb",
"name": "",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "cost",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 360,
"wires": [
[
"58510885dbc75e25"
]
]
},
{
"id": "05452333b8a861c0",
"type": "debug",
"z": "1f152ae0632b70bb",
"name": "debug 127",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1030,
"y": 340,
"wires": []
},
{
"id": "58510885dbc75e25",
"type": "change",
"z": "1f152ae0632b70bb",
"name": "set DB values",
"rules": [
{
"t": "set",
"p": "table",
"pt": "msg",
"to": "energy",
"tot": "str"
},
{
"t": "set",
"p": "device",
"pt": "msg",
"to": "IP22",
"tot": "str"
},
{
"t": "set",
"p": "data",
"pt": "msg",
"to": "data",
"tot": "msg"
},
{
"t": "set",
"p": "cost",
"pt": "msg",
"to": "cost",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 850,
"y": 340,
"wires": [
[
"05452333b8a861c0"
]
]
}
]