NEWS
(Gelöst) http request mit speziellem header
-
Hallo zusammen
Ich versuche verzweifelt die Daten meiner Bloomsky Wetterstation in Iobroker zugänglich zu machen. Die Daten können per Api abgefragt werden, aber leider wird der Key in der Url nicht aktzeptiert. https://cookbook.nodered.org/http/set-request-header Ich versuche nun mit dieser Anweisung weiterzufahren, aber ich komme nicht weiter.
So sieht Mein Flow im Moment aus.Funktions Node````
msg.payload = "get";
msg.headers = 'Authorization:';
msg.headers['X-Auth-User'] = 't5-xstrliNvXrZunuLY=';
return msg;Hier das http request Node ![8804_2.jpg](/assets/uploads/files/8804_2.jpg) Im Debug kommt immer diese Fehlermeldung
msg : Object
object
_msgid: "5047bdd1.b5f4b4"
topic: ""
payload: "{↵ "detail": "Method "USE" not allowed."↵}"
statusCode: 405
headers: object
responseUrl: "http://api.bloomsky.com/api/skydata/"Ich habe schon diverse Einstellungen versucht, die Fehlermeldung ändert sich jedoch nie.
-
Hallo liebe Forengemeinde
Bisher wart ihr ja keine besonders grosse Hilfe, trotzdem bin ich mit viel Einsatz ein gutes Stück weiter gekommen. Ich hoffe ihr könnt nun den letzten Tip für den Abschluss dieses Flows geben.
[ { "id": "68d9eafb.1ce0ac", "type": "inject", "z": "b285f7fb.6e5d8", "name": "5 Minuti", "topic": "", "payload": "", "payloadType": "date", "repeat": "300", "crontab": "", "once": false, "onceDelay": 0.1, "x": 109, "y": 42, "wires": [ [ "16095f99.442048" ] ] }, { "id": "16095f99.442048", "type": "function", "z": "b285f7fb.6e5d8", "name": "msg.method", "func": "msg.method = \"GET\";\nmsg.headers = {\n \"Authorization\": \"t5-xstrliNvXrZunuLY=\",\n \"Content-Type\": \"application/json\"\n};\nreturn msg;", "outputs": 1, "noerr": 0, "x": 269, "y": 44, "wires": [ [ "7b6ff8ab.cd49c8" ] ] }, { "id": "7b6ff8ab.cd49c8", "type": "http request", "z": "b285f7fb.6e5d8", "name": "http", "method": "use", "ret": "obj", "url": "https://api.bloomsky.com/api/skydata/?unit=intl", "tls": "", "x": 101, "y": 154, "wires": [ [ "862f3c15.c44a5", "69e3dfb2.8b3e98", "87de4641.0d7d08", "f1af9e87.e5d44", "561ec95e.0a9ff8", "c8bbba66.594f28", "943fcf1e.36f4c", "e0c04b60.d739e", "bb54b628.8df3a", "db915621.e75818", "1a160a3.5a2a2f6", "135aecea.685f8b", "87615da7.73db6" ] ], "inputLabels": [ "msg.payload" ], "outputLabels": [ "msg.payload" ] }, { "id": "862f3c15.c44a5", "type": "function", "z": "b285f7fb.6e5d8", "name": "Windrichtung", "func": "msg.payload = msg.payload[0].Storm.WindDirection;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 265, "y": 207, "wires": [ [ "e7f67803.679f68" ] ], "outputLabels": [ "Windrichtung" ] }, { "id": "69e3dfb2.8b3e98", "type": "function", "z": "b285f7fb.6e5d8", "name": "UV Index", "func": "msg.payload = msg.payload[0].Storm.UVIndex;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 259, "y": 162, "wires": [ [ "bfcb06d2.c5fa1" ] ], "outputLabels": [ "Windrichtung" ] }, { "id": "87de4641.0d7d08", "type": "function", "z": "b285f7fb.6e5d8", "name": "Niederschlag Heute", "func": "msg.payload = msg.payload[0].Storm.RainDaily;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 285, "y": 248, "wires": [ [] ], "outputLabels": [ "Windrichtung" ] }, { "id": "561ec95e.0a9ff8", "type": "function", "z": "b285f7fb.6e5d8", "name": "Windgeschwindigkeit", "func": "msg.payload = msg.payload[0].Storm.SustainedWindSpeed;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 300, "y": 324, "wires": [ [] ], "outputLabels": [ "Windrichtung" ] }, { "id": "f1af9e87.e5d44", "type": "function", "z": "b285f7fb.6e5d8", "name": "Windböhen", "func": "msg.payload = msg.payload[0].Storm.WindGust;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 273, "y": 284, "wires": [ [] ], "outputLabels": [ "Windrichtung" ] }, { "id": "c8bbba66.594f28", "type": "function", "z": "b285f7fb.6e5d8", "name": "Niederschlagsintensität", "func": "msg.payload = msg.payload[0].Storm.RainRate;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 312, "y": 369, "wires": [ [] ], "outputLabels": [ "Windrichtung" ] }, { "id": "943fcf1e.36f4c", "type": "function", "z": "b285f7fb.6e5d8", "name": "Niederschlag 24h", "func": "msg.payload = msg.payload[0].Storm[\"24hRain\"];\nreturn msg;", "outputs": 1, "noerr": 0, "x": 292, "y": 417, "wires": [ [] ], "outputLabels": [ "Windrichtung" ] }, { "id": "e0c04b60.d739e", "type": "function", "z": "b285f7fb.6e5d8", "name": "Helligkeit", "func": "msg.payload = msg.payload[0].Data.Luminance;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 263, "y": 460, "wires": [ [] ], "outputLabels": [ "Windrichtung" ] }, { "id": "bb54b628.8df3a", "type": "function", "z": "b285f7fb.6e5d8", "name": "Aussentemperatur", "func": "msg.payload = msg.payload[0].Data.Temperature;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 289, "y": 507, "wires": [ [ "ef747394.c1f878", "6cd03757.fc1788", "f05733dc.c5bd68" ] ], "outputLabels": [ "Windrichtung" ] }, { "id": "db915621.e75818", "type": "function", "z": "b285f7fb.6e5d8", "name": "Regen J/N", "func": "msg.payload = msg.payload[0].Data.Rain;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 267, "y": 549, "wires": [ [ "45f4874a.236208" ] ], "outputLabels": [ "Windrichtung" ] }, { "id": "1a160a3.5a2a2f6", "type": "function", "z": "b285f7fb.6e5d8", "name": "Luftfeuchtigkeit", "func": "msg.payload = msg.payload[0].Data.Humidity;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 271, "y": 592, "wires": [ [] ], "outputLabels": [ "Windrichtung" ] }, { "id": "135aecea.685f8b", "type": "function", "z": "b285f7fb.6e5d8", "name": "Luftdruck", "func": "msg.payload = msg.payload[0].Data.Pressure;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 256, "y": 638, "wires": [ [] ], "outputLabels": [ "Windrichtung" ] }, { "id": "87615da7.73db6", "type": "function", "z": "b285f7fb.6e5d8", "name": "Nacht J/N", "func": "msg.payload = msg.payload[0].Data.Night;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 257, "y": 684, "wires": [ [ "b66a38b5.60bca" ] ], "outputLabels": [ "Windrichtung" ] }, { "id": "baeb34e.4ad3b48", "type": "ioBroker out", "z": "b285f7fb.6e5d8", "name": "UV Index", "topic": "Bloomsky.UV_Index", "ack": "true", "autoCreate": "true", "x": 675, "y": 133, "wires": [] }, { "id": "e7f67803.679f68", "type": "ioBroker out", "z": "b285f7fb.6e5d8", "name": "Windrichtung", "topic": "Bloomsky.Windrichtung", "ack": "false", "autoCreate": "true", "x": 569, "y": 187, "wires": [] }, { "id": "f05733dc.c5bd68", "type": "ioBroker out", "z": "b285f7fb.6e5d8", "name": "Aussentemperatur", "topic": "Bloomsky.Aussentemperatur", "ack": "false", "autoCreate": "true", "x": 969, "y": 379, "wires": [] }, { "id": "ef747394.c1f878", "type": "change", "z": "b285f7fb.6e5d8", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 580, "y": 506, "wires": [ [ "a56a9f5d.efb888" ] ] }, { "id": "bfcb06d2.c5fa1", "type": "change", "z": "b285f7fb.6e5d8", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 470, "y": 132, "wires": [ [ "baeb34e.4ad3b48" ] ] }, { "id": "a56a9f5d.efb888", "type": "debug", "z": "b285f7fb.6e5d8", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 954.5, "y": 503, "wires": [] }, { "id": "45f4874a.236208", "type": "change", "z": "b285f7fb.6e5d8", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "true", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 572, "y": 557, "wires": [ [ "81c701b.0bd01" ] ] }, { "id": "b66a38b5.60bca", "type": "change", "z": "b285f7fb.6e5d8", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "true", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 568, "y": 699, "wires": [ [ "d1d3d178.a7cb88" ] ] }, { "id": "81c701b.0bd01", "type": "ioBroker out", "z": "b285f7fb.6e5d8", "name": "Regen", "topic": "Bloomsky.Regen", "ack": "false", "autoCreate": "true", "x": 907, "y": 556, "wires": [] }, { "id": "d1d3d178.a7cb88", "type": "ioBroker out", "z": "b285f7fb.6e5d8", "name": "Nacht", "topic": "Bloomsky.Nacht", "ack": "true", "autoCreate": "true", "x": 895, "y": 706, "wires": [] }, { "id": "6cd03757.fc1788", "type": "debug", "z": "b285f7fb.6e5d8", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 579, "y": 442, "wires": [] } ]
Dieser Flow erstellt mir bereits die gewünschten Objekte im IoBroker und liefert die Werte bis zum IoBroker Node.Mein leztes Problem sind die Werte, welche nicht übernommen werden. Ich habe bereits mit einem Change Node versucht den String in andere Formate zu ändern, aber beim Objekt ist bisher noch nichts angekommen.
Daher die Frage: Wie bekomme ich die Werte zu den IoBroker Objekten?
-
Also ich hab dir mal als Beispiel nur für die Außentemperatur gemacht, den Rest solltest du hinbekommen.
! ````
[
{
"id": "a9a2a713.60106",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "247269d7.fab636",
"type": "inject",
"z": "a9a2a713.60106",
"name": "5 Minuti",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 90,
"y": 140,
"wires": [
[
"f7a97781.3c9188"
]
]
},
{
"id": "f7a97781.3c9188",
"type": "function",
"z": "a9a2a713.60106",
"name": "msg.method",
"func": "msg.method = "GET";\nmsg.headers = {\n "Authorization": "t5-xstrliNvXrZunuLY=",\n "Content-Type": "application/json"\n};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 260,
"y": 142,
"wires": [
[
"39486894.3eb198"
]
]
},
{
"id": "39486894.3eb198",
"type": "http request",
"z": "a9a2a713.60106",
"name": "http",
"method": "use",
"ret": "obj",
"url": "https://api.bloomsky.com/api/skydata/?unit=intl",
"tls": "",
"x": 110,
"y": 260,
"wires": [
[
"39b281f5.ba96e6"
]
],
"inputLabels": [
"msg.payload"
],
"outputLabels": [
"msg.payload"
]
},
{
"id": "d357a8f9.f6cdd",
"type": "ioBroker out",
"z": "a9a2a713.60106",
"name": "Aussentemperatur",
"topic": "node-red.0.Bloomsky.Aussentemperatur",
"ack": "false",
"autoCreate": "true",
"x": 550,
"y": 260,
"wires": []
},
{
"id": "c7e5f99e.d0acb8",
"type": "debug",
"z": "a9a2a713.60106",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 945.5,
"y": 601,
"wires": []
},
{
"id": "39b281f5.ba96e6",
"type": "change",
"z": "a9a2a713.60106",
"name": "Außentemperatur",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Data.Temperature",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 290,
"y": 260,
"wires": [
[
"d357a8f9.f6cdd"
]
]
}
]Prinzipiell: Die function-nodes sind überflüssig, das kann man alles jeweils mit einer JSONata-Expression machen. Falls du doch lieber Function-node (FN) benutzen willst, hier ein paar Anmerkungen: FN sind recht ressourcenhungrig, weil sie jeweils in einer Sandbox laufen. Deshalb so wenige wie nötig in einem Flow einsetzen. In deinem Fall hättest du besser nur ein FN mit mehreren Ausgängen benutzen können. Beim ioBroker-out node musst du den kompletten Pfad (inkl. Instanz) angeben. ![3999_iobroker-out-node.png](/assets/uploads/files/3999_iobroker-out-node.png) Schönen Abend noch
-
Vielen Dank für deine Hilfe und das Aufklären. Die JSONata-Expression Funktion kannte ich bisher nicht, auch der Ressourcenhunger der Funkions-nodes ist mir neu.
-
Beim ioBroker-out node musst du den kompletten Pfad (inkl. Instanz) angeben. `
Das ganze läuft nun schon einige Tage Problemlos und sieht so aus
[ { "id": "da4c9417.6cfca", "type": "inject", "z": "cf69d3aa.73ae28", "name": "1 Minute", "topic": "", "payload": "", "payloadType": "date", "repeat": "60", "crontab": "", "once": false, "onceDelay": 0.1, "x": 103, "y": 470, "wires": [ [ "f1ce2b02.e3f1a" ] ] }, { "id": "f1ce2b02.e3f1a", "type": "function", "z": "cf69d3aa.73ae28", "name": "msg.method", "func": "msg.method = \"GET\";\nmsg.headers = {\n \"Authorization\": \"t5-xstrliNvXrZunuLY=\",\n \"Content-Type\": \"application/json\"\n};\nreturn msg;", "outputs": 1, "noerr": 0, "x": 95, "y": 528, "wires": [ [ "ba93ee4.8a3071" ] ] }, { "id": "ba93ee4.8a3071", "type": "http request", "z": "cf69d3aa.73ae28", "name": "http", "method": "use", "ret": "obj", "url": "https://api.bloomsky.com/api/skydata/?unit=intl", "tls": "", "x": 108, "y": 584, "wires": [ [ "22ed56e1.36f812", "ca9ca821.642c98", "381d27f3.81f3d", "5c578fae.9f8618", "efa29b54.4059", "d9e2fb03.3f025", "7733c9d1.ab4048", "64038f1.4b33d7", "747b03e5.4b74f4", "e7fc05d3.cf7408", "c1945dc8.8f691", "4c307da4.b6faec", "198537d.f38cf48", "de39e8fc.6c3f38", "d7b2d9d3.f988a" ] ], "inputLabels": [ "msg.payload" ], "outputLabels": [ "msg.payload" ] }, { "id": "99a77b47.fa2e8", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Aussentemperatur", "topic": "node-red.0.Bloomsky.Aussentemperatur", "ack": "false", "autoCreate": "true", "x": 739, "y": 256, "wires": [] }, { "id": "22ed56e1.36f812", "type": "change", "z": "cf69d3aa.73ae28", "name": "Außentemperatur", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Data.Temperature", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 464, "y": 264, "wires": [ [ "99a77b47.fa2e8" ] ] }, { "id": "b1ad7a5b.6ce4e8", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "UV Index", "topic": "node-red.0.Bloomsky.UV_Index", "ack": "true", "autoCreate": "true", "x": 710, "y": 122, "wires": [] }, { "id": "205cc257.a958d6", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Windrichtung", "topic": "node-red.0.Bloomsky.Windrichtung", "ack": "false", "autoCreate": "true", "x": 724, "y": 189, "wires": [] }, { "id": "f152a2d2.cec6", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Regen", "topic": "node-red.0.Bloomsky.Regen", "ack": "false", "autoCreate": "true", "x": 698, "y": 697, "wires": [], "inputLabels": [ "payload" ] }, { "id": "7609e3b3.ec65cc", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Nacht", "topic": "node-red.0.Bloomsky.Nacht", "ack": "false", "autoCreate": "true", "x": 1023, "y": 1014, "wires": [] }, { "id": "ca9ca821.642c98", "type": "change", "z": "cf69d3aa.73ae28", "name": "Windrichtung", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Storm.WindDirection", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 453, "y": 198, "wires": [ [ "205cc257.a958d6" ] ] }, { "id": "381d27f3.81f3d", "type": "change", "z": "cf69d3aa.73ae28", "name": "UV Storm", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Storm.UVIndex", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 444, "y": 139, "wires": [ [ "b1ad7a5b.6ce4e8" ] ] }, { "id": "5c578fae.9f8618", "type": "change", "z": "cf69d3aa.73ae28", "name": "Niederschlag heute", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Storm.RainDaily", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 468, "y": 326, "wires": [ [ "13281358.e99515" ] ] }, { "id": "efa29b54.4059", "type": "change", "z": "cf69d3aa.73ae28", "name": "Windböhen spitze", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Storm.WindGust", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 462, "y": 389, "wires": [ [ "f8748f61.2059e8", "2caaf795.40ed1" ] ] }, { "id": "d9e2fb03.3f025", "type": "change", "z": "cf69d3aa.73ae28", "name": "Windgeschwindigkeit", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Storm.SustainedWindSpeed", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 441.25, "y": 490.25, "wires": [ [ "894992af.49d3e8" ] ] }, { "id": "7733c9d1.ab4048", "type": "change", "z": "cf69d3aa.73ae28", "name": "Nierderschlagsintensität", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Storm.RainRate", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 442.75, "y": 553, "wires": [ [ "e085b98f.9393e" ] ] }, { "id": "64038f1.4b33d7", "type": "change", "z": "cf69d3aa.73ae28", "name": "Niederschlag 24h", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Storm.24hRain", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 481, "y": 634, "wires": [ [ "be8590cb.596e4", "f34c9ed5.1ca9a" ] ] }, { "id": "747b03e5.4b74f4", "type": "change", "z": "cf69d3aa.73ae28", "name": "Lichtstärke (Lumen)", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Data.Luminance", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 471, "y": 892, "wires": [ [ "955c1dc0.45ead8", "5c208c7b.7eb61c" ] ] }, { "id": "e7fc05d3.cf7408", "type": "change", "z": "cf69d3aa.73ae28", "name": "Regen J/N", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Data.Rain", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 445, "y": 676, "wires": [ [ "f152a2d2.cec6" ] ] }, { "id": "c1945dc8.8f691", "type": "change", "z": "cf69d3aa.73ae28", "name": "Luftfeuchtigkeit", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Data.Humidity", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 468, "y": 725, "wires": [ [ "43807917.6c1228" ] ] }, { "id": "4c307da4.b6faec", "type": "change", "z": "cf69d3aa.73ae28", "name": "Luftdruck", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Data.Pressure", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 440, "y": 783, "wires": [ [ "4df1258a.a79964" ] ] }, { "id": "198537d.f38cf48", "type": "change", "z": "cf69d3aa.73ae28", "name": "Spannung Sky1", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Data.Voltage", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 456, "y": 836, "wires": [ [ "94019662.c095d8" ] ] }, { "id": "de39e8fc.6c3f38", "type": "change", "z": "cf69d3aa.73ae28", "name": "Nacht J/N", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Data.Night", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 412, "y": 975, "wires": [ [] ] }, { "id": "13281358.e99515", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Niederschlag heute", "topic": "node-red.0.Bloomsky.Niederschlag_heute", "ack": "false", "autoCreate": "true", "x": 738, "y": 317, "wires": [] }, { "id": "f8748f61.2059e8", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Windböen", "topic": "node-red.0.Bloomsky.Windböen_spitze", "ack": "false", "autoCreate": "true", "x": 725, "y": 379, "wires": [] }, { "id": "894992af.49d3e8", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Windgeschwindigkeit", "topic": "node-red.0.Bloomsky.Windgeschwindigkeit", "ack": "false", "autoCreate": "true", "x": 735.5, "y": 518.25, "wires": [] }, { "id": "e085b98f.9393e", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Nierderschlagsintensität", "topic": "node-red.0.Bloomsky.Nierderschlagsintensität", "ack": "false", "autoCreate": "true", "x": 753.5, "y": 571.0000305175781, "wires": [] }, { "id": "be8590cb.596e4", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Niederschlag 24h", "topic": "node-red.0.Bloomsky.Niederschlag_24h", "ack": "false", "autoCreate": "true", "x": 765, "y": 628, "wires": [] }, { "id": "955c1dc0.45ead8", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Lichtstärke", "topic": "node-red.0.Bloomsky.Lichtstärke", "ack": "false", "autoCreate": "true", "x": 717, "y": 901, "wires": [] }, { "id": "43807917.6c1228", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Luftfeuchtigkeit", "topic": "node-red.0.Bloomsky.Luftfeuchtigkeit", "ack": "false", "autoCreate": "true", "x": 725, "y": 748, "wires": [] }, { "id": "4df1258a.a79964", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Luftdruck", "topic": "node-red.0.Bloomsky.Luftdruck", "ack": "false", "autoCreate": "true", "x": 700, "y": 792, "wires": [] }, { "id": "94019662.c095d8", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Spannung Sky1", "topic": "node-red.0.Bloomsky.Spannung_Sky1", "ack": "false", "autoCreate": "true", "x": 722, "y": 847, "wires": [] }, { "id": "5c208c7b.7eb61c", "type": "switch", "z": "cf69d3aa.73ae28", "name": "Nacht", "property": "payload", "propertyType": "msg", "rules": [ { "t": "lt", "v": "400", "vt": "num" }, { "t": "gte", "v": "400", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 656, "y": 1006, "wires": [ [ "b79e5aaf.9281c" ], [ "f35f0d5a.dd919" ] ] }, { "id": "b79e5aaf.9281c", "type": "change", "z": "cf69d3aa.73ae28", "name": "true", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "true", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 820, "y": 999, "wires": [ [ "7609e3b3.ec65cc" ] ] }, { "id": "f35f0d5a.dd919", "type": "change", "z": "cf69d3aa.73ae28", "name": "false", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "false", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 828, "y": 1048, "wires": [ [ "7609e3b3.ec65cc" ] ] }, { "id": "2caaf795.40ed1", "type": "switch", "z": "cf69d3aa.73ae28", "name": "Sturm Bewegungsmelder", "property": "payload", "propertyType": "msg", "rules": [ { "t": "lt", "v": "40", "vt": "num" }, { "t": "gte", "v": "40", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 689, "y": 455, "wires": [ [ "2b54063f.2f75da" ], [ "f35b484.ee4b1b8" ] ] }, { "id": "f35b484.ee4b1b8", "type": "change", "z": "cf69d3aa.73ae28", "name": "true", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "true", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 889, "y": 472, "wires": [ [ "589c1dfb.6ad8ec" ] ] }, { "id": "2b54063f.2f75da", "type": "change", "z": "cf69d3aa.73ae28", "name": "false", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "false", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 889, "y": 425, "wires": [ [ "589c1dfb.6ad8ec" ] ] }, { "id": "589c1dfb.6ad8ec", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Sturm Bewegungsmelder", "topic": "node-red.0.Bloomsky.Sturm_Bewegungsmelder", "ack": "false", "autoCreate": "true", "x": 1092, "y": 440, "wires": [] }, { "id": "f34c9ed5.1ca9a", "type": "debug", "z": "cf69d3aa.73ae28", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 903.5, "y": 687.75, "wires": [] }, { "id": "d7b2d9d3.f988a", "type": "change", "z": "cf69d3aa.73ae28", "name": "Zeit", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload[0].Data.TS", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 440, "y": 61, "wires": [ [ "3a2a75db.eebc02" ] ] }, { "id": "3a2a75db.eebc02", "type": "ioBroker out", "z": "cf69d3aa.73ae28", "name": "Zeit", "topic": "node-red.0.Bloomsky.Zeit", "ack": "true", "autoCreate": "true", "x": 714.5000610351562, "y": 47.5, "wires": [] } ]
Nun habe ich noch zwei Problemchen nicht lösen können.
1. Wie bekomme ich die Zeit richtig angezeigt?
2. Beim Punkt welcher die Regenmenge der letzten 24h anzeigen soll habe ich noch etwas Mühe. Der Pfad im JSONata-Expression sollte "payload[0].Storm.24hRain" lauten. Kann es sein dass da Zahlen im Pfad nicht angenommen werden?
-
Schön, dass du es hinbekommen hast.
` > Nun habe ich noch zwei Problemchen nicht lösen können.
1. Wie bekomme ich die Zeit richtig angezeigt?
2. Beim Punkt welcher die Regenmenge der letzten 24h anzeigen soll habe ich noch etwas Mühe. Der Pfad im JSONata-Expression sollte "payload[0].Storm.24hRain" lauten. Kann es sein dass da Zahlen im Pfad nicht angenommen werden? `
1. JSONata unterstützt keine Konvertierung Timestamp->Datum. Nur umgekehrt;-) Es gibt eine JSONata kompatible Moment-Lib, die ist aber in node-red nicht implementiert. Deshalb machst du das am Besten im Funktionsnode. Das gewünschte Format kannst du selbst anpassen.
2. böse Falle;-) JSONata ist ja nicht Javascript und hält sich nicht an dessen Object-Zugriffssyntax.
In JSONata werden Objectbezeichner, die Leerzeichen oder reservierte Wörter enthalten in Backticks eingeschlossen.
Also:
payload[0].Storm.`24hRain`
Hier der flow:
! ````
[
{
"id": "fbf94dd5.b17568",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Niederschlag 24h",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Storm.24hRain
",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 445,
"y": 733,
"wires": [
[
"44faeaea.5efe1c",
"64d0ae41.019568"
]
]
}
] -
Cool, Danke fürs Aufklären, weshalb muss bloss alles so kompliziert sein :?:
Nachdem du das Funktionsnode derart verteufelt hast, habe ich mich gar nicht gewagt damit zu kommen :roll: aber schade hast du mir nicht gleich noch den dazugehörigen Code angehängt. Nach einigem Suchen habe ich den hier gefunden.
var now = new Date(); now.setTime(msg.payload[0].Data.TS); // Zeit aus dem Payload var year = now.getFullYear(); var month = now.getMonth()+1; var day = now.getDate(); var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); if(month.toString().length == 1) { var month = '0'+month; } if(day.toString().length == 1) { var day = '0'+day; } if(hour.toString().length == 1) { var hour = '0'+hour; } if(minute.toString().length == 1) { var minute = '0'+minute; } if(second.toString().length == 1) { var second = '0'+second; } //msg.timestamp = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second; msg.payload = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second; return msg;
Aber leider zeigt er immer nur
> 1970-01-18 20:43:12
Die anderen Codes von viewtopic.php?t=653 funktionieren irgendwie auch nicht. -
aber schade hast du mir nicht gleich noch den dazugehörigen Code angehängt. Nach einigem Suchen habe ich den hier gefunden. `
Nanu, hatte doch den kompletten korrigierten Flow drangehangen. (Spoiler)
-
Ich fürchte da ist etwas auf der Strecke geblieben, der Code erzeugt nur das Node für den Niederschlag 24h
-
Oh weh, da hatte ich wohl beim Export geschusselt. Hier noch mal der Vollständigkeit halber den kompletten Export.
Tut mir echt leid.
! ````
[
{
"id": "f3d84dc6.6835d8",
"type": "tab",
"label": "Bloomsky",
"disabled": true,
"info": ""
},
{
"id": "8117fc26.f9766",
"type": "inject",
"z": "f3d84dc6.6835d8",
"name": "1 Minute",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 100,
"y": 520,
"wires": [
[
"44f420e6.2b2ee8"
]
]
},
{
"id": "44f420e6.2b2ee8",
"type": "function",
"z": "f3d84dc6.6835d8",
"name": "msg.method",
"func": "msg.method = "GET";\nmsg.headers = {\n "Authorization": "t5-xstrliNvXrZunuLY=",\n "Content-Type": "application/json"\n};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 92,
"y": 578,
"wires": [
[
"7253d082.2ba1a"
]
]
},
{
"id": "7253d082.2ba1a",
"type": "http request",
"z": "f3d84dc6.6835d8",
"name": "http",
"method": "use",
"ret": "obj",
"url": "https://api.bloomsky.com/api/skydata/?unit=intl",
"tls": "",
"x": 105,
"y": 634,
"wires": [
[
"f7bd27ab.a762b8",
"4dcff224.168804",
"8e87729f.1530a8",
"fb70599c.03443",
"bb15cf90.a2f6c8",
"bb605f69.f36328",
"a7879189.b6d68",
"fbf94dd5.b17568",
"21c9ba9f.c6f696",
"cf2b11a4.b77df8",
"5e70f203.d770a4",
"b1c25557.fc45d8",
"5506ba12.9a2bfc",
"4f1d2820.168dc",
"65058b32.1b2aac"
]
],
"inputLabels": [
"msg.payload"
],
"outputLabels": [
"msg.payload"
]
},
{
"id": "740cea.d9f8b318",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Aussentemperatur",
"topic": "node-red.0.Bloomsky.Aussentemperatur",
"ack": "false",
"autoCreate": "true",
"x": 736,
"y": 306,
"wires": []
},
{
"id": "f7bd27ab.a762b8",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Außentemperatur",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Data.Temperature",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 461,
"y": 314,
"wires": [
[
"740cea.d9f8b318"
]
]
},
{
"id": "3e54f7f8.191ee8",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "UV Index",
"topic": "node-red.0.Bloomsky.UV_Index",
"ack": "true",
"autoCreate": "true",
"x": 707,
"y": 172,
"wires": []
},
{
"id": "f46f7cf9.6d3b9",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Windrichtung",
"topic": "node-red.0.Bloomsky.Windrichtung",
"ack": "false",
"autoCreate": "true",
"x": 721,
"y": 239,
"wires": []
},
{
"id": "647f5cc3.c29d44",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Regen",
"topic": "node-red.0.Bloomsky.Regen",
"ack": "false",
"autoCreate": "true",
"x": 630,
"y": 800,
"wires": [],
"inputLabels": [
"payload"
]
},
{
"id": "bed53cac.197bd",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Nacht",
"topic": "node-red.0.Bloomsky.Nacht",
"ack": "false",
"autoCreate": "true",
"x": 955,
"y": 1117,
"wires": []
},
{
"id": "4dcff224.168804",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Windrichtung",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Storm.WindDirection",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 450,
"y": 248,
"wires": [
[
"f46f7cf9.6d3b9"
]
]
},
{
"id": "8e87729f.1530a8",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "UV Storm",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Storm.UVIndex",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 440,
"y": 200,
"wires": [
[
"3e54f7f8.191ee8"
]
]
},
{
"id": "fb70599c.03443",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Niederschlag heute",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Storm.RainDaily",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 465,
"y": 376,
"wires": [
[
"1091029d.fe438d"
]
]
},
{
"id": "bb15cf90.a2f6c8",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Windböhen spitze",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Storm.WindGust",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 459,
"y": 439,
"wires": [
[
"d13b6d39.be62e",
"5457db73.8919a4"
]
]
},
{
"id": "bb605f69.f36328",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Windgeschwindigkeit",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Storm.SustainedWindSpeed",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 438.25,
"y": 540.25,
"wires": [
[
"b82c521c.c2b058"
]
]
},
{
"id": "a7879189.b6d68",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Nierderschlagsintensität",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Storm.RainRate",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 439.75,
"y": 603,
"wires": [
[
"20ef4188.195486"
]
]
},
{
"id": "fbf94dd5.b17568",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Niederschlag 24h",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Storm.24hRain
",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 445,
"y": 733,
"wires": [
[
"44faeaea.5efe1c",
"64d0ae41.019568"
]
]
},
{
"id": "21c9ba9f.c6f696",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Lichtstärke (Lumen)",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Data.Luminance",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 403,
"y": 995,
"wires": [
[
"8df5202a.4c3e5",
"b1e2adb6.7d8598"
]
]
},
{
"id": "cf2b11a4.b77df8",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Regen J/N",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Data.Rain",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 377,
"y": 779,
"wires": [
[
"647f5cc3.c29d44"
]
]
},
{
"id": "5e70f203.d770a4",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Luftfeuchtigkeit",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Data.Humidity",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 400,
"y": 828,
"wires": [
[
"bedff47d.7458f8"
]
]
},
{
"id": "b1c25557.fc45d8",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Luftdruck",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Data.Pressure",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 372,
"y": 886,
"wires": [
[
"a961ae20.028c88"
]
]
},
{
"id": "5506ba12.9a2bfc",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Spannung Sky1",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Data.Voltage",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 388,
"y": 939,
"wires": [
[
"4b294d41.e8403c"
]
]
},
{
"id": "4f1d2820.168dc",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "Nacht J/N",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[0].Data.Night",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 344,
"y": 1078,
"wires": [
[]
]
},
{
"id": "1091029d.fe438d",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Niederschlag heute",
"topic": "node-red.0.Bloomsky.Niederschlag_heute",
"ack": "false",
"autoCreate": "true",
"x": 735,
"y": 367,
"wires": []
},
{
"id": "d13b6d39.be62e",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Windböen",
"topic": "node-red.0.Bloomsky.Windböen_spitze",
"ack": "false",
"autoCreate": "true",
"x": 722,
"y": 429,
"wires": []
},
{
"id": "b82c521c.c2b058",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Windgeschwindigkeit",
"topic": "node-red.0.Bloomsky.Windgeschwindigkeit",
"ack": "false",
"autoCreate": "true",
"x": 732.5,
"y": 568.25,
"wires": []
},
{
"id": "20ef4188.195486",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Nierderschlagsintensität",
"topic": "node-red.0.Bloomsky.Nierderschlagsintensität",
"ack": "false",
"autoCreate": "true",
"x": 750.5,
"y": 621.0000305175781,
"wires": []
},
{
"id": "44faeaea.5efe1c",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Niederschlag 24h",
"topic": "node-red.0.Bloomsky.Niederschlag_24h",
"ack": "false",
"autoCreate": "true",
"x": 730,
"y": 700,
"wires": []
},
{
"id": "8df5202a.4c3e5",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Lichtstärke",
"topic": "node-red.0.Bloomsky.Lichtstärke",
"ack": "false",
"autoCreate": "true",
"x": 649,
"y": 1004,
"wires": []
},
{
"id": "bedff47d.7458f8",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Luftfeuchtigkeit",
"topic": "node-red.0.Bloomsky.Luftfeuchtigkeit",
"ack": "false",
"autoCreate": "true",
"x": 657,
"y": 851,
"wires": []
},
{
"id": "a961ae20.028c88",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Luftdruck",
"topic": "node-red.0.Bloomsky.Luftdruck",
"ack": "false",
"autoCreate": "true",
"x": 632,
"y": 895,
"wires": []
},
{
"id": "4b294d41.e8403c",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Spannung Sky1",
"topic": "node-red.0.Bloomsky.Spannung_Sky1",
"ack": "false",
"autoCreate": "true",
"x": 654,
"y": 950,
"wires": []
},
{
"id": "b1e2adb6.7d8598",
"type": "switch",
"z": "f3d84dc6.6835d8",
"name": "Nacht",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "400",
"vt": "num"
},
{
"t": "gte",
"v": "400",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 588,
"y": 1109,
"wires": [
[
"c82c12cf.8a7498"
],
[
"f3732a5d.bd99a"
]
]
},
{
"id": "c82c12cf.8a7498",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "true",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 752,
"y": 1102,
"wires": [
[
"bed53cac.197bd"
]
]
},
{
"id": "f3732a5d.bd99a",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "false",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "false",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 760,
"y": 1151,
"wires": [
[
"bed53cac.197bd"
]
]
},
{
"id": "5457db73.8919a4",
"type": "switch",
"z": "f3d84dc6.6835d8",
"name": "Sturm Bewegungsmelder",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "40",
"vt": "num"
},
{
"t": "gte",
"v": "40",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 686,
"y": 505,
"wires": [
[
"984cbde2.e95af"
],
[
"332049b1.a1ed46"
]
]
},
{
"id": "332049b1.a1ed46",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "true",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 886,
"y": 522,
"wires": [
[
"e4bcb30.699fad"
]
]
},
{
"id": "984cbde2.e95af",
"type": "change",
"z": "f3d84dc6.6835d8",
"name": "false",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "false",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 886,
"y": 475,
"wires": [
[
"e4bcb30.699fad"
]
]
},
{
"id": "e4bcb30.699fad",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Sturm Bewegungsmelder",
"topic": "node-red.0.Bloomsky.Sturm_Bewegungsmelder",
"ack": "false",
"autoCreate": "true",
"x": 1089,
"y": 490,
"wires": []
},
{
"id": "64d0ae41.019568",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "24hRain",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 700,
"y": 760,
"wires": []
},
{
"id": "56c80ce3.2f033c",
"type": "ioBroker out",
"z": "f3d84dc6.6835d8",
"name": "Zeit",
"topic": "node-red.0.Bloomsky.Zeit",
"ack": "true",
"autoCreate": "true",
"x": 710,
"y": 60,
"wires": []
},
{
"id": "65058b32.1b2aac",
"type": "function",
"z": "f3d84dc6.6835d8",
"name": "convert timestamp to date",
"func": "//mit Min/sec\nvar options = { hour: 'numeric', minute: 'numeric', second: 'numeric'};\n\nvar myTime = new Date(); //new date object\n\nmyTime.setTime(msg.payload[0].Data.TS * 1000); //set linux time\n\nvar myTimeString = myTime.toLocaleDateString('de-DE', options); //convert to string\nnode.status({fill:"green",shape:"dot",text:myTimeString});\n\n// dd:mm:jj\n//msg.payload = myTime.toLocaleDateString(); //convert to string\n\n// dd:mm:jj hh:mm:ss\nmsg.payload = myTimeString;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 460,
"y": 120,
"wires": [
[
"56c80ce3.2f033c",
"f6a7399c.a08e7"
]
]
},
{
"id": "f6a7399c.a08e7",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "Datum/Zeit",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 730,
"y": 120,
"wires": []
}
] -
Nachtrag.
Natürlich kannst du in den Change-nodes mit JSONata-Ausdrücken arbeiten.
Allerdings musst du das in deinem Fall, wo ja der gewünschte Wert direkt adressiert werden kann, nicht.
JSONata ist eher was, wo der/die Ergebnis-Werte nicht einfach direkt adressiert werden können, oder man damit rechnen muss, dass sich das Object ändert oder man die Ausgabe erst zusammen basteln muss.
In deinem Fall kannst du ja immer direkt adressieren und dann auch die normale Javascript - Object - Adressierung verwenden.
Hier mal als Beispiel für die Luftfeuchte.
bzw. bei Leerzeichen oder beginnt mit Zahl (24hRain)
-
Perfekt, nochmals vielen Dank. Nun kann ich mich um die nächste Baustelle kümmern.
Gruss
Hansjürg
-
..Nachdem du das Funktionsnode derart verteufelt hast, habe ich mich gar nicht gewagt damit zu kommen . `
Da hast du mich missverstanden Ich meinte, man soll so wenige function nodes wie nötig in einem Flow haben. Mein allererster Vorschlag lief ja auf sowas hinauf (ist keine vollständige Umsetzung, hab mal nur debug nodes, statt der iobroker-out genommen):
! ````
[
{
"id": "f3d84dc6.6835d8",
"type": "tab",
"label": "Bloomsky",
"disabled": false,
"info": ""
},
{
"id": "8117fc26.f9766",
"type": "inject",
"z": "f3d84dc6.6835d8",
"name": "1 Minute",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 140,
"y": 240,
"wires": [
[
"44f420e6.2b2ee8"
]
]
},
{
"id": "44f420e6.2b2ee8",
"type": "function",
"z": "f3d84dc6.6835d8",
"name": "msg.method",
"func": "msg.method = "GET";\nmsg.headers = {\n "Authorization": "t5-xstrliNvXrZunuLY=",\n "Content-Type": "application/json"\n};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 150,
"y": 300,
"wires": [
[
"7253d082.2ba1a"
]
]
},
{
"id": "7253d082.2ba1a",
"type": "http request",
"z": "f3d84dc6.6835d8",
"name": "http",
"method": "use",
"ret": "obj",
"url": "https://api.bloomsky.com/api/skydata/?unit=intl",
"tls": "",
"x": 130,
"y": 360,
"wires": [
[
"65058b32.1b2aac"
]
],
"inputLabels": [
"msg.payload"
],
"outputLabels": [
"msg.payload"
]
},
{
"id": "64d0ae41.019568",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "24hRain",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 740,
"y": 520,
"wires": []
},
{
"id": "65058b32.1b2aac",
"type": "function",
"z": "f3d84dc6.6835d8",
"name": "convert all incoming data",
"func": "//Min/sec\nvar options = { hour: 'numeric', minute: 'numeric', second: 'numeric'};\n\n//reat/generate Outputs\nvar myTime = new Date(); //new date object\nmyTime.setTime(msg.payload[0].Data.TS * 1000); //set linux time\n// dd:mm:jj hh:mm:ss\n\n//dateTime\nvar msg1 = {};\nmsg1.payload = myTime.toLocaleDateString('de-DE', options); //convert to string\nnode.status({fill:"green",shape:"dot",text:msg1.payload});\n\n//UVIndex\nvar msg2 = {};\nmsg2.payload = msg.payload[0].Storm.UVIndex; \n\n//Windrichtung\nvar msg3 = {};\nmsg3.payload = msg.payload[0].Storm.WindDirection;\n\n\n//Aussentemperature\nvar msg4 = {};\nmsg4.payload = msg.payload[0].Data.Temperature;\n\n//Niederschlag heute\nvar msg5 = {};\nmsg5.payload = msg.payload[0].Storm.RainDaily;\n\n\n//Windböhen\nvar msg6 = {};\nmsg6.payload = msg.payload[0].Storm.WindGust;\n\n//Sturm Bewegungsmelder\nvar msg7 = {};\nmsg7.payload = (msg6.payload < 40) ? false : true;\n\n//24hRain\nvar msg8 = {};\nmsg8.payload = msg.payload[0].Storm["24hRain"];\n\nreturn [msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8];\n",
"outputs": 8,
"noerr": 0,
"x": 470,
"y": 300,
"wires": [
[
"f6a7399c.a08e7"
],
[
"c231c80e.7fe89"
],
[
"8d26382c.ea7fa8"
],
[
"e5c857a5.7785a8"
],
[
"672522ec.1d0654"
],
[
"111cbfba.484ae8"
],
[
"200cd894.d8d3b"
],
[
"64d0ae41.019568"
]
],
"outputLabels": [
"dateTime",
"UV Index",
"Windrichtung",
"Aussentemperature",
"Niederschlag heute",
"Windböhen",
"Sturm Bewegungsmelder",
"24hRain"
]
},
{
"id": "f6a7399c.a08e7",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "Datum/Zeit",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 750,
"y": 100,
"wires": []
},
{
"id": "c231c80e.7fe89",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "UV Index",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 740,
"y": 160,
"wires": []
},
{
"id": "8d26382c.ea7fa8",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "Windrichtung",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 750,
"y": 220,
"wires": []
},
{
"id": "e5c857a5.7785a8",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "Aussentemperature",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 770,
"y": 280,
"wires": []
},
{
"id": "672522ec.1d0654",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "Niederschlag heute",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 770,
"y": 340,
"wires": []
},
{
"id": "111cbfba.484ae8",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "Windböhen",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 750,
"y": 400,
"wires": []
},
{
"id": "200cd894.d8d3b",
"type": "debug",
"z": "f3d84dc6.6835d8",
"name": "Sturm Bewegungsmelder",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"x": 790,
"y": 460,
"wires": []
}
]Aaaber, obwohl das recht aufgeräumt aussieht und äußerst flexibel ist, ist es auch weitaus fehleranfälliger. Und es geht nicht mehr einfach nur mit klicky. Also bleib ruhig erst einmal bei den viel robusteren change-nodes.
-
bei mir muss es nur funktionieren, die Optik eines Flows ist nun wirklich egal.