# Help with how to parse this message

**URL:** <https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817>\
**Category:** General\
**Created:** [21 August 2020 10:08 UTC](https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817 "2020-08-21T10:08:24Z")\
**Posts on this page:** 6\
**Page:** 3

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [21 August 2020 13:34 UTC](https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817/41 "2020-08-21T13:34:10Z")

</div>

Ok, just for the sake of it:

The whole flow:

```auto
[{"id":"7264fb4e.c6e44c","type":"ui_template","z":"a1911aa3.c45be8","group":"ef4cdff9.3f4b4","name":"","order":2,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1120,"y":2140,"wires":[[]]},{"id":"cd36d859.72e13","type":"debug","z":"a1911aa3.c45be8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1110,"y":2240,"wires":[]},{"id":"d4b19fd2.f4c96","type":"switch","z":"a1911aa3.c45be8","name":"","property":"device","propertyType":"msg","rules":[{"t":"cont","v":"Marvin","vt":"str"},{"t":"cont","v":"S5","vt":"str"},{"t":"cont","v":"TABBYCAT","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":900,"y":2180,"wires":[[],[],["cd36d859.72e13","7264fb4e.c6e44c"]]},{"id":"497b5cc9.9dd91c","type":"function","z":"a1911aa3.c45be8","name":"","func":"msg.device = \"TABBYCAT\";\n\n//var x = msg.payload.split(\",\");\n//node.warn(\"X \"+x)\n\n//var y = x[2];\n//node.warn(y);\n\nvar dev = msg.device;\n\n//var spl = msg.payload.split(\",\");\n//var rgbPart = spl[0]; //get the rgb part (element 0)\n//var idPart = spl[1]; //get the id part (element 1)\n//var rgb = spl.slice(2); //get remaining parts (elements 2 ~ the end)\n//var rgbStr = rgb.join(\",\"); // join these last three parts by comma back to a string\n\nmsg = {\n\n \"payload\":\"<i class='fa fa-bullseye fa-2x' ng-style=\\\"{color:'rgb(200,0,0)'}\\\"></i>\",\n\n\n// \"payload\":\"<i class='fa fa-bullseye fa-2x' ng-style=\"{color:'rgb(200,0,0)'}\"></i>\"\n\n// \"payload\":\"<font color='rgb(200,0,0)'><i class='fa fa-bullseye fa-2x'></i></font>\",\n \"device\": dev\n}\nreturn msg;\n\n//set the payload as required - example...\n//msg.payload = {\n// id: idPart,\n// rgb: rgb,\n// rgbStr: rgbStr\n//}\n//return msg;\n\n\n\n\n\n//node.warn(msg.colour)\n\n//return msg;","outputs":1,"noerr":0,"x":720,"y":2220,"wires":[["d4b19fd2.f4c96"]]},{"id":"180f4891.538f47","type":"inject","z":"a1911aa3.c45be8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":570,"y":2220,"wires":[["497b5cc9.9dd91c"]]},{"id":"ef4cdff9.3f4b4","type":"ui_group","z":"","name":"Mobile devices","tab":"325a9fd4.22bde8","order":4,"disp":true,"width":"6","collapse":false},{"id":"325a9fd4.22bde8","type":"ui_tab","z":"","name":"Big device status","icon":"mi-drag_indicator","order":2,"disabled":false,"hidden":false}]

```

The output of the `debug` node:

```auto
{"payload":"<i class='fa fa-bullseye fa-2x' ng-style=\"{color:'rgb(200,0,0)'}\"></i>","device":"TABBYCAT","_msgid":"c4103fbe.d386"}

```

The screen:

![Screenshot from 2020-08-21 23-31-53](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b6df173d971c43e375218c1ca4e2e5125de4ca89.png)

And I have the setting:  
`angular theme in ui-template` set.  
Just so it is declared.

(sorry)  
But look at what is being sent to it. rgb.....  
`ng-style=\"{color:'rgb(200,0,0)'}`

It is 23:44 local time.

I have been up since 07:15.

Bed is calling.  
Bye and thanks for the help so far.  
It isn't I am running away from the problem. I am just tired.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [21 August 2020 13:59 UTC](https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817/42 "2020-08-21T13:59:37Z")

</div>

Change the function node to:

```auto
msg.device = "TABBYCAT";
color = "200,0,0"
msg.template ="<i class='fa fa-bullseye fa-2x' style='color:rgb("+color+")'></i>"
return msg;

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 August 2020 14:07 UTC](https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817/43 "2020-08-21T14:07:23Z")

</div>

In post 29 you said

> [@Trying\_to\_learn](#):
>
> If I put that where the other line is/was I get the same error:
> 
> `unclosed regular expression` .

The 'that' in question being the changed line with the quotes fixed, so you were saying that with the modified line you still got the error, which you now say was not correct.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [21 August 2020 21:10 UTC](https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817/44 "2020-08-21T21:10:57Z")

</div>

That is the error the node had. Not what it was sending as a message.

I have shown the screen shot of the error.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [22 August 2020 01:52 UTC](https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817/45 "2020-08-22T01:52:30Z")

</div>

(If you are still reading)

Got a night's sleep. Got up and thought about it.

The code was dumped as not being viable and I found another way to get it done.

Sometimes you have to walk away from something you don't understand and accept not understanding it or knowing a solution.

---

<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:** [5 September 2020 01:52 UTC](https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817/46 "2020-09-05T01:52:35Z")

</div>

Closed on 5 September 2020 01:52 UTC

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

[Previous page](https://discourse.nodered.org/t/help-with-how-to-parse-this-message/31817.md?page=2)
