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": ""
}
]