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

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Node-Red
  5. Rasp2 serial überwachen, per mqtt an iobroker übertragen.

NEWS

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

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    2.2k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    16
    1
    3.1k

Rasp2 serial überwachen, per mqtt an iobroker übertragen.

Geplant Angeheftet Gesperrt Verschoben Node-Red
28 Beiträge 2 Kommentatoren 1.7k Aufrufe 2 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • Beliar_666B Beliar_666

    @mickym genau da liegt ja das Problem. wie überwache ich die serielle Schnittstelle? Mit Serial in passiert eben nichts. Und vor allem soll er übertragen sobald seriell etwas herein kommt.

    Für jemanden der sich mit Node Red super auskennt mag das ganz simpel sein, aber für einen Noob ist das erstmal ne gewaltige Hausnummer.
    Aus Node Red an iob per mqtt klappte ja schon, nur wie nun die seriellen Daten in den Flow bekommen....

    mickymM Online
    mickymM Online
    mickym
    Most Active
    schrieb am zuletzt editiert von mickym
    #4

    Nun entweder gibts einen Adapter im iobroker, der Dir die Daten auslesen kann und in entsprechende Datenpunkte schreibt, oder Du verwendest dafür eigens geschriebene NodeRed Nodes wie so was:

    https://flows.nodered.org/node/node-red-node-serialport

    @beliar_666 sagte in Rasp2 serial überwachen, per mqtt an iobroker übertragen.:

    Mit Serial in passiert eben nichts.

    Das heißt Du hast diese Nodes schon installiert? - Nun dann musst Du ggf. schauen, ob die serielle Schnittstelle überhaupt frei ist oder entsprechende angesprochen werden kann.

    So wie ich sehe - kann man mit der InNode entsprechende serielle Schnittstellen erkennen lassen - muss diese dann aber noch konfigurieren

    0e62585a-f2b4-43cc-bac3-f7e9afdd6bb5-image.png

    Das heißt die serial-port Node muss händisch konfiguriert sein und die serial in Node bezieht sich auf diese.

    So interpretiere ich den Orgnialtext:

    Input
    Reads data from a local serial port.

    Clicking on the search icon will attempt to autodetect serial ports attached to the device, however you many need to manually specify it. COM1, /dev/ttyUSB0, etc

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

    Beliar_666B 1 Antwort Letzte Antwort
    1
    • mickymM mickym

      Nun entweder gibts einen Adapter im iobroker, der Dir die Daten auslesen kann und in entsprechende Datenpunkte schreibt, oder Du verwendest dafür eigens geschriebene NodeRed Nodes wie so was:

      https://flows.nodered.org/node/node-red-node-serialport

      @beliar_666 sagte in Rasp2 serial überwachen, per mqtt an iobroker übertragen.:

      Mit Serial in passiert eben nichts.

      Das heißt Du hast diese Nodes schon installiert? - Nun dann musst Du ggf. schauen, ob die serielle Schnittstelle überhaupt frei ist oder entsprechende angesprochen werden kann.

      So wie ich sehe - kann man mit der InNode entsprechende serielle Schnittstellen erkennen lassen - muss diese dann aber noch konfigurieren

      0e62585a-f2b4-43cc-bac3-f7e9afdd6bb5-image.png

      Das heißt die serial-port Node muss händisch konfiguriert sein und die serial in Node bezieht sich auf diese.

      So interpretiere ich den Orgnialtext:

      Input
      Reads data from a local serial port.

      Clicking on the search icon will attempt to autodetect serial ports attached to the device, however you many need to manually specify it. COM1, /dev/ttyUSB0, etc

      Beliar_666B Offline
      Beliar_666B Offline
      Beliar_666
      schrieb am zuletzt editiert von
      #5

      @mickym Danke! Aaaalso, soweit habe ich das nun:

      Daten werden seriell erfasst und landen nun per Mqtt im Iobroker. Das klappt nun schon mal.

      Aaaber, nun hat mein Datenpunkt keinen eigenen Ordner sondern liegt direkt in mqtt.0. wie bekomme ich das nun in einen Unterordner.

      Und dann wäre da noch eine kosmetische Frage: Ich habe 2 verschiedene Datensätze "1 v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0" und "2 v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2" Die muss ich eh noch parsen, aber wäre es auch irgendwie möglich die schon von vorn herein in unterschiedliche Datenpunkte zu schreiben? Die Ziffern am Anfang sind jeweils die Kennungen der Sender (1 und 2).

      mickymM 1 Antwort Letzte Antwort
      0
      • Beliar_666B Beliar_666

        @mickym Danke! Aaaalso, soweit habe ich das nun:

        Daten werden seriell erfasst und landen nun per Mqtt im Iobroker. Das klappt nun schon mal.

        Aaaber, nun hat mein Datenpunkt keinen eigenen Ordner sondern liegt direkt in mqtt.0. wie bekomme ich das nun in einen Unterordner.

        Und dann wäre da noch eine kosmetische Frage: Ich habe 2 verschiedene Datensätze "1 v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0" und "2 v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2" Die muss ich eh noch parsen, aber wäre es auch irgendwie möglich die schon von vorn herein in unterschiedliche Datenpunkte zu schreiben? Die Ziffern am Anfang sind jeweils die Kennungen der Sender (1 und 2).

        mickymM Online
        mickymM Online
        mickym
        Most Active
        schrieb am zuletzt editiert von mickym
        #6

        @beliar_666 Mach ein Objekt mit Array draus - und dann nutzt Du meinen Subflow bzw. Datennode. ;) Die legt Dir die Struktur nicht im mqtt sondern im iobroker an. das macht aber auch mehr Sinn als über mqtt in iobroker.

        Ich mach das mal schnell für Deine beiden Beispielstrings bevor Du wieder Strings manipulierst. ;)

        c77d5d8d-b428-4907-a08d-487f8ceecf64-image.png

        8e4cfbd5-1a7e-48d5-9e59-d0375153e427-image.png

        Hier der Flow:

        [
           {
               "id": "c3403a60.92fbb8",
               "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 no `msg.top` property is defined, then you will get an error in the following iobroker-out node (key or topic does not exist) - if you append a debug node to the subflow node you will get the message: \n> Please define msg.top as root for the object structure \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 in keine Angabe in msg.top definiert wurde, wird man in der darauffolgenden iobroker-out node den Fehler erhalten, dass kein key oder topic definiert ist. Falls eine debug Node an den Subflow angehängt wirde erhält man folgende Ausgabe:\n> Please define msg.top as root for the object structure ",
               "category": "",
               "in": [
                   {
                       "x": 60,
                       "y": 160,
                       "wires": [
                           {
                               "id": "94876630.f71748"
                           }
                       ]
                   }
               ],
               "out": [
                   {
                       "x": 2280,
                       "y": 260,
                       "wires": [
                           {
                               "id": "74b0b536.02371c",
                               "port": 0
                           },
                           {
                               "id": "ab9b1e85.eea2a",
                               "port": 0
                           }
                       ]
                   }
               ],
               "env": [],
               "color": "#E2D96E",
               "icon": "node-red/batch.svg"
           },
           {
               "id": "eea737e7.7e8fb8",
               "type": "split",
               "z": "c3403a60.92fbb8",
               "name": "split object",
               "splt": "\\n",
               "spltType": "str",
               "arraySplt": 1,
               "arraySpltType": "len",
               "stream": false,
               "addname": "key",
               "x": 1170,
               "y": 160,
               "wires": [
                   [
                       "dc473616.c2b508"
                   ]
               ]
           },
           {
               "id": "dc473616.c2b508",
               "type": "change",
               "z": "c3403a60.92fbb8",
               "name": "add key to topic",
               "rules": [
                   {
                       "t": "set",
                       "p": "stateName",
                       "pt": "msg",
                       "to": "key",
                       "tot": "msg"
                   },
                   {
                       "t": "set",
                       "p": "topic",
                       "pt": "msg",
                       "to": "topic  & '.' & key",
                       "tot": "jsonata"
                   },
                   {
                       "t": "change",
                       "p": "topic",
                       "pt": "msg",
                       "from": " ",
                       "fromt": "str",
                       "to": "_",
                       "tot": "str"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 1360,
               "y": 160,
               "wires": [
                   [
                       "78697695.9a72c8"
                   ]
               ]
           },
           {
               "id": "78697695.9a72c8",
               "type": "switch",
               "z": "c3403a60.92fbb8",
               "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": 1540,
               "y": 160,
               "wires": [
                   [
                       "d839cef8.577f1"
                   ],
                   [
                       "eea737e7.7e8fb8"
                   ],
                   [
                       "bdfdae99.f4d9d"
                   ]
               ]
           },
           {
               "id": "d839cef8.577f1",
               "type": "split",
               "z": "c3403a60.92fbb8",
               "name": "split array",
               "splt": "\\n",
               "spltType": "str",
               "arraySplt": 1,
               "arraySpltType": "len",
               "stream": false,
               "addname": "",
               "x": 580,
               "y": 280,
               "wires": [
                   [
                       "36327f2d.8efc3"
                   ]
               ]
           },
           {
               "id": "36327f2d.8efc3",
               "type": "change",
               "z": "c3403a60.92fbb8",
               "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": 770,
               "y": 280,
               "wires": [
                   [
                       "d8f58d9b.b6a1"
                   ]
               ]
           },
           {
               "id": "74b0b536.02371c",
               "type": "change",
               "z": "c3403a60.92fbb8",
               "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": 1970,
               "y": 240,
               "wires": [
                   []
               ]
           },
           {
               "id": "4cdee7cb.910c38",
               "type": "switch",
               "z": "c3403a60.92fbb8",
               "name": "is type?",
               "property": "payload",
               "propertyType": "msg",
               "rules": [
                   {
                       "t": "istype",
                       "v": "json",
                       "vt": "json"
                   },
                   {
                       "t": "istype",
                       "v": "object",
                       "vt": "object"
                   },
                   {
                       "t": "istype",
                       "v": "array",
                       "vt": "array"
                   },
                   {
                       "t": "else"
                   }
               ],
               "checkall": "true",
               "repair": false,
               "outputs": 4,
               "x": 400,
               "y": 160,
               "wires": [
                   [
                       "c1c41535.17d3b8"
                   ],
                   [
                       "eea737e7.7e8fb8"
                   ],
                   [
                       "d839cef8.577f1"
                   ],
                   [
                       "d8f58d9b.b6a1"
                   ]
               ]
           },
           {
               "id": "c1c41535.17d3b8",
               "type": "json",
               "z": "c3403a60.92fbb8",
               "name": "",
               "property": "payload",
               "action": "",
               "pretty": false,
               "x": 570,
               "y": 120,
               "wires": [
                   [
                       "3ccd67db.375058"
                   ]
               ]
           },
           {
               "id": "bdfdae99.f4d9d",
               "type": "switch",
               "z": "c3403a60.92fbb8",
               "name": "is msg.top != null",
               "property": "top",
               "propertyType": "msg",
               "rules": [
                   {
                       "t": "nnull"
                   },
                   {
                       "t": "null"
                   }
               ],
               "checkall": "true",
               "repair": false,
               "outputs": 2,
               "x": 1750,
               "y": 280,
               "wires": [
                   [
                       "74b0b536.02371c"
                   ],
                   [
                       "7ba7dc21.fdb214"
                   ]
               ]
           },
           {
               "id": "7ba7dc21.fdb214",
               "type": "change",
               "z": "c3403a60.92fbb8",
               "name": "payload = warning",
               "rules": [
                   {
                       "t": "set",
                       "p": "payload",
                       "pt": "msg",
                       "to": "Please define msg.top as root for the object structure",
                       "tot": "str"
                   },
                   {
                       "t": "delete",
                       "p": "topic",
                       "pt": "msg"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 1970,
               "y": 300,
               "wires": [
                   [
                       "ab9b1e85.eea2a"
                   ]
               ]
           },
           {
               "id": "ab9b1e85.eea2a",
               "type": "rbe",
               "z": "c3403a60.92fbb8",
               "name": "",
               "func": "rbe",
               "gap": "",
               "start": "",
               "inout": "out",
               "septopics": true,
               "property": "payload",
               "x": 2130,
               "y": 300,
               "wires": [
                   []
               ]
           },
           {
               "id": "94876630.f71748",
               "type": "change",
               "z": "c3403a60.92fbb8",
               "name": "",
               "rules": [
                   {
                       "t": "delete",
                       "p": "topic",
                       "pt": "msg"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 210,
               "y": 160,
               "wires": [
                   [
                       "4cdee7cb.910c38"
                   ]
               ]
           },
           {
               "id": "3ccd67db.375058",
               "type": "switch",
               "z": "c3403a60.92fbb8",
               "name": "is array?",
               "property": "payload",
               "propertyType": "msg",
               "rules": [
                   {
                       "t": "istype",
                       "v": "array",
                       "vt": "array"
                   },
                   {
                       "t": "else"
                   }
               ],
               "checkall": "true",
               "repair": false,
               "outputs": 2,
               "x": 700,
               "y": 120,
               "wires": [
                   [
                       "d839cef8.577f1"
                   ],
                   [
                       "eea737e7.7e8fb8"
                   ]
               ]
           },
           {
               "id": "80dde279.c28ec",
               "type": "comment",
               "z": "c3403a60.92fbb8",
               "name": "Array",
               "info": "",
               "x": 400,
               "y": 280,
               "wires": []
           },
           {
               "id": "95ee816e.68a16",
               "type": "comment",
               "z": "c3403a60.92fbb8",
               "name": "object",
               "info": "",
               "x": 1140,
               "y": 100,
               "wires": []
           },
           {
               "id": "d8f58d9b.b6a1",
               "type": "switch",
               "z": "c3403a60.92fbb8",
               "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": 960,
               "y": 280,
               "wires": [
                   [
                       "eea737e7.7e8fb8"
                   ],
                   [
                       "d839cef8.577f1"
                   ],
                   [
                       "bdfdae99.f4d9d"
                   ]
               ]
           },
           {
               "id": "1b10b0fb.73ecff",
               "type": "inject",
               "z": "6e170384.60c96c",
               "name": "Datensatz 1",
               "props": [
                   {
                       "p": "payload"
                   }
               ],
               "repeat": "",
               "crontab": "",
               "once": false,
               "onceDelay": 0.1,
               "topic": "",
               "payload": "v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0",
               "payloadType": "str",
               "x": 1670,
               "y": 4780,
               "wires": [
                   [
                       "3b9a6fa9.037d4"
                   ]
               ]
           },
           {
               "id": "a253d1f1.67cc1",
               "type": "inject",
               "z": "6e170384.60c96c",
               "name": "Datensatz 2",
               "props": [
                   {
                       "p": "payload"
                   }
               ],
               "repeat": "",
               "crontab": "",
               "once": false,
               "onceDelay": 0.1,
               "topic": "",
               "payload": "v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2",
               "payloadType": "str",
               "x": 1670,
               "y": 4840,
               "wires": [
                   [
                       "5f386be8.935b14"
                   ]
               ]
           },
           {
               "id": "3b9a6fa9.037d4",
               "type": "change",
               "z": "6e170384.60c96c",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "payload",
                       "pt": "msg",
                       "to": "$split(payload, '&')\t",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 1870,
               "y": 4780,
               "wires": [
                   [
                       "9c340f0e.d5f03"
                   ]
               ]
           },
           {
               "id": "9c340f0e.d5f03",
               "type": "split",
               "z": "6e170384.60c96c",
               "name": "",
               "splt": "\\n",
               "spltType": "str",
               "arraySplt": 1,
               "arraySpltType": "len",
               "stream": false,
               "addname": "",
               "x": 2060,
               "y": 4780,
               "wires": [
                   [
                       "c388497e.dbcb38"
                   ]
               ]
           },
           {
               "id": "c388497e.dbcb38",
               "type": "change",
               "z": "6e170384.60c96c",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "topic",
                       "pt": "msg",
                       "to": "payload",
                       "tot": "msg"
                   },
                   {
                       "t": "change",
                       "p": "topic",
                       "pt": "msg",
                       "from": "(.*)=.*",
                       "fromt": "re",
                       "to": "$1",
                       "tot": "str"
                   },
                   {
                       "t": "change",
                       "p": "payload",
                       "pt": "msg",
                       "from": ".*=(.*)",
                       "fromt": "re",
                       "to": "$1",
                       "tot": "str"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 2240,
               "y": 4780,
               "wires": [
                   [
                       "8170ee69.17c9f"
                   ]
               ]
           },
           {
               "id": "8170ee69.17c9f",
               "type": "join",
               "z": "6e170384.60c96c",
               "name": "",
               "mode": "custom",
               "build": "object",
               "property": "payload",
               "propertyType": "msg",
               "key": "topic",
               "joiner": "\\n",
               "joinerType": "str",
               "accumulate": false,
               "timeout": "",
               "count": "9",
               "reduceRight": false,
               "reduceExp": "",
               "reduceInit": "",
               "reduceInitType": "",
               "reduceFixup": "",
               "x": 2410,
               "y": 4780,
               "wires": [
                   [
                       "c5ea5e47.11c63"
                   ]
               ]
           },
           {
               "id": "398a01f1.9fc18e",
               "type": "subflow:c3403a60.92fbb8",
               "z": "6e170384.60c96c",
               "name": "",
               "x": 2810,
               "y": 4780,
               "wires": [
                   [
                       "47c9051f.c7c3bc"
                   ]
               ]
           },
           {
               "id": "c5ea5e47.11c63",
               "type": "change",
               "z": "6e170384.60c96c",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "top",
                       "pt": "msg",
                       "to": "Example.Datensatz1",
                       "tot": "str"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 2580,
               "y": 4780,
               "wires": [
                   [
                       "398a01f1.9fc18e"
                   ]
               ]
           },
           {
               "id": "5f386be8.935b14",
               "type": "change",
               "z": "6e170384.60c96c",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "payload",
                       "pt": "msg",
                       "to": "$split(payload, '&')\t",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 1870,
               "y": 4840,
               "wires": [
                   [
                       "b8512a76.8e8fa8"
                   ]
               ]
           },
           {
               "id": "b8512a76.8e8fa8",
               "type": "split",
               "z": "6e170384.60c96c",
               "name": "",
               "splt": "\\n",
               "spltType": "str",
               "arraySplt": 1,
               "arraySpltType": "len",
               "stream": false,
               "addname": "",
               "x": 2060,
               "y": 4840,
               "wires": [
                   [
                       "f78bec21.ce306"
                   ]
               ]
           },
           {
               "id": "f78bec21.ce306",
               "type": "change",
               "z": "6e170384.60c96c",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "topic",
                       "pt": "msg",
                       "to": "payload",
                       "tot": "msg"
                   },
                   {
                       "t": "change",
                       "p": "topic",
                       "pt": "msg",
                       "from": "(.*)=.*",
                       "fromt": "re",
                       "to": "$1",
                       "tot": "str"
                   },
                   {
                       "t": "change",
                       "p": "payload",
                       "pt": "msg",
                       "from": ".*=(.*)",
                       "fromt": "re",
                       "to": "$1",
                       "tot": "str"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 2240,
               "y": 4840,
               "wires": [
                   [
                       "8d025386.2461b"
                   ]
               ]
           },
           {
               "id": "8d025386.2461b",
               "type": "join",
               "z": "6e170384.60c96c",
               "name": "",
               "mode": "custom",
               "build": "object",
               "property": "payload",
               "propertyType": "msg",
               "key": "topic",
               "joiner": "\\n",
               "joinerType": "str",
               "accumulate": false,
               "timeout": "",
               "count": "9",
               "reduceRight": false,
               "reduceExp": "",
               "reduceInit": "",
               "reduceInitType": "",
               "reduceFixup": "",
               "x": 2410,
               "y": 4840,
               "wires": [
                   [
                       "2e0613d6.21e6cc"
                   ]
               ]
           },
           {
               "id": "49a3d467.0b096c",
               "type": "subflow:c3403a60.92fbb8",
               "z": "6e170384.60c96c",
               "name": "",
               "x": 2810,
               "y": 4840,
               "wires": [
                   [
                       "47c9051f.c7c3bc"
                   ]
               ]
           },
           {
               "id": "2e0613d6.21e6cc",
               "type": "change",
               "z": "6e170384.60c96c",
               "name": "",
               "rules": [
                   {
                       "t": "set",
                       "p": "top",
                       "pt": "msg",
                       "to": "Example.Datensatz2",
                       "tot": "str"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 2580,
               "y": 4840,
               "wires": [
                   [
                       "49a3d467.0b096c"
                   ]
               ]
           },
           {
               "id": "47c9051f.c7c3bc",
               "type": "ioBroker out",
               "z": "6e170384.60c96c",
               "name": "",
               "topic": "",
               "ack": "true",
               "autoCreate": "true",
               "stateName": "",
               "role": "",
               "payloadType": "",
               "readonly": "",
               "stateUnit": "",
               "stateMin": "",
               "stateMax": "",
               "x": 3060,
               "y": 4800,
               "wires": []
           }
        ]
        

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

        Beliar_666B 1 Antwort Letzte Antwort
        1
        • mickymM mickym

          @beliar_666 Mach ein Objekt mit Array draus - und dann nutzt Du meinen Subflow bzw. Datennode. ;) Die legt Dir die Struktur nicht im mqtt sondern im iobroker an. das macht aber auch mehr Sinn als über mqtt in iobroker.

          Ich mach das mal schnell für Deine beiden Beispielstrings bevor Du wieder Strings manipulierst. ;)

          c77d5d8d-b428-4907-a08d-487f8ceecf64-image.png

          8e4cfbd5-1a7e-48d5-9e59-d0375153e427-image.png

          Hier der Flow:

          [
             {
                 "id": "c3403a60.92fbb8",
                 "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 no `msg.top` property is defined, then you will get an error in the following iobroker-out node (key or topic does not exist) - if you append a debug node to the subflow node you will get the message: \n> Please define msg.top as root for the object structure \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 in keine Angabe in msg.top definiert wurde, wird man in der darauffolgenden iobroker-out node den Fehler erhalten, dass kein key oder topic definiert ist. Falls eine debug Node an den Subflow angehängt wirde erhält man folgende Ausgabe:\n> Please define msg.top as root for the object structure ",
                 "category": "",
                 "in": [
                     {
                         "x": 60,
                         "y": 160,
                         "wires": [
                             {
                                 "id": "94876630.f71748"
                             }
                         ]
                     }
                 ],
                 "out": [
                     {
                         "x": 2280,
                         "y": 260,
                         "wires": [
                             {
                                 "id": "74b0b536.02371c",
                                 "port": 0
                             },
                             {
                                 "id": "ab9b1e85.eea2a",
                                 "port": 0
                             }
                         ]
                     }
                 ],
                 "env": [],
                 "color": "#E2D96E",
                 "icon": "node-red/batch.svg"
             },
             {
                 "id": "eea737e7.7e8fb8",
                 "type": "split",
                 "z": "c3403a60.92fbb8",
                 "name": "split object",
                 "splt": "\\n",
                 "spltType": "str",
                 "arraySplt": 1,
                 "arraySpltType": "len",
                 "stream": false,
                 "addname": "key",
                 "x": 1170,
                 "y": 160,
                 "wires": [
                     [
                         "dc473616.c2b508"
                     ]
                 ]
             },
             {
                 "id": "dc473616.c2b508",
                 "type": "change",
                 "z": "c3403a60.92fbb8",
                 "name": "add key to topic",
                 "rules": [
                     {
                         "t": "set",
                         "p": "stateName",
                         "pt": "msg",
                         "to": "key",
                         "tot": "msg"
                     },
                     {
                         "t": "set",
                         "p": "topic",
                         "pt": "msg",
                         "to": "topic  & '.' & key",
                         "tot": "jsonata"
                     },
                     {
                         "t": "change",
                         "p": "topic",
                         "pt": "msg",
                         "from": " ",
                         "fromt": "str",
                         "to": "_",
                         "tot": "str"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 1360,
                 "y": 160,
                 "wires": [
                     [
                         "78697695.9a72c8"
                     ]
                 ]
             },
             {
                 "id": "78697695.9a72c8",
                 "type": "switch",
                 "z": "c3403a60.92fbb8",
                 "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": 1540,
                 "y": 160,
                 "wires": [
                     [
                         "d839cef8.577f1"
                     ],
                     [
                         "eea737e7.7e8fb8"
                     ],
                     [
                         "bdfdae99.f4d9d"
                     ]
                 ]
             },
             {
                 "id": "d839cef8.577f1",
                 "type": "split",
                 "z": "c3403a60.92fbb8",
                 "name": "split array",
                 "splt": "\\n",
                 "spltType": "str",
                 "arraySplt": 1,
                 "arraySpltType": "len",
                 "stream": false,
                 "addname": "",
                 "x": 580,
                 "y": 280,
                 "wires": [
                     [
                         "36327f2d.8efc3"
                     ]
                 ]
             },
             {
                 "id": "36327f2d.8efc3",
                 "type": "change",
                 "z": "c3403a60.92fbb8",
                 "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": 770,
                 "y": 280,
                 "wires": [
                     [
                         "d8f58d9b.b6a1"
                     ]
                 ]
             },
             {
                 "id": "74b0b536.02371c",
                 "type": "change",
                 "z": "c3403a60.92fbb8",
                 "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": 1970,
                 "y": 240,
                 "wires": [
                     []
                 ]
             },
             {
                 "id": "4cdee7cb.910c38",
                 "type": "switch",
                 "z": "c3403a60.92fbb8",
                 "name": "is type?",
                 "property": "payload",
                 "propertyType": "msg",
                 "rules": [
                     {
                         "t": "istype",
                         "v": "json",
                         "vt": "json"
                     },
                     {
                         "t": "istype",
                         "v": "object",
                         "vt": "object"
                     },
                     {
                         "t": "istype",
                         "v": "array",
                         "vt": "array"
                     },
                     {
                         "t": "else"
                     }
                 ],
                 "checkall": "true",
                 "repair": false,
                 "outputs": 4,
                 "x": 400,
                 "y": 160,
                 "wires": [
                     [
                         "c1c41535.17d3b8"
                     ],
                     [
                         "eea737e7.7e8fb8"
                     ],
                     [
                         "d839cef8.577f1"
                     ],
                     [
                         "d8f58d9b.b6a1"
                     ]
                 ]
             },
             {
                 "id": "c1c41535.17d3b8",
                 "type": "json",
                 "z": "c3403a60.92fbb8",
                 "name": "",
                 "property": "payload",
                 "action": "",
                 "pretty": false,
                 "x": 570,
                 "y": 120,
                 "wires": [
                     [
                         "3ccd67db.375058"
                     ]
                 ]
             },
             {
                 "id": "bdfdae99.f4d9d",
                 "type": "switch",
                 "z": "c3403a60.92fbb8",
                 "name": "is msg.top != null",
                 "property": "top",
                 "propertyType": "msg",
                 "rules": [
                     {
                         "t": "nnull"
                     },
                     {
                         "t": "null"
                     }
                 ],
                 "checkall": "true",
                 "repair": false,
                 "outputs": 2,
                 "x": 1750,
                 "y": 280,
                 "wires": [
                     [
                         "74b0b536.02371c"
                     ],
                     [
                         "7ba7dc21.fdb214"
                     ]
                 ]
             },
             {
                 "id": "7ba7dc21.fdb214",
                 "type": "change",
                 "z": "c3403a60.92fbb8",
                 "name": "payload = warning",
                 "rules": [
                     {
                         "t": "set",
                         "p": "payload",
                         "pt": "msg",
                         "to": "Please define msg.top as root for the object structure",
                         "tot": "str"
                     },
                     {
                         "t": "delete",
                         "p": "topic",
                         "pt": "msg"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 1970,
                 "y": 300,
                 "wires": [
                     [
                         "ab9b1e85.eea2a"
                     ]
                 ]
             },
             {
                 "id": "ab9b1e85.eea2a",
                 "type": "rbe",
                 "z": "c3403a60.92fbb8",
                 "name": "",
                 "func": "rbe",
                 "gap": "",
                 "start": "",
                 "inout": "out",
                 "septopics": true,
                 "property": "payload",
                 "x": 2130,
                 "y": 300,
                 "wires": [
                     []
                 ]
             },
             {
                 "id": "94876630.f71748",
                 "type": "change",
                 "z": "c3403a60.92fbb8",
                 "name": "",
                 "rules": [
                     {
                         "t": "delete",
                         "p": "topic",
                         "pt": "msg"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 210,
                 "y": 160,
                 "wires": [
                     [
                         "4cdee7cb.910c38"
                     ]
                 ]
             },
             {
                 "id": "3ccd67db.375058",
                 "type": "switch",
                 "z": "c3403a60.92fbb8",
                 "name": "is array?",
                 "property": "payload",
                 "propertyType": "msg",
                 "rules": [
                     {
                         "t": "istype",
                         "v": "array",
                         "vt": "array"
                     },
                     {
                         "t": "else"
                     }
                 ],
                 "checkall": "true",
                 "repair": false,
                 "outputs": 2,
                 "x": 700,
                 "y": 120,
                 "wires": [
                     [
                         "d839cef8.577f1"
                     ],
                     [
                         "eea737e7.7e8fb8"
                     ]
                 ]
             },
             {
                 "id": "80dde279.c28ec",
                 "type": "comment",
                 "z": "c3403a60.92fbb8",
                 "name": "Array",
                 "info": "",
                 "x": 400,
                 "y": 280,
                 "wires": []
             },
             {
                 "id": "95ee816e.68a16",
                 "type": "comment",
                 "z": "c3403a60.92fbb8",
                 "name": "object",
                 "info": "",
                 "x": 1140,
                 "y": 100,
                 "wires": []
             },
             {
                 "id": "d8f58d9b.b6a1",
                 "type": "switch",
                 "z": "c3403a60.92fbb8",
                 "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": 960,
                 "y": 280,
                 "wires": [
                     [
                         "eea737e7.7e8fb8"
                     ],
                     [
                         "d839cef8.577f1"
                     ],
                     [
                         "bdfdae99.f4d9d"
                     ]
                 ]
             },
             {
                 "id": "1b10b0fb.73ecff",
                 "type": "inject",
                 "z": "6e170384.60c96c",
                 "name": "Datensatz 1",
                 "props": [
                     {
                         "p": "payload"
                     }
                 ],
                 "repeat": "",
                 "crontab": "",
                 "once": false,
                 "onceDelay": 0.1,
                 "topic": "",
                 "payload": "v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0",
                 "payloadType": "str",
                 "x": 1670,
                 "y": 4780,
                 "wires": [
                     [
                         "3b9a6fa9.037d4"
                     ]
                 ]
             },
             {
                 "id": "a253d1f1.67cc1",
                 "type": "inject",
                 "z": "6e170384.60c96c",
                 "name": "Datensatz 2",
                 "props": [
                     {
                         "p": "payload"
                     }
                 ],
                 "repeat": "",
                 "crontab": "",
                 "once": false,
                 "onceDelay": 0.1,
                 "topic": "",
                 "payload": "v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2",
                 "payloadType": "str",
                 "x": 1670,
                 "y": 4840,
                 "wires": [
                     [
                         "5f386be8.935b14"
                     ]
                 ]
             },
             {
                 "id": "3b9a6fa9.037d4",
                 "type": "change",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "rules": [
                     {
                         "t": "set",
                         "p": "payload",
                         "pt": "msg",
                         "to": "$split(payload, '&')\t",
                         "tot": "jsonata"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 1870,
                 "y": 4780,
                 "wires": [
                     [
                         "9c340f0e.d5f03"
                     ]
                 ]
             },
             {
                 "id": "9c340f0e.d5f03",
                 "type": "split",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "splt": "\\n",
                 "spltType": "str",
                 "arraySplt": 1,
                 "arraySpltType": "len",
                 "stream": false,
                 "addname": "",
                 "x": 2060,
                 "y": 4780,
                 "wires": [
                     [
                         "c388497e.dbcb38"
                     ]
                 ]
             },
             {
                 "id": "c388497e.dbcb38",
                 "type": "change",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "rules": [
                     {
                         "t": "set",
                         "p": "topic",
                         "pt": "msg",
                         "to": "payload",
                         "tot": "msg"
                     },
                     {
                         "t": "change",
                         "p": "topic",
                         "pt": "msg",
                         "from": "(.*)=.*",
                         "fromt": "re",
                         "to": "$1",
                         "tot": "str"
                     },
                     {
                         "t": "change",
                         "p": "payload",
                         "pt": "msg",
                         "from": ".*=(.*)",
                         "fromt": "re",
                         "to": "$1",
                         "tot": "str"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 2240,
                 "y": 4780,
                 "wires": [
                     [
                         "8170ee69.17c9f"
                     ]
                 ]
             },
             {
                 "id": "8170ee69.17c9f",
                 "type": "join",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "mode": "custom",
                 "build": "object",
                 "property": "payload",
                 "propertyType": "msg",
                 "key": "topic",
                 "joiner": "\\n",
                 "joinerType": "str",
                 "accumulate": false,
                 "timeout": "",
                 "count": "9",
                 "reduceRight": false,
                 "reduceExp": "",
                 "reduceInit": "",
                 "reduceInitType": "",
                 "reduceFixup": "",
                 "x": 2410,
                 "y": 4780,
                 "wires": [
                     [
                         "c5ea5e47.11c63"
                     ]
                 ]
             },
             {
                 "id": "398a01f1.9fc18e",
                 "type": "subflow:c3403a60.92fbb8",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "x": 2810,
                 "y": 4780,
                 "wires": [
                     [
                         "47c9051f.c7c3bc"
                     ]
                 ]
             },
             {
                 "id": "c5ea5e47.11c63",
                 "type": "change",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "rules": [
                     {
                         "t": "set",
                         "p": "top",
                         "pt": "msg",
                         "to": "Example.Datensatz1",
                         "tot": "str"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 2580,
                 "y": 4780,
                 "wires": [
                     [
                         "398a01f1.9fc18e"
                     ]
                 ]
             },
             {
                 "id": "5f386be8.935b14",
                 "type": "change",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "rules": [
                     {
                         "t": "set",
                         "p": "payload",
                         "pt": "msg",
                         "to": "$split(payload, '&')\t",
                         "tot": "jsonata"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 1870,
                 "y": 4840,
                 "wires": [
                     [
                         "b8512a76.8e8fa8"
                     ]
                 ]
             },
             {
                 "id": "b8512a76.8e8fa8",
                 "type": "split",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "splt": "\\n",
                 "spltType": "str",
                 "arraySplt": 1,
                 "arraySpltType": "len",
                 "stream": false,
                 "addname": "",
                 "x": 2060,
                 "y": 4840,
                 "wires": [
                     [
                         "f78bec21.ce306"
                     ]
                 ]
             },
             {
                 "id": "f78bec21.ce306",
                 "type": "change",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "rules": [
                     {
                         "t": "set",
                         "p": "topic",
                         "pt": "msg",
                         "to": "payload",
                         "tot": "msg"
                     },
                     {
                         "t": "change",
                         "p": "topic",
                         "pt": "msg",
                         "from": "(.*)=.*",
                         "fromt": "re",
                         "to": "$1",
                         "tot": "str"
                     },
                     {
                         "t": "change",
                         "p": "payload",
                         "pt": "msg",
                         "from": ".*=(.*)",
                         "fromt": "re",
                         "to": "$1",
                         "tot": "str"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 2240,
                 "y": 4840,
                 "wires": [
                     [
                         "8d025386.2461b"
                     ]
                 ]
             },
             {
                 "id": "8d025386.2461b",
                 "type": "join",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "mode": "custom",
                 "build": "object",
                 "property": "payload",
                 "propertyType": "msg",
                 "key": "topic",
                 "joiner": "\\n",
                 "joinerType": "str",
                 "accumulate": false,
                 "timeout": "",
                 "count": "9",
                 "reduceRight": false,
                 "reduceExp": "",
                 "reduceInit": "",
                 "reduceInitType": "",
                 "reduceFixup": "",
                 "x": 2410,
                 "y": 4840,
                 "wires": [
                     [
                         "2e0613d6.21e6cc"
                     ]
                 ]
             },
             {
                 "id": "49a3d467.0b096c",
                 "type": "subflow:c3403a60.92fbb8",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "x": 2810,
                 "y": 4840,
                 "wires": [
                     [
                         "47c9051f.c7c3bc"
                     ]
                 ]
             },
             {
                 "id": "2e0613d6.21e6cc",
                 "type": "change",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "rules": [
                     {
                         "t": "set",
                         "p": "top",
                         "pt": "msg",
                         "to": "Example.Datensatz2",
                         "tot": "str"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 2580,
                 "y": 4840,
                 "wires": [
                     [
                         "49a3d467.0b096c"
                     ]
                 ]
             },
             {
                 "id": "47c9051f.c7c3bc",
                 "type": "ioBroker out",
                 "z": "6e170384.60c96c",
                 "name": "",
                 "topic": "",
                 "ack": "true",
                 "autoCreate": "true",
                 "stateName": "",
                 "role": "",
                 "payloadType": "",
                 "readonly": "",
                 "stateUnit": "",
                 "stateMin": "",
                 "stateMax": "",
                 "x": 3060,
                 "y": 4800,
                 "wires": []
             }
          ]
          

          Beliar_666B Offline
          Beliar_666B Offline
          Beliar_666
          schrieb am zuletzt editiert von
          #7

          @mickym Danke, aber entweder stehe ich grad wieder auf dem Schlauch, oder wir haben etwas aneinander vorbei geredet.

          Mein Node Red läuft ausserhalb vom IoBroker auf einem seperaten Pi, der sonst nichts mit IoBroker zu tun hat.
          Den Funkempfänger kann ich so ohne weiteres nämlich nicht an die VM in der IoBroker läuft anbinden.

          Und wenn ich das jetzt richtig interpretiere dann ist dein Flow für die Node Red Instanz in IOBroker, oder?

          mickymM 1 Antwort Letzte Antwort
          0
          • Beliar_666B Beliar_666

            @mickym Danke, aber entweder stehe ich grad wieder auf dem Schlauch, oder wir haben etwas aneinander vorbei geredet.

            Mein Node Red läuft ausserhalb vom IoBroker auf einem seperaten Pi, der sonst nichts mit IoBroker zu tun hat.
            Den Funkempfänger kann ich so ohne weiteres nämlich nicht an die VM in der IoBroker läuft anbinden.

            Und wenn ich das jetzt richtig interpretiere dann ist dein Flow für die Node Red Instanz in IOBroker, oder?

            mickymM Online
            mickymM Online
            mickym
            Most Active
            schrieb am zuletzt editiert von mickym
            #8

            @beliar_666 sagte in Rasp2 serial überwachen, per mqtt an iobroker übertragen.:

            Und wenn ich das jetzt richtig interpretiere dann ist dein Flow für die Node Red Instanz in IOBroker, oder?

            JA - war es! - aber hab ihn nun geändert, sodass er auch auf einem Standalone Node-Red laufen müsste. ;)

            So habe den NodeRed Flow etwas abgeändert und die iob Pfade in mqtt Pfade gewandelt:

            09b07029-119e-4da1-bf45-9a041fcd079b-image.png

            Damit musst Du nur noch statt der Debug Node eine mqtt Node dran hängen. Die Ordnerstruktur gibst Du in der msg.top ein - bevor der Subflow gestartet wird.

            [
                {
                    "id": "c3403a60.92fbb8",
                    "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 no `msg.top` property is defined, then you will get an error in the following iobroker-out node (key or topic does not exist) - if you append a debug node to the subflow node you will get the message: \n> Please define msg.top as root for the object structure \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 in keine Angabe in msg.top definiert wurde, wird man in der darauffolgenden iobroker-out node den Fehler erhalten, dass kein key oder topic definiert ist. Falls eine debug Node an den Subflow angehängt wirde erhält man folgende Ausgabe:\n> Please define msg.top as root for the object structure ",
                    "category": "",
                    "in": [
                        {
                            "x": 60,
                            "y": 160,
                            "wires": [
                                {
                                    "id": "94876630.f71748"
                                }
                            ]
                        }
                    ],
                    "out": [
                        {
                            "x": 2280,
                            "y": 260,
                            "wires": [
                                {
                                    "id": "74b0b536.02371c",
                                    "port": 0
                                },
                                {
                                    "id": "ab9b1e85.eea2a",
                                    "port": 0
                                }
                            ]
                        }
                    ],
                    "env": [],
                    "color": "#E2D96E",
                    "icon": "node-red/batch.svg"
                },
                {
                    "id": "eea737e7.7e8fb8",
                    "type": "split",
                    "z": "c3403a60.92fbb8",
                    "name": "split object",
                    "splt": "\\n",
                    "spltType": "str",
                    "arraySplt": 1,
                    "arraySpltType": "len",
                    "stream": false,
                    "addname": "key",
                    "x": 1170,
                    "y": 160,
                    "wires": [
                        [
                            "dc473616.c2b508"
                        ]
                    ]
                },
                {
                    "id": "dc473616.c2b508",
                    "type": "change",
                    "z": "c3403a60.92fbb8",
                    "name": "add key to topic",
                    "rules": [
                        {
                            "t": "set",
                            "p": "stateName",
                            "pt": "msg",
                            "to": "key",
                            "tot": "msg"
                        },
                        {
                            "t": "set",
                            "p": "topic",
                            "pt": "msg",
                            "to": "topic  & '.' & key",
                            "tot": "jsonata"
                        },
                        {
                            "t": "change",
                            "p": "topic",
                            "pt": "msg",
                            "from": " ",
                            "fromt": "str",
                            "to": "_",
                            "tot": "str"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 1360,
                    "y": 160,
                    "wires": [
                        [
                            "78697695.9a72c8"
                        ]
                    ]
                },
                {
                    "id": "78697695.9a72c8",
                    "type": "switch",
                    "z": "c3403a60.92fbb8",
                    "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": 1540,
                    "y": 160,
                    "wires": [
                        [
                            "d839cef8.577f1"
                        ],
                        [
                            "eea737e7.7e8fb8"
                        ],
                        [
                            "bdfdae99.f4d9d"
                        ]
                    ]
                },
                {
                    "id": "d839cef8.577f1",
                    "type": "split",
                    "z": "c3403a60.92fbb8",
                    "name": "split array",
                    "splt": "\\n",
                    "spltType": "str",
                    "arraySplt": 1,
                    "arraySpltType": "len",
                    "stream": false,
                    "addname": "",
                    "x": 580,
                    "y": 280,
                    "wires": [
                        [
                            "36327f2d.8efc3"
                        ]
                    ]
                },
                {
                    "id": "36327f2d.8efc3",
                    "type": "change",
                    "z": "c3403a60.92fbb8",
                    "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": 770,
                    "y": 280,
                    "wires": [
                        [
                            "d8f58d9b.b6a1"
                        ]
                    ]
                },
                {
                    "id": "74b0b536.02371c",
                    "type": "change",
                    "z": "c3403a60.92fbb8",
                    "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": 1970,
                    "y": 240,
                    "wires": [
                        []
                    ]
                },
                {
                    "id": "4cdee7cb.910c38",
                    "type": "switch",
                    "z": "c3403a60.92fbb8",
                    "name": "is type?",
                    "property": "payload",
                    "propertyType": "msg",
                    "rules": [
                        {
                            "t": "istype",
                            "v": "json",
                            "vt": "json"
                        },
                        {
                            "t": "istype",
                            "v": "object",
                            "vt": "object"
                        },
                        {
                            "t": "istype",
                            "v": "array",
                            "vt": "array"
                        },
                        {
                            "t": "else"
                        }
                    ],
                    "checkall": "true",
                    "repair": false,
                    "outputs": 4,
                    "x": 400,
                    "y": 160,
                    "wires": [
                        [
                            "c1c41535.17d3b8"
                        ],
                        [
                            "eea737e7.7e8fb8"
                        ],
                        [
                            "d839cef8.577f1"
                        ],
                        [
                            "d8f58d9b.b6a1"
                        ]
                    ]
                },
                {
                    "id": "c1c41535.17d3b8",
                    "type": "json",
                    "z": "c3403a60.92fbb8",
                    "name": "",
                    "property": "payload",
                    "action": "",
                    "pretty": false,
                    "x": 570,
                    "y": 120,
                    "wires": [
                        [
                            "3ccd67db.375058"
                        ]
                    ]
                },
                {
                    "id": "bdfdae99.f4d9d",
                    "type": "switch",
                    "z": "c3403a60.92fbb8",
                    "name": "is msg.top != null",
                    "property": "top",
                    "propertyType": "msg",
                    "rules": [
                        {
                            "t": "nnull"
                        },
                        {
                            "t": "null"
                        }
                    ],
                    "checkall": "true",
                    "repair": false,
                    "outputs": 2,
                    "x": 1750,
                    "y": 280,
                    "wires": [
                        [
                            "74b0b536.02371c"
                        ],
                        [
                            "7ba7dc21.fdb214"
                        ]
                    ]
                },
                {
                    "id": "7ba7dc21.fdb214",
                    "type": "change",
                    "z": "c3403a60.92fbb8",
                    "name": "payload = warning",
                    "rules": [
                        {
                            "t": "set",
                            "p": "payload",
                            "pt": "msg",
                            "to": "Please define msg.top as root for the object structure",
                            "tot": "str"
                        },
                        {
                            "t": "delete",
                            "p": "topic",
                            "pt": "msg"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 1970,
                    "y": 300,
                    "wires": [
                        [
                            "ab9b1e85.eea2a"
                        ]
                    ]
                },
                {
                    "id": "ab9b1e85.eea2a",
                    "type": "rbe",
                    "z": "c3403a60.92fbb8",
                    "name": "",
                    "func": "rbe",
                    "gap": "",
                    "start": "",
                    "inout": "out",
                    "septopics": true,
                    "property": "payload",
                    "x": 2130,
                    "y": 300,
                    "wires": [
                        []
                    ]
                },
                {
                    "id": "94876630.f71748",
                    "type": "change",
                    "z": "c3403a60.92fbb8",
                    "name": "",
                    "rules": [
                        {
                            "t": "delete",
                            "p": "topic",
                            "pt": "msg"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 210,
                    "y": 160,
                    "wires": [
                        [
                            "4cdee7cb.910c38"
                        ]
                    ]
                },
                {
                    "id": "3ccd67db.375058",
                    "type": "switch",
                    "z": "c3403a60.92fbb8",
                    "name": "is array?",
                    "property": "payload",
                    "propertyType": "msg",
                    "rules": [
                        {
                            "t": "istype",
                            "v": "array",
                            "vt": "array"
                        },
                        {
                            "t": "else"
                        }
                    ],
                    "checkall": "true",
                    "repair": false,
                    "outputs": 2,
                    "x": 700,
                    "y": 120,
                    "wires": [
                        [
                            "d839cef8.577f1"
                        ],
                        [
                            "eea737e7.7e8fb8"
                        ]
                    ]
                },
                {
                    "id": "80dde279.c28ec",
                    "type": "comment",
                    "z": "c3403a60.92fbb8",
                    "name": "Array",
                    "info": "",
                    "x": 400,
                    "y": 280,
                    "wires": []
                },
                {
                    "id": "95ee816e.68a16",
                    "type": "comment",
                    "z": "c3403a60.92fbb8",
                    "name": "object",
                    "info": "",
                    "x": 1140,
                    "y": 100,
                    "wires": []
                },
                {
                    "id": "d8f58d9b.b6a1",
                    "type": "switch",
                    "z": "c3403a60.92fbb8",
                    "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": 960,
                    "y": 280,
                    "wires": [
                        [
                            "eea737e7.7e8fb8"
                        ],
                        [
                            "d839cef8.577f1"
                        ],
                        [
                            "bdfdae99.f4d9d"
                        ]
                    ]
                },
                {
                    "id": "b5789e69.e3a02",
                    "type": "inject",
                    "z": "6e170384.60c96c",
                    "name": "Datensatz 1",
                    "props": [
                        {
                            "p": "payload"
                        }
                    ],
                    "repeat": "",
                    "crontab": "",
                    "once": false,
                    "onceDelay": 0.1,
                    "topic": "",
                    "payload": "v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0",
                    "payloadType": "str",
                    "x": 2670,
                    "y": 3740,
                    "wires": [
                        [
                            "d378241f.a87128"
                        ]
                    ]
                },
                {
                    "id": "69bd20a3.1522e",
                    "type": "inject",
                    "z": "6e170384.60c96c",
                    "name": "Datensatz 2",
                    "props": [
                        {
                            "p": "payload"
                        }
                    ],
                    "repeat": "",
                    "crontab": "",
                    "once": false,
                    "onceDelay": 0.1,
                    "topic": "",
                    "payload": "v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2",
                    "payloadType": "str",
                    "x": 2670,
                    "y": 3800,
                    "wires": [
                        [
                            "a360e97c.537608"
                        ]
                    ]
                },
                {
                    "id": "d378241f.a87128",
                    "type": "change",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "rules": [
                        {
                            "t": "set",
                            "p": "payload",
                            "pt": "msg",
                            "to": "$split(payload, '&')\t",
                            "tot": "jsonata"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 2870,
                    "y": 3740,
                    "wires": [
                        [
                            "34e1631d.13947c"
                        ]
                    ]
                },
                {
                    "id": "34e1631d.13947c",
                    "type": "split",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "splt": "\\n",
                    "spltType": "str",
                    "arraySplt": 1,
                    "arraySpltType": "len",
                    "stream": false,
                    "addname": "",
                    "x": 3060,
                    "y": 3740,
                    "wires": [
                        [
                            "c8b3a65e.8c7188"
                        ]
                    ]
                },
                {
                    "id": "c8b3a65e.8c7188",
                    "type": "change",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "rules": [
                        {
                            "t": "set",
                            "p": "topic",
                            "pt": "msg",
                            "to": "payload",
                            "tot": "msg"
                        },
                        {
                            "t": "change",
                            "p": "topic",
                            "pt": "msg",
                            "from": "(.*)=.*",
                            "fromt": "re",
                            "to": "$1",
                            "tot": "str"
                        },
                        {
                            "t": "change",
                            "p": "payload",
                            "pt": "msg",
                            "from": ".*=(.*)",
                            "fromt": "re",
                            "to": "$1",
                            "tot": "str"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 3240,
                    "y": 3740,
                    "wires": [
                        [
                            "2d7ef1a3.2b16fe"
                        ]
                    ]
                },
                {
                    "id": "2d7ef1a3.2b16fe",
                    "type": "join",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "mode": "custom",
                    "build": "object",
                    "property": "payload",
                    "propertyType": "msg",
                    "key": "topic",
                    "joiner": "\\n",
                    "joinerType": "str",
                    "accumulate": false,
                    "timeout": "",
                    "count": "9",
                    "reduceRight": false,
                    "reduceExp": "",
                    "reduceInit": "",
                    "reduceInitType": "",
                    "reduceFixup": "",
                    "x": 3410,
                    "y": 3740,
                    "wires": [
                        [
                            "627bea68.682c54"
                        ]
                    ]
                },
                {
                    "id": "7ce06732.dda3d8",
                    "type": "subflow:c3403a60.92fbb8",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "x": 3810,
                    "y": 3740,
                    "wires": [
                        [
                            "4f0801a2.47905"
                        ]
                    ]
                },
                {
                    "id": "627bea68.682c54",
                    "type": "change",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "rules": [
                        {
                            "t": "set",
                            "p": "top",
                            "pt": "msg",
                            "to": "Example.Datensatz1",
                            "tot": "str"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 3580,
                    "y": 3740,
                    "wires": [
                        [
                            "7ce06732.dda3d8"
                        ]
                    ]
                },
                {
                    "id": "a360e97c.537608",
                    "type": "change",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "rules": [
                        {
                            "t": "set",
                            "p": "payload",
                            "pt": "msg",
                            "to": "$split(payload, '&')\t",
                            "tot": "jsonata"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 2870,
                    "y": 3800,
                    "wires": [
                        [
                            "ef6afa0.cca1908"
                        ]
                    ]
                },
                {
                    "id": "ef6afa0.cca1908",
                    "type": "split",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "splt": "\\n",
                    "spltType": "str",
                    "arraySplt": 1,
                    "arraySpltType": "len",
                    "stream": false,
                    "addname": "",
                    "x": 3060,
                    "y": 3800,
                    "wires": [
                        [
                            "7fe229a5.6890e8"
                        ]
                    ]
                },
                {
                    "id": "7fe229a5.6890e8",
                    "type": "change",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "rules": [
                        {
                            "t": "set",
                            "p": "topic",
                            "pt": "msg",
                            "to": "payload",
                            "tot": "msg"
                        },
                        {
                            "t": "change",
                            "p": "topic",
                            "pt": "msg",
                            "from": "(.*)=.*",
                            "fromt": "re",
                            "to": "$1",
                            "tot": "str"
                        },
                        {
                            "t": "change",
                            "p": "payload",
                            "pt": "msg",
                            "from": ".*=(.*)",
                            "fromt": "re",
                            "to": "$1",
                            "tot": "str"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 3240,
                    "y": 3800,
                    "wires": [
                        [
                            "9a198893.f81948"
                        ]
                    ]
                },
                {
                    "id": "9a198893.f81948",
                    "type": "join",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "mode": "custom",
                    "build": "object",
                    "property": "payload",
                    "propertyType": "msg",
                    "key": "topic",
                    "joiner": "\\n",
                    "joinerType": "str",
                    "accumulate": false,
                    "timeout": "",
                    "count": "9",
                    "reduceRight": false,
                    "reduceExp": "",
                    "reduceInit": "",
                    "reduceInitType": "",
                    "reduceFixup": "",
                    "x": 3410,
                    "y": 3800,
                    "wires": [
                        [
                            "fe4fa48a.2ad628"
                        ]
                    ]
                },
                {
                    "id": "2142e352.10597c",
                    "type": "subflow:c3403a60.92fbb8",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "x": 3810,
                    "y": 3800,
                    "wires": [
                        [
                            "4f0801a2.47905"
                        ]
                    ]
                },
                {
                    "id": "fe4fa48a.2ad628",
                    "type": "change",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "rules": [
                        {
                            "t": "set",
                            "p": "top",
                            "pt": "msg",
                            "to": "Example.Datensatz2",
                            "tot": "str"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 3580,
                    "y": 3800,
                    "wires": [
                        [
                            "2142e352.10597c"
                        ]
                    ]
                },
                {
                    "id": "17661ac4.01d545",
                    "type": "debug",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "active": true,
                    "tosidebar": true,
                    "console": false,
                    "tostatus": false,
                    "complete": "false",
                    "statusVal": "",
                    "statusType": "auto",
                    "x": 4250,
                    "y": 3780,
                    "wires": []
                },
                {
                    "id": "4f0801a2.47905",
                    "type": "change",
                    "z": "6e170384.60c96c",
                    "name": "",
                    "rules": [
                        {
                            "t": "change",
                            "p": "topic",
                            "pt": "msg",
                            "from": "0_userdata.0",
                            "fromt": "str",
                            "to": "",
                            "tot": "str"
                        },
                        {
                            "t": "change",
                            "p": "topic",
                            "pt": "msg",
                            "from": ".",
                            "fromt": "str",
                            "to": "/",
                            "tot": "str"
                        }
                    ],
                    "action": "",
                    "property": "",
                    "from": "",
                    "to": "",
                    "reg": false,
                    "x": 4050,
                    "y": 3780,
                    "wires": [
                        [
                            "17661ac4.01d545"
                        ]
                    ]
                }
            ]
            

            Falls Du nicht alle Objekte brauchst - kannst Du ja auch nach der JOIN Node direkt auf die Werte zugreifen. Nach der JOIN NOde hast Du fertige JAVA-Objekte über die zum Beispiel payload.fo auf den einzelnen Wert zugreifst.

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

            Beliar_666B 1 Antwort Letzte Antwort
            1
            • mickymM mickym

              @beliar_666 sagte in Rasp2 serial überwachen, per mqtt an iobroker übertragen.:

              Und wenn ich das jetzt richtig interpretiere dann ist dein Flow für die Node Red Instanz in IOBroker, oder?

              JA - war es! - aber hab ihn nun geändert, sodass er auch auf einem Standalone Node-Red laufen müsste. ;)

              So habe den NodeRed Flow etwas abgeändert und die iob Pfade in mqtt Pfade gewandelt:

              09b07029-119e-4da1-bf45-9a041fcd079b-image.png

              Damit musst Du nur noch statt der Debug Node eine mqtt Node dran hängen. Die Ordnerstruktur gibst Du in der msg.top ein - bevor der Subflow gestartet wird.

              [
                  {
                      "id": "c3403a60.92fbb8",
                      "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 no `msg.top` property is defined, then you will get an error in the following iobroker-out node (key or topic does not exist) - if you append a debug node to the subflow node you will get the message: \n> Please define msg.top as root for the object structure \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 in keine Angabe in msg.top definiert wurde, wird man in der darauffolgenden iobroker-out node den Fehler erhalten, dass kein key oder topic definiert ist. Falls eine debug Node an den Subflow angehängt wirde erhält man folgende Ausgabe:\n> Please define msg.top as root for the object structure ",
                      "category": "",
                      "in": [
                          {
                              "x": 60,
                              "y": 160,
                              "wires": [
                                  {
                                      "id": "94876630.f71748"
                                  }
                              ]
                          }
                      ],
                      "out": [
                          {
                              "x": 2280,
                              "y": 260,
                              "wires": [
                                  {
                                      "id": "74b0b536.02371c",
                                      "port": 0
                                  },
                                  {
                                      "id": "ab9b1e85.eea2a",
                                      "port": 0
                                  }
                              ]
                          }
                      ],
                      "env": [],
                      "color": "#E2D96E",
                      "icon": "node-red/batch.svg"
                  },
                  {
                      "id": "eea737e7.7e8fb8",
                      "type": "split",
                      "z": "c3403a60.92fbb8",
                      "name": "split object",
                      "splt": "\\n",
                      "spltType": "str",
                      "arraySplt": 1,
                      "arraySpltType": "len",
                      "stream": false,
                      "addname": "key",
                      "x": 1170,
                      "y": 160,
                      "wires": [
                          [
                              "dc473616.c2b508"
                          ]
                      ]
                  },
                  {
                      "id": "dc473616.c2b508",
                      "type": "change",
                      "z": "c3403a60.92fbb8",
                      "name": "add key to topic",
                      "rules": [
                          {
                              "t": "set",
                              "p": "stateName",
                              "pt": "msg",
                              "to": "key",
                              "tot": "msg"
                          },
                          {
                              "t": "set",
                              "p": "topic",
                              "pt": "msg",
                              "to": "topic  & '.' & key",
                              "tot": "jsonata"
                          },
                          {
                              "t": "change",
                              "p": "topic",
                              "pt": "msg",
                              "from": " ",
                              "fromt": "str",
                              "to": "_",
                              "tot": "str"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 1360,
                      "y": 160,
                      "wires": [
                          [
                              "78697695.9a72c8"
                          ]
                      ]
                  },
                  {
                      "id": "78697695.9a72c8",
                      "type": "switch",
                      "z": "c3403a60.92fbb8",
                      "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": 1540,
                      "y": 160,
                      "wires": [
                          [
                              "d839cef8.577f1"
                          ],
                          [
                              "eea737e7.7e8fb8"
                          ],
                          [
                              "bdfdae99.f4d9d"
                          ]
                      ]
                  },
                  {
                      "id": "d839cef8.577f1",
                      "type": "split",
                      "z": "c3403a60.92fbb8",
                      "name": "split array",
                      "splt": "\\n",
                      "spltType": "str",
                      "arraySplt": 1,
                      "arraySpltType": "len",
                      "stream": false,
                      "addname": "",
                      "x": 580,
                      "y": 280,
                      "wires": [
                          [
                              "36327f2d.8efc3"
                          ]
                      ]
                  },
                  {
                      "id": "36327f2d.8efc3",
                      "type": "change",
                      "z": "c3403a60.92fbb8",
                      "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": 770,
                      "y": 280,
                      "wires": [
                          [
                              "d8f58d9b.b6a1"
                          ]
                      ]
                  },
                  {
                      "id": "74b0b536.02371c",
                      "type": "change",
                      "z": "c3403a60.92fbb8",
                      "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": 1970,
                      "y": 240,
                      "wires": [
                          []
                      ]
                  },
                  {
                      "id": "4cdee7cb.910c38",
                      "type": "switch",
                      "z": "c3403a60.92fbb8",
                      "name": "is type?",
                      "property": "payload",
                      "propertyType": "msg",
                      "rules": [
                          {
                              "t": "istype",
                              "v": "json",
                              "vt": "json"
                          },
                          {
                              "t": "istype",
                              "v": "object",
                              "vt": "object"
                          },
                          {
                              "t": "istype",
                              "v": "array",
                              "vt": "array"
                          },
                          {
                              "t": "else"
                          }
                      ],
                      "checkall": "true",
                      "repair": false,
                      "outputs": 4,
                      "x": 400,
                      "y": 160,
                      "wires": [
                          [
                              "c1c41535.17d3b8"
                          ],
                          [
                              "eea737e7.7e8fb8"
                          ],
                          [
                              "d839cef8.577f1"
                          ],
                          [
                              "d8f58d9b.b6a1"
                          ]
                      ]
                  },
                  {
                      "id": "c1c41535.17d3b8",
                      "type": "json",
                      "z": "c3403a60.92fbb8",
                      "name": "",
                      "property": "payload",
                      "action": "",
                      "pretty": false,
                      "x": 570,
                      "y": 120,
                      "wires": [
                          [
                              "3ccd67db.375058"
                          ]
                      ]
                  },
                  {
                      "id": "bdfdae99.f4d9d",
                      "type": "switch",
                      "z": "c3403a60.92fbb8",
                      "name": "is msg.top != null",
                      "property": "top",
                      "propertyType": "msg",
                      "rules": [
                          {
                              "t": "nnull"
                          },
                          {
                              "t": "null"
                          }
                      ],
                      "checkall": "true",
                      "repair": false,
                      "outputs": 2,
                      "x": 1750,
                      "y": 280,
                      "wires": [
                          [
                              "74b0b536.02371c"
                          ],
                          [
                              "7ba7dc21.fdb214"
                          ]
                      ]
                  },
                  {
                      "id": "7ba7dc21.fdb214",
                      "type": "change",
                      "z": "c3403a60.92fbb8",
                      "name": "payload = warning",
                      "rules": [
                          {
                              "t": "set",
                              "p": "payload",
                              "pt": "msg",
                              "to": "Please define msg.top as root for the object structure",
                              "tot": "str"
                          },
                          {
                              "t": "delete",
                              "p": "topic",
                              "pt": "msg"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 1970,
                      "y": 300,
                      "wires": [
                          [
                              "ab9b1e85.eea2a"
                          ]
                      ]
                  },
                  {
                      "id": "ab9b1e85.eea2a",
                      "type": "rbe",
                      "z": "c3403a60.92fbb8",
                      "name": "",
                      "func": "rbe",
                      "gap": "",
                      "start": "",
                      "inout": "out",
                      "septopics": true,
                      "property": "payload",
                      "x": 2130,
                      "y": 300,
                      "wires": [
                          []
                      ]
                  },
                  {
                      "id": "94876630.f71748",
                      "type": "change",
                      "z": "c3403a60.92fbb8",
                      "name": "",
                      "rules": [
                          {
                              "t": "delete",
                              "p": "topic",
                              "pt": "msg"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 210,
                      "y": 160,
                      "wires": [
                          [
                              "4cdee7cb.910c38"
                          ]
                      ]
                  },
                  {
                      "id": "3ccd67db.375058",
                      "type": "switch",
                      "z": "c3403a60.92fbb8",
                      "name": "is array?",
                      "property": "payload",
                      "propertyType": "msg",
                      "rules": [
                          {
                              "t": "istype",
                              "v": "array",
                              "vt": "array"
                          },
                          {
                              "t": "else"
                          }
                      ],
                      "checkall": "true",
                      "repair": false,
                      "outputs": 2,
                      "x": 700,
                      "y": 120,
                      "wires": [
                          [
                              "d839cef8.577f1"
                          ],
                          [
                              "eea737e7.7e8fb8"
                          ]
                      ]
                  },
                  {
                      "id": "80dde279.c28ec",
                      "type": "comment",
                      "z": "c3403a60.92fbb8",
                      "name": "Array",
                      "info": "",
                      "x": 400,
                      "y": 280,
                      "wires": []
                  },
                  {
                      "id": "95ee816e.68a16",
                      "type": "comment",
                      "z": "c3403a60.92fbb8",
                      "name": "object",
                      "info": "",
                      "x": 1140,
                      "y": 100,
                      "wires": []
                  },
                  {
                      "id": "d8f58d9b.b6a1",
                      "type": "switch",
                      "z": "c3403a60.92fbb8",
                      "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": 960,
                      "y": 280,
                      "wires": [
                          [
                              "eea737e7.7e8fb8"
                          ],
                          [
                              "d839cef8.577f1"
                          ],
                          [
                              "bdfdae99.f4d9d"
                          ]
                      ]
                  },
                  {
                      "id": "b5789e69.e3a02",
                      "type": "inject",
                      "z": "6e170384.60c96c",
                      "name": "Datensatz 1",
                      "props": [
                          {
                              "p": "payload"
                          }
                      ],
                      "repeat": "",
                      "crontab": "",
                      "once": false,
                      "onceDelay": 0.1,
                      "topic": "",
                      "payload": "v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0",
                      "payloadType": "str",
                      "x": 2670,
                      "y": 3740,
                      "wires": [
                          [
                              "d378241f.a87128"
                          ]
                      ]
                  },
                  {
                      "id": "69bd20a3.1522e",
                      "type": "inject",
                      "z": "6e170384.60c96c",
                      "name": "Datensatz 2",
                      "props": [
                          {
                              "p": "payload"
                          }
                      ],
                      "repeat": "",
                      "crontab": "",
                      "once": false,
                      "onceDelay": 0.1,
                      "topic": "",
                      "payload": "v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2",
                      "payloadType": "str",
                      "x": 2670,
                      "y": 3800,
                      "wires": [
                          [
                              "a360e97c.537608"
                          ]
                      ]
                  },
                  {
                      "id": "d378241f.a87128",
                      "type": "change",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "rules": [
                          {
                              "t": "set",
                              "p": "payload",
                              "pt": "msg",
                              "to": "$split(payload, '&')\t",
                              "tot": "jsonata"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 2870,
                      "y": 3740,
                      "wires": [
                          [
                              "34e1631d.13947c"
                          ]
                      ]
                  },
                  {
                      "id": "34e1631d.13947c",
                      "type": "split",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "splt": "\\n",
                      "spltType": "str",
                      "arraySplt": 1,
                      "arraySpltType": "len",
                      "stream": false,
                      "addname": "",
                      "x": 3060,
                      "y": 3740,
                      "wires": [
                          [
                              "c8b3a65e.8c7188"
                          ]
                      ]
                  },
                  {
                      "id": "c8b3a65e.8c7188",
                      "type": "change",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "rules": [
                          {
                              "t": "set",
                              "p": "topic",
                              "pt": "msg",
                              "to": "payload",
                              "tot": "msg"
                          },
                          {
                              "t": "change",
                              "p": "topic",
                              "pt": "msg",
                              "from": "(.*)=.*",
                              "fromt": "re",
                              "to": "$1",
                              "tot": "str"
                          },
                          {
                              "t": "change",
                              "p": "payload",
                              "pt": "msg",
                              "from": ".*=(.*)",
                              "fromt": "re",
                              "to": "$1",
                              "tot": "str"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 3240,
                      "y": 3740,
                      "wires": [
                          [
                              "2d7ef1a3.2b16fe"
                          ]
                      ]
                  },
                  {
                      "id": "2d7ef1a3.2b16fe",
                      "type": "join",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "mode": "custom",
                      "build": "object",
                      "property": "payload",
                      "propertyType": "msg",
                      "key": "topic",
                      "joiner": "\\n",
                      "joinerType": "str",
                      "accumulate": false,
                      "timeout": "",
                      "count": "9",
                      "reduceRight": false,
                      "reduceExp": "",
                      "reduceInit": "",
                      "reduceInitType": "",
                      "reduceFixup": "",
                      "x": 3410,
                      "y": 3740,
                      "wires": [
                          [
                              "627bea68.682c54"
                          ]
                      ]
                  },
                  {
                      "id": "7ce06732.dda3d8",
                      "type": "subflow:c3403a60.92fbb8",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "x": 3810,
                      "y": 3740,
                      "wires": [
                          [
                              "4f0801a2.47905"
                          ]
                      ]
                  },
                  {
                      "id": "627bea68.682c54",
                      "type": "change",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "rules": [
                          {
                              "t": "set",
                              "p": "top",
                              "pt": "msg",
                              "to": "Example.Datensatz1",
                              "tot": "str"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 3580,
                      "y": 3740,
                      "wires": [
                          [
                              "7ce06732.dda3d8"
                          ]
                      ]
                  },
                  {
                      "id": "a360e97c.537608",
                      "type": "change",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "rules": [
                          {
                              "t": "set",
                              "p": "payload",
                              "pt": "msg",
                              "to": "$split(payload, '&')\t",
                              "tot": "jsonata"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 2870,
                      "y": 3800,
                      "wires": [
                          [
                              "ef6afa0.cca1908"
                          ]
                      ]
                  },
                  {
                      "id": "ef6afa0.cca1908",
                      "type": "split",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "splt": "\\n",
                      "spltType": "str",
                      "arraySplt": 1,
                      "arraySpltType": "len",
                      "stream": false,
                      "addname": "",
                      "x": 3060,
                      "y": 3800,
                      "wires": [
                          [
                              "7fe229a5.6890e8"
                          ]
                      ]
                  },
                  {
                      "id": "7fe229a5.6890e8",
                      "type": "change",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "rules": [
                          {
                              "t": "set",
                              "p": "topic",
                              "pt": "msg",
                              "to": "payload",
                              "tot": "msg"
                          },
                          {
                              "t": "change",
                              "p": "topic",
                              "pt": "msg",
                              "from": "(.*)=.*",
                              "fromt": "re",
                              "to": "$1",
                              "tot": "str"
                          },
                          {
                              "t": "change",
                              "p": "payload",
                              "pt": "msg",
                              "from": ".*=(.*)",
                              "fromt": "re",
                              "to": "$1",
                              "tot": "str"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 3240,
                      "y": 3800,
                      "wires": [
                          [
                              "9a198893.f81948"
                          ]
                      ]
                  },
                  {
                      "id": "9a198893.f81948",
                      "type": "join",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "mode": "custom",
                      "build": "object",
                      "property": "payload",
                      "propertyType": "msg",
                      "key": "topic",
                      "joiner": "\\n",
                      "joinerType": "str",
                      "accumulate": false,
                      "timeout": "",
                      "count": "9",
                      "reduceRight": false,
                      "reduceExp": "",
                      "reduceInit": "",
                      "reduceInitType": "",
                      "reduceFixup": "",
                      "x": 3410,
                      "y": 3800,
                      "wires": [
                          [
                              "fe4fa48a.2ad628"
                          ]
                      ]
                  },
                  {
                      "id": "2142e352.10597c",
                      "type": "subflow:c3403a60.92fbb8",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "x": 3810,
                      "y": 3800,
                      "wires": [
                          [
                              "4f0801a2.47905"
                          ]
                      ]
                  },
                  {
                      "id": "fe4fa48a.2ad628",
                      "type": "change",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "rules": [
                          {
                              "t": "set",
                              "p": "top",
                              "pt": "msg",
                              "to": "Example.Datensatz2",
                              "tot": "str"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 3580,
                      "y": 3800,
                      "wires": [
                          [
                              "2142e352.10597c"
                          ]
                      ]
                  },
                  {
                      "id": "17661ac4.01d545",
                      "type": "debug",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "active": true,
                      "tosidebar": true,
                      "console": false,
                      "tostatus": false,
                      "complete": "false",
                      "statusVal": "",
                      "statusType": "auto",
                      "x": 4250,
                      "y": 3780,
                      "wires": []
                  },
                  {
                      "id": "4f0801a2.47905",
                      "type": "change",
                      "z": "6e170384.60c96c",
                      "name": "",
                      "rules": [
                          {
                              "t": "change",
                              "p": "topic",
                              "pt": "msg",
                              "from": "0_userdata.0",
                              "fromt": "str",
                              "to": "",
                              "tot": "str"
                          },
                          {
                              "t": "change",
                              "p": "topic",
                              "pt": "msg",
                              "from": ".",
                              "fromt": "str",
                              "to": "/",
                              "tot": "str"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 4050,
                      "y": 3780,
                      "wires": [
                          [
                              "17661ac4.01d545"
                          ]
                      ]
                  }
              ]
              

              Falls Du nicht alle Objekte brauchst - kannst Du ja auch nach der JOIN Node direkt auf die Werte zugreifen. Nach der JOIN NOde hast Du fertige JAVA-Objekte über die zum Beispiel payload.fo auf den einzelnen Wert zugreifst.

              Beliar_666B Offline
              Beliar_666B Offline
              Beliar_666
              schrieb am zuletzt editiert von
              #9

              @mickym Ok, im Großen und Ganzen schaut das plausibel aus, aber wie teile ich nun meine Abfrage auf einem seriellen Port, der mir beide Strings liefert auf, das ich 2 getrennte Zweige habe?

              mickymM 1 Antwort Letzte Antwort
              0
              • Beliar_666B Beliar_666

                @mickym Ok, im Großen und Ganzen schaut das plausibel aus, aber wie teile ich nun meine Abfrage auf einem seriellen Port, der mir beide Strings liefert auf, das ich 2 getrennte Zweige habe?

                mickymM Online
                mickymM Online
                mickym
                Most Active
                schrieb am zuletzt editiert von mickym
                #10

                @beliar_666 Du brauchst ja vielleicht keine 2 Zweige ich habe keine Ahnung was Du mit Datensatz 1 oder 2 meinst und wie sich die Unterscheiden. Ich weiß doch auch nicht was aus Deinen seriellen Nodes rauskommt und wie Du die Datensätze auseinanderhälst. Du hast das doch geschrieben. Geht ja auch ein Datensatz bzw. Ast. Wenn Du nur 1 Ast nimmst, dann siehtst Du ja, dass damit immer wenn alle 9 Parameter voll sind - eine Nachricht generiert wird.

                Ich habe Dir im Prinzip eine Vorgehensweise gezeigt, wie man diese Strings über ein Objekt handhabbar machst. Die Details musst Du halt implementieren.

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

                Beliar_666B 1 Antwort Letzte Antwort
                1
                • mickymM mickym

                  @beliar_666 Du brauchst ja vielleicht keine 2 Zweige ich habe keine Ahnung was Du mit Datensatz 1 oder 2 meinst und wie sich die Unterscheiden. Ich weiß doch auch nicht was aus Deinen seriellen Nodes rauskommt und wie Du die Datensätze auseinanderhälst. Du hast das doch geschrieben. Geht ja auch ein Datensatz bzw. Ast. Wenn Du nur 1 Ast nimmst, dann siehtst Du ja, dass damit immer wenn alle 9 Parameter voll sind - eine Nachricht generiert wird.

                  Ich habe Dir im Prinzip eine Vorgehensweise gezeigt, wie man diese Strings über ein Objekt handhabbar machst. Die Details musst Du halt implementieren.

                  Beliar_666B Offline
                  Beliar_666B Offline
                  Beliar_666
                  schrieb am zuletzt editiert von
                  #11

                  @mickym 1 Serieller Node der einmal den Datensatz 1
                  1 v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0
                  und einmal Datensatz 2
                  2 v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2

                  raus gibt. Je nach dem von welchem Sensor dann das Signal kommt steht wie dort abgebildet vorne dran eine 1 oder eine 2, das sind die Kennungen der Funksensoren. Alles was danach steht sind die Werte wie Akku, Temp, Feuchtigkeit etc...

                  Dachte das hatte ich oben schon klar genug formuliert. Also 1 Serieller Empfänger, der 2 Signale liefert, die ich getrennt haben möchte.
                  Der Ansatz mit den 2 Zweigen ist somit eigentlich gar nicht verkehrt, nur wie bekomme ich aus eben diesem einen Node 2 getrennte Zweige...

                  mickymM 1 Antwort Letzte Antwort
                  0
                  • Beliar_666B Beliar_666

                    @mickym 1 Serieller Node der einmal den Datensatz 1
                    1 v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0
                    und einmal Datensatz 2
                    2 v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2

                    raus gibt. Je nach dem von welchem Sensor dann das Signal kommt steht wie dort abgebildet vorne dran eine 1 oder eine 2, das sind die Kennungen der Funksensoren. Alles was danach steht sind die Werte wie Akku, Temp, Feuchtigkeit etc...

                    Dachte das hatte ich oben schon klar genug formuliert. Also 1 Serieller Empfänger, der 2 Signale liefert, die ich getrennt haben möchte.
                    Der Ansatz mit den 2 Zweigen ist somit eigentlich gar nicht verkehrt, nur wie bekomme ich aus eben diesem einen Node 2 getrennte Zweige...

                    mickymM Online
                    mickymM Online
                    mickym
                    Most Active
                    schrieb am zuletzt editiert von mickym
                    #12

                    @beliar_666 Nun ich dachte Du hast das Prinzip des Flows verstanden .

                    Dann hängst Du einfach diese Change mit der Switch Node vorne dran.

                    7dcd8e21-1bee-4973-8a6f-56bebee86f5a-image.png

                    Hier die beiden Nodes mit der switch Node:

                    [
                       {
                           "id": "a6df2a84.daee68",
                           "type": "change",
                           "z": "6e170384.60c96c",
                           "name": "",
                           "rules": [
                               {
                                   "t": "set",
                                   "p": "topic",
                                   "pt": "msg",
                                   "to": "payload",
                                   "tot": "msg"
                               },
                               {
                                   "t": "change",
                                   "p": "payload",
                                   "pt": "msg",
                                   "from": "\\d\\s(.*)",
                                   "fromt": "re",
                                   "to": "$1",
                                   "tot": "str"
                               },
                               {
                                   "t": "change",
                                   "p": "topic",
                                   "pt": "msg",
                                   "from": "(\\d)\\s.*",
                                   "fromt": "re",
                                   "to": "$1",
                                   "tot": "str"
                               }
                           ],
                           "action": "",
                           "property": "",
                           "from": "",
                           "to": "",
                           "reg": false,
                           "x": 2120,
                           "y": 4680,
                           "wires": [
                               [
                                   "25852f83.4a1bd"
                               ]
                           ]
                       },
                       {
                           "id": "25852f83.4a1bd",
                           "type": "switch",
                           "z": "6e170384.60c96c",
                           "name": "",
                           "property": "topic",
                           "propertyType": "msg",
                           "rules": [
                               {
                                   "t": "eq",
                                   "v": "1",
                                   "vt": "str"
                               },
                               {
                                   "t": "eq",
                                   "v": "2",
                                   "vt": "str"
                               }
                           ],
                           "checkall": "true",
                           "repair": false,
                           "outputs": 2,
                           "x": 2290,
                           "y": 4680,
                           "wires": [
                               [
                                   "84622001.c6709"
                               ],
                               [
                                   "9e453c85.1f93a"
                               ]
                           ]
                       }
                    ]
                    

                    Du kannst das auch in einer anderen Eigenschaft mitschleppen und dann die Zahl in msg.top unterbringen - dann langt auch ein Ast. Dann braucht man nicht für jeden Sensor einen Ast machen.

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

                    Beliar_666B 1 Antwort Letzte Antwort
                    1
                    • mickymM mickym

                      @beliar_666 Nun ich dachte Du hast das Prinzip des Flows verstanden .

                      Dann hängst Du einfach diese Change mit der Switch Node vorne dran.

                      7dcd8e21-1bee-4973-8a6f-56bebee86f5a-image.png

                      Hier die beiden Nodes mit der switch Node:

                      [
                         {
                             "id": "a6df2a84.daee68",
                             "type": "change",
                             "z": "6e170384.60c96c",
                             "name": "",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "topic",
                                     "pt": "msg",
                                     "to": "payload",
                                     "tot": "msg"
                                 },
                                 {
                                     "t": "change",
                                     "p": "payload",
                                     "pt": "msg",
                                     "from": "\\d\\s(.*)",
                                     "fromt": "re",
                                     "to": "$1",
                                     "tot": "str"
                                 },
                                 {
                                     "t": "change",
                                     "p": "topic",
                                     "pt": "msg",
                                     "from": "(\\d)\\s.*",
                                     "fromt": "re",
                                     "to": "$1",
                                     "tot": "str"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 2120,
                             "y": 4680,
                             "wires": [
                                 [
                                     "25852f83.4a1bd"
                                 ]
                             ]
                         },
                         {
                             "id": "25852f83.4a1bd",
                             "type": "switch",
                             "z": "6e170384.60c96c",
                             "name": "",
                             "property": "topic",
                             "propertyType": "msg",
                             "rules": [
                                 {
                                     "t": "eq",
                                     "v": "1",
                                     "vt": "str"
                                 },
                                 {
                                     "t": "eq",
                                     "v": "2",
                                     "vt": "str"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 2,
                             "x": 2290,
                             "y": 4680,
                             "wires": [
                                 [
                                     "84622001.c6709"
                                 ],
                                 [
                                     "9e453c85.1f93a"
                                 ]
                             ]
                         }
                      ]
                      

                      Du kannst das auch in einer anderen Eigenschaft mitschleppen und dann die Zahl in msg.top unterbringen - dann langt auch ein Ast. Dann braucht man nicht für jeden Sensor einen Ast machen.

                      Beliar_666B Offline
                      Beliar_666B Offline
                      Beliar_666
                      schrieb am zuletzt editiert von
                      #13

                      @mickym

                      Nein ao komme ich nicht weiter. Bei mir kommen hinter Switch keine Daten an. Davor aber schon.


                      [{"id":"c3403a60.92fbb8","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 no msg.top property is defined, then you will get an error in the following iobroker-out node (key or topic does not exist) - if you append a debug node to the subflow node you will get the message: \n> Please define msg.top as root for the object structure \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 in keine Angabe in msg.top definiert wurde, wird man in der darauffolgenden iobroker-out node den Fehler erhalten, dass kein key oder topic definiert ist. Falls eine debug Node an den Subflow angehängt wirde erhält man folgende Ausgabe:\n> Please define msg.top as root for the object structure ","category":"","in":[{"x":60,"y":160,"wires":[{"id":"94876630.f71748"}]}],"out":[{"x":2280,"y":260,"wires":[{"id":"74b0b536.02371c","port":0},{"id":"ab9b1e85.eea2a","port":0}]}],"env":[],"color":"#E2D96E","icon":"node-red/batch.svg"},{"id":"eea737e7.7e8fb8","type":"split","z":"c3403a60.92fbb8","name":"split object","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"key","x":1170,"y":160,"wires":[["dc473616.c2b508"]]},{"id":"dc473616.c2b508","type":"change","z":"c3403a60.92fbb8","name":"add key to topic","rules":[{"t":"set","p":"stateName","pt":"msg","to":"key","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"topic & '.' & key","tot":"jsonata"},{"t":"change","p":"topic","pt":"msg","from":" ","fromt":"str","to":"_","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":160,"wires":[["78697695.9a72c8"]]},{"id":"78697695.9a72c8","type":"switch","z":"c3403a60.92fbb8","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":1540,"y":160,"wires":[["d839cef8.577f1"],["eea737e7.7e8fb8"],["bdfdae99.f4d9d"]]},{"id":"d839cef8.577f1","type":"split","z":"c3403a60.92fbb8","name":"split array","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":580,"y":280,"wires":[["36327f2d.8efc3"]]},{"id":"36327f2d.8efc3","type":"change","z":"c3403a60.92fbb8","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":770,"y":280,"wires":[["d8f58d9b.b6a1"]]},{"id":"74b0b536.02371c","type":"change","z":"c3403a60.92fbb8","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":1970,"y":240,"wires":[[]]},{"id":"4cdee7cb.910c38","type":"switch","z":"c3403a60.92fbb8","name":"is type?","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"json","vt":"json"},{"t":"istype","v":"object","vt":"object"},{"t":"istype","v":"array","vt":"array"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":400,"y":160,"wires":[["c1c41535.17d3b8"],["eea737e7.7e8fb8"],["d839cef8.577f1"],["d8f58d9b.b6a1"]]},{"id":"c1c41535.17d3b8","type":"json","z":"c3403a60.92fbb8","name":"","property":"payload","action":"","pretty":false,"x":570,"y":120,"wires":[["3ccd67db.375058"]]},{"id":"bdfdae99.f4d9d","type":"switch","z":"c3403a60.92fbb8","name":"is msg.top != null","property":"top","propertyType":"msg","rules":[{"t":"nnull"},{"t":"null"}],"checkall":"true","repair":false,"outputs":2,"x":1750,"y":280,"wires":[["74b0b536.02371c"],["7ba7dc21.fdb214"]]},{"id":"7ba7dc21.fdb214","type":"change","z":"c3403a60.92fbb8","name":"payload = warning","rules":[{"t":"set","p":"payload","pt":"msg","to":"Please define msg.top as root for the object structure","tot":"str"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1970,"y":300,"wires":[["ab9b1e85.eea2a"]]},{"id":"ab9b1e85.eea2a","type":"rbe","z":"c3403a60.92fbb8","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":2130,"y":300,"wires":[[]]},{"id":"94876630.f71748","type":"change","z":"c3403a60.92fbb8","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":160,"wires":[["4cdee7cb.910c38"]]},{"id":"3ccd67db.375058","type":"switch","z":"c3403a60.92fbb8","name":"is array?","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"array","vt":"array"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":700,"y":120,"wires":[["d839cef8.577f1"],["eea737e7.7e8fb8"]]},{"id":"80dde279.c28ec","type":"comment","z":"c3403a60.92fbb8","name":"Array","info":"","x":400,"y":280,"wires":[]},{"id":"95ee816e.68a16","type":"comment","z":"c3403a60.92fbb8","name":"object","info":"","x":1140,"y":100,"wires":[]},{"id":"d8f58d9b.b6a1","type":"switch","z":"c3403a60.92fbb8","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":960,"y":280,"wires":[["eea737e7.7e8fb8"],["d839cef8.577f1"],["bdfdae99.f4d9d"]]},{"id":"57ffde1.50cf02","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"8f8c462c.e0c798","type":"serial in","z":"57ffde1.50cf02","name":"","serial":"a585d7e5.b8b0c8","x":340,"y":260,"wires":[["a6df2a84.daee68"]]},{"id":"a6df2a84.daee68","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"},{"t":"change","p":"payload","pt":"msg","from":"\d\s(.)","fromt":"re","to":"$1","tot":"str"},{"t":"change","p":"topic","pt":"msg","from":"(\d)\s.","fromt":"re","to":"$1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":520,"wires":[["496065c5.4a662c"]]},{"id":"8da01c2a.204f3","type":"mqtt out","z":"57ffde1.50cf02","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a13c6d76.800e5","x":2150,"y":280,"wires":[]},{"id":"247c510e.11f7fe","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$split(payload, '&')\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":320,"wires":[["836058f0.cf9868"]]},{"id":"836058f0.cf9868","type":"split","z":"57ffde1.50cf02","name":"","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":980,"y":320,"wires":[["566e83e3.8f44dc"]]},{"id":"566e83e3.8f44dc","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"},{"t":"change","p":"topic","pt":"msg","from":"(.)=.","fromt":"re","to":"$1","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":".=(.)","fromt":"re","to":"$1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":320,"wires":[["cd1ae430.5b9078"]]},{"id":"cd1ae430.5b9078","type":"join","z":"57ffde1.50cf02","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\n","joinerType":"str","accumulate":false,"timeout":"","count":"9","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1330,"y":320,"wires":[["b2ee4df2.5e52"]]},{"id":"86fc2c3b.89109","type":"subflow:c3403a60.92fbb8","z":"57ffde1.50cf02","name":"","x":1730,"y":320,"wires":[["7fc7782c.dfb178"]]},{"id":"b2ee4df2.5e52","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"top","pt":"msg","to":"Example.Datensatz1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":320,"wires":[["86fc2c3b.89109"]]},{"id":"a822af38.b986f","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$split(payload, '&')\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":380,"wires":[["943e6f1e.50c2c"]]},{"id":"943e6f1e.50c2c","type":"split","z":"57ffde1.50cf02","name":"","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":980,"y":380,"wires":[["31b0041c.28041c"]]},{"id":"31b0041c.28041c","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"},{"t":"change","p":"topic","pt":"msg","from":"(.)=.","fromt":"re","to":"$1","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":".=(.)","fromt":"re","to":"$1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":380,"wires":[["fc7c50b3.e856a"]]},{"id":"fc7c50b3.e856a","type":"join","z":"57ffde1.50cf02","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\n","joinerType":"str","accumulate":false,"timeout":"","count":"9","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1330,"y":380,"wires":[["d3fb24a6.424af8"]]},{"id":"7c8c1763.03be08","type":"subflow:c3403a60.92fbb8","z":"57ffde1.50cf02","name":"","x":1730,"y":380,"wires":[["7fc7782c.dfb178"]]},{"id":"d3fb24a6.424af8","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"top","pt":"msg","to":"Example.Datensatz2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":380,"wires":[["7c8c1763.03be08"]]},{"id":"ba13d42b.0f4ce8","type":"debug","z":"57ffde1.50cf02","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2170,"y":380,"wires":[]},{"id":"7fc7782c.dfb178","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"change","p":"topic","pt":"msg","from":"0_userdata.0","fromt":"str","to":"","tot":"str"},{"t":"change","p":"topic","pt":"msg","from":".","fromt":"str","to":"/","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1970,"y":360,"wires":[["ba13d42b.0f4ce8"]]},{"id":"496065c5.4a662c","type":"switch","z":"57ffde1.50cf02","name":"","property":"top","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":360,"wires":[["247c510e.11f7fe"],[]]},{"id":"a585d7e5.b8b0c8","type":"serial-port","serialport":"/dev/ttyAMA0","serialbaud":"38400","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"400","bin":"false","out":"interbyte","addchar":"\n","responsetimeout":"10000"},{"id":"a13c6d76.800e5","type":"mqtt-broker","name":"","broker":"192.168.178.205","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

                      mickymM 1 Antwort Letzte Antwort
                      0
                      • Beliar_666B Beliar_666

                        @mickym

                        Nein ao komme ich nicht weiter. Bei mir kommen hinter Switch keine Daten an. Davor aber schon.


                        [{"id":"c3403a60.92fbb8","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 no msg.top property is defined, then you will get an error in the following iobroker-out node (key or topic does not exist) - if you append a debug node to the subflow node you will get the message: \n> Please define msg.top as root for the object structure \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 in keine Angabe in msg.top definiert wurde, wird man in der darauffolgenden iobroker-out node den Fehler erhalten, dass kein key oder topic definiert ist. Falls eine debug Node an den Subflow angehängt wirde erhält man folgende Ausgabe:\n> Please define msg.top as root for the object structure ","category":"","in":[{"x":60,"y":160,"wires":[{"id":"94876630.f71748"}]}],"out":[{"x":2280,"y":260,"wires":[{"id":"74b0b536.02371c","port":0},{"id":"ab9b1e85.eea2a","port":0}]}],"env":[],"color":"#E2D96E","icon":"node-red/batch.svg"},{"id":"eea737e7.7e8fb8","type":"split","z":"c3403a60.92fbb8","name":"split object","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"key","x":1170,"y":160,"wires":[["dc473616.c2b508"]]},{"id":"dc473616.c2b508","type":"change","z":"c3403a60.92fbb8","name":"add key to topic","rules":[{"t":"set","p":"stateName","pt":"msg","to":"key","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"topic & '.' & key","tot":"jsonata"},{"t":"change","p":"topic","pt":"msg","from":" ","fromt":"str","to":"_","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":160,"wires":[["78697695.9a72c8"]]},{"id":"78697695.9a72c8","type":"switch","z":"c3403a60.92fbb8","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":1540,"y":160,"wires":[["d839cef8.577f1"],["eea737e7.7e8fb8"],["bdfdae99.f4d9d"]]},{"id":"d839cef8.577f1","type":"split","z":"c3403a60.92fbb8","name":"split array","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":580,"y":280,"wires":[["36327f2d.8efc3"]]},{"id":"36327f2d.8efc3","type":"change","z":"c3403a60.92fbb8","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":770,"y":280,"wires":[["d8f58d9b.b6a1"]]},{"id":"74b0b536.02371c","type":"change","z":"c3403a60.92fbb8","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":1970,"y":240,"wires":[[]]},{"id":"4cdee7cb.910c38","type":"switch","z":"c3403a60.92fbb8","name":"is type?","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"json","vt":"json"},{"t":"istype","v":"object","vt":"object"},{"t":"istype","v":"array","vt":"array"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":400,"y":160,"wires":[["c1c41535.17d3b8"],["eea737e7.7e8fb8"],["d839cef8.577f1"],["d8f58d9b.b6a1"]]},{"id":"c1c41535.17d3b8","type":"json","z":"c3403a60.92fbb8","name":"","property":"payload","action":"","pretty":false,"x":570,"y":120,"wires":[["3ccd67db.375058"]]},{"id":"bdfdae99.f4d9d","type":"switch","z":"c3403a60.92fbb8","name":"is msg.top != null","property":"top","propertyType":"msg","rules":[{"t":"nnull"},{"t":"null"}],"checkall":"true","repair":false,"outputs":2,"x":1750,"y":280,"wires":[["74b0b536.02371c"],["7ba7dc21.fdb214"]]},{"id":"7ba7dc21.fdb214","type":"change","z":"c3403a60.92fbb8","name":"payload = warning","rules":[{"t":"set","p":"payload","pt":"msg","to":"Please define msg.top as root for the object structure","tot":"str"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1970,"y":300,"wires":[["ab9b1e85.eea2a"]]},{"id":"ab9b1e85.eea2a","type":"rbe","z":"c3403a60.92fbb8","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":2130,"y":300,"wires":[[]]},{"id":"94876630.f71748","type":"change","z":"c3403a60.92fbb8","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":160,"wires":[["4cdee7cb.910c38"]]},{"id":"3ccd67db.375058","type":"switch","z":"c3403a60.92fbb8","name":"is array?","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"array","vt":"array"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":700,"y":120,"wires":[["d839cef8.577f1"],["eea737e7.7e8fb8"]]},{"id":"80dde279.c28ec","type":"comment","z":"c3403a60.92fbb8","name":"Array","info":"","x":400,"y":280,"wires":[]},{"id":"95ee816e.68a16","type":"comment","z":"c3403a60.92fbb8","name":"object","info":"","x":1140,"y":100,"wires":[]},{"id":"d8f58d9b.b6a1","type":"switch","z":"c3403a60.92fbb8","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":960,"y":280,"wires":[["eea737e7.7e8fb8"],["d839cef8.577f1"],["bdfdae99.f4d9d"]]},{"id":"57ffde1.50cf02","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"8f8c462c.e0c798","type":"serial in","z":"57ffde1.50cf02","name":"","serial":"a585d7e5.b8b0c8","x":340,"y":260,"wires":[["a6df2a84.daee68"]]},{"id":"a6df2a84.daee68","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"},{"t":"change","p":"payload","pt":"msg","from":"\d\s(.)","fromt":"re","to":"$1","tot":"str"},{"t":"change","p":"topic","pt":"msg","from":"(\d)\s.","fromt":"re","to":"$1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":520,"wires":[["496065c5.4a662c"]]},{"id":"8da01c2a.204f3","type":"mqtt out","z":"57ffde1.50cf02","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a13c6d76.800e5","x":2150,"y":280,"wires":[]},{"id":"247c510e.11f7fe","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$split(payload, '&')\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":320,"wires":[["836058f0.cf9868"]]},{"id":"836058f0.cf9868","type":"split","z":"57ffde1.50cf02","name":"","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":980,"y":320,"wires":[["566e83e3.8f44dc"]]},{"id":"566e83e3.8f44dc","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"},{"t":"change","p":"topic","pt":"msg","from":"(.)=.","fromt":"re","to":"$1","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":".=(.)","fromt":"re","to":"$1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":320,"wires":[["cd1ae430.5b9078"]]},{"id":"cd1ae430.5b9078","type":"join","z":"57ffde1.50cf02","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\n","joinerType":"str","accumulate":false,"timeout":"","count":"9","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1330,"y":320,"wires":[["b2ee4df2.5e52"]]},{"id":"86fc2c3b.89109","type":"subflow:c3403a60.92fbb8","z":"57ffde1.50cf02","name":"","x":1730,"y":320,"wires":[["7fc7782c.dfb178"]]},{"id":"b2ee4df2.5e52","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"top","pt":"msg","to":"Example.Datensatz1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":320,"wires":[["86fc2c3b.89109"]]},{"id":"a822af38.b986f","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$split(payload, '&')\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":380,"wires":[["943e6f1e.50c2c"]]},{"id":"943e6f1e.50c2c","type":"split","z":"57ffde1.50cf02","name":"","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":980,"y":380,"wires":[["31b0041c.28041c"]]},{"id":"31b0041c.28041c","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"},{"t":"change","p":"topic","pt":"msg","from":"(.)=.","fromt":"re","to":"$1","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":".=(.)","fromt":"re","to":"$1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":380,"wires":[["fc7c50b3.e856a"]]},{"id":"fc7c50b3.e856a","type":"join","z":"57ffde1.50cf02","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\n","joinerType":"str","accumulate":false,"timeout":"","count":"9","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1330,"y":380,"wires":[["d3fb24a6.424af8"]]},{"id":"7c8c1763.03be08","type":"subflow:c3403a60.92fbb8","z":"57ffde1.50cf02","name":"","x":1730,"y":380,"wires":[["7fc7782c.dfb178"]]},{"id":"d3fb24a6.424af8","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"set","p":"top","pt":"msg","to":"Example.Datensatz2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":380,"wires":[["7c8c1763.03be08"]]},{"id":"ba13d42b.0f4ce8","type":"debug","z":"57ffde1.50cf02","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2170,"y":380,"wires":[]},{"id":"7fc7782c.dfb178","type":"change","z":"57ffde1.50cf02","name":"","rules":[{"t":"change","p":"topic","pt":"msg","from":"0_userdata.0","fromt":"str","to":"","tot":"str"},{"t":"change","p":"topic","pt":"msg","from":".","fromt":"str","to":"/","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1970,"y":360,"wires":[["ba13d42b.0f4ce8"]]},{"id":"496065c5.4a662c","type":"switch","z":"57ffde1.50cf02","name":"","property":"top","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":360,"wires":[["247c510e.11f7fe"],[]]},{"id":"a585d7e5.b8b0c8","type":"serial-port","serialport":"/dev/ttyAMA0","serialbaud":"38400","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"400","bin":"false","out":"interbyte","addchar":"\n","responsetimeout":"10000"},{"id":"a13c6d76.800e5","type":"mqtt-broker","name":"","broker":"192.168.178.205","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

                        mickymM Online
                        mickymM Online
                        mickym
                        Most Active
                        schrieb am zuletzt editiert von
                        #14

                        @beliar_666 OK - ich kann den Flow nicht mehr zurück importieren - weil die Importfunktion ein Problem mit den regulären Ausdrücken hat. In Zukunft bitte den Export in </> Code Tags.

                        Aber ich habe trotzdem gesehen, wo das Problem ist. In der Switch Node steht msg.top da muss aber stehen msg.topic.
                        Wenn die Strings so sind, wie Du sie unten gepostet hast - dann die Change und Switch Node wie folgt konfigurieren - hier

                        die Screenshots - erstmal gesamt - ich habe natürlich wieder die Inject Nodes anstelle der seriellen Node hingehängt um den Input zu simulieren:

                        2e3821c8-70d4-4779-b510-48e6d43c376d-image.png

                        So die erste Change Node - da wird der Input scheitern schaut so aus. Die musst Du halt aus dem Screenshot nun selbst abbilden.

                        Achte darauf dass Du am Anfang beim Ändern auf reguläre Ausdrücke gestellt hast .* und dann kannst Du sowohl beim topic oder payload den gleichen regulären Ausdruck verwenden:

                        (\d)\s(.*)
                        

                        c11177f4-c9ff-497e-a401-e50f52f73e52-image.png

                        Das msg.topic ist dann $1 und msg.payload ist $2.

                        Die switch Node muss so aussehen:

                        Achte auf Typ und das nach msg.topic unterschieden wird - wie in der Change Node zuvor definiert:

                        01454340-1bb1-48be-be43-0c6ff5249519-image.png

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

                        Beliar_666B 1 Antwort Letzte Antwort
                        1
                        • mickymM mickym

                          @beliar_666 OK - ich kann den Flow nicht mehr zurück importieren - weil die Importfunktion ein Problem mit den regulären Ausdrücken hat. In Zukunft bitte den Export in </> Code Tags.

                          Aber ich habe trotzdem gesehen, wo das Problem ist. In der Switch Node steht msg.top da muss aber stehen msg.topic.
                          Wenn die Strings so sind, wie Du sie unten gepostet hast - dann die Change und Switch Node wie folgt konfigurieren - hier

                          die Screenshots - erstmal gesamt - ich habe natürlich wieder die Inject Nodes anstelle der seriellen Node hingehängt um den Input zu simulieren:

                          2e3821c8-70d4-4779-b510-48e6d43c376d-image.png

                          So die erste Change Node - da wird der Input scheitern schaut so aus. Die musst Du halt aus dem Screenshot nun selbst abbilden.

                          Achte darauf dass Du am Anfang beim Ändern auf reguläre Ausdrücke gestellt hast .* und dann kannst Du sowohl beim topic oder payload den gleichen regulären Ausdruck verwenden:

                          (\d)\s(.*)
                          

                          c11177f4-c9ff-497e-a401-e50f52f73e52-image.png

                          Das msg.topic ist dann $1 und msg.payload ist $2.

                          Die switch Node muss so aussehen:

                          Achte auf Typ und das nach msg.topic unterschieden wird - wie in der Change Node zuvor definiert:

                          01454340-1bb1-48be-be43-0c6ff5249519-image.png

                          Beliar_666B Offline
                          Beliar_666B Offline
                          Beliar_666
                          schrieb am zuletzt editiert von Beliar_666
                          #15

                          @mickym sagte in Rasp2 serial überwachen, per mqtt an iobroker übertragen.:

                          Also nach Change teilt er mir die 2 auf, siehe Screenshot. Aber der Switch blockt wieder. Nachg dem Switch bleibt die Ausgabe wieder leer.

                          Bild_2021-04-14_215552.png

                          mickymM 2 Antworten Letzte Antwort
                          0
                          • Beliar_666B Beliar_666

                            @mickym sagte in Rasp2 serial überwachen, per mqtt an iobroker übertragen.:

                            Also nach Change teilt er mir die 2 auf, siehe Screenshot. Aber der Switch blockt wieder. Nachg dem Switch bleibt die Ausgabe wieder leer.

                            Bild_2021-04-14_215552.png

                            mickymM Online
                            mickymM Online
                            mickym
                            Most Active
                            schrieb am zuletzt editiert von mickym
                            #16

                            @beliar_666 Ja passt doch - der switch teilt das dann auf die beiden Äste. ggf. muss man am Schluss noch die Zeilenschaltung entfernen. - Du könntest den regulären Ausdruck nochmals wie folgt ändern

                            (\d)\s(.*)\s
                            

                            Mach halt mal einen Screenshot des switch hast du msg.top gegen msg.topic geändert wie gesagt?

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

                            Beliar_666B 1 Antwort Letzte Antwort
                            1
                            • mickymM mickym

                              @beliar_666 Ja passt doch - der switch teilt das dann auf die beiden Äste. ggf. muss man am Schluss noch die Zeilenschaltung entfernen. - Du könntest den regulären Ausdruck nochmals wie folgt ändern

                              (\d)\s(.*)\s
                              

                              Mach halt mal einen Screenshot des switch hast du msg.top gegen msg.topic geändert wie gesagt?

                              Beliar_666B Offline
                              Beliar_666B Offline
                              Beliar_666
                              schrieb am zuletzt editiert von
                              #17

                              @mickym !

                              msg.topic so wie in dem Screenshot

                              Bild_2021-04-14_221235.png

                              mickymM 1 Antwort Letzte Antwort
                              0
                              • Beliar_666B Beliar_666

                                @mickym !

                                msg.topic so wie in dem Screenshot

                                Bild_2021-04-14_221235.png

                                mickymM Online
                                mickymM Online
                                mickym
                                Most Active
                                schrieb am zuletzt editiert von
                                #18

                                @beliar_666 Nun vielleicht ist da irgendein Steuerzeichen drin, dass ich nicht sehe.

                                Dann mach mal in dem Switch statt == 1 ==> enthält 1 bzw. enthält 2

                                da3c94d3-3242-4c5b-b31d-35e3fffd5ef8-image.png

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

                                Beliar_666B 1 Antwort Letzte Antwort
                                1
                                • Beliar_666B Beliar_666

                                  @mickym sagte in Rasp2 serial überwachen, per mqtt an iobroker übertragen.:

                                  Also nach Change teilt er mir die 2 auf, siehe Screenshot. Aber der Switch blockt wieder. Nachg dem Switch bleibt die Ausgabe wieder leer.

                                  Bild_2021-04-14_215552.png

                                  mickymM Online
                                  mickymM Online
                                  mickym
                                  Most Active
                                  schrieb am zuletzt editiert von
                                  #19

                                  @beliar_666 Andernfalls zeig mal den Screenshot dieser Debug-Nodes mit dem vollständigen Nachrichtenobjekt und klappe bitte alle Daten aus (Pfeil nach unten)

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

                                  1 Antwort Letzte Antwort
                                  1
                                  • mickymM mickym

                                    @beliar_666 Nun vielleicht ist da irgendein Steuerzeichen drin, dass ich nicht sehe.

                                    Dann mach mal in dem Switch statt == 1 ==> enthält 1 bzw. enthält 2

                                    da3c94d3-3242-4c5b-b31d-35e3fffd5ef8-image.png

                                    Beliar_666B Offline
                                    Beliar_666B Offline
                                    Beliar_666
                                    schrieb am zuletzt editiert von
                                    #20

                                    @mickym Genau das war es so wie es ausschaut kommen jetzt Daten hinterm Switch an.

                                    Aber nun kam mir grad noch etwas in den Sinn, wenn jetzt weitere Sender hinzu kommen, die dann als Kennung 0, 3, 4, 5, etc. haben, wie binde ich die dann in den change ein? Oder geht das dann gar nicht?

                                    mickymM 1 Antwort Letzte Antwort
                                    0
                                    • Beliar_666B Beliar_666

                                      @mickym Genau das war es so wie es ausschaut kommen jetzt Daten hinterm Switch an.

                                      Aber nun kam mir grad noch etwas in den Sinn, wenn jetzt weitere Sender hinzu kommen, die dann als Kennung 0, 3, 4, 5, etc. haben, wie binde ich die dann in den change ein? Oder geht das dann gar nicht?

                                      mickymM Online
                                      mickymM Online
                                      mickym
                                      Most Active
                                      schrieb am zuletzt editiert von
                                      #21

                                      @beliar_666
                                      Geht alles - aber wenn das variable ist - dann muss man halt den topic erst später aufteilen. Dann machen wir nur einen Ast. Ich überlege mir mal eine Alternative.

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

                                      Beliar_666B 1 Antwort Letzte Antwort
                                      1
                                      • mickymM mickym

                                        @beliar_666
                                        Geht alles - aber wenn das variable ist - dann muss man halt den topic erst später aufteilen. Dann machen wir nur einen Ast. Ich überlege mir mal eine Alternative.

                                        Beliar_666B Offline
                                        Beliar_666B Offline
                                        Beliar_666
                                        schrieb am zuletzt editiert von Beliar_666
                                        #22

                                        @mickym Ich habe jetzt grad mal den Flow zu ende gebracht. Ich glaube in einem Zweig ist ein Fehler. Denn beim Datensatz 1 kommt nur der Wert be an.

                                        Bild_2021-04-14_224414.png

                                        nun vermute ich den Fehler im change im Zweig 1 oder 2, denn die sind identisch und lauten beide auf $1. Oder ist das hier richtig weil es nach dem switch getrennte Zweige sind?

                                        Bild_2021-04-14_225305.png

                                        mickymM 1 Antwort Letzte Antwort
                                        0
                                        • Beliar_666B Beliar_666

                                          @mickym Ich habe jetzt grad mal den Flow zu ende gebracht. Ich glaube in einem Zweig ist ein Fehler. Denn beim Datensatz 1 kommt nur der Wert be an.

                                          Bild_2021-04-14_224414.png

                                          nun vermute ich den Fehler im change im Zweig 1 oder 2, denn die sind identisch und lauten beide auf $1. Oder ist das hier richtig weil es nach dem switch getrennte Zweige sind?

                                          Bild_2021-04-14_225305.png

                                          mickymM Online
                                          mickymM Online
                                          mickym
                                          Most Active
                                          schrieb am zuletzt editiert von mickym
                                          #23

                                          @beliar_666
                                          So nun mal eine weitere Version - Sorgen macht mir zwar dieses komische Steuerzeichen - aber schaun wir mal.

                                          1e15f43d-ea2b-4583-833e-874edb83e85f-image.png

                                          Nachdem der Import mit den regulären Ausdrücken Probleme macht - hier erst mal der Flow die regulären Ausdrücken nacharbeiten.

                                          [
                                             {
                                                 "id": "6fabb801.91dd08",
                                                 "type": "subflow",
                                                 "name": "JSON or Obj to IOBroker (2)",
                                                 "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 no msg.top property is defined, then you will get an error in the following iobroker-out node (key or topic does not exist) - if you append a debug node to the subflow node you will get the message: \n> Please define msg.top as root for the object structure \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 in keine Angabe in msg.top definiert wurde, wird man in der darauffolgenden iobroker-out node den Fehler erhalten, dass kein key oder topic definiert ist. Falls eine debug Node an den Subflow angehängt wirde erhält man folgende Ausgabe:\n> Please define msg.top as root for the object structure ",
                                                 "category": "",
                                                 "in": [
                                                     {
                                                         "x": 60,
                                                         "y": 160,
                                                         "wires": [
                                                             {
                                                                 "id": "c15e0c9c.ecc39"
                                                             }
                                                         ]
                                                     }
                                                 ],
                                                 "out": [
                                                     {
                                                         "x": 2280,
                                                         "y": 260,
                                                         "wires": [
                                                             {
                                                                 "id": "8a2f0a9e.602858",
                                                                 "port": 0
                                                             },
                                                             {
                                                                 "id": "98a0ed8b.13619",
                                                                 "port": 0
                                                             }
                                                         ]
                                                     }
                                                 ],
                                                 "env": [],
                                                 "color": "#E2D96E",
                                                 "icon": "node-red/batch.svg"
                                             },
                                             {
                                                 "id": "45b4186c.2d7be8",
                                                 "type": "split",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "split object",
                                                 "splt": "\n",
                                                 "spltType": "str",
                                                 "arraySplt": 1,
                                                 "arraySpltType": "len",
                                                 "stream": false,
                                                 "addname": "key",
                                                 "x": 1170,
                                                 "y": 160,
                                                 "wires": [
                                                     [
                                                         "60d65adf.58b3e4"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "60d65adf.58b3e4",
                                                 "type": "change",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "add key to topic",
                                                 "rules": [
                                                     {
                                                         "t": "set",
                                                         "p": "stateName",
                                                         "pt": "msg",
                                                         "to": "key",
                                                         "tot": "msg"
                                                     },
                                                     {
                                                         "t": "set",
                                                         "p": "topic",
                                                         "pt": "msg",
                                                         "to": "topic & '.' & key",
                                                         "tot": "jsonata"
                                                     },
                                                     {
                                                         "t": "change",
                                                         "p": "topic",
                                                         "pt": "msg",
                                                         "from": " ",
                                                         "fromt": "str",
                                                         "to": "_",
                                                         "tot": "str"
                                                     }
                                                 ],
                                                 "action": "",
                                                 "property": "",
                                                 "from": "",
                                                 "to": "",
                                                 "reg": false,
                                                 "x": 1360,
                                                 "y": 160,
                                                 "wires": [
                                                     [
                                                         "8c4bc152.c6d6d"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "8c4bc152.c6d6d",
                                                 "type": "switch",
                                                 "z": "6fabb801.91dd08",
                                                 "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": 1540,
                                                 "y": 160,
                                                 "wires": [
                                                     [
                                                         "1ee1b9e5.d9c646"
                                                     ],
                                                     [
                                                         "45b4186c.2d7be8"
                                                     ],
                                                     [
                                                         "4a5f7457.df580c"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "1ee1b9e5.d9c646",
                                                 "type": "split",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "split array",
                                                 "splt": "\n",
                                                 "spltType": "str",
                                                 "arraySplt": 1,
                                                 "arraySpltType": "len",
                                                 "stream": false,
                                                 "addname": "",
                                                 "x": 580,
                                                 "y": 280,
                                                 "wires": [
                                                     [
                                                         "da3bfa91.495ae8"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "da3bfa91.495ae8",
                                                 "type": "change",
                                                 "z": "6fabb801.91dd08",
                                                 "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": 770,
                                                 "y": 280,
                                                 "wires": [
                                                     [
                                                         "434be766.d8d348"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "8a2f0a9e.602858",
                                                 "type": "change",
                                                 "z": "6fabb801.91dd08",
                                                 "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": 1970,
                                                 "y": 240,
                                                 "wires": [
                                                     []
                                                 ]
                                             },
                                             {
                                                 "id": "d5c90bb.83349f8",
                                                 "type": "switch",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "is type?",
                                                 "property": "payload",
                                                 "propertyType": "msg",
                                                 "rules": [
                                                     {
                                                         "t": "istype",
                                                         "v": "json",
                                                         "vt": "json"
                                                     },
                                                     {
                                                         "t": "istype",
                                                         "v": "object",
                                                         "vt": "object"
                                                     },
                                                     {
                                                         "t": "istype",
                                                         "v": "array",
                                                         "vt": "array"
                                                     },
                                                     {
                                                         "t": "else"
                                                     }
                                                 ],
                                                 "checkall": "true",
                                                 "repair": false,
                                                 "outputs": 4,
                                                 "x": 400,
                                                 "y": 160,
                                                 "wires": [
                                                     [
                                                         "6c970fd8.5d158"
                                                     ],
                                                     [
                                                         "45b4186c.2d7be8"
                                                     ],
                                                     [
                                                         "1ee1b9e5.d9c646"
                                                     ],
                                                     [
                                                         "434be766.d8d348"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "6c970fd8.5d158",
                                                 "type": "json",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "",
                                                 "property": "payload",
                                                 "action": "",
                                                 "pretty": false,
                                                 "x": 570,
                                                 "y": 120,
                                                 "wires": [
                                                     [
                                                         "911aeb92.3731a8"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "4a5f7457.df580c",
                                                 "type": "switch",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "is msg.top != null",
                                                 "property": "top",
                                                 "propertyType": "msg",
                                                 "rules": [
                                                     {
                                                         "t": "nnull"
                                                     },
                                                     {
                                                         "t": "null"
                                                     }
                                                 ],
                                                 "checkall": "true",
                                                 "repair": false,
                                                 "outputs": 2,
                                                 "x": 1750,
                                                 "y": 280,
                                                 "wires": [
                                                     [
                                                         "8a2f0a9e.602858"
                                                     ],
                                                     [
                                                         "17a9b663.ac136a"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "17a9b663.ac136a",
                                                 "type": "change",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "payload = warning",
                                                 "rules": [
                                                     {
                                                         "t": "set",
                                                         "p": "payload",
                                                         "pt": "msg",
                                                         "to": "Please define msg.top as root for the object structure",
                                                         "tot": "str"
                                                     },
                                                     {
                                                         "t": "delete",
                                                         "p": "topic",
                                                         "pt": "msg"
                                                     }
                                                 ],
                                                 "action": "",
                                                 "property": "",
                                                 "from": "",
                                                 "to": "",
                                                 "reg": false,
                                                 "x": 1970,
                                                 "y": 300,
                                                 "wires": [
                                                     [
                                                         "98a0ed8b.13619"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "98a0ed8b.13619",
                                                 "type": "rbe",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "",
                                                 "func": "rbe",
                                                 "gap": "",
                                                 "start": "",
                                                 "inout": "out",
                                                 "septopics": true,
                                                 "property": "payload",
                                                 "x": 2130,
                                                 "y": 300,
                                                 "wires": [
                                                     []
                                                 ]
                                             },
                                             {
                                                 "id": "c15e0c9c.ecc39",
                                                 "type": "change",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "",
                                                 "rules": [
                                                     {
                                                         "t": "delete",
                                                         "p": "topic",
                                                         "pt": "msg"
                                                     }
                                                 ],
                                                 "action": "",
                                                 "property": "",
                                                 "from": "",
                                                 "to": "",
                                                 "reg": false,
                                                 "x": 210,
                                                 "y": 160,
                                                 "wires": [
                                                     [
                                                         "d5c90bb.83349f8"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "911aeb92.3731a8",
                                                 "type": "switch",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "is array?",
                                                 "property": "payload",
                                                 "propertyType": "msg",
                                                 "rules": [
                                                     {
                                                         "t": "istype",
                                                         "v": "array",
                                                         "vt": "array"
                                                     },
                                                     {
                                                         "t": "else"
                                                     }
                                                 ],
                                                 "checkall": "true",
                                                 "repair": false,
                                                 "outputs": 2,
                                                 "x": 700,
                                                 "y": 120,
                                                 "wires": [
                                                     [
                                                         "1ee1b9e5.d9c646"
                                                     ],
                                                     [
                                                         "45b4186c.2d7be8"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "4b5fe636.eaf288",
                                                 "type": "comment",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "Array",
                                                 "info": "",
                                                 "x": 400,
                                                 "y": 280,
                                                 "wires": []
                                             },
                                             {
                                                 "id": "bb1a76c3.031228",
                                                 "type": "comment",
                                                 "z": "6fabb801.91dd08",
                                                 "name": "object",
                                                 "info": "",
                                                 "x": 1140,
                                                 "y": 100,
                                                 "wires": []
                                             },
                                             {
                                                 "id": "434be766.d8d348",
                                                 "type": "switch",
                                                 "z": "6fabb801.91dd08",
                                                 "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": 960,
                                                 "y": 280,
                                                 "wires": [
                                                     [
                                                         "45b4186c.2d7be8"
                                                     ],
                                                     [
                                                         "1ee1b9e5.d9c646"
                                                     ],
                                                     [
                                                         "4a5f7457.df580c"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "1a84a0da.5e21bf",
                                                 "type": "change",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "Binde Sensortyp in Datensatz",
                                                 "rules": [
                                                     {
                                                         "t": "set",
                                                         "p": "sensor",
                                                         "pt": "msg",
                                                         "to": "payload",
                                                         "tot": "msg"
                                                     },
                                                     {
                                                         "t": "change",
                                                         "p": "sensor",
                                                         "pt": "msg",
                                                         "from": "regulärer Ausdruck 1",
                                                         "fromt": "re",
                                                         "to": "sensor=$1&",
                                                         "tot": "str"
                                                     },
                                                     {
                                                         "t": "change",
                                                         "p": "payload",
                                                         "pt": "msg",
                                                         "from": "regulärer Ausdruck 1",
                                                         "fromt": "re",
                                                         "to": "$2",
                                                         "tot": "str"
                                                     },
                                                     {
                                                         "t": "set",
                                                         "p": "payload",
                                                         "pt": "msg",
                                                         "to": "sensor & payload",
                                                         "tot": "jsonata"
                                                     }
                                                 ],
                                                 "action": "",
                                                 "property": "",
                                                 "from": "",
                                                 "to": "",
                                                 "reg": false,
                                                 "x": 370,
                                                 "y": 420,
                                                 "wires": [
                                                     [
                                                         "8f2f9056.142df"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "422395bb.577e9c",
                                                 "type": "inject",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "Datensatz 1",
                                                 "props": [
                                                     {
                                                         "p": "payload"
                                                     }
                                                 ],
                                                 "repeat": "",
                                                 "crontab": "",
                                                 "once": false,
                                                 "onceDelay": 0.1,
                                                 "topic": "",
                                                 "payload": "1 v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0",
                                                 "payloadType": "str",
                                                 "x": 130,
                                                 "y": 380,
                                                 "wires": [
                                                     [
                                                         "1a84a0da.5e21bf"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "5847e67d.8cb448",
                                                 "type": "inject",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "Datensatz 2",
                                                 "props": [
                                                     {
                                                         "p": "payload"
                                                     }
                                                 ],
                                                 "repeat": "",
                                                 "crontab": "",
                                                 "once": false,
                                                 "onceDelay": 0.1,
                                                 "topic": "",
                                                 "payload": "2 v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2",
                                                 "payloadType": "str",
                                                 "x": 130,
                                                 "y": 460,
                                                 "wires": [
                                                     [
                                                         "1a84a0da.5e21bf"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "8f2f9056.142df",
                                                 "type": "change",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "",
                                                 "rules": [
                                                     {
                                                         "t": "set",
                                                         "p": "payload",
                                                         "pt": "msg",
                                                         "to": "$split(payload, '&')\t",
                                                         "tot": "jsonata"
                                                     }
                                                 ],
                                                 "action": "",
                                                 "property": "",
                                                 "from": "",
                                                 "to": "",
                                                 "reg": false,
                                                 "x": 630,
                                                 "y": 420,
                                                 "wires": [
                                                     [
                                                         "7fde6acc.98bef4"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "7fde6acc.98bef4",
                                                 "type": "split",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "",
                                                 "splt": "\n",
                                                 "spltType": "str",
                                                 "arraySplt": 1,
                                                 "arraySpltType": "len",
                                                 "stream": false,
                                                 "addname": "",
                                                 "x": 820,
                                                 "y": 420,
                                                 "wires": [
                                                     [
                                                         "ca901074.f895"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "ca901074.f895",
                                                 "type": "change",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "Bilde Key:Value Paare",
                                                 "rules": [
                                                     {
                                                         "t": "set",
                                                         "p": "topic",
                                                         "pt": "msg",
                                                         "to": "payload",
                                                         "tot": "msg"
                                                     },
                                                     {
                                                         "t": "change",
                                                         "p": "topic",
                                                         "pt": "msg",
                                                         "from": "regulärer Ausdruck 2",
                                                         "fromt": "re",
                                                         "to": "$1",
                                                         "tot": "str"
                                                     },
                                                     {
                                                         "t": "change",
                                                         "p": "payload",
                                                         "pt": "msg",
                                                         "from": "regulärer Ausdruck 2",
                                                         "fromt": "re",
                                                         "to": "$2",
                                                         "tot": "str"
                                                     }
                                                 ],
                                                 "action": "",
                                                 "property": "",
                                                 "from": "",
                                                 "to": "",
                                                 "reg": false,
                                                 "x": 1020,
                                                 "y": 420,
                                                 "wires": [
                                                     [
                                                         "17727545.61385b"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "17727545.61385b",
                                                 "type": "join",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "",
                                                 "mode": "custom",
                                                 "build": "object",
                                                 "property": "payload",
                                                 "propertyType": "msg",
                                                 "key": "topic",
                                                 "joiner": "",
                                                 "joinerType": "str",
                                                 "accumulate": false,
                                                 "timeout": "",
                                                 "count": "10",
                                                 "reduceRight": false,
                                                 "reduceExp": "",
                                                 "reduceInit": "",
                                                 "reduceInitType": "",
                                                 "reduceFixup": "",
                                                 "x": 1210,
                                                 "y": 420,
                                                 "wires": [
                                                     [
                                                         "9d55be3c.257f5"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "9d55be3c.257f5",
                                                 "type": "change",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "",
                                                 "rules": [
                                                     {
                                                         "t": "set",
                                                         "p": "top",
                                                         "pt": "msg",
                                                         "to": "'Example.Sensor' & payload.sensor",
                                                         "tot": "jsonata"
                                                     }
                                                 ],
                                                 "action": "",
                                                 "property": "",
                                                 "from": "",
                                                 "to": "",
                                                 "reg": false,
                                                 "x": 1380,
                                                 "y": 420,
                                                 "wires": [
                                                     [
                                                         "e764eefc.a2835"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "e764eefc.a2835",
                                                 "type": "subflow:6fabb801.91dd08",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "",
                                                 "x": 1620,
                                                 "y": 420,
                                                 "wires": [
                                                     [
                                                         "71bf22b3.d044ac"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "71bf22b3.d044ac",
                                                 "type": "change",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "",
                                                 "rules": [
                                                     {
                                                         "t": "change",
                                                         "p": "topic",
                                                         "pt": "msg",
                                                         "from": "0_userdata.0",
                                                         "fromt": "str",
                                                         "to": "",
                                                         "tot": "str"
                                                     },
                                                     {
                                                         "t": "change",
                                                         "p": "topic",
                                                         "pt": "msg",
                                                         "from": ".",
                                                         "fromt": "str",
                                                         "to": "/",
                                                         "tot": "str"
                                                     }
                                                 ],
                                                 "action": "",
                                                 "property": "",
                                                 "from": "",
                                                 "to": "",
                                                 "reg": false,
                                                 "x": 1860,
                                                 "y": 420,
                                                 "wires": [
                                                     [
                                                         "ea7816e.9451be8"
                                                     ]
                                                 ]
                                             },
                                             {
                                                 "id": "ea7816e.9451be8",
                                                 "type": "debug",
                                                 "z": "3a33383f.1533a8",
                                                 "name": "mqtt output",
                                                 "active": true,
                                                 "tosidebar": true,
                                                 "console": false,
                                                 "tostatus": false,
                                                 "complete": "payload",
                                                 "targetType": "msg",
                                                 "statusVal": "",
                                                 "statusType": "auto",
                                                 "x": 2050,
                                                 "y": 420,
                                                 "wires": []
                                             }
                                          ]
                                          

                                          In die 1. Change Node folgenden regulären Ausdruck:

                                          (\d)\s(.*)
                                          

                                          In die 2. Change Node folgenden regulären Ausdruck:

                                          (.*)=(.*)
                                          

                                          Das ist das Ergebnis - aber mit dem Steuerzeichen, weiß ich nicht 100%ig obs klappt.
                                          93efcd03-a9a2-4879-9f8b-01c38fbc3665-image.png

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

                                          Beliar_666B 1 Antwort Letzte Antwort
                                          1
                                          Antworten
                                          • In einem neuen Thema antworten
                                          Anmelden zum Antworten
                                          • Älteste zuerst
                                          • Neuste zuerst
                                          • Meiste Stimmen


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          984

                                          Online

                                          32.4k

                                          Benutzer

                                          81.5k

                                          Themen

                                          1.3m

                                          Beiträge
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Anmelden

                                          • Du hast noch kein Konto? Registrieren

                                          • Anmelden oder registrieren, um zu suchen
                                          • Erster Beitrag
                                            Letzter Beitrag
                                          0
                                          • Home
                                          • Aktuell
                                          • Tags
                                          • Ungelesen 0
                                          • Kategorien
                                          • Unreplied
                                          • Beliebt
                                          • GitHub
                                          • Docu
                                          • Hilfe