# Display apcaccess (UPS) Attribute:Value Data in Dashboard

**URL:** <https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869>\
**Category:** Dashboard\
**Created:** [2 March 2021 04:40 UTC](https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869 "2021-03-02T04:40:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![plfinch](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@plfinch](https://discourse.nodered.org/u/plfinch)\
**Post date:** [2 March 2021 04:40 UTC](https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869/1 "2021-03-02T04:40:40Z")

</div>

I use an exec node to execute a command that queries UPS system status and returns textual data as shown in the command line snippet below. I want to display this output in the dashboard just as it is, or with two columns where the left column contains the attribute and the right column contains the corresponding value. Unfortunately, the exec node strips out whitespace and newlines or the output could easily be displayed in a UI template node. Is there a way to run a linux command and capture the unmolested output? I suppose this could be done with a custom function.

Here is the invocation and output for the apcaccess command. I can pipe the output to appropriate linux commands to format as needed (running on a Pi), such as sed or awk I guess. It just seems like a lot of effort to start with the format I already want in linux and perform a bunch of steps to get back to it in the node-red dashboard.

I am looking for the obvious "easy button" solution I have missed.

```auto
pi@NetMon:~/netmon/logs $ apcaccess -f /etc/apcupsd/apcupsd.upsCOMMS.conf
APC : 001,036,0869
DATE : 2021-03-01 22:30:48 -0500
HOSTNAME : NetMon
VERSION : 3.14.14 (31 May 2016) debian
UPSNAME : upsCOMMS
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2021-03-01 17:39:52 -0500
MODEL : J25B AV UPS
STATUS : ONLINE
LINEV : 124.0 Volts
LOADPCT : 3.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 116.5 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 96.0 Volts
HITRANS : 136.0 Volts
ALARMDEL : No alarm
BATTV : 27.0 Volts
LASTXFER : Automatic or explicit self test
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
SERIALNO : QB1048332151
BATTDATE : 2010-11-26
NOMINV : 120 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 865 Watts
FIRMWARE : 873.P2 .D USB FW:P2
END APC : 2021-03-01 22:31:36 -0500
pi@NetMon:~/netmon/logs $

```

---

<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:** [2 March 2021 07:01 UTC](https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869/2 "2021-03-02T07:01:31Z")

</div>

Perhaps with a function node (i put your output in a text file and read it into node-red - which should be the same output as the exec node)

```auto
let input = msg.payload
let lines = input.split("\n")
let ups = {}

for(let x=0;x<lines.length;x++){
    
    let row = lines[x].split(":")
    
    if(row[0]!="" && row[1]!=""){
        let left = row[0].trim()
        let right = row[1].trim()
        ups[left] = right
    }
}
return {payload:ups}

```

 ![Screenshot 2021-03-02 at 07.59.40](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/168e9ec75e56770bf40c8013b020ccbf1107170a.jpeg)

edit - perhaps i should read in the early morning, anyway you can modify it to your liking to get a formatted output.

---

<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:** [2 March 2021 07:28 UTC](https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869/3 "2021-03-02T07:28:55Z")

</div>

> [@plfinch](#):
>
> Unfortunately, the exec node strips out whitespace and newlines

That should not happen, can you feed it into a debug node and show us please.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [2 March 2021 10:44 UTC](https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869/4 "2021-03-02T10:44:43Z")

</div>

Add a `split` connected to a `change` connected to a `join` node between the `exec` and `ui-text` nodes. Leave the `split` and `join` nodes to their defaults and in the `change` node, set msg.payload to JSONata `payload&'<br>'` and that should do it.

```auto
[{"id":"465000e5.b25e48","type":"split","z":"64275f30.98b31","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":190,"y":400,"wires":[["f8e06a1.ae42998"]]},{"id":"ef324c4d.caf9e","type":"join","z":"64275f30.98b31","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":530,"y":400,"wires":[["6e47d13e.5844d","1068b271.49b40e"]]},{"id":"f8e06a1.ae42998","type":"change","z":"64275f30.98b31","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload&'<br>'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":400,"wires":[["ef324c4d.caf9e"]]}]

```

---

<div class="post-metadata">

**Author:** ![plfinch](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@plfinch](https://discourse.nodered.org/u/plfinch)\
**Post date:** [2 March 2021 14:33 UTC](https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869/5 "2021-03-02T14:33:43Z")

</div>

And you are correct, it did not really happen. Dumping the Exec Node msg.payload output to debug shows all multiple spaces and newlines are preserved. They are removed when displaying in the dashboard text node or template node.

I was using the default template node with:

```auto
<div ng-bind-html="msg.payload"></div>

```

I added a style tag to preserve whitespace with proportional spacing. Everything displays properly now.

```auto
<style>
    #mytext {
        font-family:monospace;
        white-space: pre;
    }
</style>
<div id="mytext" ng-bind="msg.payload"></div>

```

Don't I feel silly... Thank you!

---

<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:** [2 March 2021 18:51 UTC](https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869/6 "2021-03-02T18:51:28Z")

</div>

or for the lazy of us

```auto
<pre><div ng-bind-html="msg.payload"></div></pre>

```

---

<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:** [16 March 2021 18:52 UTC](https://discourse.nodered.org/t/display-apcaccess-ups-attribute-value-data-in-dashboard/41869/7 "2021-03-16T18:52:09Z")

</div>

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