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

**URL:** <https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891>\
**Category:** General\
**Created:** [18 September 2022 17:09 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891 "2022-09-18T17:09:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![dapper](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@dapper](https://discourse.nodered.org/u/dapper)\
**Post date:** [18 September 2022 17:09 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/1 "2022-09-18T17:09:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 September 2022 09:42 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/2 "2022-09-19T09:42:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 September 2022 10:17 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/3 "2022-09-19T10:17:36Z")

</div>

It looks like a simple ascii string.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 September 2022 10:23 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/4 "2022-09-19T10:23:32Z")

</div>

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..

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

```

---

<div class="post-metadata">

**Author:** ![dapper](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@dapper](https://discourse.nodered.org/u/dapper)\
**Post date:** [19 September 2022 11:32 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/5 "2022-09-19T11:32:21Z")

</div>

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

19/09/2022, 12:29:32[node: debug 1](http://192.168.0.65:8123/api/hassio_ingress/7iNAgO6kU17YttSCgAKhVbYivz1n75wa63hpE5YHHlM/#)msg.payload : buffer[8]

buffer[8][raw](http://192.168.0.65:8123/api/hassio_ingress/7iNAgO6kU17YttSCgAKhVbYivz1n75wa63hpE5YHHlM/#)

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.

---

<div class="post-metadata">

**Author:** ![dapper](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@dapper](https://discourse.nodered.org/u/dapper)\
**Post date:** [19 September 2022 11:43 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/6 "2022-09-19T11:43:54Z")

</div>

Tried that and got this error.

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

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

---

<div class="post-metadata">

**Author:** ![dapper](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@dapper](https://discourse.nodered.org/u/dapper)\
**Post date:** [19 September 2022 11:47 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/7 "2022-09-19T11:47:32Z")

</div>

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

I get this;

AV\_/P1t

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 September 2022 11:57 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/8 "2022-09-19T11:57:45Z")

</div>

Try this

```auto
[{"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":[]}]

```

```auto
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](https://flows.nodered.org/node/node-red-contrib-buffer-parser)

---

<div class="post-metadata">

**Author:** ![dapper](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@dapper](https://discourse.nodered.org/u/dapper)\
**Post date:** [19 September 2022 12:22 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/9 "2022-09-19T12:22:19Z")

</div>

> [@E1cid](#):
>
> `[{"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":[]}]`

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!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 September 2022 12:30 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/10 "2022-09-19T12:30:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dapper](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@dapper](https://discourse.nodered.org/u/dapper)\
**Post date:** [19 September 2022 12:32 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/11 "2022-09-19T12:32:19Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [19 September 2022 22:01 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/12 "2022-09-19T22:01:45Z")

</div>

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

> **[Help needed to pass a Node-Red value to HA](https://community.home-assistant.io/t/help-needed-to-pass-a-node-red-value-to-ha/195245/5)**
>
> Really appreciate the help! Why I used a template sensor was based on nothing than my inexsperience. I moved from domoticz and there it is called a virtual sensor. So I searched how to create and then the template sensor showed up. So based on your...

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 November 2022 22:01 UTC](https://discourse.nodered.org/t/can-anyone-help-with-splitting-a-serial-message-from-a-arcam-av-amp/67891/13 "2022-11-18T22:01:51Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
