Pioneer vsx 921

Hello i have an Pioneer VSX 921 and i have a flow that i can control it.
But i want a button on ex dashboard to turn up or down volume 10 notches. but when i get value from receiver it wont work in function with if this. what to do?

[{"id":"6c0f88c4.2e46b8","type":"inject","z":"4e99ff3b.00121","name":"","topic":"Get Volume","payload":"?V","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":144.2857208251953,"y":304.2857313156128,"wires":[["a8ebbabd.1af658"]]},{"id":"c4ddf455.155238","type":"inject","z":"4e99ff3b.00121","name":"","topic":"Volume Up","payload":"VU","payloadType":"str","repeat":"","crontab":"","once":false,"x":129.71428680419922,"y":366.57142639160156,"wires":[["a8ebbabd.1af658"]]},{"id":"8ea0f05f.1b573","type":"inject","z":"4e99ff3b.00121","name":"","topic":"Volume Down","payload":"VD","payloadType":"str","repeat":"","crontab":"","once":false,"x":120.71428680419922,"y":411.57142639160156,"wires":[["a8ebbabd.1af658"]]},{"id":"a8ebbabd.1af658","type":"function","z":"4e99ff3b.00121","name":"Add <CR>","func":"msg.payload = msg.payload + '\\r';\n\nreturn msg;","outputs":1,"noerr":0,"x":364.8571357727051,"y":352.42857933044434,"wires":[["2a2a105c.47aa9"]]},{"id":"2a2a105c.47aa9","type":"tcp request","z":"4e99ff3b.00121","server":"192.168.1.7","port":"23","out":"time","splitc":"10","name":"Pioneer SCLX56 ","x":541.7143478393555,"y":353.42856311798096,"wires":[["d06c35dc.6b1e88"]]},{"id":"d06c35dc.6b1e88","type":"function","z":"4e99ff3b.00121","name":"Convert to String","func":"msg.payload = msg.payload.toString();\nreturn msg;","outputs":1,"noerr":0,"x":751.71435546875,"y":358.71427726745605,"wires":[["c7644439.6b3478","e77165d5.6e7348"]]},{"id":"c7644439.6b3478","type":"debug","z":"4e99ff3b.00121","name":"","active":true,"console":"false","complete":"payload","x":958.2857055664062,"y":314.00000762939453,"wires":[]},{"id":"e77165d5.6e7348","type":"function","z":"4e99ff3b.00121","name":"This doesn´t work","func":"if(msg.payload === \"VOL081\"){\n //then do this.\n //this is where it stops\n msg.payload = \"hh\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":937.1428871154785,"y":424.2856864929199,"wires":[["c7644439.6b3478"]]},{"id":"a26b82a5.dd0e3","type":"comment","z":"4e99ff3b.00121","name":"Info about the flow","info":"When i press Get Volume it gets EX VOL081 in \ndebug, from Convert to string function.\nbut the if this function wont read it","x":506.4285774230957,"y":85.71429347991943,"wires":[]}]

For some reason your flow won't import (for me anyway). Did you use the Export to clipboard feature to get it and then paste it here? Have you got a line with three backticks before it and after it in the message?

However, if you have a function node that is not working as you expect (if that is the situation, I am not sure) then first use a debug node to show the data going into the function node and one showing what is coming out of the function node. If you still cannot work out the problem then show us the data going in and paste just the function node here.

