Hey Guys,
I have about 30 Shelly 3EM sending simultaneus MQTT Messages to my MQTT Broker. I want to combine their measurements into a single payload to hand into InfluxDB but so far I am failing
The Devices more or less send their Information whenever they want. It seems like they send their Energy in Watt/Minutes every minute and the Power/Voltage/Current/PF every second.
Now I have read alot about the join node but I cannot get it to work when I have multiple shellys sending this data can I ?
Basically I want something like:
msg.payload = [{
Watt/Min: 12,
Current: 12,
Voltage: 12,
Power: 12,
PF: 12,
},
{
tag1:"sensor1",
}];
return msg;
Do you know if that is possible or what would be the best way to do this?
This is my current experiment but its either sending every message or combining multiple devices into one join
[
{
"id": "53f0c48e369e1106",
"type": "mqtt in",
"z": "5f5f00d7.65a72",
"name": "MQTT IN",
"topic": "shellies/+/emeter/+/+",
"qos": "2",
"datatype": "auto",
"broker": "18443a8c.6ef695",
"nl": false,
"rap": false,
"inputs": 0,
"x": 320,
"y": 520,
"wires": [
[
"32c61e22a5dbcd7b"
]
]
},
{
"id": "32c61e22a5dbcd7b",
"type": "function",
"z": "5f5f00d7.65a72",
"name": "function 2",
"func": "var Payload = msg.topic\nvar Machine = []\nMachine = Payload.split(\"/\")\nmsg.machine = Machine\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 460,
"y": 520,
"wires": [
[
"2bdb43e7ff879b5e"
]
]
},
{
"id": "2bdb43e7ff879b5e",
"type": "change",
"z": "5f5f00d7.65a72",
"name": "",
"rules": [
{
"t": "set",
"p": "tag",
"pt": "msg",
"to": "machine.4",
"tot": "msg"
},
{
"t": "set",
"p": "Maschine",
"pt": "msg",
"to": "machine.1",
"tot": "msg"
},
{
"t": "set",
"p": "Phase",
"pt": "msg",
"to": "machine.3",
"tot": "msg"
},
{
"t": "change",
"p": "topic",
"pt": "msg",
"from": "shellies/",
"fromt": "str",
"to": "",
"tot": "str"
},
{
"t": "change",
"p": "topic",
"pt": "msg",
"from": "/emeter",
"fromt": "str",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 630,
"y": 520,
"wires": [
[
"cdbf5a034242ba92"
]
]
},
{
"id": "cdbf5a034242ba92",
"type": "switch",
"z": "5f5f00d7.65a72",
"name": "",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "/energy",
"vt": "str"
},
{
"t": "cont",
"v": "/power",
"vt": "str"
},
{
"t": "cont",
"v": "/voltage",
"vt": "str"
},
{
"t": "cont",
"v": "/current",
"vt": "str"
},
{
"t": "cont",
"v": "/pf",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 5,
"x": 790,
"y": 520,
"wires": [
[
"1d384af782366bed"
],
[
"1d384af782366bed"
],
[
"1d384af782366bed"
],
[
"1d384af782366bed"
],
[
"1d384af782366bed"
]
]
},
{
"id": "1d384af782366bed",
"type": "join",
"z": "5f5f00d7.65a72",
"name": "",
"mode": "custom",
"build": "object",
"property": "Maschine",
"propertyType": "msg",
"key": "Maschine",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "5",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "num",
"reduceFixup": "",
"x": 930,
"y": 520,
"wires": [
[
"36f8452feb77c470"
]
]
},
{
"id": "36f8452feb77c470",
"type": "debug",
"z": "5f5f00d7.65a72",
"name": "debug 12",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1080,
"y": 520,
"wires": []
},
{
"id": "18443a8c.6ef695",
"type": "mqtt-broker",
"name": "Mosquitto",
"broker": "10.1.1.200",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"compatmode": false,
"protocolVersion": 4,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]