hello all,
I have tried in different ways to add 2 numbers in a function. I can not do it.
I also have very little experience with functions in Nodende.
Who wants to help me get this done.
Thankx,
Peter
[{"id":"960cbfbbef2d69c6","type":"inject","z":"2f5ea886d00cd91e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":175,"wires":[["100cb4654a40c9fd","6e78c632028d6c8f"]]},{"id":"100cb4654a40c9fd","type":"api-current-state","z":"2f5ea886d00cd91e","name":"getal1","server":"3c6b2d2d.b63e72","version":3,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"input_number.getal1","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"node1","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":270,"y":150,"wires":[["0f2e0c0827bc1986"]]},{"id":"6e78c632028d6c8f","type":"api-current-state","z":"2f5ea886d00cd91e","name":"getal2","server":"3c6b2d2d.b63e72","version":3,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"input_number.getal1","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"node2","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":270,"y":200,"wires":[["0f2e0c0827bc1986"]]},{"id":"0f2e0c0827bc1986","type":"function","z":"2f5ea886d00cd91e","name":"c = context.node2 + context.node1","func":"context.node1 = context.node1 || 0;\ncontext.node2 = context.node2 || 0;\n\nif(msg.topic == 'node1'){\n context.node1 = msg.payload;\n} else if (msg.topic == 'node2') {\n context.node2 = msg.payload; \n}\n\nvar c = context.node2 + context.node1;\n\n\nreturn c;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":175,"wires":[["68cd5c749e374caf"]]},{"id":"68cd5c749e374caf","type":"debug","z":"2f5ea886d00cd91e","name":"debug 358","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":795,"y":175,"wires":[]},{"id":"3c6b2d2d.b63e72","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]