Multi udp in-out

Hi everuone! I have an power supply uses UDP porotocol. I has multi UDP request for the power supply and i need separate answer from the power supply (answer looks like number - 20.00). Will be good if i can transmit into UDP used subport. And i can transmited the packet from sub-ports.
Now i hase:


I want:

Sorry, It's not clear to me what you are asking for... but do you mean this


which lets you use a single node and send it the ip and port dynamically.

You do need to configure listening input ports in advance.

Now i send to UDP port command and I am listening to the port to which all the data comes. I cannot distinguish them among myself. I need separate the UDP packages.

Sorry it's still not overly clear.

Are you trying to match up a UDP packet response, to a UDP packet request?

Yes, it is.

Ok,

This isn't really a thing that the UDP node should be responsible for.
You need to create a flag in your flow design, so you know what the next response should be.

i.e You want to request voltage.

  1. Set a property in flow context, example expectedResponseType = Voltage
  2. Send request
  3. Check expectedResponseType when you receive a UDP payload, and route the data accordingly based on what the expectedResponseType is currently set to.

This will be trivial with a switch node

UDP is statless, therefore you need to poly fill this behaviour, where as TCP can do Req/Res

I'm not sure that I understood you.
I cannot form a UDP response from the device. In response, only numbers are returning to me.
I don't understand how I can SET A Property in Flow Context

A brief example, of what I think you are trying to achieve, but it is just a guess

