Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Auslesen und Filtern der autobahn.api von bund.dev

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Auslesen und Filtern der autobahn.api von bund.dev

    This topic has been deleted. Only users with topic management privileges can see it.
    • icebear
      icebear @mickym last edited by

      @mickym

      Vielen Dank, das funktioniert super, auch mit dem Blockly.

      Jetzt müsste ich das Blockly nur noch dahingehend erweitern, wenn ich mehrere Meldung auf der gleichen Autobahn in meinem Bereich hab.
      Im Moment schreib er halt nur die letzte Meldung von mehreren in den DP (is ja auch logisch).

      mickym 1 Reply Last reply Reply Quote 0
      • mickym
        mickym Most Active @icebear last edited by mickym

        @icebear Wieso Du bekommst doch ggf. mehrere Objekte als Array. Da würde ich dann einen Datenpunkt machen, in dem ich die Anzahl der Elemente reinschreibe.
        Die Objekte kann man dann (gibt glaub auch ein JS Script) - aber ansonsten nimmst mein NodeRed Flow in einzelne Datenpunkte schreiben.

        Mit NodeRed könnte ich Dir leicht eine fertige Lösung präsentieren - das JS finde ich nicht.

        icebear 1 Reply Last reply Reply Quote 0
        • icebear
          icebear @mickym last edited by

          @mickym said in Auslesen und Filtern der autobahn.api von bund.dev:

          Mit NodeRed könnte ich Dir leicht eine fertige Lösung präsentieren

          Das Node-Red würd ich nehmen 🙄

          mickym 1 Reply Last reply Reply Quote 0
          • mickym
            mickym Most Active @icebear last edited by mickym

            @icebear sagte in Auslesen und Filtern der autobahn.api von bund.dev:

            @mickym said in Auslesen und Filtern der autobahn.api von bund.dev:

            Mit NodeRed könnte ich Dir leicht eine fertige Lösung präsentieren

            Das Node-Red würd ich nehmen 🙄

            Also nur aus der Beschreibung Beginn, Ende und die Beschreibung selbst?

            Also so?

            d44b6349-5a25-456b-aae9-f83dc62906ee-image.png

            icebear 1 Reply Last reply Reply Quote 0
            • icebear
              icebear @mickym last edited by

              @mickym

              Also so wäre schön:

              Verkehr.png

              mickym 1 Reply Last reply Reply Quote 0
              • mickym
                mickym Most Active @icebear last edited by mickym

                @icebear OK - Also - Du musst natürlich im NodeRed Adapter zulassen, dass Fremdobjekte erstellt werden.

                Gelöscht werden können Datenpunkte nicht - zumindest nicht in NodeRed. Sprich die Anzahl der Warnungen, die aktuell sind werden in einem eigenen Datenpunkt gespeichert.

                1768d1b3-21b6-4872-b08e-ee728f42faa8-image.png

                Also hast Du 15 Meldungen - und die adressierst Du von 0-14. 😉

                1a955fe1-0e45-41e6-94f4-5e58708bb3cb-image.png

                Die Debug-Nodes kannst Du bei Bedarf - durch Betätigung der Schaltfläche Ausgaben tätigen lassen oder lässt es bleiben.

                d465801a-8548-4959-9dd8-c305560a9f4a-image.png

                Hier der Flow zum Import:

                [
                   {
                       "id": "6e802f1553b18149",
                       "type": "subflow",
                       "name": "JSON or Obj to IOBroker",
                       "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
                       "category": "",
                       "in": [
                           {
                               "x": 60,
                               "y": 160,
                               "wires": [
                                   {
                                       "id": "554b8c663bcb46c2"
                                   }
                               ]
                           }
                       ],
                       "out": [
                           {
                               "x": 2620,
                               "y": 280,
                               "wires": [
                                   {
                                       "id": "0962842ebd23e0d7",
                                       "port": 0
                                   }
                               ]
                           }
                       ],
                       "env": [
                           {
                               "name": "top",
                               "type": "str",
                               "value": "objRoot"
                           },
                           {
                               "name": "keepTopic",
                               "type": "bool",
                               "value": "false"
                           }
                       ],
                       "meta": {},
                       "color": "#E2D96E",
                       "icon": "node-red/batch.svg"
                   },
                   {
                       "id": "3e11e8338f694832",
                       "type": "split",
                       "z": "6e802f1553b18149",
                       "name": "split object",
                       "splt": "\\n",
                       "spltType": "str",
                       "arraySplt": 1,
                       "arraySpltType": "len",
                       "stream": false,
                       "addname": "key",
                       "x": 1370,
                       "y": 160,
                       "wires": [
                           [
                               "0562a4249c8b856b"
                           ]
                       ]
                   },
                   {
                       "id": "0562a4249c8b856b",
                       "type": "change",
                       "z": "6e802f1553b18149",
                       "name": "add key to topic",
                       "rules": [
                           {
                               "t": "set",
                               "p": "stateName",
                               "pt": "msg",
                               "to": "key",
                               "tot": "msg"
                           },
                           {
                               "t": "change",
                               "p": "key",
                               "pt": "msg",
                               "from": ".",
                               "fromt": "str",
                               "to": "_",
                               "tot": "str"
                           },
                           {
                               "t": "set",
                               "p": "topic",
                               "pt": "msg",
                               "to": "topic  & '.' & key",
                               "tot": "jsonata"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 1560,
                       "y": 160,
                       "wires": [
                           [
                               "ddc90985bef0fafa"
                           ]
                       ]
                   },
                   {
                       "id": "ddc90985bef0fafa",
                       "type": "switch",
                       "z": "6e802f1553b18149",
                       "name": "is type?",
                       "property": "payload",
                       "propertyType": "msg",
                       "rules": [
                           {
                               "t": "istype",
                               "v": "array",
                               "vt": "array"
                           },
                           {
                               "t": "istype",
                               "v": "object",
                               "vt": "object"
                           },
                           {
                               "t": "else"
                           }
                       ],
                       "checkall": "true",
                       "repair": false,
                       "outputs": 3,
                       "x": 1740,
                       "y": 160,
                       "wires": [
                           [
                               "bfce19b206660fbe"
                           ],
                           [
                               "3e11e8338f694832"
                           ],
                           [
                               "1a8c03d866b85b12"
                           ]
                       ]
                   },
                   {
                       "id": "bfce19b206660fbe",
                       "type": "split",
                       "z": "6e802f1553b18149",
                       "name": "split array",
                       "splt": "\\n",
                       "spltType": "str",
                       "arraySplt": 1,
                       "arraySpltType": "len",
                       "stream": false,
                       "addname": "",
                       "x": 780,
                       "y": 280,
                       "wires": [
                           [
                               "e89927810c6d75ec"
                           ]
                       ]
                   },
                   {
                       "id": "e89927810c6d75ec",
                       "type": "change",
                       "z": "6e802f1553b18149",
                       "name": "add index to topic",
                       "rules": [
                           {
                               "t": "set",
                               "p": "topic",
                               "pt": "msg",
                               "to": "topic  & '.' & parts.index",
                               "tot": "jsonata"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 970,
                       "y": 280,
                       "wires": [
                           [
                               "a4d1a5d04564dc77"
                           ]
                       ]
                   },
                   {
                       "id": "f5d52c6a57d08904",
                       "type": "change",
                       "z": "6e802f1553b18149",
                       "name": "finalize msg.topic",
                       "rules": [
                           {
                               "t": "set",
                               "p": "top",
                               "pt": "msg",
                               "to": "'0_userdata.0.' & top",
                               "tot": "jsonata"
                           },
                           {
                               "t": "set",
                               "p": "topic",
                               "pt": "msg",
                               "to": "top & '.' & topic",
                               "tot": "jsonata"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 2170,
                       "y": 240,
                       "wires": [
                           [
                               "0962842ebd23e0d7"
                           ]
                       ]
                   },
                   {
                       "id": "1a8c03d866b85b12",
                       "type": "switch",
                       "z": "6e802f1553b18149",
                       "name": "is msg.top != null",
                       "property": "top",
                       "propertyType": "msg",
                       "rules": [
                           {
                               "t": "nnull"
                           },
                           {
                               "t": "null"
                           }
                       ],
                       "checkall": "true",
                       "repair": false,
                       "outputs": 2,
                       "x": 1950,
                       "y": 280,
                       "wires": [
                           [
                               "f5d52c6a57d08904"
                           ],
                           [
                               "74c895ce724750de"
                           ]
                       ]
                   },
                   {
                       "id": "e023fe88445ce43e",
                       "type": "change",
                       "z": "6e802f1553b18149",
                       "name": "",
                       "rules": [
                           {
                               "t": "delete",
                               "p": "topic",
                               "pt": "msg"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 350,
                       "y": 200,
                       "wires": [
                           [
                               "3649300b4c233b10"
                           ]
                       ]
                   },
                   {
                       "id": "3649300b4c233b10",
                       "type": "switch",
                       "z": "6e802f1553b18149",
                       "name": "is type?",
                       "property": "payload",
                       "propertyType": "msg",
                       "rules": [
                           {
                               "t": "istype",
                               "v": "json",
                               "vt": "json"
                           },
                           {
                               "t": "istype",
                               "v": "array",
                               "vt": "array"
                           },
                           {
                               "t": "istype",
                               "v": "object",
                               "vt": "object"
                           },
                           {
                               "t": "else"
                           }
                       ],
                       "checkall": "true",
                       "repair": false,
                       "outputs": 4,
                       "x": 600,
                       "y": 160,
                       "wires": [
                           [
                               "fc7913a8524badb7"
                           ],
                           [
                               "bfce19b206660fbe"
                           ],
                           [
                               "3e11e8338f694832"
                           ],
                           [
                               "9ac3cc3681e8b6c6"
                           ]
                       ]
                   },
                   {
                       "id": "1b8480cd2df7ba3f",
                       "type": "comment",
                       "z": "6e802f1553b18149",
                       "name": "Array",
                       "info": "",
                       "x": 600,
                       "y": 280,
                       "wires": []
                   },
                   {
                       "id": "b3541807672be040",
                       "type": "comment",
                       "z": "6e802f1553b18149",
                       "name": "object",
                       "info": "",
                       "x": 1340,
                       "y": 100,
                       "wires": []
                   },
                   {
                       "id": "a4d1a5d04564dc77",
                       "type": "switch",
                       "z": "6e802f1553b18149",
                       "name": "is type?",
                       "property": "payload",
                       "propertyType": "msg",
                       "rules": [
                           {
                               "t": "istype",
                               "v": "object",
                               "vt": "object"
                           },
                           {
                               "t": "istype",
                               "v": "array",
                               "vt": "array"
                           },
                           {
                               "t": "else"
                           }
                       ],
                       "checkall": "true",
                       "repair": false,
                       "outputs": 3,
                       "x": 1160,
                       "y": 280,
                       "wires": [
                           [
                               "3e11e8338f694832"
                           ],
                           [
                               "bfce19b206660fbe"
                           ],
                           [
                               "a096a93bb82b7a93"
                           ]
                       ]
                   },
                   {
                       "id": "74c895ce724750de",
                       "type": "change",
                       "z": "6e802f1553b18149",
                       "name": "finalize msg.topic",
                       "rules": [
                           {
                               "t": "set",
                               "p": "top",
                               "pt": "msg",
                               "to": "top",
                               "tot": "env"
                           },
                           {
                               "t": "set",
                               "p": "top",
                               "pt": "msg",
                               "to": "'0_userdata.0.' & top",
                               "tot": "jsonata"
                           },
                           {
                               "t": "set",
                               "p": "topic",
                               "pt": "msg",
                               "to": "top & '.' & topic",
                               "tot": "jsonata"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 2170,
                       "y": 320,
                       "wires": [
                           [
                               "0962842ebd23e0d7"
                           ]
                       ]
                   },
                   {
                       "id": "554b8c663bcb46c2",
                       "type": "switch",
                       "z": "6e802f1553b18149",
                       "name": "",
                       "property": "keepTopic",
                       "propertyType": "env",
                       "rules": [
                           {
                               "t": "true"
                           },
                           {
                               "t": "false"
                           }
                       ],
                       "checkall": "true",
                       "repair": false,
                       "outputs": 2,
                       "x": 170,
                       "y": 160,
                       "wires": [
                           [
                               "e30ba9f0483285e4"
                           ],
                           [
                               "e023fe88445ce43e"
                           ]
                       ]
                   },
                   {
                       "id": "e30ba9f0483285e4",
                       "type": "change",
                       "z": "6e802f1553b18149",
                       "name": "",
                       "rules": [
                           {
                               "t": "change",
                               "p": "topic",
                               "pt": "msg",
                               "from": "/",
                               "fromt": "str",
                               "to": ".",
                               "tot": "str"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 350,
                       "y": 120,
                       "wires": [
                           [
                               "3649300b4c233b10"
                           ]
                       ]
                   },
                   {
                       "id": "0962842ebd23e0d7",
                       "type": "change",
                       "z": "6e802f1553b18149",
                       "name": "translate invalid chars in topic",
                       "rules": [
                           {
                               "t": "change",
                               "p": "topic",
                               "pt": "msg",
                               "from": "..",
                               "fromt": "str",
                               "to": ".",
                               "tot": "str"
                           },
                           {
                               "t": "change",
                               "p": "topic",
                               "pt": "msg",
                               "from": "€",
                               "fromt": "str",
                               "to": "EUR",
                               "tot": "str"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 2430,
                       "y": 280,
                       "wires": [
                           []
                       ]
                   },
                   {
                       "id": "9ac3cc3681e8b6c6",
                       "type": "change",
                       "z": "6e802f1553b18149",
                       "name": "set topic, if empty",
                       "rules": [
                           {
                               "t": "set",
                               "p": "topic",
                               "pt": "msg",
                               "to": "topic ? topic : $type(payload)\t",
                               "tot": "jsonata"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 950,
                       "y": 200,
                       "wires": [
                           [
                               "a096a93bb82b7a93"
                           ]
                       ]
                   },
                   {
                       "id": "fc7913a8524badb7",
                       "type": "json",
                       "z": "6e802f1553b18149",
                       "name": "",
                       "property": "payload",
                       "action": "obj",
                       "pretty": false,
                       "x": 750,
                       "y": 100,
                       "wires": [
                           [
                               "d9e7bdd4c48a8aa1"
                           ]
                       ]
                   },
                   {
                       "id": "d9e7bdd4c48a8aa1",
                       "type": "switch",
                       "z": "6e802f1553b18149",
                       "name": "is type?",
                       "property": "payload",
                       "propertyType": "msg",
                       "rules": [
                           {
                               "t": "istype",
                               "v": "array",
                               "vt": "array"
                           },
                           {
                               "t": "istype",
                               "v": "object",
                               "vt": "object"
                           },
                           {
                               "t": "else"
                           }
                       ],
                       "checkall": "true",
                       "repair": false,
                       "outputs": 3,
                       "x": 900,
                       "y": 100,
                       "wires": [
                           [
                               "1520be42bcc2145e"
                           ],
                           [
                               "1520be42bcc2145e"
                           ],
                           [
                               "9ac3cc3681e8b6c6"
                           ]
                       ]
                   },
                   {
                       "id": "a096a93bb82b7a93",
                       "type": "junction",
                       "z": "6e802f1553b18149",
                       "x": 1380,
                       "y": 280,
                       "wires": [
                           [
                               "1a8c03d866b85b12"
                           ]
                       ]
                   },
                   {
                       "id": "1520be42bcc2145e",
                       "type": "junction",
                       "z": "6e802f1553b18149",
                       "x": 480,
                       "y": 20,
                       "wires": [
                           [
                               "3649300b4c233b10"
                           ]
                       ]
                   },
                   {
                       "id": "3e7ed9c7e1462b09",
                       "type": "inject",
                       "z": "7e6af0015415146d",
                       "name": "AB  & Filter",
                       "props": [
                           {
                               "p": "autobahn",
                               "v": "A7",
                               "vt": "str"
                           },
                           {
                               "p": "filter",
                               "v": "(coordinate.lat > 50.0 and coordinate.lat < 54.4) and (coordinate.long > 9.0 and coordinate.long < 10)",
                               "vt": "str"
                           }
                       ],
                       "repeat": "",
                       "crontab": "",
                       "once": false,
                       "onceDelay": 0.1,
                       "topic": "",
                       "x": 180,
                       "y": 7160,
                       "wires": [
                           [
                               "e9f4765fa483a48a"
                           ]
                       ]
                   },
                   {
                       "id": "e9f4765fa483a48a",
                       "type": "template",
                       "z": "7e6af0015415146d",
                       "name": "",
                       "field": "url",
                       "fieldType": "msg",
                       "format": "handlebars",
                       "syntax": "mustache",
                       "template": "https://verkehr.autobahn.de/o/autobahn/{{autobahn}}/services/warning",
                       "output": "str",
                       "x": 320,
                       "y": 7160,
                       "wires": [
                           [
                               "4759ede23832569c",
                               "a73f68ca019bab89"
                           ]
                       ]
                   },
                   {
                       "id": "4759ede23832569c",
                       "type": "debug",
                       "z": "7e6af0015415146d",
                       "name": "url",
                       "active": false,
                       "tosidebar": true,
                       "console": false,
                       "tostatus": false,
                       "complete": "true",
                       "targetType": "full",
                       "statusVal": "",
                       "statusType": "auto",
                       "x": 510,
                       "y": 7100,
                       "wires": []
                   },
                   {
                       "id": "a73f68ca019bab89",
                       "type": "http request",
                       "z": "7e6af0015415146d",
                       "name": "",
                       "method": "GET",
                       "ret": "obj",
                       "paytoqs": "ignore",
                       "url": "",
                       "tls": "",
                       "persist": false,
                       "proxy": "",
                       "insecureHTTPParser": false,
                       "authType": "",
                       "senderr": false,
                       "headers": [],
                       "x": 490,
                       "y": 7160,
                       "wires": [
                           [
                               "8d7bc4d16a712bc4",
                               "e4e045e2d7b0f1f3"
                           ]
                       ]
                   },
                   {
                       "id": "8d7bc4d16a712bc4",
                       "type": "debug",
                       "z": "7e6af0015415146d",
                       "name": "JSON",
                       "active": false,
                       "tosidebar": true,
                       "console": false,
                       "tostatus": false,
                       "complete": "true",
                       "targetType": "full",
                       "statusVal": "",
                       "statusType": "auto",
                       "x": 670,
                       "y": 7200,
                       "wires": []
                   },
                   {
                       "id": "e4e045e2d7b0f1f3",
                       "type": "change",
                       "z": "7e6af0015415146d",
                       "name": "Filter",
                       "rules": [
                           {
                               "t": "set",
                               "p": "payload",
                               "pt": "msg",
                               "to": "payload.warning[$$.filter].{\t    \"ID\": identifier, \"Titel\":title,\t    \"Verzögerung\": (delayTimeValue ? delayTimeValue : \"0\") & \" Minuten\",\t    \"Durchschnittsgeschwindigkeit\" : averageSpeed,\t   \"Beginn\": description[0] ~> $substringAfter(\": \"),\t   \"Ende\": description[1] ~> $substringAfter(\": \"),\t   \"Beschreibung\": description#$i[$i in [3..$count(%.description)]] ~> $join(\" \")\t}[]",
                               "tot": "jsonata"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 650,
                       "y": 7160,
                       "wires": [
                           [
                               "7b995bd410358394",
                               "ad94c8961362eb3c"
                           ]
                       ]
                   },
                   {
                       "id": "7b995bd410358394",
                       "type": "change",
                       "z": "7e6af0015415146d",
                       "name": "Anzahl Warnungen",
                       "rules": [
                           {
                               "t": "set",
                               "p": "topic",
                               "pt": "msg",
                               "to": "\"0_userdata.0.Test.Autobahn.\" & autobahn & \".AnzahlWarnungen\"",
                               "tot": "jsonata"
                           },
                           {
                               "t": "set",
                               "p": "payload",
                               "pt": "msg",
                               "to": "$count(payload)",
                               "tot": "jsonata"
                           },
                           {
                               "t": "set",
                               "p": "top",
                               "pt": "msg",
                               "to": "\"0_userdata.0.Test.Autobahn.\" & autobahn & \".Warnungen\"",
                               "tot": "jsonata"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 830,
                       "y": 7100,
                       "wires": [
                           [
                               "abf49b5aa9ca3e7e"
                           ]
                       ]
                   },
                   {
                       "id": "abf49b5aa9ca3e7e",
                       "type": "ioBroker out",
                       "z": "7e6af0015415146d",
                       "name": "",
                       "topic": "",
                       "ack": "true",
                       "autoCreate": "true",
                       "stateName": "",
                       "role": "",
                       "payloadType": "",
                       "readonly": "",
                       "stateUnit": "",
                       "stateMin": "",
                       "stateMax": "",
                       "x": 1040,
                       "y": 7100,
                       "wires": []
                   },
                   {
                       "id": "ccecbbc4a466efa8",
                       "type": "subflow:6e802f1553b18149",
                       "z": "7e6af0015415146d",
                       "name": "",
                       "x": 1010,
                       "y": 7160,
                       "wires": [
                           [
                               "a72e0e225946d210"
                           ]
                       ]
                   },
                   {
                       "id": "a72e0e225946d210",
                       "type": "ioBroker out",
                       "z": "7e6af0015415146d",
                       "name": "",
                       "topic": "",
                       "ack": "true",
                       "autoCreate": "true",
                       "stateName": "",
                       "role": "",
                       "payloadType": "",
                       "readonly": "",
                       "stateUnit": "",
                       "stateMin": "",
                       "stateMax": "",
                       "x": 1240,
                       "y": 7160,
                       "wires": []
                   },
                   {
                       "id": "df1966a24326d1f3",
                       "type": "debug",
                       "z": "7e6af0015415146d",
                       "name": "Ergebnisse",
                       "active": false,
                       "tosidebar": true,
                       "console": false,
                       "tostatus": false,
                       "complete": "payload",
                       "targetType": "msg",
                       "statusVal": "",
                       "statusType": "auto",
                       "x": 970,
                       "y": 7200,
                       "wires": []
                   },
                   {
                       "id": "ad94c8961362eb3c",
                       "type": "change",
                       "z": "7e6af0015415146d",
                       "name": "Top Tree",
                       "rules": [
                           {
                               "t": "set",
                               "p": "top",
                               "pt": "msg",
                               "to": "\"Test.Autobahn.\" & autobahn & \".Warnungen\"",
                               "tot": "jsonata"
                           }
                       ],
                       "action": "",
                       "property": "",
                       "from": "",
                       "to": "",
                       "reg": false,
                       "x": 800,
                       "y": 7160,
                       "wires": [
                           [
                               "ccecbbc4a466efa8",
                               "df1966a24326d1f3"
                           ]
                       ]
                   }
                ]
                

                In der Inject Node am Anfang - kannst Du die Autobahn und den Filter spezifizieren:

                aa03ecc3-6899-4e0e-93d3-ad235ebdd779-image.png

                Die Autobahn wird in den Datenpfad übernommen:

                af41b510-1af3-4d67-9bc0-97855946d3e5-image.png

                WICHTIG:
                Wie gesagt - Datenpunkte können mit NodeRed nicht gelöscht werden. Sprich Du musst über die Anzahl prüfen, welche Datenpunkte überhaupt aktuell bzw. relevant sind.

                Die DebugNodes kannst Du natürlich löschen - die nehm ich immer, um zu schauen, ob die Zwischenergebnisse stimmten.

                1 Reply Last reply Reply Quote 0
                • mickym
                  mickym Most Active last edited by mickym

                  Warte mal - ich glaub mit dem Filter stimmt noch was nicht.

                  Ja der Filter muss evaluiert werden - also in der Filterchange Node folgendes ändern:

                  payload.warning[$eval($$.filter)].{
                      "ID": identifier, "Titel":title,
                      "Verzögerung": (delayTimeValue ? delayTimeValue : "0") & " Minuten",
                      "Durchschnittsgeschwindigkeit" : averageSpeed,
                     "Beginn": description[0] ~> $substringAfter(": "),
                     "Ende": description[1] ~> $substringAfter(": "),
                     "Beschreibung": description#$i[$i in [3..$count(%.description)]] ~> $join(" ")
                  }[]
                  

                  a3fde61e-dd3b-4ba1-a66a-5314e95a0aee-image.png

                  Hier nochmal der ganze Flow:

                  [
                     {
                         "id": "6e802f1553b18149",
                         "type": "subflow",
                         "name": "JSON or Obj to IOBroker",
                         "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
                         "category": "",
                         "in": [
                             {
                                 "x": 60,
                                 "y": 160,
                                 "wires": [
                                     {
                                         "id": "554b8c663bcb46c2"
                                     }
                                 ]
                             }
                         ],
                         "out": [
                             {
                                 "x": 2620,
                                 "y": 280,
                                 "wires": [
                                     {
                                         "id": "0962842ebd23e0d7",
                                         "port": 0
                                     }
                                 ]
                             }
                         ],
                         "env": [
                             {
                                 "name": "top",
                                 "type": "str",
                                 "value": "objRoot"
                             },
                             {
                                 "name": "keepTopic",
                                 "type": "bool",
                                 "value": "false"
                             }
                         ],
                         "meta": {},
                         "color": "#E2D96E",
                         "icon": "node-red/batch.svg"
                     },
                     {
                         "id": "3e11e8338f694832",
                         "type": "split",
                         "z": "6e802f1553b18149",
                         "name": "split object",
                         "splt": "\\n",
                         "spltType": "str",
                         "arraySplt": 1,
                         "arraySpltType": "len",
                         "stream": false,
                         "addname": "key",
                         "x": 1370,
                         "y": 160,
                         "wires": [
                             [
                                 "0562a4249c8b856b"
                             ]
                         ]
                     },
                     {
                         "id": "0562a4249c8b856b",
                         "type": "change",
                         "z": "6e802f1553b18149",
                         "name": "add key to topic",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "stateName",
                                 "pt": "msg",
                                 "to": "key",
                                 "tot": "msg"
                             },
                             {
                                 "t": "change",
                                 "p": "key",
                                 "pt": "msg",
                                 "from": ".",
                                 "fromt": "str",
                                 "to": "_",
                                 "tot": "str"
                             },
                             {
                                 "t": "set",
                                 "p": "topic",
                                 "pt": "msg",
                                 "to": "topic  & '.' & key",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 1560,
                         "y": 160,
                         "wires": [
                             [
                                 "ddc90985bef0fafa"
                             ]
                         ]
                     },
                     {
                         "id": "ddc90985bef0fafa",
                         "type": "switch",
                         "z": "6e802f1553b18149",
                         "name": "is type?",
                         "property": "payload",
                         "propertyType": "msg",
                         "rules": [
                             {
                                 "t": "istype",
                                 "v": "array",
                                 "vt": "array"
                             },
                             {
                                 "t": "istype",
                                 "v": "object",
                                 "vt": "object"
                             },
                             {
                                 "t": "else"
                             }
                         ],
                         "checkall": "true",
                         "repair": false,
                         "outputs": 3,
                         "x": 1740,
                         "y": 160,
                         "wires": [
                             [
                                 "bfce19b206660fbe"
                             ],
                             [
                                 "3e11e8338f694832"
                             ],
                             [
                                 "1a8c03d866b85b12"
                             ]
                         ]
                     },
                     {
                         "id": "bfce19b206660fbe",
                         "type": "split",
                         "z": "6e802f1553b18149",
                         "name": "split array",
                         "splt": "\\n",
                         "spltType": "str",
                         "arraySplt": 1,
                         "arraySpltType": "len",
                         "stream": false,
                         "addname": "",
                         "x": 780,
                         "y": 280,
                         "wires": [
                             [
                                 "e89927810c6d75ec"
                             ]
                         ]
                     },
                     {
                         "id": "e89927810c6d75ec",
                         "type": "change",
                         "z": "6e802f1553b18149",
                         "name": "add index to topic",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "topic",
                                 "pt": "msg",
                                 "to": "topic  & '.' & parts.index",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 970,
                         "y": 280,
                         "wires": [
                             [
                                 "a4d1a5d04564dc77"
                             ]
                         ]
                     },
                     {
                         "id": "f5d52c6a57d08904",
                         "type": "change",
                         "z": "6e802f1553b18149",
                         "name": "finalize msg.topic",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "top",
                                 "pt": "msg",
                                 "to": "'0_userdata.0.' & top",
                                 "tot": "jsonata"
                             },
                             {
                                 "t": "set",
                                 "p": "topic",
                                 "pt": "msg",
                                 "to": "top & '.' & topic",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 2170,
                         "y": 240,
                         "wires": [
                             [
                                 "0962842ebd23e0d7"
                             ]
                         ]
                     },
                     {
                         "id": "1a8c03d866b85b12",
                         "type": "switch",
                         "z": "6e802f1553b18149",
                         "name": "is msg.top != null",
                         "property": "top",
                         "propertyType": "msg",
                         "rules": [
                             {
                                 "t": "nnull"
                             },
                             {
                                 "t": "null"
                             }
                         ],
                         "checkall": "true",
                         "repair": false,
                         "outputs": 2,
                         "x": 1950,
                         "y": 280,
                         "wires": [
                             [
                                 "f5d52c6a57d08904"
                             ],
                             [
                                 "74c895ce724750de"
                             ]
                         ]
                     },
                     {
                         "id": "e023fe88445ce43e",
                         "type": "change",
                         "z": "6e802f1553b18149",
                         "name": "",
                         "rules": [
                             {
                                 "t": "delete",
                                 "p": "topic",
                                 "pt": "msg"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 350,
                         "y": 200,
                         "wires": [
                             [
                                 "3649300b4c233b10"
                             ]
                         ]
                     },
                     {
                         "id": "3649300b4c233b10",
                         "type": "switch",
                         "z": "6e802f1553b18149",
                         "name": "is type?",
                         "property": "payload",
                         "propertyType": "msg",
                         "rules": [
                             {
                                 "t": "istype",
                                 "v": "json",
                                 "vt": "json"
                             },
                             {
                                 "t": "istype",
                                 "v": "array",
                                 "vt": "array"
                             },
                             {
                                 "t": "istype",
                                 "v": "object",
                                 "vt": "object"
                             },
                             {
                                 "t": "else"
                             }
                         ],
                         "checkall": "true",
                         "repair": false,
                         "outputs": 4,
                         "x": 600,
                         "y": 160,
                         "wires": [
                             [
                                 "fc7913a8524badb7"
                             ],
                             [
                                 "bfce19b206660fbe"
                             ],
                             [
                                 "3e11e8338f694832"
                             ],
                             [
                                 "9ac3cc3681e8b6c6"
                             ]
                         ]
                     },
                     {
                         "id": "1b8480cd2df7ba3f",
                         "type": "comment",
                         "z": "6e802f1553b18149",
                         "name": "Array",
                         "info": "",
                         "x": 600,
                         "y": 280,
                         "wires": []
                     },
                     {
                         "id": "b3541807672be040",
                         "type": "comment",
                         "z": "6e802f1553b18149",
                         "name": "object",
                         "info": "",
                         "x": 1340,
                         "y": 100,
                         "wires": []
                     },
                     {
                         "id": "a4d1a5d04564dc77",
                         "type": "switch",
                         "z": "6e802f1553b18149",
                         "name": "is type?",
                         "property": "payload",
                         "propertyType": "msg",
                         "rules": [
                             {
                                 "t": "istype",
                                 "v": "object",
                                 "vt": "object"
                             },
                             {
                                 "t": "istype",
                                 "v": "array",
                                 "vt": "array"
                             },
                             {
                                 "t": "else"
                             }
                         ],
                         "checkall": "true",
                         "repair": false,
                         "outputs": 3,
                         "x": 1160,
                         "y": 280,
                         "wires": [
                             [
                                 "3e11e8338f694832"
                             ],
                             [
                                 "bfce19b206660fbe"
                             ],
                             [
                                 "a096a93bb82b7a93"
                             ]
                         ]
                     },
                     {
                         "id": "74c895ce724750de",
                         "type": "change",
                         "z": "6e802f1553b18149",
                         "name": "finalize msg.topic",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "top",
                                 "pt": "msg",
                                 "to": "top",
                                 "tot": "env"
                             },
                             {
                                 "t": "set",
                                 "p": "top",
                                 "pt": "msg",
                                 "to": "'0_userdata.0.' & top",
                                 "tot": "jsonata"
                             },
                             {
                                 "t": "set",
                                 "p": "topic",
                                 "pt": "msg",
                                 "to": "top & '.' & topic",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 2170,
                         "y": 320,
                         "wires": [
                             [
                                 "0962842ebd23e0d7"
                             ]
                         ]
                     },
                     {
                         "id": "554b8c663bcb46c2",
                         "type": "switch",
                         "z": "6e802f1553b18149",
                         "name": "",
                         "property": "keepTopic",
                         "propertyType": "env",
                         "rules": [
                             {
                                 "t": "true"
                             },
                             {
                                 "t": "false"
                             }
                         ],
                         "checkall": "true",
                         "repair": false,
                         "outputs": 2,
                         "x": 170,
                         "y": 160,
                         "wires": [
                             [
                                 "e30ba9f0483285e4"
                             ],
                             [
                                 "e023fe88445ce43e"
                             ]
                         ]
                     },
                     {
                         "id": "e30ba9f0483285e4",
                         "type": "change",
                         "z": "6e802f1553b18149",
                         "name": "",
                         "rules": [
                             {
                                 "t": "change",
                                 "p": "topic",
                                 "pt": "msg",
                                 "from": "/",
                                 "fromt": "str",
                                 "to": ".",
                                 "tot": "str"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 350,
                         "y": 120,
                         "wires": [
                             [
                                 "3649300b4c233b10"
                             ]
                         ]
                     },
                     {
                         "id": "0962842ebd23e0d7",
                         "type": "change",
                         "z": "6e802f1553b18149",
                         "name": "translate invalid chars in topic",
                         "rules": [
                             {
                                 "t": "change",
                                 "p": "topic",
                                 "pt": "msg",
                                 "from": "..",
                                 "fromt": "str",
                                 "to": ".",
                                 "tot": "str"
                             },
                             {
                                 "t": "change",
                                 "p": "topic",
                                 "pt": "msg",
                                 "from": "€",
                                 "fromt": "str",
                                 "to": "EUR",
                                 "tot": "str"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 2430,
                         "y": 280,
                         "wires": [
                             []
                         ]
                     },
                     {
                         "id": "9ac3cc3681e8b6c6",
                         "type": "change",
                         "z": "6e802f1553b18149",
                         "name": "set topic, if empty",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "topic",
                                 "pt": "msg",
                                 "to": "topic ? topic : $type(payload)\t",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 950,
                         "y": 200,
                         "wires": [
                             [
                                 "a096a93bb82b7a93"
                             ]
                         ]
                     },
                     {
                         "id": "fc7913a8524badb7",
                         "type": "json",
                         "z": "6e802f1553b18149",
                         "name": "",
                         "property": "payload",
                         "action": "obj",
                         "pretty": false,
                         "x": 750,
                         "y": 100,
                         "wires": [
                             [
                                 "d9e7bdd4c48a8aa1"
                             ]
                         ]
                     },
                     {
                         "id": "d9e7bdd4c48a8aa1",
                         "type": "switch",
                         "z": "6e802f1553b18149",
                         "name": "is type?",
                         "property": "payload",
                         "propertyType": "msg",
                         "rules": [
                             {
                                 "t": "istype",
                                 "v": "array",
                                 "vt": "array"
                             },
                             {
                                 "t": "istype",
                                 "v": "object",
                                 "vt": "object"
                             },
                             {
                                 "t": "else"
                             }
                         ],
                         "checkall": "true",
                         "repair": false,
                         "outputs": 3,
                         "x": 900,
                         "y": 100,
                         "wires": [
                             [
                                 "1520be42bcc2145e"
                             ],
                             [
                                 "1520be42bcc2145e"
                             ],
                             [
                                 "9ac3cc3681e8b6c6"
                             ]
                         ]
                     },
                     {
                         "id": "a096a93bb82b7a93",
                         "type": "junction",
                         "z": "6e802f1553b18149",
                         "x": 1380,
                         "y": 280,
                         "wires": [
                             [
                                 "1a8c03d866b85b12"
                             ]
                         ]
                     },
                     {
                         "id": "1520be42bcc2145e",
                         "type": "junction",
                         "z": "6e802f1553b18149",
                         "x": 480,
                         "y": 20,
                         "wires": [
                             [
                                 "3649300b4c233b10"
                             ]
                         ]
                     },
                     {
                         "id": "3e7ed9c7e1462b09",
                         "type": "inject",
                         "z": "7e6af0015415146d",
                         "name": "AB  & Filter",
                         "props": [
                             {
                                 "p": "autobahn",
                                 "v": "A7",
                                 "vt": "str"
                             },
                             {
                                 "p": "filter",
                                 "v": "(coordinate.lat > 51.0 and coordinate.lat < 54.4) and (coordinate.long > 9.0 and coordinate.long < 10)",
                                 "vt": "str"
                             }
                         ],
                         "repeat": "",
                         "crontab": "",
                         "once": false,
                         "onceDelay": 0.1,
                         "topic": "",
                         "x": 180,
                         "y": 7160,
                         "wires": [
                             [
                                 "e9f4765fa483a48a"
                             ]
                         ]
                     },
                     {
                         "id": "e9f4765fa483a48a",
                         "type": "template",
                         "z": "7e6af0015415146d",
                         "name": "",
                         "field": "url",
                         "fieldType": "msg",
                         "format": "handlebars",
                         "syntax": "mustache",
                         "template": "https://verkehr.autobahn.de/o/autobahn/{{autobahn}}/services/warning",
                         "output": "str",
                         "x": 320,
                         "y": 7160,
                         "wires": [
                             [
                                 "4759ede23832569c",
                                 "a73f68ca019bab89"
                             ]
                         ]
                     },
                     {
                         "id": "4759ede23832569c",
                         "type": "debug",
                         "z": "7e6af0015415146d",
                         "name": "url",
                         "active": false,
                         "tosidebar": true,
                         "console": false,
                         "tostatus": false,
                         "complete": "true",
                         "targetType": "full",
                         "statusVal": "",
                         "statusType": "auto",
                         "x": 510,
                         "y": 7100,
                         "wires": []
                     },
                     {
                         "id": "a73f68ca019bab89",
                         "type": "http request",
                         "z": "7e6af0015415146d",
                         "name": "",
                         "method": "GET",
                         "ret": "obj",
                         "paytoqs": "ignore",
                         "url": "",
                         "tls": "",
                         "persist": false,
                         "proxy": "",
                         "insecureHTTPParser": false,
                         "authType": "",
                         "senderr": false,
                         "headers": [],
                         "x": 490,
                         "y": 7160,
                         "wires": [
                             [
                                 "8d7bc4d16a712bc4",
                                 "e4e045e2d7b0f1f3"
                             ]
                         ]
                     },
                     {
                         "id": "8d7bc4d16a712bc4",
                         "type": "debug",
                         "z": "7e6af0015415146d",
                         "name": "JSON",
                         "active": false,
                         "tosidebar": true,
                         "console": false,
                         "tostatus": false,
                         "complete": "true",
                         "targetType": "full",
                         "statusVal": "",
                         "statusType": "auto",
                         "x": 670,
                         "y": 7200,
                         "wires": []
                     },
                     {
                         "id": "e4e045e2d7b0f1f3",
                         "type": "change",
                         "z": "7e6af0015415146d",
                         "name": "Filter",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "payload",
                                 "pt": "msg",
                                 "to": "payload.warning[$eval($$.filter)].{\t    \"ID\": identifier, \"Titel\":title,\t    \"Verzögerung\": (delayTimeValue ? delayTimeValue : \"0\") & \" Minuten\",\t    \"Durchschnittsgeschwindigkeit\" : averageSpeed,\t   \"Beginn\": description[0] ~> $substringAfter(\": \"),\t   \"Ende\": description[1] ~> $substringAfter(\": \"),\t   \"Beschreibung\": description#$i[$i in [3..$count(%.description)]] ~> $join(\" \")\t}[]",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 650,
                         "y": 7160,
                         "wires": [
                             [
                                 "7b995bd410358394",
                                 "ad94c8961362eb3c"
                             ]
                         ]
                     },
                     {
                         "id": "7b995bd410358394",
                         "type": "change",
                         "z": "7e6af0015415146d",
                         "name": "Anzahl Warnungen",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "topic",
                                 "pt": "msg",
                                 "to": "\"0_userdata.0.Test.Autobahn.\" & autobahn & \".AnzahlWarnungen\"",
                                 "tot": "jsonata"
                             },
                             {
                                 "t": "set",
                                 "p": "payload",
                                 "pt": "msg",
                                 "to": "$count(payload)",
                                 "tot": "jsonata"
                             },
                             {
                                 "t": "set",
                                 "p": "top",
                                 "pt": "msg",
                                 "to": "\"0_userdata.0.Test.Autobahn.\" & autobahn & \".Warnungen\"",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 830,
                         "y": 7100,
                         "wires": [
                             [
                                 "abf49b5aa9ca3e7e"
                             ]
                         ]
                     },
                     {
                         "id": "abf49b5aa9ca3e7e",
                         "type": "ioBroker out",
                         "z": "7e6af0015415146d",
                         "name": "",
                         "topic": "",
                         "ack": "true",
                         "autoCreate": "true",
                         "stateName": "",
                         "role": "",
                         "payloadType": "",
                         "readonly": "",
                         "stateUnit": "",
                         "stateMin": "",
                         "stateMax": "",
                         "x": 1040,
                         "y": 7100,
                         "wires": []
                     },
                     {
                         "id": "ccecbbc4a466efa8",
                         "type": "subflow:6e802f1553b18149",
                         "z": "7e6af0015415146d",
                         "name": "",
                         "x": 1010,
                         "y": 7160,
                         "wires": [
                             [
                                 "a72e0e225946d210"
                             ]
                         ]
                     },
                     {
                         "id": "a72e0e225946d210",
                         "type": "ioBroker out",
                         "z": "7e6af0015415146d",
                         "name": "",
                         "topic": "",
                         "ack": "true",
                         "autoCreate": "true",
                         "stateName": "",
                         "role": "",
                         "payloadType": "",
                         "readonly": "",
                         "stateUnit": "",
                         "stateMin": "",
                         "stateMax": "",
                         "x": 1240,
                         "y": 7160,
                         "wires": []
                     },
                     {
                         "id": "df1966a24326d1f3",
                         "type": "debug",
                         "z": "7e6af0015415146d",
                         "name": "Ergebnisse",
                         "active": false,
                         "tosidebar": true,
                         "console": false,
                         "tostatus": false,
                         "complete": "payload",
                         "targetType": "msg",
                         "statusVal": "",
                         "statusType": "auto",
                         "x": 970,
                         "y": 7200,
                         "wires": []
                     },
                     {
                         "id": "ad94c8961362eb3c",
                         "type": "change",
                         "z": "7e6af0015415146d",
                         "name": "Top Tree",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "top",
                                 "pt": "msg",
                                 "to": "\"Test.Autobahn.\" & autobahn & \".Warnungen\"",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 800,
                         "y": 7160,
                         "wires": [
                             [
                                 "ccecbbc4a466efa8",
                                 "df1966a24326d1f3"
                             ]
                         ]
                     }
                  ]
                  

                  icebear 1 Reply Last reply Reply Quote 0
                  • icebear
                    icebear @mickym last edited by

                    @mickym

                    Super Vielen Dank für deine Arbeit, ich werde das testen und berichten.

                    mickym 1 Reply Last reply Reply Quote 0
                    • mickym
                      mickym Most Active @icebear last edited by

                      @icebear sagte in Auslesen und Filtern der autobahn.api von bund.dev:

                      @mickym

                      Super Vielen Dank für deine Arbeit, ich werde das testen und berichten.

                      Ja noch einen Filter, als Sicherheitsabfrage, wenn keine Ergebnisse vorhanden sind.

                      fb28cefe-ee4f-42b4-8772-df52c1cef10c-image.png

                      Sonst stürzt der NodeRed Adapter ab .

                      Also diesen Flow bitte verwenden:

                      [
                         {
                             "id": "6e802f1553b18149",
                             "type": "subflow",
                             "name": "JSON or Obj to IOBroker",
                             "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
                             "category": "",
                             "in": [
                                 {
                                     "x": 60,
                                     "y": 160,
                                     "wires": [
                                         {
                                             "id": "554b8c663bcb46c2"
                                         }
                                     ]
                                 }
                             ],
                             "out": [
                                 {
                                     "x": 2620,
                                     "y": 280,
                                     "wires": [
                                         {
                                             "id": "0962842ebd23e0d7",
                                             "port": 0
                                         }
                                     ]
                                 }
                             ],
                             "env": [
                                 {
                                     "name": "top",
                                     "type": "str",
                                     "value": "objRoot"
                                 },
                                 {
                                     "name": "keepTopic",
                                     "type": "bool",
                                     "value": "false"
                                 }
                             ],
                             "meta": {},
                             "color": "#E2D96E",
                             "icon": "node-red/batch.svg"
                         },
                         {
                             "id": "3e11e8338f694832",
                             "type": "split",
                             "z": "6e802f1553b18149",
                             "name": "split object",
                             "splt": "\\n",
                             "spltType": "str",
                             "arraySplt": 1,
                             "arraySpltType": "len",
                             "stream": false,
                             "addname": "key",
                             "x": 1370,
                             "y": 160,
                             "wires": [
                                 [
                                     "0562a4249c8b856b"
                                 ]
                             ]
                         },
                         {
                             "id": "0562a4249c8b856b",
                             "type": "change",
                             "z": "6e802f1553b18149",
                             "name": "add key to topic",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "stateName",
                                     "pt": "msg",
                                     "to": "key",
                                     "tot": "msg"
                                 },
                                 {
                                     "t": "change",
                                     "p": "key",
                                     "pt": "msg",
                                     "from": ".",
                                     "fromt": "str",
                                     "to": "_",
                                     "tot": "str"
                                 },
                                 {
                                     "t": "set",
                                     "p": "topic",
                                     "pt": "msg",
                                     "to": "topic  & '.' & key",
                                     "tot": "jsonata"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 1560,
                             "y": 160,
                             "wires": [
                                 [
                                     "ddc90985bef0fafa"
                                 ]
                             ]
                         },
                         {
                             "id": "ddc90985bef0fafa",
                             "type": "switch",
                             "z": "6e802f1553b18149",
                             "name": "is type?",
                             "property": "payload",
                             "propertyType": "msg",
                             "rules": [
                                 {
                                     "t": "istype",
                                     "v": "array",
                                     "vt": "array"
                                 },
                                 {
                                     "t": "istype",
                                     "v": "object",
                                     "vt": "object"
                                 },
                                 {
                                     "t": "else"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 3,
                             "x": 1740,
                             "y": 160,
                             "wires": [
                                 [
                                     "bfce19b206660fbe"
                                 ],
                                 [
                                     "3e11e8338f694832"
                                 ],
                                 [
                                     "1a8c03d866b85b12"
                                 ]
                             ]
                         },
                         {
                             "id": "bfce19b206660fbe",
                             "type": "split",
                             "z": "6e802f1553b18149",
                             "name": "split array",
                             "splt": "\\n",
                             "spltType": "str",
                             "arraySplt": 1,
                             "arraySpltType": "len",
                             "stream": false,
                             "addname": "",
                             "x": 780,
                             "y": 280,
                             "wires": [
                                 [
                                     "e89927810c6d75ec"
                                 ]
                             ]
                         },
                         {
                             "id": "e89927810c6d75ec",
                             "type": "change",
                             "z": "6e802f1553b18149",
                             "name": "add index to topic",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "topic",
                                     "pt": "msg",
                                     "to": "topic  & '.' & parts.index",
                                     "tot": "jsonata"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 970,
                             "y": 280,
                             "wires": [
                                 [
                                     "a4d1a5d04564dc77"
                                 ]
                             ]
                         },
                         {
                             "id": "f5d52c6a57d08904",
                             "type": "change",
                             "z": "6e802f1553b18149",
                             "name": "finalize msg.topic",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "top",
                                     "pt": "msg",
                                     "to": "'0_userdata.0.' & top",
                                     "tot": "jsonata"
                                 },
                                 {
                                     "t": "set",
                                     "p": "topic",
                                     "pt": "msg",
                                     "to": "top & '.' & topic",
                                     "tot": "jsonata"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 2170,
                             "y": 240,
                             "wires": [
                                 [
                                     "0962842ebd23e0d7"
                                 ]
                             ]
                         },
                         {
                             "id": "1a8c03d866b85b12",
                             "type": "switch",
                             "z": "6e802f1553b18149",
                             "name": "is msg.top != null",
                             "property": "top",
                             "propertyType": "msg",
                             "rules": [
                                 {
                                     "t": "nnull"
                                 },
                                 {
                                     "t": "null"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 2,
                             "x": 1950,
                             "y": 280,
                             "wires": [
                                 [
                                     "f5d52c6a57d08904"
                                 ],
                                 [
                                     "74c895ce724750de"
                                 ]
                             ]
                         },
                         {
                             "id": "e023fe88445ce43e",
                             "type": "change",
                             "z": "6e802f1553b18149",
                             "name": "",
                             "rules": [
                                 {
                                     "t": "delete",
                                     "p": "topic",
                                     "pt": "msg"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 350,
                             "y": 200,
                             "wires": [
                                 [
                                     "3649300b4c233b10"
                                 ]
                             ]
                         },
                         {
                             "id": "3649300b4c233b10",
                             "type": "switch",
                             "z": "6e802f1553b18149",
                             "name": "is type?",
                             "property": "payload",
                             "propertyType": "msg",
                             "rules": [
                                 {
                                     "t": "istype",
                                     "v": "json",
                                     "vt": "json"
                                 },
                                 {
                                     "t": "istype",
                                     "v": "array",
                                     "vt": "array"
                                 },
                                 {
                                     "t": "istype",
                                     "v": "object",
                                     "vt": "object"
                                 },
                                 {
                                     "t": "else"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 4,
                             "x": 600,
                             "y": 160,
                             "wires": [
                                 [
                                     "fc7913a8524badb7"
                                 ],
                                 [
                                     "bfce19b206660fbe"
                                 ],
                                 [
                                     "3e11e8338f694832"
                                 ],
                                 [
                                     "9ac3cc3681e8b6c6"
                                 ]
                             ]
                         },
                         {
                             "id": "1b8480cd2df7ba3f",
                             "type": "comment",
                             "z": "6e802f1553b18149",
                             "name": "Array",
                             "info": "",
                             "x": 600,
                             "y": 280,
                             "wires": []
                         },
                         {
                             "id": "b3541807672be040",
                             "type": "comment",
                             "z": "6e802f1553b18149",
                             "name": "object",
                             "info": "",
                             "x": 1340,
                             "y": 100,
                             "wires": []
                         },
                         {
                             "id": "a4d1a5d04564dc77",
                             "type": "switch",
                             "z": "6e802f1553b18149",
                             "name": "is type?",
                             "property": "payload",
                             "propertyType": "msg",
                             "rules": [
                                 {
                                     "t": "istype",
                                     "v": "object",
                                     "vt": "object"
                                 },
                                 {
                                     "t": "istype",
                                     "v": "array",
                                     "vt": "array"
                                 },
                                 {
                                     "t": "else"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 3,
                             "x": 1160,
                             "y": 280,
                             "wires": [
                                 [
                                     "3e11e8338f694832"
                                 ],
                                 [
                                     "bfce19b206660fbe"
                                 ],
                                 [
                                     "a096a93bb82b7a93"
                                 ]
                             ]
                         },
                         {
                             "id": "74c895ce724750de",
                             "type": "change",
                             "z": "6e802f1553b18149",
                             "name": "finalize msg.topic",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "top",
                                     "pt": "msg",
                                     "to": "top",
                                     "tot": "env"
                                 },
                                 {
                                     "t": "set",
                                     "p": "top",
                                     "pt": "msg",
                                     "to": "'0_userdata.0.' & top",
                                     "tot": "jsonata"
                                 },
                                 {
                                     "t": "set",
                                     "p": "topic",
                                     "pt": "msg",
                                     "to": "top & '.' & topic",
                                     "tot": "jsonata"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 2170,
                             "y": 320,
                             "wires": [
                                 [
                                     "0962842ebd23e0d7"
                                 ]
                             ]
                         },
                         {
                             "id": "554b8c663bcb46c2",
                             "type": "switch",
                             "z": "6e802f1553b18149",
                             "name": "",
                             "property": "keepTopic",
                             "propertyType": "env",
                             "rules": [
                                 {
                                     "t": "true"
                                 },
                                 {
                                     "t": "false"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 2,
                             "x": 170,
                             "y": 160,
                             "wires": [
                                 [
                                     "e30ba9f0483285e4"
                                 ],
                                 [
                                     "e023fe88445ce43e"
                                 ]
                             ]
                         },
                         {
                             "id": "e30ba9f0483285e4",
                             "type": "change",
                             "z": "6e802f1553b18149",
                             "name": "",
                             "rules": [
                                 {
                                     "t": "change",
                                     "p": "topic",
                                     "pt": "msg",
                                     "from": "/",
                                     "fromt": "str",
                                     "to": ".",
                                     "tot": "str"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 350,
                             "y": 120,
                             "wires": [
                                 [
                                     "3649300b4c233b10"
                                 ]
                             ]
                         },
                         {
                             "id": "0962842ebd23e0d7",
                             "type": "change",
                             "z": "6e802f1553b18149",
                             "name": "translate invalid chars in topic",
                             "rules": [
                                 {
                                     "t": "change",
                                     "p": "topic",
                                     "pt": "msg",
                                     "from": "..",
                                     "fromt": "str",
                                     "to": ".",
                                     "tot": "str"
                                 },
                                 {
                                     "t": "change",
                                     "p": "topic",
                                     "pt": "msg",
                                     "from": "€",
                                     "fromt": "str",
                                     "to": "EUR",
                                     "tot": "str"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 2430,
                             "y": 280,
                             "wires": [
                                 []
                             ]
                         },
                         {
                             "id": "9ac3cc3681e8b6c6",
                             "type": "change",
                             "z": "6e802f1553b18149",
                             "name": "set topic, if empty",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "topic",
                                     "pt": "msg",
                                     "to": "topic ? topic : $type(payload)\t",
                                     "tot": "jsonata"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 950,
                             "y": 200,
                             "wires": [
                                 [
                                     "a096a93bb82b7a93"
                                 ]
                             ]
                         },
                         {
                             "id": "fc7913a8524badb7",
                             "type": "json",
                             "z": "6e802f1553b18149",
                             "name": "",
                             "property": "payload",
                             "action": "obj",
                             "pretty": false,
                             "x": 750,
                             "y": 100,
                             "wires": [
                                 [
                                     "d9e7bdd4c48a8aa1"
                                 ]
                             ]
                         },
                         {
                             "id": "d9e7bdd4c48a8aa1",
                             "type": "switch",
                             "z": "6e802f1553b18149",
                             "name": "is type?",
                             "property": "payload",
                             "propertyType": "msg",
                             "rules": [
                                 {
                                     "t": "istype",
                                     "v": "array",
                                     "vt": "array"
                                 },
                                 {
                                     "t": "istype",
                                     "v": "object",
                                     "vt": "object"
                                 },
                                 {
                                     "t": "else"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 3,
                             "x": 900,
                             "y": 100,
                             "wires": [
                                 [
                                     "1520be42bcc2145e"
                                 ],
                                 [
                                     "1520be42bcc2145e"
                                 ],
                                 [
                                     "9ac3cc3681e8b6c6"
                                 ]
                             ]
                         },
                         {
                             "id": "a096a93bb82b7a93",
                             "type": "junction",
                             "z": "6e802f1553b18149",
                             "x": 1380,
                             "y": 280,
                             "wires": [
                                 [
                                     "1a8c03d866b85b12"
                                 ]
                             ]
                         },
                         {
                             "id": "1520be42bcc2145e",
                             "type": "junction",
                             "z": "6e802f1553b18149",
                             "x": 480,
                             "y": 20,
                             "wires": [
                                 [
                                     "3649300b4c233b10"
                                 ]
                             ]
                         },
                         {
                             "id": "3e7ed9c7e1462b09",
                             "type": "inject",
                             "z": "7e6af0015415146d",
                             "name": "AB  & Filter",
                             "props": [
                                 {
                                     "p": "autobahn",
                                     "v": "A7",
                                     "vt": "str"
                                 },
                                 {
                                     "p": "filter",
                                     "v": "(coordinate.lat > 49.0 and coordinate.lat < 54.4) and (coordinate.long > 6.0 and coordinate.long < 10)",
                                     "vt": "str"
                                 }
                             ],
                             "repeat": "",
                             "crontab": "",
                             "once": false,
                             "onceDelay": 0.1,
                             "topic": "",
                             "x": 180,
                             "y": 7160,
                             "wires": [
                                 [
                                     "e9f4765fa483a48a"
                                 ]
                             ]
                         },
                         {
                             "id": "e9f4765fa483a48a",
                             "type": "template",
                             "z": "7e6af0015415146d",
                             "name": "",
                             "field": "url",
                             "fieldType": "msg",
                             "format": "handlebars",
                             "syntax": "mustache",
                             "template": "https://verkehr.autobahn.de/o/autobahn/{{autobahn}}/services/warning",
                             "output": "str",
                             "x": 320,
                             "y": 7160,
                             "wires": [
                                 [
                                     "4759ede23832569c",
                                     "a73f68ca019bab89"
                                 ]
                             ]
                         },
                         {
                             "id": "4759ede23832569c",
                             "type": "debug",
                             "z": "7e6af0015415146d",
                             "name": "url",
                             "active": false,
                             "tosidebar": true,
                             "console": false,
                             "tostatus": false,
                             "complete": "true",
                             "targetType": "full",
                             "statusVal": "",
                             "statusType": "auto",
                             "x": 510,
                             "y": 7100,
                             "wires": []
                         },
                         {
                             "id": "a73f68ca019bab89",
                             "type": "http request",
                             "z": "7e6af0015415146d",
                             "name": "",
                             "method": "GET",
                             "ret": "obj",
                             "paytoqs": "ignore",
                             "url": "",
                             "tls": "",
                             "persist": false,
                             "proxy": "",
                             "insecureHTTPParser": false,
                             "authType": "",
                             "senderr": false,
                             "headers": [],
                             "x": 490,
                             "y": 7160,
                             "wires": [
                                 [
                                     "8d7bc4d16a712bc4",
                                     "e4e045e2d7b0f1f3"
                                 ]
                             ]
                         },
                         {
                             "id": "8d7bc4d16a712bc4",
                             "type": "debug",
                             "z": "7e6af0015415146d",
                             "name": "JSON",
                             "active": false,
                             "tosidebar": true,
                             "console": false,
                             "tostatus": false,
                             "complete": "true",
                             "targetType": "full",
                             "statusVal": "",
                             "statusType": "auto",
                             "x": 670,
                             "y": 7200,
                             "wires": []
                         },
                         {
                             "id": "e4e045e2d7b0f1f3",
                             "type": "change",
                             "z": "7e6af0015415146d",
                             "name": "Filter",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "payload",
                                     "pt": "msg",
                                     "to": "payload.warning[$eval($$.filter)].{\t    \"ID\": identifier, \"Titel\":title,\t    \"Verzögerung\": (delayTimeValue ? delayTimeValue : \"0\") & \" Minuten\",\t    \"Durchschnittsgeschwindigkeit\" : averageSpeed,\t   \"Beginn\": description[0] ~> $substringAfter(\": \"),\t   \"Ende\": description[1] ~> $substringAfter(\": \"),\t   \"Beschreibung\": description#$i[$i in [3..$count(%.description)]] ~> $join(\" \")\t}[]",
                                     "tot": "jsonata"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 650,
                             "y": 7160,
                             "wires": [
                                 [
                                     "7b995bd410358394",
                                     "37f05e634adffcfb"
                                 ]
                             ]
                         },
                         {
                             "id": "7b995bd410358394",
                             "type": "change",
                             "z": "7e6af0015415146d",
                             "name": "Anzahl Warnungen",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "topic",
                                     "pt": "msg",
                                     "to": "\"0_userdata.0.Test.Autobahn.\" & autobahn & \".AnzahlWarnungen\"",
                                     "tot": "jsonata"
                                 },
                                 {
                                     "t": "set",
                                     "p": "payload",
                                     "pt": "msg",
                                     "to": "$count(payload)",
                                     "tot": "jsonata"
                                 },
                                 {
                                     "t": "set",
                                     "p": "top",
                                     "pt": "msg",
                                     "to": "\"0_userdata.0.Test.Autobahn.\" & autobahn & \".Warnungen\"",
                                     "tot": "jsonata"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 830,
                             "y": 7100,
                             "wires": [
                                 [
                                     "abf49b5aa9ca3e7e"
                                 ]
                             ]
                         },
                         {
                             "id": "abf49b5aa9ca3e7e",
                             "type": "ioBroker out",
                             "z": "7e6af0015415146d",
                             "name": "",
                             "topic": "",
                             "ack": "true",
                             "autoCreate": "true",
                             "stateName": "",
                             "role": "",
                             "payloadType": "",
                             "readonly": "",
                             "stateUnit": "",
                             "stateMin": "",
                             "stateMax": "",
                             "x": 1040,
                             "y": 7100,
                             "wires": []
                         },
                         {
                             "id": "ccecbbc4a466efa8",
                             "type": "subflow:6e802f1553b18149",
                             "z": "7e6af0015415146d",
                             "name": "",
                             "x": 1170,
                             "y": 7160,
                             "wires": [
                                 [
                                     "a72e0e225946d210"
                                 ]
                             ]
                         },
                         {
                             "id": "a72e0e225946d210",
                             "type": "ioBroker out",
                             "z": "7e6af0015415146d",
                             "name": "",
                             "topic": "",
                             "ack": "true",
                             "autoCreate": "true",
                             "stateName": "",
                             "role": "",
                             "payloadType": "",
                             "readonly": "",
                             "stateUnit": "",
                             "stateMin": "",
                             "stateMax": "",
                             "x": 1400,
                             "y": 7160,
                             "wires": []
                         },
                         {
                             "id": "df1966a24326d1f3",
                             "type": "debug",
                             "z": "7e6af0015415146d",
                             "name": "Ergebnisse",
                             "active": false,
                             "tosidebar": true,
                             "console": false,
                             "tostatus": false,
                             "complete": "payload",
                             "targetType": "msg",
                             "statusVal": "",
                             "statusType": "auto",
                             "x": 1150,
                             "y": 7200,
                             "wires": []
                         },
                         {
                             "id": "ad94c8961362eb3c",
                             "type": "change",
                             "z": "7e6af0015415146d",
                             "name": "Top Tree",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "top",
                                     "pt": "msg",
                                     "to": "\"Test.Autobahn.\" & autobahn & \".Warnungen\"",
                                     "tot": "jsonata"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 960,
                             "y": 7160,
                             "wires": [
                                 [
                                     "ccecbbc4a466efa8",
                                     "df1966a24326d1f3"
                                 ]
                             ]
                         },
                         {
                             "id": "37f05e634adffcfb",
                             "type": "switch",
                             "z": "7e6af0015415146d",
                             "name": "",
                             "property": "$count(payload)",
                             "propertyType": "jsonata",
                             "rules": [
                                 {
                                     "t": "gt",
                                     "v": "0",
                                     "vt": "num"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 1,
                             "x": 810,
                             "y": 7160,
                             "wires": [
                                 [
                                     "ad94c8961362eb3c"
                                 ]
                             ]
                         }
                      ]
                      

                      1 Reply Last reply Reply Quote 0
                      • G
                        gutgut30 last edited by

                        @mickym said in Auslesen und Filtern der autobahn.api von bund.dev:

                        :title,
                        "Verzögerung": (delayTimeValue ? delayTimeValue : "0") & " Minuten"

                        Funktioniert perfekt. Ich schreibe inzwischen auch einfach das JSON in den Datenpunkt und gebe es in Jarvis als einfache JSON Liste aus. Das reicht mir vollkommen.

                        An einer Kleinigkeit habe ich mir aber nun dann doch noch die Zähne ausgebissen und bin mit Google und KI nicht zum Ziel gekommen...

                        Ich gehe davon aus, dass der Wert "isBlocked" in der Rückgabe für eine Vollsperrung steht. Wie bekomme ich es hin, dass ich in der Ausgabe bei false den Wert gar nicht habe, bei true aber ein Wert "Vollsperrung" : "ja" kommt?

                        Ich hab es replacen können, aber eine Selektion mal "Vollsperrung" und mal nicht mit auszugeben hat mich dann leider überfordert.

                        mickym 1 Reply Last reply Reply Quote 0
                        • mickym
                          mickym Most Active @gutgut30 last edited by mickym

                          @gutgut30 sagte in Auslesen und Filtern der autobahn.api von bund.dev:

                          ch gehe davon aus, dass der Wert "isBlocked" in der Rückgabe für eine Vollsperrung steht. Wie bekomme ich es hin, dass ich in der Ausgabe bei false den Wert gar nicht habe, bei true aber ein Wert "Vollsperrung" : "ja" kommt?
                          Ich hab es replacen können, aber eine Selektion mal "Vollsperrung" und mal nicht mit auszugeben hat mich dann leider überfordert.

                          5b89464b-1987-44d7-a18d-5a86c99441a9-image.png

                          $.warning[(coordinate.lat > 51.0 and coordinate.lat < 54.4) and (coordinate.long > 9.0 and coordinate.long < 10)].{
                              "ID": identifier, "Titel":title,
                              "Vollsperrung": isBlocked="false" ? undefined : "ja"}[]
                          

                          https://try.jsonata.org/yQ2hFUzFf

                          Ach hatte ich schon erwähnt, dass JSONATA so genial ist und nur Eigenschaften anzeigt, die definiert sind?

                          G 1 Reply Last reply Reply Quote 0
                          • G
                            gutgut30 @mickym last edited by

                            Ich möchte euch herzlich danken - ich habe nun fast das, was ich haben wollte.

                            Ich lese 3 Autobahnen aus, filtere auf mein Teistück und kombiniere diese. Anschließend erscheinen die Meldungen auf meiner VIS. Mein Lese-Blockly sieht so aus:

                            52c76b93-0ff8-4c8e-97d2-e1c70f2f5c55-image.png

                            Das Kombinieren der Meldungen so (und, ja, es geht sicher geschickter...):
                            4270ed68-ab2a-4185-8231-18ae75b7e205-image.png

                            Die JSONata, je nach Autobahn, so (füllen von Verzögerung, Splitten des Titels):

                            $.warning[(coordinate.lat > 1.1 and coordinate.lat < 99.999)].{"Autobahn":$substringBefore(title, " |"),"Teilstück":$substringAfter(title, " | "),"Verzögerung": (delayTimeValue ? delayTimeValue : "0") & " Minuten","Vollsperrung": isBlocked="false" ? undefined : "ja"}[]
                            

                            Und was ich damit am Ende bezwecken wollte:
                            72b9a1ae-0dda-41b7-b97c-3a5edc6803c1-image.png

                            Was ich jetzt noch versuchen werde:

                            • das zusammenbauen der Kombination besser bauen

                            • nur die Meldungen ausgeben die entweder Verzögerung von mehr als 2 Minuten haben ODER eine Vollsperrung ergeben. Das dürfte eigentlich schon mit JSONata Filtern machbar sein

                            • Und, sicher die größte Herausforderung, nur die Meldungen anzeigen, die in die gewünschte Richtung gelten.
                              Derzeit bekomme ich ja auch Meldungen auf der Gegenfahrbahn, die brauche ich nicht. Das müsste ja eigentlich möglich sein, es zu filtern durch "gebe nur Meldungen die Koordinate von Nord nach Süd haben".

                            icebear 1 Reply Last reply Reply Quote 0
                            • icebear
                              icebear @gutgut30 last edited by icebear

                              @gutgut30

                              wie hast du denn die google maps Karte eingebunden?

                              Edit: Hat sich erledigt

                              1 Reply Last reply Reply Quote 0
                              • bahnuhr
                                bahnuhr Forum Testing Most Active last edited by bahnuhr

                                Hallo,
                                ich habe auch mal ne Frage zu der api.

                                Bei folgender url:
                                https://verkehr.autobahn.de/o/autobahn/A7/services/webcam
                                bekomme ich nur sowas:
                                3ca531a2-2b87-4a8b-a543-82e123dddecd-image.png

                                Lt. api sollte doch aber eine Auflistung folgen:
                                07e4225e-53af-4096-8004-d409b0170261-image.png

                                Wie gesagt, ich hätte gerne das u.g. json.

                                Folgendes Script habe ich zum auslesen mal schnell geschrieben:

                                httpGet('https://verkehr.autobahn.de/o/autobahn/A7/services/webcam', { timeout: 1000 }, (error, response) => {
                                    if (!error) {
                                        console.log(response.statusCode);
                                        console.log(response.data);
                                    } else {
                                        console.error(error);
                                    }
                                });
                                

                                Im log kommt dann:

                                script.js.Scripte.Sonstige.Autobahn: {"webcam":[]}
                                

                                Frage:
                                Muss die httpget anders aussehen?

                                Die anderen url von der api funktionieren; nur halt nicht die webcam url.

                                R 1 Reply Last reply Reply Quote 0
                                • bahnuhr
                                  bahnuhr Forum Testing Most Active last edited by

                                  Keiner eine Idee ?

                                  1 Reply Last reply Reply Quote 0
                                  • R
                                    Ralf 2 @bahnuhr last edited by

                                    @bahnuhr sagte in Auslesen und Filtern der autobahn.api von bund.dev:

                                    bekomme ich nur sowas:
                                    3ca531a2-2b87-4a8b-a543-82e123dddecd-image.png

                                    Die Webcams sind bereits seit einigen Jahren nicht mehr für die Öffentlichkeit verfügbar - Datenschutz.
                                    Ich finde das auch blöde, früher hatte ich mir immer den Verkehr auf der Rheinbrücke vor der Fahrt angesehen, geht in Deutschland nicht mehr.

                                    bahnuhr 1 Reply Last reply Reply Quote 0
                                    • bahnuhr
                                      bahnuhr Forum Testing Most Active @Ralf 2 last edited by

                                      @ralf-2
                                      Danke für die Info.
                                      Dann ist aber auch die api Beschreibung veraltet.

                                      R 1 Reply Last reply Reply Quote 0
                                      • R
                                        Ralf 2 @bahnuhr last edited by

                                        @bahnuhr
                                        Ja, aber vielleicht will man die wieder aktivieren.
                                        Die Kameras wurden März 2022 wegen dem Ukrainekrieg abgeschaltet um es den Russen nicht zu leicht zu machen Truppenbewegungen in Deutschland zu erkennen.

                                        1 Reply Last reply Reply Quote 1
                                        • First post
                                          Last post

                                        Support us

                                        ioBroker
                                        Community Adapters
                                        Donate

                                        629
                                        Online

                                        31.7k
                                        Users

                                        79.7k
                                        Topics

                                        1.3m
                                        Posts

                                        6
                                        30
                                        856
                                        Loading More Posts
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        Community
                                        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                        The ioBroker Community 2014-2023
                                        logo