I came across node-red with a flow which is reading out charging values from my SMA wallbox. The flow was pre configured. From that starting point I played around a lot, dove into node-red, looked at all parts of the flow, expanded and personalized the flow and actually produced something very useful for me.
There is still one thing I don't understand, I did not manage to translate the curl command into an native node-red flow.
Here is the working curl command including verbose output, the bearer token is .
curl -v http://192.168.47.82/api/v1/measurements/live/ -d "[{\"componentId\":\"IGULD:SELF\"}]" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTkxOTMxNDgsInN1YiI6ImFkbWluIiwidWlkIjoiMDI5N2FhMjMtODI1YS00ZGUzLWFiYzQtMzQ1Y2U5ODBhZDQ3IiwiZXhwIjoxNjk5MTk2NzQ4fQ.6vTTw9Eid4iLWqIdMrBvmbSODiz2ApclVzrgYA3Yryo"
and the verbose output
* Trying 192.168.47.82:80...
* Connected to 192.168.47.82 (192.168.47.82) port 80 (#0)
> POST /api/v1/measurements/live/ HTTP/1.1
> Host: 192.168.47.82
> User-Agent: curl/8.0.1
> Accept: */*
> Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTkxOTMxNDgsInN1YiI6ImFkbWluIiwidWlkIjoiMDI5N2FhMjMtODI1YS00ZGUzLWFiYzQtMzQ1Y2U5ODBhZDQ3IiwiZXhwIjoxNjk5MTk2NzQ4fQ.6vTTw9Eid4iLWqIdMrBvmbSODiz2ApclVzrgYA3Yryo
> Content-Length: 30
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Sun, 05 Nov 2023 14:06:08 GMT
< Cache-Control: no-cache,no-store,must-revalidate
< Content-Type: application/json
< Transfer-Encoding: chunked
[{"channelId":"Measurement.ChaSess.WhIn", ....
...
...
here comes the requested data
Here is the flow I would like to use to replace it, I tried many different settings, return is either a "not logged" in message or a "500 Server error"
[
{
"id": "6ef9a42282b67566",
"type": "inject",
"z": "fce05b304dab0b49",
"name": "Ausloeser",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 160,
"y": 840,
"wires": [
[
"node1"
]
]
},
{
"id": "node1",
"type": "function",
"z": "fce05b304dab0b49",
"name": "Daten vorbereiten",
"func": "var Befehl = {'componentId':'IGULD:SELF'};\nmsg.headers = {};\nmsg.headers = {\n 'User-Agent': 'curl/8.0.1',\n 'Accept': '*/*',\n 'Authorization': 'Bearer ' + flow.get(\"wallbox_data_retrieve_token\"),\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\nmsg.payload = Befehl;\nmsg.url = \"http://192.168.47.82/api/v1/measurements/live/\";\nmsg.method = \"POST\";\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 370,
"y": 840,
"wires": [
[
"node2",
"89537487970d119e"
]
]
},
{
"id": "node2",
"type": "http request",
"z": "fce05b304dab0b49",
"name": "HTTP POST-Anfrage",
"method": "use",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 600,
"y": 840,
"wires": [
[
"node3"
]
]
},
{
"id": "89537487970d119e",
"type": "debug",
"z": "fce05b304dab0b49",
"name": "Post Daten",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 550,
"y": 760,
"wires": []
},
{
"id": "node3",
"type": "debug",
"z": "fce05b304dab0b49",
"name": "Rueckgabe Wallbox",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 840,
"y": 840,
"wires": []
}
]