Hello People of node red believers.
I am a problem with adding ( sum ) of an memory variable with a fresh variable like following.
TotalToday = SaveOpname + TotalToday
But is not working ( still get the same sum of the value's )
Meaning of this flow ( function ) is that the value is keep adding on the value before.
example of my function
let TussenVar = {};
let TotalToday = {};
let SaveOpname = {};
let Opname = {};
TotalToday = parseInt(flow.get("TotalToday"));
SaveOpname = parseInt(flow.get("Opname"));
TotalToday = SaveOpname + TotalToday;
msg.payload = TotalToday;
return msg;
I think this is an easy one , but stills failures on this easy flow.
Is there a tric to do what i want ?
this is the flow:
[{"id":"fec2a12e.68c73","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"e2678a2d.d07a68","type":"function","z":"fec2a12e.68c73","name":"","func":"let TussenVar = {};\nlet TotalToday = {};\nlet SaveOpname = {};\nlet Opname = {};\nTotalToday = parseInt(flow.get(\"TotalToday\"));\nSaveOpname = parseInt(flow.get(\"Opname\"));\nTotalToday = SaveOpname + TotalToday;\nmsg.payload = TotalToday; \nreturn msg;","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\n//var nothing = 0;\n//let TotalToday = 0;\n//let SaveOpname = 0;\n//let Opname = 0;\n//let TussenVar = 0;\n","finalize":"","libs":[],"x":460,"y":340,"wires":[["76996b81.60d704"]]},{"id":"3909ba4c.203486","type":"sma-webconnect","z":"fec2a12e.68c73","ip_address":"192.168.0.134","right":"usr","use_tls":true,"device_selection":"sb_tripower","x":640,"y":260,"wires":[["e2678a2d.d07a68","5c795b47.9375e4"]],"info":"{\r\n \"sma_config\": {\r\n \"id\": \"1\",\r\n \"values\": {\r\n \"6100_0046E500\": {\r\n \"name\": \"phase1_voltage\",\r\n \"divider\": 100\r\n },\r\n \"6100_0046E600\": {\r\n \"name\": \"phase2_voltage\",\r\n \"divider\": 100\r\n },\r\n \"6100_0046E700\": {\r\n \"name\": \"phase3_voltage\",\r\n \"divider\": 100\r\n },\r\n \"6100_40463600\": {\r\n \"name\": \"grid_feedin\",\r\n \"divider\": 1\r\n },\r\n \"6400_00262200\": {\r\n \"name\": \"daily\",\r\n \"divider\": 1\r\n },\r\n \"6100_40263F00\": {\r\n \"name\": \"power\",\r\n \"divider\": 1\r\n }\r\n }\r\n }\r\n}"},{"id":"8ffb32a9.9ae3b","type":"inject","z":"fec2a12e.68c73","name":"Solar opname per sec","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":410,"y":260,"wires":[["3909ba4c.203486"]],"info":"{\n \"sma_config\": {\n \"id\": \"1\",\n \"values\": {\n \"v6100_402613F00\": {\n \"name\": \"power\",\n \"divider\": 1\n }\n }\n }\n}"},{"id":"76996b81.60d704","type":"debug","z":"fec2a12e.68c73","name":"opname","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":660,"y":360,"wires":[]},{"id":"8da23ee9.f2949","type":"inject","z":"fec2a12e.68c73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":350,"y":440,"wires":[["217ff9b5.6822c6","de712ae5.7b0688"]]},{"id":"217ff9b5.6822c6","type":"change","z":"fec2a12e.68c73","name":"","rules":[{"t":"set","p":"SaveOpname","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":440,"wires":[[]]},{"id":"de712ae5.7b0688","type":"change","z":"fec2a12e.68c73","name":"","rules":[{"t":"set","p":"TussenVar","pt":"flow","to":"1000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":480,"wires":[[]]},{"id":"5c795b47.9375e4","type":"change","z":"fec2a12e.68c73","name":"","rules":[{"t":"set","p":"Opname","pt":"flow","to":"payload.power","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":200,"wires":[[]]}]