Can anyone help with splitting a serial message from a Arcam AV amp?

I have a Home Assistant set up with the Node Red addon. I've been trying to get responses from the Arcam from the serial port and then send the info like volume etc, back into Home Assistant.

I can receive the responses but I'm stuck on how to split the responses into something readable by Home Assistant.

The format from the manual looks like this for the Arcam response to a volume change;

Response: 0x41 0x56 0x5f 0x2f 0x50 0x32 0x68 0x0d

The volume level is the 7th value but minus -0x30, the other values are zone etc. (Formula: actual volume = (reported volume – 0x30)

Can someone please explain how can I split into separate values and then do the subtraction to get a value back to Home Assistant?

Thanks in advance! it might be easy for some of you but I'm scratching my head.

What type is the response, is an array, string etc?
Can we see a debug of the response please.

1 Like

It looks like a simple ascii string.

1 Like

Thats what I think but it is not clear. You know yourself that some time beginners confuse information.
If it is a string then a simple split and subtraction should work in a function node..

let data = msg.payload.split(" ");
msg.payload = data[6] - 48; // or 0x30 or "0x30"
return msg;
2 Likes

Thanks for replying! The serial port is delivering binary buffers. Here is the response from the serial port.

19/09/2022, 12:29:32node: debug 1msg.payload : buffer[8]

buffer[8]raw

0: 0x41

1: 0x56

2: 0x5f

3: 0x2f

4: 0x50

5: 0x31

6: 0x6c

7: 0xd

The other data bits are info about the speaker zones, source input etc. I would like to split these as well so I can display this in Home Assistant if possible.

Tried that and got this error.

"TypeError: msg.payload.split is not a function"

You're right, I am very confused around the information. :grinning: It feels like I'm playing with a variety of options and not landing on the correct configuration all the time.

BTW. If I press on the string/raw button beside the 'buffer[8][raw ]'

I get this;

AV_/P1t

Try this

[{"id":"f4409487.fa405","type":"function","z":"bf9e1e33.030598","name":"","func":"let data = [...msg.payload]\ndata = data.map(hex => parseInt(hex));\ndata[6] = data[6] - 48; // or 0x30 or \"0x30\"\nmsg.payload = data;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1410,"y":1540,"wires":[["d830bfbc.e5794"]]},{"id":"2b397f45.41b268","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"0x41\", \"0x56\", \"0x5f\", \"0x2f\", \"0x50\", \"0x32\", \"0x68\", \"0x0d\"]","payloadType":"bin","x":1160,"y":1540,"wires":[["f4409487.fa405"]]},{"id":"d830bfbc.e5794","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1660,"y":1540,"wires":[]}]
let data = [...msg.payload] //convert to an array
data = data.map(hex => parseInt(hex)); // or Number(hex)
data[6] = data[6] - 48; // 0x30
msg.payload = data;
return msg;

[edit forgot to convert buffer to array]
You could also use node-red-contrib-buffer-parser

2 Likes

It works! Now I see;

array[8]

0: 65

1: 86

2: 95

3: 47

4: 80

5: 49

6: 54

7: 13

with the 7th being the correct volume. Thank you!! One more thing. How do I split these values into separate entities to send to Home Assistant? It's the last piece of the puzzle for me. I did try buffer parser, but I was lost with that as well!

You can use msg.payload[6] to send the 7th value to where you want it, msg.payload[0] is the first value. I do not use HA so can not tell you which HA node to use. I believe @craigcurtin uses HA, he may step in to help further

1 Like

I will experiment more and work it out. I've been struggling with this on and off for around three years tbh. Thanks for all your help! Much appreciated!

OK good work - really would suggest you put some time into Buffer parser from Steve as it is nice.

But now that you have got the value you want you need to send it back to HA

Here is a good thread on the NR forum of HA that covers the different approaches you can take

  1. Use the Entity Node - which will allow you to create a HA entity and feed it the data
  2. Use MQTT and create an MQTT entity in HA to "catch" the data from NR and then whatever automations etc in HA to move it where you want

The Entity node is the better more pure way to go - and i would assume you already have some form of dashboard that is displaying these entities anyway

Craig