# Summarize +50 values from MQTT

**URL:** <https://discourse.nodered.org/t/summarize-50-values-from-mqtt/76411>\
**Category:** General\
**Created:** [10 March 2023 20:10 UTC](https://discourse.nodered.org/t/summarize-50-values-from-mqtt/76411 "2023-03-10T20:10:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RedSnapper](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@RedSnapper](https://discourse.nodered.org/u/RedSnapper)\
**Post date:** [10 March 2023 20:10 UTC](https://discourse.nodered.org/t/summarize-50-values-from-mqtt/76411/1 "2023-03-10T20:10:51Z")

</div>

Hey community,

I am new to Node Red which I want to utilise to gain more insights into my power consumption.  
The main goal is to know how much I consume overall - meaning over all device.

I´ve +50 devices reporting per MQTT like this example:

shellies/shellyswitch25-C45BBE6C5739/relay/0/power: 167.34  
shellies/shellyswitch25-68C63AF926B8/relay/1/power: 0  
shellies/shellyplug-s-E868E7C16AF7/relay/0/power: 68.23  
shellies/shellydimmer2-F4CFA2ECE263/light/0/power: 7.75

I am totally struggling in summarising them. I´ve used a JOIN node to bring all MQTT payloads into a key/value object but parsing and $sum($$.payload.power) failed.

Can you support please?

Thx!

> **\*\*Flow\*\***
>
> [  
> {  
> "id": "e8dc97d32a38102b",  
> "type": "tab",  
> "label": "Flow 7",  
> "disabled": false,  
> "info": "",  
> "env":   
> },  
> {  
> "id": "60a544b770c89c6d",  
> "type": "mqtt in",  
> "z": "e8dc97d32a38102b",  
> "name": "Fernseher",  
> "topic": "shellies/shellyswitch25-C45BBE6C5739/relay/0/power",  
> "qos": "0",  
> "datatype": "json",  
> "broker": "250712f8e4cd2178",  
> "nl": false,  
> "rap": true,  
> "rh": 0,  
> "inputs": 0,  
> "x": 100,  
> "y": 140,  
> "wires": [  
> [  
> "dc66be3def5d40f3"  
> ]  
> ],  
> "outputLabels": [  
> "msg.payload"  
> ]  
> },  
> {  
> "id": "981beab0950976aa",  
> "type": "mqtt in",  
> "z": "e8dc97d32a38102b",  
> "name": "Kühlschrank",  
> "topic": "shellies/shellyplug-s-E868E7C16AF7/relay/0/power",  
> "qos": "0",  
> "datatype": "json",  
> "broker": "250712f8e4cd2178",  
> "nl": false,  
> "rap": true,  
> "rh": 0,  
> "inputs": 0,  
> "x": 110,  
> "y": 220,  
> "wires": [  
> [  
> "dc66be3def5d40f3"  
> ]  
> ]  
> },  
> {  
> "id": "d25365ca15507510",  
> "type": "mqtt in",  
> "z": "e8dc97d32a38102b",  
> "name": "Lüftung",  
> "topic": "shellies/shellyswitch25-68C63AF926B8/relay/1/power",  
> "qos": "0",  
> "datatype": "json",  
> "broker": "250712f8e4cd2178",  
> "nl": false,  
> "rap": true,  
> "rh": 0,  
> "inputs": 0,  
> "x": 90,  
> "y": 300,  
> "wires": [  
> [  
> "dc66be3def5d40f3"  
> ]  
> ]  
> },  
> {  
> "id": "5dc22020bf2129db",  
> "type": "mqtt in",  
> "z": "e8dc97d32a38102b",  
> "name": "Licht Esstisch",  
> "topic": "shellies/shellydimmer2-F4CFA2ECE263/light/0/power",  
> "qos": "0",  
> "datatype": "json",  
> "broker": "250712f8e4cd2178",  
> "nl": false,  
> "rap": true,  
> "rh": 0,  
> "inputs": 0,  
> "x": 110,  
> "y": 380,  
> "wires": [  
> [  
> "dc66be3def5d40f3"  
> ]  
> ]  
> },  
> {  
> "id": "dc66be3def5d40f3",  
> "type": "join",  
> "z": "e8dc97d32a38102b",  
> "name": "",  
> "mode": "custom",  
> "build": "object",  
> "property": "payload",  
> "propertyType": "msg",  
> "key": "topic",  
> "joiner": ",",  
> "joinerType": "str",  
> "accumulate": true,  
> "timeout": "30",  
> "count": "4",  
> "reduceRight": false,  
> "reduceExp": "",  
> "reduceInit": "",  
> "reduceInitType": "",  
> "reduceFixup": "",  
> "x": 390,  
> "y": 220,  
> "wires": [  
> [  
> "d7b032c921ed3391"  
> ]  
> ]  
> },  
> {  
> "id": "5a11504dd4cc0b53",  
> "type": "change",  
> "z": "e8dc97d32a38102b",  
> "name": "",  
> "rules": [  
> {  
> "t": "set",  
> "p": "payload",  
> "pt": "msg",  
> "to": "$sum($$.payload.power)",  
> "tot": "jsonata"  
> }  
> ],  
> "action": "",  
> "property": "",  
> "from": "",  
> "to": "",  
> "reg": false,  
> "x": 600,  
> "y": 300,  
> "wires": [  
>   
> ]  
> },  
> {  
> "id": "d7b032c921ed3391",  
> "type": "debug",  
> "z": "e8dc97d32a38102b",  
> "name": "debug 4",  
> "active": true,  
> "tosidebar": true,  
> "console": false,  
> "tostatus": false,  
> "complete": "payload",  
> "targetType": "msg",  
> "statusVal": "",  
> "statusType": "auto",  
> "x": 800,  
> "y": 220,  
> "wires":   
> },  
> {  
> "id": "250712f8e4cd2178",  
> "type": "mqtt-broker",  
> "name": "",  
> "broker": "ATVMSRVHB.home.internal",  
> "port": "1883",  
> "clientid": "",  
> "autoConnect": true,  
> "usetls": false,  
> "protocolVersion": "4",  
> "keepalive": "60",  
> "cleansession": true,  
> "birthTopic": "",  
> "birthQos": "0",  
> "birthPayload": "",  
> "birthMsg": {},  
> "closeTopic": "",  
> "closeQos": "0",  
> "closePayload": "",  
> "closeMsg": {},  
> "willTopic": "",  
> "willQos": "0",  
> "willPayload": "",  
> "willMsg": {},  
> "userProps": "",  
> "sessionExpiry": ""  
> }  
> ]

---

<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:** [10 March 2023 20:15 UTC](https://discourse.nodered.org/t/summarize-50-values-from-mqtt/76411/2 "2023-03-10T20:15:11Z")

</div>

If you show the joined object i could be sure, but try

```auto
$sum($$.payload.*)

```

This [section](https://nodered.org/docs/user-guide/messages#understanding-the-structure-of-a-message) of the docs shows how to copy values from the debug sidebar

---

<div class="post-metadata">

**Author:** ![RedSnapper](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@RedSnapper](https://discourse.nodered.org/u/RedSnapper)\
**Post date:** [10 March 2023 20:51 UTC](https://discourse.nodered.org/t/summarize-50-values-from-mqtt/76411/3 "2023-03-10T20:51:15Z")

</div>

Got it !! Works like a charm.

Way easier than expected. Thank you

---

<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:** [24 March 2023 20:52 UTC](https://discourse.nodered.org/t/summarize-50-values-from-mqtt/76411/4 "2023-03-24T20:52:13Z")

</div>

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