[{"id":"4e99ff3b.00121","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"6c0f88c4.2e46b8","type":"inject","z":"4e99ff3b.00121","name":"","topic":"Get Volume","payload":"?V","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":144.2857208251953,"y":304.2857313156128,"wires":[["a8ebbabd.1af658"]]},{"id":"c4ddf455.155238","type":"inject","z":"4e99ff3b.00121","name":"","topic":"Volume Up","payload":"VU","payloadType":"str","repeat":"","crontab":"","once":false,"x":129.71428680419922,"y":366.57142639160156,"wires":[["a8ebbabd.1af658"]]},{"id":"8ea0f05f.1b573","type":"inject","z":"4e99ff3b.00121","name":"","topic":"Volume Down","payload":"VD","payloadType":"str","repeat":"","crontab":"","once":false,"x":120.71428680419922,"y":411.57142639160156,"wires":[["a8ebbabd.1af658"]]},{"id":"a8ebbabd.1af658","type":"function","z":"4e99ff3b.00121","name":"Add <CR>","func":"msg.payload = msg.payload + '\\r';\n\nreturn msg;","outputs":1,"noerr":0,"x":364.8571357727051,"y":352.42857933044434,"wires":[["2a2a105c.47aa9"]]},{"id":"2a2a105c.47aa9","type":"tcp request","z":"4e99ff3b.00121","server":"192.168.1.7","port":"23","out":"time","splitc":"10","name":"Pioneer SCLX56 ","x":541.7143478393555,"y":353.42856311798096,"wires":[["d06c35dc.6b1e88"]]},{"id":"d06c35dc.6b1e88","type":"function","z":"4e99ff3b.00121","name":"Convert to String","func":"msg.payload = msg.payload.toString();\nreturn msg;","outputs":1,"noerr":0,"x":751.71435546875,"y":358.71427726745605,"wires":[["c7644439.6b3478","e77165d5.6e7348"]]},{"id":"c7644439.6b3478","type":"debug","z":"4e99ff3b.00121","name":"","active":true,"console":"false","complete":"payload","x":958.2857055664062,"y":314.00000762939453,"wires":[]},{"id":"e77165d5.6e7348","type":"function","z":"4e99ff3b.00121","name":"This doesn´t work","func":"if(msg.payload === \"VOL081\"){\n    //then do this.\n    //this is where it stops\n    msg.payload = \"hh\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":937.1428871154785,"y":424.2856864929199,"wires":[["c7644439.6b3478"]]},{"id":"a26b82a5.dd0e3","type":"comment","z":"4e99ff3b.00121","name":"Info about the flow","info":"When i press Get Volume it gets EX VOL081 in \ndebug, from Convert to string function.\nbut the if this function wont read it","x":506.4285774230957,"y":85.71429347991943,"wires":[]}]

As @Colin said, I don't have a Pioneer VSX 921 but we still can help you.

Put a debug node (set to display the complete msg object) at the output of the Pioneer SCLX56 node and show us what it produces. That way someone could mimic that data and feed it into the rest of your flow to see what the results are.

I would also have two debug nodes, one for the Convert to String function and one for the 'This doesn't work' function to allow you to determine which node the debug message is coming from.

Here is from the pioneer node.
{"_msgid":"71c05bed.6ac724","topic":"Get Volume","payload":[86,79,76,48,56,49,13,10]}

convert to string node.

[86,79,76,48,56,49,13,10]

and the this does not work node nothing shows up

Ok, that says that the data you are betting backfrom the TCP node is not a buffer but a string array. Try this, first change the msg.payload to a buffer then to a string, so change your 'Convert to String' function to this:

msg.payload = Buffer.from(msg.payload);
msg.payload = msg.payload.toString();
return msg;

and see what you get

First two is from the Convert to string node and the "This does not work".
The last is from the TCP node.

35

So with 1 & 2 you have a string that contains the current volume setting

Assuming you want to display on a slider in the dashboard you can easily strip off the VOL and the carriage return.

Yes but the string wont work in the function. That is the problem

Which string? The debugs you show look fine, so what won't work? Give us a step by step of what is happening and what you want/expect to happen.

I want to use the string ex VOL081 in an if this in the function so i controll the volume with the function

Ok, so your IF statement if (msg.payload === "VOL081") doesn't work which means that msg.payload coes not contain the exact value 'VOL081'. Look at the results of the debug nodes and tell me why they don't match exactly.

I have tried "VOL081↵" which is displayed in the debug also.

If you look at the debug of the buffer, you have 8 items, but "VOL081' is only 6. Comparinge something that is 6 in length againse something that is 8 in length is going to result in a not equal condition.

I would grab the first 6 characters of the msg.payload before doing the compare.

Aha, good catch Paul... those last two characters are CR/NL

Before doing the comparison, you could try to use the trim function:

if (msg.payload.trim() === "VOL081")