Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Node-Red
  5. Variable in Node "influxdb in"

NEWS

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    22
    1
    1.1k

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    9.2k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    14
    1
    2.4k

Variable in Node "influxdb in"

Scheduled Pinned Locked Moved Node-Red
6 Posts 2 Posters 468 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hinti
    wrote on last edited by
    #1

    Hallo!

    Ich verwende die Node "influxdb in" und habe ein Problem mit einer Variable.
    Bei

    SELECT sum("Pool_vom_Netz") / 120000 FROM "Bilanz" WHERE time > now() -31d
    

    funktioniert es. Ich möchte aber die (-31d) Tage in einer Variable verpacken.
    Das was ich im Netz gefunden habe funktioniert leider nicht.

    SELECT sum("Pool_vom_Netz") / 120000 FROM "Bilanz" WHERE time > now() '-${payload.Tage}d'
    

    Wie schaut die Variable richtig aus?
    Hier der Flow:


    [
    {
    "id": "c4adbc7357d003d1",
    "type": "tab",
    "label": "Flow 1",
    "disabled": false,
    "info": "",
    "env": []
    },
    {
    "id": "45b9ad6228447b62",
    "type": "inject",
    "z": "c4adbc7357d003d1",
    "name": "",
    "props": [
    {
    "p": "payload"
    },
    {
    "p": "topic",
    "vt": "str"
    }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "",
    "payloadType": "date",
    "x": 200,
    "y": 160,
    "wires": [
    [
    "473b104681483dc8"
    ]
    ]
    },
    {
    "id": "473b104681483dc8",
    "type": "function",
    "z": "c4adbc7357d003d1",
    "name": "Monatstage",
    "func": "var msg = {};\n\n// ------------- Aktuellen Monat herausfinden -------------------------\nvar Tage;\nvar now = new Date();\nvar month = now.getMonth() + 1;\n\nif (month == 1) {Tage = 31}\nif (month == 2) { Tage = 28 }\nif (month == 3) { Tage = 31}\nif (month == 4) { Tage = 30 }\nif (month == 5) { Tage = 31}\nif (month == 6) { Tage = 30 }\nif (month == 7) { Tage = 31 }\nif (month == 8) { Tage = 31 }\nif (month == 9) { Tage = 30 }\nif (month == 10) { Tage = 31 }\nif (month == 11) { Tage = 30 }\nif (month == 12) { Tage = 31 }\n// --------------------------------------------------------------------\n\n\nmsg.payload =\n{\n Tage:Tage,\n}\nreturn [msg];",
    "outputs": 1,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 370,
    "y": 160,
    "wires": [
    [
    "e73be277cb1cc425"
    ]
    ]
    },
    {
    "id": "e73be277cb1cc425",
    "type": "influxdb in",
    "z": "c4adbc7357d003d1",
    "influxdb": "655abc6ff1dd28f5",
    "name": "Abfrage Zählerst. Energie",
    "query": "SELECT sum("Pool_vom_Netz") / 120000 FROM "Bilanz" WHERE time > now() '-${payload.Tage}d'",
    "rawOutput": true,
    "precision": "",
    "retentionPolicy": "",
    "org": "",
    "x": 590,
    "y": 160,
    "wires": [
    []
    ]
    },
    {
    "id": "655abc6ff1dd28f5",
    "type": "influxdb",
    "hostname": "10.1.1.113",
    "port": "8086",
    "protocol": "http",
    "database": "whirlpool",
    "name": "whirlpool",
    "usetls": false,
    "tls": "",
    "influxdbVersion": "1.x",
    "url": "http://localhost:8086",
    "rejectUnauthorized": true
    }
    ]

    Danke.

    mickymM 1 Reply Last reply
    0
    • H hinti

      Hallo!

      Ich verwende die Node "influxdb in" und habe ein Problem mit einer Variable.
      Bei

      SELECT sum("Pool_vom_Netz") / 120000 FROM "Bilanz" WHERE time > now() -31d
      

      funktioniert es. Ich möchte aber die (-31d) Tage in einer Variable verpacken.
      Das was ich im Netz gefunden habe funktioniert leider nicht.

      SELECT sum("Pool_vom_Netz") / 120000 FROM "Bilanz" WHERE time > now() '-${payload.Tage}d'
      

      Wie schaut die Variable richtig aus?
      Hier der Flow:


      [
      {
      "id": "c4adbc7357d003d1",
      "type": "tab",
      "label": "Flow 1",
      "disabled": false,
      "info": "",
      "env": []
      },
      {
      "id": "45b9ad6228447b62",
      "type": "inject",
      "z": "c4adbc7357d003d1",
      "name": "",
      "props": [
      {
      "p": "payload"
      },
      {
      "p": "topic",
      "vt": "str"
      }
      ],
      "repeat": "",
      "crontab": "",
      "once": false,
      "onceDelay": 0.1,
      "topic": "",
      "payload": "",
      "payloadType": "date",
      "x": 200,
      "y": 160,
      "wires": [
      [
      "473b104681483dc8"
      ]
      ]
      },
      {
      "id": "473b104681483dc8",
      "type": "function",
      "z": "c4adbc7357d003d1",
      "name": "Monatstage",
      "func": "var msg = {};\n\n// ------------- Aktuellen Monat herausfinden -------------------------\nvar Tage;\nvar now = new Date();\nvar month = now.getMonth() + 1;\n\nif (month == 1) {Tage = 31}\nif (month == 2) { Tage = 28 }\nif (month == 3) { Tage = 31}\nif (month == 4) { Tage = 30 }\nif (month == 5) { Tage = 31}\nif (month == 6) { Tage = 30 }\nif (month == 7) { Tage = 31 }\nif (month == 8) { Tage = 31 }\nif (month == 9) { Tage = 30 }\nif (month == 10) { Tage = 31 }\nif (month == 11) { Tage = 30 }\nif (month == 12) { Tage = 31 }\n// --------------------------------------------------------------------\n\n\nmsg.payload =\n{\n Tage:Tage,\n}\nreturn [msg];",
      "outputs": 1,
      "noerr": 0,
      "initialize": "",
      "finalize": "",
      "libs": [],
      "x": 370,
      "y": 160,
      "wires": [
      [
      "e73be277cb1cc425"
      ]
      ]
      },
      {
      "id": "e73be277cb1cc425",
      "type": "influxdb in",
      "z": "c4adbc7357d003d1",
      "influxdb": "655abc6ff1dd28f5",
      "name": "Abfrage Zählerst. Energie",
      "query": "SELECT sum("Pool_vom_Netz") / 120000 FROM "Bilanz" WHERE time > now() '-${payload.Tage}d'",
      "rawOutput": true,
      "precision": "",
      "retentionPolicy": "",
      "org": "",
      "x": 590,
      "y": 160,
      "wires": [
      []
      ]
      },
      {
      "id": "655abc6ff1dd28f5",
      "type": "influxdb",
      "hostname": "10.1.1.113",
      "port": "8086",
      "protocol": "http",
      "database": "whirlpool",
      "name": "whirlpool",
      "usetls": false,
      "tls": "",
      "influxdbVersion": "1.x",
      "url": "http://localhost:8086",
      "rejectUnauthorized": true
      }
      ]

      Danke.

      mickymM Online
      mickymM Online
      mickym
      Most Active
      wrote on last edited by mickym
      #2

      Mit Deinem Flow kann man nichts anfangen weil Du das nicht in Code-Tags gepackt hast.

      Code-Tags.gif

      Wenn Du das so reinkopierst interpretiert der Browser zeichen und man kann es nicht importieren.

      Du setzt einfach Deine komplette msg.query zusammen. Was heißt Variable ist es ein Eigenschaft des Nachrichtenobjektes oder nicht?

      32771477-ead3-47d6-8cfb-9de508fe1809-image.png

      [
         {
             "id": "a0f099e28f8b85fc",
             "type": "inject",
             "z": "5ad55a7b0d4580eb",
             "name": "",
             "props": [
                 {
                     "p": "payload"
                 }
             ],
             "repeat": "",
             "crontab": "",
             "once": false,
             "onceDelay": 0.1,
             "topic": "",
             "payload": "{\"Tage\":31}",
             "payloadType": "json",
             "x": 340,
             "y": 2740,
             "wires": [
                 [
                     "2b43c618076c4c06",
                     "21b7ebf788d45e74"
                 ]
             ]
         },
         {
             "id": "2b43c618076c4c06",
             "type": "change",
             "z": "5ad55a7b0d4580eb",
             "name": "",
             "rules": [
                 {
                     "t": "set",
                     "p": "query",
                     "pt": "msg",
                     "to": "'SELECT sum(\"Pool_vom_Netz\") / 120000 FROM \"Bilanz\" WHERE time > now() -' & payload.Tage & 'd'",
                     "tot": "jsonata"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 540,
             "y": 2740,
             "wires": [
                 [
                     "5cdbd6f2567e8a20"
                 ]
             ]
         },
         {
             "id": "21b7ebf788d45e74",
             "type": "debug",
             "z": "5ad55a7b0d4580eb",
             "name": "payload",
             "active": true,
             "tosidebar": true,
             "console": false,
             "tostatus": false,
             "complete": "payload",
             "targetType": "msg",
             "statusVal": "",
             "statusType": "auto",
             "x": 520,
             "y": 2680,
             "wires": []
         },
         {
             "id": "5cdbd6f2567e8a20",
             "type": "debug",
             "z": "5ad55a7b0d4580eb",
             "name": "query",
             "active": true,
             "tosidebar": true,
             "console": false,
             "tostatus": false,
             "complete": "query",
             "targetType": "msg",
             "statusVal": "",
             "statusType": "auto",
             "x": 730,
             "y": 2680,
             "wires": []
         }
      ]
      

      Wie gesagt woher Deine Tage kommen - kann ich nicht sagen - da man Deinen Flow nicht importierten kann. Das Nachrichtenobjekt siehst Du ja - falls Du anderen Kontext nimmst, entweder in das Nachrichtenobjekt aufnehmen oder halt mit den entsprechenden Funktionen darauf zugreifen.

      Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.

      H 1 Reply Last reply
      0
      • mickymM mickym

        Mit Deinem Flow kann man nichts anfangen weil Du das nicht in Code-Tags gepackt hast.

        Code-Tags.gif

        Wenn Du das so reinkopierst interpretiert der Browser zeichen und man kann es nicht importieren.

        Du setzt einfach Deine komplette msg.query zusammen. Was heißt Variable ist es ein Eigenschaft des Nachrichtenobjektes oder nicht?

        32771477-ead3-47d6-8cfb-9de508fe1809-image.png

        [
           {
               "id": "a0f099e28f8b85fc",
               "type": "inject",
               "z": "5ad55a7b0d4580eb",
               "name": "",
               "props": [
                   {
                       "p": "payload"
                   }
               ],
               "repeat": "",
               "crontab": "",
               "once": false,
               "onceDelay": 0.1,
               "topic": "",
               "payload": "{\"Tage\":31}",
               "payloadType": "json",
               "x": 340,
               "y": 2740,
               "wires": [
                   [
                       "2b43c618076c4c06",
                       "21b7ebf788d45e74"
                   ]
               ]
           },
           {
               "id": "2b43c618076c4c06",
               "type": "change",
               "z": "5ad55a7b0d4580eb",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "query",
                       "pt": "msg",
                       "to": "'SELECT sum(\"Pool_vom_Netz\") / 120000 FROM \"Bilanz\" WHERE time > now() -' & payload.Tage & 'd'",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 540,
               "y": 2740,
               "wires": [
                   [
                       "5cdbd6f2567e8a20"
                   ]
               ]
           },
           {
               "id": "21b7ebf788d45e74",
               "type": "debug",
               "z": "5ad55a7b0d4580eb",
               "name": "payload",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 520,
               "y": 2680,
               "wires": []
           },
           {
               "id": "5cdbd6f2567e8a20",
               "type": "debug",
               "z": "5ad55a7b0d4580eb",
               "name": "query",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "query",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 730,
               "y": 2680,
               "wires": []
           }
        ]
        

        Wie gesagt woher Deine Tage kommen - kann ich nicht sagen - da man Deinen Flow nicht importierten kann. Das Nachrichtenobjekt siehst Du ja - falls Du anderen Kontext nimmst, entweder in das Nachrichtenobjekt aufnehmen oder halt mit den entsprechenden Funktionen darauf zugreifen.

        H Offline
        H Offline
        hinti
        wrote on last edited by
        #3

        @mickym
        Danke für die Antwort.
        Hier nochmals der Flow:

        [
           {
               "id": "72c36d015644d984",
               "type": "tab",
               "label": "Flow 2",
               "disabled": false,
               "info": "",
               "env": []
           },
           {
               "id": "8a88b6fdb45f100c",
               "type": "inject",
               "z": "72c36d015644d984",
               "name": "",
               "props": [
                   {
                       "p": "payload"
                   },
                   {
                       "p": "topic",
                       "vt": "str"
                   }
               ],
               "repeat": "",
               "crontab": "",
               "once": false,
               "onceDelay": 0.1,
               "topic": "",
               "payload": "",
               "payloadType": "date",
               "x": 120,
               "y": 140,
               "wires": [
                   [
                       "a9316343deec6c53"
                   ]
               ]
           },
           {
               "id": "a9316343deec6c53",
               "type": "function",
               "z": "72c36d015644d984",
               "name": "Monatstage",
               "func": "var msg = {};\n\n// ------------- Aktuellen Monat herausfinden -------------------------\nvar Tage;\nvar now = new Date();\nvar month = now.getMonth() + 1;\n\nif (month == 1) {Tage = 31}\nif (month == 2) { Tage = 28 }\nif (month == 3) { Tage = 31}\nif (month == 4) { Tage = 30 }\nif (month == 5) { Tage = 31}\nif (month == 6) { Tage = 30 }\nif (month == 7) { Tage = 31 }\nif (month == 8) { Tage = 31 }\nif (month == 9) { Tage = 30 }\nif (month == 10) { Tage = 31 }\nif (month == 11) { Tage = 30 }\nif (month == 12) { Tage = 31 }\n// --------------------------------------------------------------------\n\n\nmsg.payload =\n{\n   Tage:Tage,\n}\nreturn [msg];",
               "outputs": 1,
               "noerr": 0,
               "initialize": "",
               "finalize": "",
               "libs": [],
               "x": 290,
               "y": 140,
               "wires": [
                   [
                       "7e701c0656398ec3",
                       "1ea910c9a8ca6a24"
                   ]
               ]
           },
           {
               "id": "7e701c0656398ec3",
               "type": "influxdb in",
               "z": "72c36d015644d984",
               "influxdb": "655abc6ff1dd28f5",
               "name": "Abfrage Zählerst. Energie",
               "query": "SELECT sum(\"Pool_vom_Netz\") / 120000 FROM \"Bilanz\" WHERE time > now() '-${payload.Tage}d'",
               "rawOutput": true,
               "precision": "",
               "retentionPolicy": "",
               "org": "",
               "x": 510,
               "y": 140,
               "wires": [
                   [
                       "31afc62051488e86"
                   ]
               ]
           },
           {
               "id": "31afc62051488e86",
               "type": "debug",
               "z": "72c36d015644d984",
               "name": "payload",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 720,
               "y": 140,
               "wires": []
           },
           {
               "id": "1ea910c9a8ca6a24",
               "type": "debug",
               "z": "72c36d015644d984",
               "name": "payload",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 460,
               "y": 80,
               "wires": []
           },
           {
               "id": "655abc6ff1dd28f5",
               "type": "influxdb",
               "hostname": "10.1.1.113",
               "port": "8086",
               "protocol": "http",
               "database": "whirlpool",
               "name": "whirlpool",
               "usetls": false,
               "tls": "",
               "influxdbVersion": "1.x",
               "url": "http://localhost:8086",
               "rejectUnauthorized": true
           }
        ]
        


        Mit der Variable direkt im Query hab ich das Problem. Mit deiner Lösung mit dem Change Node funktioniert es jetzt

        [
           {
               "id": "f6bfa45d44848e0b",
               "type": "tab",
               "label": "Flow 3",
               "disabled": false,
               "info": "",
               "env": []
           },
           {
               "id": "d6218fe1418c8ae9",
               "type": "inject",
               "z": "f6bfa45d44848e0b",
               "name": "",
               "props": [
                   {
                       "p": "payload"
                   },
                   {
                       "p": "topic",
                       "vt": "str"
                   }
               ],
               "repeat": "",
               "crontab": "",
               "once": false,
               "onceDelay": 0.1,
               "topic": "",
               "payload": "",
               "payloadType": "date",
               "x": 100,
               "y": 260,
               "wires": [
                   [
                       "2e25ecba20d95814"
                   ]
               ]
           },
           {
               "id": "2e25ecba20d95814",
               "type": "function",
               "z": "f6bfa45d44848e0b",
               "name": "Monatstage",
               "func": "var msg = {};\n\n// ------------- Aktuellen Monat herausfinden -------------------------\nvar Tage;\nvar now = new Date();\nvar month = now.getMonth() + 1;\n\nif (month == 1) {Tage = 31}\nif (month == 2) { Tage = 28 }\nif (month == 3) { Tage = 31}\nif (month == 4) { Tage = 30 }\nif (month == 5) { Tage = 31}\nif (month == 6) { Tage = 30 }\nif (month == 7) { Tage = 31 }\nif (month == 8) { Tage = 31 }\nif (month == 9) { Tage = 30 }\nif (month == 10) { Tage = 31 }\nif (month == 11) { Tage = 30 }\nif (month == 12) { Tage = 31 }\n// --------------------------------------------------------------------\n\n\nmsg.payload =\n{\n   Tage:Tage,\n}\nreturn [msg];",
               "outputs": 1,
               "noerr": 0,
               "initialize": "",
               "finalize": "",
               "libs": [],
               "x": 270,
               "y": 260,
               "wires": [
                   [
                       "0374cab1d63834c4",
                       "42e42ac5275c90ae"
                   ]
               ]
           },
           {
               "id": "42e42ac5275c90ae",
               "type": "debug",
               "z": "f6bfa45d44848e0b",
               "name": "payload",
               "active": false,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 440,
               "y": 220,
               "wires": []
           },
           {
               "id": "0374cab1d63834c4",
               "type": "change",
               "z": "f6bfa45d44848e0b",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "query",
                       "pt": "msg",
                       "to": "'SELECT sum(\"Pool_vom_Netz\") / 120000 FROM \"Bilanz\" WHERE time > now() -' & payload.Tage & 'd'",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 460,
               "y": 260,
               "wires": [
                   [
                       "9005b1ef0601da83",
                       "7e1adada9963614b"
                   ]
               ]
           },
           {
               "id": "7e1adada9963614b",
               "type": "debug",
               "z": "f6bfa45d44848e0b",
               "name": "query",
               "active": false,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "query",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 630,
               "y": 220,
               "wires": []
           },
           {
               "id": "9005b1ef0601da83",
               "type": "influxdb in",
               "z": "f6bfa45d44848e0b",
               "influxdb": "655abc6ff1dd28f5",
               "name": "Abfrage Zählerst. Energie",
               "query": "msg.query",
               "rawOutput": true,
               "precision": "",
               "retentionPolicy": "",
               "org": "",
               "x": 690,
               "y": 260,
               "wires": [
                   [
                       "af64830ef5a1d939",
                       "833e8db5cdba66d3"
                   ]
               ]
           },
           {
               "id": "af64830ef5a1d939",
               "type": "debug",
               "z": "f6bfa45d44848e0b",
               "name": "payload",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 840,
               "y": 220,
               "wires": []
           },
           {
               "id": "833e8db5cdba66d3",
               "type": "function",
               "z": "f6bfa45d44848e0b",
               "name": "E_Whirlpool_Monat_v_Netz",
               "func": "var msg1 = {};\n\nvar Pool_vom_Netz = msg.payload.results[0].series[0].values[0][1];\n\n\nmsg1.payload =\n{\n\nPool_vom_Netz_Monat: parseFloat(Pool_vom_Netz.toFixed(2)),\n  \n\n}\n\n\nreturn [msg1];",
               "outputs": 1,
               "noerr": 0,
               "initialize": "",
               "finalize": "",
               "libs": [],
               "x": 940,
               "y": 260,
               "wires": [
                   [
                       "8014820292266bd7"
                   ]
               ]
           },
           {
               "id": "8014820292266bd7",
               "type": "debug",
               "z": "f6bfa45d44848e0b",
               "name": "payload",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 1020,
               "y": 220,
               "wires": []
           },
           {
               "id": "655abc6ff1dd28f5",
               "type": "influxdb",
               "hostname": "10.1.1.113",
               "port": "8086",
               "protocol": "http",
               "database": "whirlpool",
               "name": "whirlpool",
               "usetls": false,
               "tls": "",
               "influxdbVersion": "1.x",
               "url": "http://localhost:8086",
               "rejectUnauthorized": true
           }
        ]
        


        Kann man sich die change Node sparren, und die Variable direkt in die Query stecken?

        mickymM 1 Reply Last reply
        0
        • H hinti

          @mickym
          Danke für die Antwort.
          Hier nochmals der Flow:

          [
             {
                 "id": "72c36d015644d984",
                 "type": "tab",
                 "label": "Flow 2",
                 "disabled": false,
                 "info": "",
                 "env": []
             },
             {
                 "id": "8a88b6fdb45f100c",
                 "type": "inject",
                 "z": "72c36d015644d984",
                 "name": "",
                 "props": [
                     {
                         "p": "payload"
                     },
                     {
                         "p": "topic",
                         "vt": "str"
                     }
                 ],
                 "repeat": "",
                 "crontab": "",
                 "once": false,
                 "onceDelay": 0.1,
                 "topic": "",
                 "payload": "",
                 "payloadType": "date",
                 "x": 120,
                 "y": 140,
                 "wires": [
                     [
                         "a9316343deec6c53"
                     ]
                 ]
             },
             {
                 "id": "a9316343deec6c53",
                 "type": "function",
                 "z": "72c36d015644d984",
                 "name": "Monatstage",
                 "func": "var msg = {};\n\n// ------------- Aktuellen Monat herausfinden -------------------------\nvar Tage;\nvar now = new Date();\nvar month = now.getMonth() + 1;\n\nif (month == 1) {Tage = 31}\nif (month == 2) { Tage = 28 }\nif (month == 3) { Tage = 31}\nif (month == 4) { Tage = 30 }\nif (month == 5) { Tage = 31}\nif (month == 6) { Tage = 30 }\nif (month == 7) { Tage = 31 }\nif (month == 8) { Tage = 31 }\nif (month == 9) { Tage = 30 }\nif (month == 10) { Tage = 31 }\nif (month == 11) { Tage = 30 }\nif (month == 12) { Tage = 31 }\n// --------------------------------------------------------------------\n\n\nmsg.payload =\n{\n   Tage:Tage,\n}\nreturn [msg];",
                 "outputs": 1,
                 "noerr": 0,
                 "initialize": "",
                 "finalize": "",
                 "libs": [],
                 "x": 290,
                 "y": 140,
                 "wires": [
                     [
                         "7e701c0656398ec3",
                         "1ea910c9a8ca6a24"
                     ]
                 ]
             },
             {
                 "id": "7e701c0656398ec3",
                 "type": "influxdb in",
                 "z": "72c36d015644d984",
                 "influxdb": "655abc6ff1dd28f5",
                 "name": "Abfrage Zählerst. Energie",
                 "query": "SELECT sum(\"Pool_vom_Netz\") / 120000 FROM \"Bilanz\" WHERE time > now() '-${payload.Tage}d'",
                 "rawOutput": true,
                 "precision": "",
                 "retentionPolicy": "",
                 "org": "",
                 "x": 510,
                 "y": 140,
                 "wires": [
                     [
                         "31afc62051488e86"
                     ]
                 ]
             },
             {
                 "id": "31afc62051488e86",
                 "type": "debug",
                 "z": "72c36d015644d984",
                 "name": "payload",
                 "active": true,
                 "tosidebar": true,
                 "console": false,
                 "tostatus": false,
                 "complete": "payload",
                 "targetType": "msg",
                 "statusVal": "",
                 "statusType": "auto",
                 "x": 720,
                 "y": 140,
                 "wires": []
             },
             {
                 "id": "1ea910c9a8ca6a24",
                 "type": "debug",
                 "z": "72c36d015644d984",
                 "name": "payload",
                 "active": true,
                 "tosidebar": true,
                 "console": false,
                 "tostatus": false,
                 "complete": "payload",
                 "targetType": "msg",
                 "statusVal": "",
                 "statusType": "auto",
                 "x": 460,
                 "y": 80,
                 "wires": []
             },
             {
                 "id": "655abc6ff1dd28f5",
                 "type": "influxdb",
                 "hostname": "10.1.1.113",
                 "port": "8086",
                 "protocol": "http",
                 "database": "whirlpool",
                 "name": "whirlpool",
                 "usetls": false,
                 "tls": "",
                 "influxdbVersion": "1.x",
                 "url": "http://localhost:8086",
                 "rejectUnauthorized": true
             }
          ]
          


          Mit der Variable direkt im Query hab ich das Problem. Mit deiner Lösung mit dem Change Node funktioniert es jetzt

          [
             {
                 "id": "f6bfa45d44848e0b",
                 "type": "tab",
                 "label": "Flow 3",
                 "disabled": false,
                 "info": "",
                 "env": []
             },
             {
                 "id": "d6218fe1418c8ae9",
                 "type": "inject",
                 "z": "f6bfa45d44848e0b",
                 "name": "",
                 "props": [
                     {
                         "p": "payload"
                     },
                     {
                         "p": "topic",
                         "vt": "str"
                     }
                 ],
                 "repeat": "",
                 "crontab": "",
                 "once": false,
                 "onceDelay": 0.1,
                 "topic": "",
                 "payload": "",
                 "payloadType": "date",
                 "x": 100,
                 "y": 260,
                 "wires": [
                     [
                         "2e25ecba20d95814"
                     ]
                 ]
             },
             {
                 "id": "2e25ecba20d95814",
                 "type": "function",
                 "z": "f6bfa45d44848e0b",
                 "name": "Monatstage",
                 "func": "var msg = {};\n\n// ------------- Aktuellen Monat herausfinden -------------------------\nvar Tage;\nvar now = new Date();\nvar month = now.getMonth() + 1;\n\nif (month == 1) {Tage = 31}\nif (month == 2) { Tage = 28 }\nif (month == 3) { Tage = 31}\nif (month == 4) { Tage = 30 }\nif (month == 5) { Tage = 31}\nif (month == 6) { Tage = 30 }\nif (month == 7) { Tage = 31 }\nif (month == 8) { Tage = 31 }\nif (month == 9) { Tage = 30 }\nif (month == 10) { Tage = 31 }\nif (month == 11) { Tage = 30 }\nif (month == 12) { Tage = 31 }\n// --------------------------------------------------------------------\n\n\nmsg.payload =\n{\n   Tage:Tage,\n}\nreturn [msg];",
                 "outputs": 1,
                 "noerr": 0,
                 "initialize": "",
                 "finalize": "",
                 "libs": [],
                 "x": 270,
                 "y": 260,
                 "wires": [
                     [
                         "0374cab1d63834c4",
                         "42e42ac5275c90ae"
                     ]
                 ]
             },
             {
                 "id": "42e42ac5275c90ae",
                 "type": "debug",
                 "z": "f6bfa45d44848e0b",
                 "name": "payload",
                 "active": false,
                 "tosidebar": true,
                 "console": false,
                 "tostatus": false,
                 "complete": "payload",
                 "targetType": "msg",
                 "statusVal": "",
                 "statusType": "auto",
                 "x": 440,
                 "y": 220,
                 "wires": []
             },
             {
                 "id": "0374cab1d63834c4",
                 "type": "change",
                 "z": "f6bfa45d44848e0b",
                 "name": "",
                 "rules": [
                     {
                         "t": "set",
                         "p": "query",
                         "pt": "msg",
                         "to": "'SELECT sum(\"Pool_vom_Netz\") / 120000 FROM \"Bilanz\" WHERE time > now() -' & payload.Tage & 'd'",
                         "tot": "jsonata"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 460,
                 "y": 260,
                 "wires": [
                     [
                         "9005b1ef0601da83",
                         "7e1adada9963614b"
                     ]
                 ]
             },
             {
                 "id": "7e1adada9963614b",
                 "type": "debug",
                 "z": "f6bfa45d44848e0b",
                 "name": "query",
                 "active": false,
                 "tosidebar": true,
                 "console": false,
                 "tostatus": false,
                 "complete": "query",
                 "targetType": "msg",
                 "statusVal": "",
                 "statusType": "auto",
                 "x": 630,
                 "y": 220,
                 "wires": []
             },
             {
                 "id": "9005b1ef0601da83",
                 "type": "influxdb in",
                 "z": "f6bfa45d44848e0b",
                 "influxdb": "655abc6ff1dd28f5",
                 "name": "Abfrage Zählerst. Energie",
                 "query": "msg.query",
                 "rawOutput": true,
                 "precision": "",
                 "retentionPolicy": "",
                 "org": "",
                 "x": 690,
                 "y": 260,
                 "wires": [
                     [
                         "af64830ef5a1d939",
                         "833e8db5cdba66d3"
                     ]
                 ]
             },
             {
                 "id": "af64830ef5a1d939",
                 "type": "debug",
                 "z": "f6bfa45d44848e0b",
                 "name": "payload",
                 "active": true,
                 "tosidebar": true,
                 "console": false,
                 "tostatus": false,
                 "complete": "payload",
                 "targetType": "msg",
                 "statusVal": "",
                 "statusType": "auto",
                 "x": 840,
                 "y": 220,
                 "wires": []
             },
             {
                 "id": "833e8db5cdba66d3",
                 "type": "function",
                 "z": "f6bfa45d44848e0b",
                 "name": "E_Whirlpool_Monat_v_Netz",
                 "func": "var msg1 = {};\n\nvar Pool_vom_Netz = msg.payload.results[0].series[0].values[0][1];\n\n\nmsg1.payload =\n{\n\nPool_vom_Netz_Monat: parseFloat(Pool_vom_Netz.toFixed(2)),\n  \n\n}\n\n\nreturn [msg1];",
                 "outputs": 1,
                 "noerr": 0,
                 "initialize": "",
                 "finalize": "",
                 "libs": [],
                 "x": 940,
                 "y": 260,
                 "wires": [
                     [
                         "8014820292266bd7"
                     ]
                 ]
             },
             {
                 "id": "8014820292266bd7",
                 "type": "debug",
                 "z": "f6bfa45d44848e0b",
                 "name": "payload",
                 "active": true,
                 "tosidebar": true,
                 "console": false,
                 "tostatus": false,
                 "complete": "payload",
                 "targetType": "msg",
                 "statusVal": "",
                 "statusType": "auto",
                 "x": 1020,
                 "y": 220,
                 "wires": []
             },
             {
                 "id": "655abc6ff1dd28f5",
                 "type": "influxdb",
                 "hostname": "10.1.1.113",
                 "port": "8086",
                 "protocol": "http",
                 "database": "whirlpool",
                 "name": "whirlpool",
                 "usetls": false,
                 "tls": "",
                 "influxdbVersion": "1.x",
                 "url": "http://localhost:8086",
                 "rejectUnauthorized": true
             }
          ]
          


          Kann man sich die change Node sparren, und die Variable direkt in die Query stecken?

          mickymM Online
          mickymM Online
          mickym
          Most Active
          wrote on last edited by mickym
          #4

          @hinti Nein msg.query musst du vorher komplett zusammenbauen. Dafür ist es ja da. Ansonsten in der Node halt nur konstante Ausdrücke

          Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.

          H 1 Reply Last reply
          0
          • mickymM mickym

            @hinti Nein msg.query musst du vorher komplett zusammenbauen. Dafür ist es ja da. Ansonsten in der Node halt nur konstante Ausdrücke

            H Offline
            H Offline
            hinti
            wrote on last edited by
            #5

            @mickym
            OK, Super. Danke für deine Hilfe.

            mickymM 1 Reply Last reply
            0
            • H hinti

              @mickym
              OK, Super. Danke für deine Hilfe.

              mickymM Online
              mickymM Online
              mickym
              Most Active
              wrote on last edited by mickym
              #6

              @hinti wenn du mehrere Parameter hast, kannst du die msg.query auch mit einer Template Node zusammenbauen. Ist zwar nicht anders als mit einer Change-Node, vielleicht nur ein wenig übersichtlicher.

              Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              Support us

              ioBroker
              Community Adapters
              Donate

              437

              Online

              32.5k

              Users

              81.7k

              Topics

              1.3m

              Posts
              Community
              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
              ioBroker Community 2014-2025
              logo
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Home
              • Recent
              • Tags
              • Unread 0
              • Categories
              • Unreplied
              • Popular
              • GitHub
              • Docu
              • Hilfe