[{"id":"e8d2c519dd678ff7","type":"inject","z":"e52e1875b36bafbd","name":"Request Voltage","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":235,"y":180,"wires":[["4b6ee7ef8acd3666"]]},{"id":"d3d99acd4e77dcd8","type":"inject","z":"e52e1875b36bafbd","name":"Request Current","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":250,"wires":[["0a8d045a934330f2"]]},{"id":"4b6ee7ef8acd3666","type":"change","z":"e52e1875b36bafbd","name":"","rules":[{"t":"set","p":"expectedResponeType","pt":"flow","to":"Voltage","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":200,"wires":[["e1ad93968a3dc303"]]},{"id":"0a8d045a934330f2","type":"change","z":"e52e1875b36bafbd","name":"","rules":[{"t":"set","p":"expectedResponeType","pt":"flow","to":"Current","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":240,"wires":[["e1ad93968a3dc303"]]},{"id":"e1ad93968a3dc303","type":"udp out","z":"e52e1875b36bafbd","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":855,"y":220,"wires":[]},{"id":"4880e234d3e3de03","type":"udp in","z":"e52e1875b36bafbd","name":"","iface":"","port":"","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":225,"y":415,"wires":[["08ced2919260265d"]]},{"id":"08ced2919260265d","type":"switch","z":"e52e1875b36bafbd","name":"Check expectedResponeType","property":"expectedResponeType","propertyType":"flow","rules":[{"t":"eq","v":"Voltage","vt":"str"},{"t":"eq","v":"Current","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":465,"y":415,"wires":[["dbe9a59add537707"],["9e31c5049bdadd3c"]]},{"id":"dbe9a59add537707","type":"debug","z":"e52e1875b36bafbd","name":"Voltage Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":385,"wires":[]},{"id":"9e31c5049bdadd3c","type":"debug","z":"e52e1875b36bafbd","name":"Current Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":435,"wires":[]}]

I work with an device.
The device returns only numbers to requests. They are no different from each other (between current and tension, these are numbers). Upon receipt, I want to send these numbers to the sensors. The resulting current value is on the current sensor, the obtained voltage value - to the voltage sensor.

and you request each value separately? and receive them separately?
or does one request yield all values (Current, Voltage etc etc)

Yes, I equest each value separately and receive them separately. But I can not form a response command from the current source, these are just numbers

What does this mean?
send the data to Home Assistance in the correct format?

if so, I suggest speaking to the HA forums - most here do not use HA.

NOTE: I have moved this thread away from Feature Request.

I do not control the return parcels from the power supplay. I send to UDP port ISET?\n or VSET?\n for asks I or V. I receive retaliatory parcels - 20.00 or 10.00. I can't distinguish where V is I - it is the problem,

Ok we seem to be going around in circles..

When you request/set values, and you receive the response, and need to determine what response this is for (V, I)

Then I have already provided 1 possible solution.

The switch node will output the values down the correct wire based on what was requested / set
so connect your HA Nodes to the correct outputs

Ok. I will test it. Where can i past the code inside a node?

Import the JSON I provided, and of course modify to your environment.

Screenshot 2023-11-22 at 12.00.14

1 Like

In debag i can see Current value and voltage. But think see only I, for example.

Because you're requesting both values at the same time, so is therefore overwriting the responseType flag, before the first has finished.

You need to wait for 1 response before issuing another in this case.

This is just the nature of UDP, you need to manage data flow your self.

Example

  1. Request V or I
  2. When V Or I has responded send the request for the other value.

Or use something like my semaphore node.
where the 2nd request will not allow to proceed until the first has been satisfied.

but that will require a different approach

1 Like

Can you send to me code it. I can't see that inside all the nodes.

[{"id":"329b3e0e034233a2","type":"inject","z":"ba790900339af802","name":"Request","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":135,"y":205,"wires":[["9ab337e2116dd80b"]]},{"id":"9ab337e2116dd80b","type":"function","z":"ba790900339af802","name":"Request V","func":"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":205,"wires":[["c471bf7e409ae082"]]},{"id":"716c6c5897a894d2","type":"udp out","z":"ba790900339af802","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":980,"y":205,"wires":[]},{"id":"c471bf7e409ae082","type":"change","z":"ba790900339af802","name":"Set Expected Respone Type","rules":[{"t":"set","p":"expectedResponseType","pt":"flow","to":"V","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":205,"wires":[["716c6c5897a894d2"]]},{"id":"5d2d9e1c322dd5a9","type":"udp in","z":"ba790900339af802","name":"","iface":"","port":"","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":115,"y":365,"wires":[["9b5c9f5a03d23978"]]},{"id":"c57391cc3ddc2eab","type":"function","z":"ba790900339af802","name":"Request I","func":"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":505,"y":345,"wires":[["a7d77ddad61add71"]]},{"id":"6cf8efcb806aba29","type":"function","z":"ba790900339af802","name":"Request V","func":"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":515,"y":385,"wires":[["acfdffccac2e9806"]]},{"id":"9b5c9f5a03d23978","type":"switch","z":"ba790900339af802","name":"Check Response Type","property":"expectedResponseType","propertyType":"flow","rules":[{"t":"eq","v":"V","vt":"str"},{"t":"eq","v":"I","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":365,"wires":[["c57391cc3ddc2eab","03e98ebd6e5bb86a"],["6cf8efcb806aba29","d676483ee0968bbf"]]},{"id":"d676483ee0968bbf","type":"debug","z":"ba790900339af802","name":"I Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":515,"y":425,"wires":[]},{"id":"03e98ebd6e5bb86a","type":"debug","z":"ba790900339af802","name":"V Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":515,"y":305,"wires":[]},{"id":"a7d77ddad61add71","type":"change","z":"ba790900339af802","name":"Set Expected Respone Type","rules":[{"t":"set","p":"expectedResponseType","pt":"flow","to":"I","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":755,"y":345,"wires":[["716c6c5897a894d2"]]},{"id":"acfdffccac2e9806","type":"change","z":"ba790900339af802","name":"Set Expected Respone Type","rules":[{"t":"set","p":"expectedResponseType","pt":"flow","to":"V","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":755,"y":385,"wires":[["716c6c5897a894d2"]]}]

Caution!!!
This will loop, so DON'T request another value once you have the 2nd

it doesn't have anything In the way of quality control
so just remove the request for the 2nd V

1 Like