Hello, I have a battery on my balcony PV panels connected. The battery can be manipulated via mqtt. Problem is that I have to sent a string to the battery which isn't json formatted. I tried with change and template node without success.
Below is the string I want to change the number behind v1= against a number I got from a different sensor. The number is responsible for the power which sending from battery to grid.
Any help appreciate!
cd=20,md=0,a1=1,b1=21:10,e1=23:59,v1=300,a2=0,b2=00:00,e2=05:30,v2=123,a3=0,b3=12:30,e3=20:30,v3=123
my flow
[
{
"id": "356f9f2a26aea580",
"type": "function",
"z": "490a6de6a9a41926",
"name": "P_Summe",
"func": "msg.topic = 'P_Summe';\nmsg.payload = msg.payload.Body.Data[\"0\"].PowerReal_P_Sum;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 400,
"wires": [
[
"5eb2acfe03978634"
]
]
},
{
"id": "c73a59b3c328b111",
"type": "mqtt in",
"z": "490a6de6a9a41926",
"name": "Batterie",
"topic": "hame_energy/HMJ-2/device/{{uid or mac}}/ctrl/#",
"qos": "0",
"datatype": "auto-detect",
"broker": "48a3a12b5a66dd33",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 130,
"y": 460,
"wires": [
[
"8edfe9e63c69f998"
]
]
},
{
"id": "8edfe9e63c69f998",
"type": "string",
"z": "490a6de6a9a41926",
"name": "Entladung",
"methods": [
{
"name": "getRightMost",
"params": [
{
"type": "str",
"value": "lv"
}
]
},
{
"name": "between",
"params": [
{
"type": "str",
"value": "="
},
{
"type": "str",
"value": ","
}
]
}
],
"prop": "payload",
"propout": "payload",
"object": "msg",
"objectout": "msg",
"x": 360,
"y": 460,
"wires": [
[
"c939d9184cb2de7e"
]
]
},
{
"id": "c939d9184cb2de7e",
"type": "change",
"z": "490a6de6a9a41926",
"name": "",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "Entladung",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 460,
"wires": [
[
"c9bce0cdea0b09e4"
]
]
},
{
"id": "c9bce0cdea0b09e4",
"type": "json",
"z": "490a6de6a9a41926",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 690,
"y": 460,
"wires": [
[
"a90e96380a9bc69b",
"0a75aed6e5477ce8"
]
]
},
{
"id": "a90e96380a9bc69b",
"type": "join",
"z": "490a6de6a9a41926",
"name": "Join",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"useparts": true,
"accumulate": false,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 890,
"y": 400,
"wires": [
[
"7eff079fb35aec4e"
]
]
},
{
"id": "7eff079fb35aec4e",
"type": "function",
"z": "490a6de6a9a41926",
"name": "v1 berechnen",
"func": "msg.topic = 'change_power';\nmsg.payload = msg.payload.Entladung + msg.payload.P_Summe;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1060,
"y": 400,
"wires": [
[
"7dac084efc2ee6a7"
]
]
},
{
"id": "5eb2acfe03978634",
"type": "switch",
"z": "490a6de6a9a41926",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "gte",
"v": "15",
"vt": "num"
},
{
"t": "lte",
"v": "-15",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 690,
"y": 400,
"wires": [
[
"a90e96380a9bc69b"
],
[
"0a75aed6e5477ce8"
]
],
"info": "Überprüfung ob noch Solar produziert wird. Bei nur positiven Werten liefert die PV Anlage nicht genügend Strom."
},
{
"id": "0a75aed6e5477ce8",
"type": "join",
"z": "490a6de6a9a41926",
"name": "Join",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"useparts": true,
"accumulate": false,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 890,
"y": 460,
"wires": [
[
"80446b571a22f01f"
]
]
},
{
"id": "80446b571a22f01f",
"type": "function",
"z": "490a6de6a9a41926",
"name": "v1 berechnen",
"func": "msg.topic = 'change_power';\nmsg.payload = msg.payload.Entladung + msg.payload.P_Summe;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1060,
"y": 460,
"wires": [
[
"8df63f458728c090"
]
]
},
{
"id": "3cd49d869df0d59c",
"type": "function",
"z": "490a6de6a9a41926",
"name": "Payload v1",
"func": "msg.payload = 'cd=20,md=0,a1=1,b1=21:10,e1=23:59,v1=300,a2=0,b2=00:00,e2=05:30,v2=123,a3=0,b3=12:30,e3=20:30,v3=123'\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1490,
"y": 440,
"wires": [
[]
]
},
{
"id": "7dac084efc2ee6a7",
"type": "switch",
"z": "490a6de6a9a41926",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "btwn",
"v": "80",
"vt": "num",
"v2": "800",
"v2t": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1210,
"y": 400,
"wires": [
[
"8435ab95fca04744"
]
]
},
{
"id": "8df63f458728c090",
"type": "switch",
"z": "490a6de6a9a41926",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "btwn",
"v": "80",
"vt": "num",
"v2": "800",
"v2t": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1210,
"y": 460,
"wires": [
[
"8435ab95fca04744"
]
],
"info": "Überprüfung ob noch Solar produziert wird. Bei nur positiven Werten liefert die PV Anlage nicht genügend Strom."
},
{
"id": "8435ab95fca04744",
"type": "json",
"z": "490a6de6a9a41926",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 1350,
"y": 440,
"wires": [
[
"3cd49d869df0d59c"
]
]
},
{
"id": "c6d434a3a78a0a6e",
"type": "comment",
"z": "490a6de6a9a41926",
"name": "",
"info": "Entladung is node-red-contrib-string\nP_Summe my powermeter sending what is going or comming from grid",
"x": 340,
"y": 400,
"wires": []
},
{
"id": "48a3a12b5a66dd33",
"type": "mqtt-broker",
"name": "",
"broker": "192.168.178.106",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]