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. JSON oder JavaScript Objekt in iobroker Datenpunkte zerlegen

NEWS

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

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

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

JSON oder JavaScript Objekt in iobroker Datenpunkte zerlegen

Geplant Angeheftet Gesperrt Verschoben Node-Red
node-red
114 Beiträge 13 Kommentatoren 26.5k Aufrufe 12 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.
  • F Frank579

    Hallo @mickym,
    erst mal Danke für den Flow, habe aber noch ein paar Probleme die bestimmt vor dem Bildschirm sitzen ;) zu aller erst mal das sind meine ersten steh und geh versuche mit NodeRed, also bitte nicht schlagen :joy:
    habe vor nach und nach alles auf Mqtt zu ändern, da sich so einiges angesammelt hat (sonoff, schelly, owtrack,....) evtl.dann im Winter noch Zigbee.
    Habe am Wochenende mal einen Test IOBoker aufgesetzt, um mal zu schauen was auf mich zu kommt...
    Habe jetzt den Flow mal soweit eingerichtet, läuft auch fast gut. Als Topic habe ich erstmal nur # genommen, macht das sinn? möchte ja im Prinzip erst alles haben, oder mache ich besser für jedes Gerät der jede Gruppe einen eigenen Flow. Bekomme einige Fehler im Log da er alle States als readonly anlegt, das muss ich bestimmt irgendwo ändern, nur wo ?
    dann habe ich bei den shellys ein komisches verhalten, da legt er 2 Ordner für jeden shelly an habe mal ein par Bilder angefügt wie es unter Userdata.0 aussieht und im MQTT Adapter. Bestimmt ist da auch nu was falsch eingestellt :see_no_evil:
    Hier erst mal die Bilder
    Userdata.0
    userdata.PNG
    MQTT Adapter
    mqtt.PNG

    könntest du bitte etwas licht ins dunkle bringen :)
    Vielen Dank
    Gruß Frank

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

    @frank579

    Hallo erstmal - ist immer bissi schwierig das herauszufinden, das herauszufinden.

    Habe jetzt den Flow mal soweit eingerichtet, läuft auch fast gut. Als Topic habe ich erstmal nur # genommen, macht das sinn?

    Vielleicht solltest Du auch nicht gleich mit # anfangen, um nicht gleich alles zu laden. Aber das nur am Rande.

    Ich gehe mal davon aus, dass Du einen mit # das Subscribe Pattern des mqtt Adapters mit einem externen Broker meinst? Oder nutzt Du die mqtt-Nodes ...

    Bekomme einige Fehler im Log da er alle States als readonly anlegt, das muss ich bestimmt irgendwo ändern, nur wo ?

    Nun das machst Du nur in der iobroker-Out Node - hat mit dem Flow selbst nichts zu tun.
    Einfach da fix eintragen. - Ich hätte das zwar auch in dem Flow machen können, aber so ist man ggf. flexibler:

    d81f0b2e-0500-4e02-91d4-0f363ca98f31-image.png

    dann habe ich bei den shellys ein komisches verhalten, da legt er 2 Ordner für jeden shelly an habe mal ein par Bilder angefügt wie es unter Userdata.0 aussieht und im MQTT Adapter.

    Ich hab den Flow überarbeitet, damit sollte der Fehler nicht mehr auftreten. Bitte die Node aus dem nachfolgenden Post importieren und den Subflow wie beschrieben ersetzen.

    @frank579 - also vielen Dank - für das Beschreiben des Bugs - das mit dem 2. Ordner sollte nicht mehr auftreten. So wird der Flow immer besser. ;) - Ich empfehle Dir nochmal den ganzen Objektbaum unter 0_userdata.0 zu löschen, der von dem Flow angelegt wurde und neu zu erstellen - auch wegen den Schreibrechten - ich werde solche Einstellungen aber nicht in dem Flow festlegen, so dass man selbst entscheiden kann über die iobroker-Out Node.

    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.

    mickymM F 2 Antworten Letzte Antwort
    1
    • mickymM mickym

      @frank579

      Hallo erstmal - ist immer bissi schwierig das herauszufinden, das herauszufinden.

      Habe jetzt den Flow mal soweit eingerichtet, läuft auch fast gut. Als Topic habe ich erstmal nur # genommen, macht das sinn?

      Vielleicht solltest Du auch nicht gleich mit # anfangen, um nicht gleich alles zu laden. Aber das nur am Rande.

      Ich gehe mal davon aus, dass Du einen mit # das Subscribe Pattern des mqtt Adapters mit einem externen Broker meinst? Oder nutzt Du die mqtt-Nodes ...

      Bekomme einige Fehler im Log da er alle States als readonly anlegt, das muss ich bestimmt irgendwo ändern, nur wo ?

      Nun das machst Du nur in der iobroker-Out Node - hat mit dem Flow selbst nichts zu tun.
      Einfach da fix eintragen. - Ich hätte das zwar auch in dem Flow machen können, aber so ist man ggf. flexibler:

      d81f0b2e-0500-4e02-91d4-0f363ca98f31-image.png

      dann habe ich bei den shellys ein komisches verhalten, da legt er 2 Ordner für jeden shelly an habe mal ein par Bilder angefügt wie es unter Userdata.0 aussieht und im MQTT Adapter.

      Ich hab den Flow überarbeitet, damit sollte der Fehler nicht mehr auftreten. Bitte die Node aus dem nachfolgenden Post importieren und den Subflow wie beschrieben ersetzen.

      @frank579 - also vielen Dank - für das Beschreiben des Bugs - das mit dem 2. Ordner sollte nicht mehr auftreten. So wird der Flow immer besser. ;) - Ich empfehle Dir nochmal den ganzen Objektbaum unter 0_userdata.0 zu löschen, der von dem Flow angelegt wurde und neu zu erstellen - auch wegen den Schreibrechten - ich werde solche Einstellungen aber nicht in dem Flow festlegen, so dass man selbst entscheiden kann über die iobroker-Out Node.

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

      @mickym So ich habe es nun selbst getestet und die Änderung durchgeführt.

      Hier ist nun eine neue Version des Subflows:

      090dce7d-22fb-4ee4-8f6f-61a0ad8e9227-image.png

      [
         {
             "id": "6e802f1553b18149",
             "type": "subflow",
             "name": "JSON or Obj to IOBroker",
             "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
             "category": "",
             "in": [
                 {
                     "x": 60,
                     "y": 160,
                     "wires": [
                         {
                             "id": "554b8c663bcb46c2"
                         }
                     ]
                 }
             ],
             "out": [
                 {
                     "x": 2620,
                     "y": 280,
                     "wires": [
                         {
                             "id": "0962842ebd23e0d7",
                             "port": 0
                         }
                     ]
                 }
             ],
             "env": [
                 {
                     "name": "top",
                     "type": "str",
                     "value": "objRoot"
                 },
                 {
                     "name": "keepTopic",
                     "type": "bool",
                     "value": "false"
                 }
             ],
             "meta": {},
             "color": "#E2D96E",
             "icon": "node-red/batch.svg"
         },
         {
             "id": "3e11e8338f694832",
             "type": "split",
             "z": "6e802f1553b18149",
             "name": "split object",
             "splt": "\\n",
             "spltType": "str",
             "arraySplt": 1,
             "arraySpltType": "len",
             "stream": false,
             "addname": "key",
             "x": 1370,
             "y": 160,
             "wires": [
                 [
                     "0562a4249c8b856b"
                 ]
             ]
         },
         {
             "id": "0562a4249c8b856b",
             "type": "change",
             "z": "6e802f1553b18149",
             "name": "add key to topic",
             "rules": [
                 {
                     "t": "set",
                     "p": "stateName",
                     "pt": "msg",
                     "to": "key",
                     "tot": "msg"
                 },
                 {
                     "t": "set",
                     "p": "topic",
                     "pt": "msg",
                     "to": "topic  & '.' & key",
                     "tot": "jsonata"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 1560,
             "y": 160,
             "wires": [
                 [
                     "ddc90985bef0fafa"
                 ]
             ]
         },
         {
             "id": "ddc90985bef0fafa",
             "type": "switch",
             "z": "6e802f1553b18149",
             "name": "is type?",
             "property": "payload",
             "propertyType": "msg",
             "rules": [
                 {
                     "t": "istype",
                     "v": "array",
                     "vt": "array"
                 },
                 {
                     "t": "istype",
                     "v": "object",
                     "vt": "object"
                 },
                 {
                     "t": "else"
                 }
             ],
             "checkall": "true",
             "repair": false,
             "outputs": 3,
             "x": 1740,
             "y": 160,
             "wires": [
                 [
                     "bfce19b206660fbe"
                 ],
                 [
                     "3e11e8338f694832"
                 ],
                 [
                     "1a8c03d866b85b12"
                 ]
             ]
         },
         {
             "id": "bfce19b206660fbe",
             "type": "split",
             "z": "6e802f1553b18149",
             "name": "split array",
             "splt": "\\n",
             "spltType": "str",
             "arraySplt": 1,
             "arraySpltType": "len",
             "stream": false,
             "addname": "",
             "x": 780,
             "y": 280,
             "wires": [
                 [
                     "e89927810c6d75ec"
                 ]
             ]
         },
         {
             "id": "e89927810c6d75ec",
             "type": "change",
             "z": "6e802f1553b18149",
             "name": "add index to topic",
             "rules": [
                 {
                     "t": "set",
                     "p": "topic",
                     "pt": "msg",
                     "to": "topic  & '.' & parts.index",
                     "tot": "jsonata"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 970,
             "y": 280,
             "wires": [
                 [
                     "a4d1a5d04564dc77"
                 ]
             ]
         },
         {
             "id": "f5d52c6a57d08904",
             "type": "change",
             "z": "6e802f1553b18149",
             "name": "finalize msg.topic",
             "rules": [
                 {
                     "t": "set",
                     "p": "top",
                     "pt": "msg",
                     "to": "'0_userdata.0.' & top",
                     "tot": "jsonata"
                 },
                 {
                     "t": "set",
                     "p": "topic",
                     "pt": "msg",
                     "to": "top & '.' & topic",
                     "tot": "jsonata"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 2170,
             "y": 240,
             "wires": [
                 [
                     "0962842ebd23e0d7"
                 ]
             ]
         },
         {
             "id": "c863dd7d651b2272",
             "type": "switch",
             "z": "6e802f1553b18149",
             "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": 580,
             "y": 160,
             "wires": [
                 [
                     "158930afddd0780b"
                 ],
                 [
                     "3e11e8338f694832"
                 ],
                 [
                     "bfce19b206660fbe"
                 ],
                 [
                     "a4d1a5d04564dc77"
                 ]
             ]
         },
         {
             "id": "158930afddd0780b",
             "type": "json",
             "z": "6e802f1553b18149",
             "name": "",
             "property": "payload",
             "action": "",
             "pretty": false,
             "x": 770,
             "y": 120,
             "wires": [
                 [
                     "3649300b4c233b10"
                 ]
             ]
         },
         {
             "id": "1a8c03d866b85b12",
             "type": "switch",
             "z": "6e802f1553b18149",
             "name": "is msg.top != null",
             "property": "top",
             "propertyType": "msg",
             "rules": [
                 {
                     "t": "nnull"
                 },
                 {
                     "t": "null"
                 }
             ],
             "checkall": "true",
             "repair": false,
             "outputs": 2,
             "x": 1950,
             "y": 280,
             "wires": [
                 [
                     "f5d52c6a57d08904"
                 ],
                 [
                     "74c895ce724750de"
                 ]
             ]
         },
         {
             "id": "e023fe88445ce43e",
             "type": "change",
             "z": "6e802f1553b18149",
             "name": "",
             "rules": [
                 {
                     "t": "delete",
                     "p": "topic",
                     "pt": "msg"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 350,
             "y": 200,
             "wires": [
                 [
                     "c863dd7d651b2272"
                 ]
             ]
         },
         {
             "id": "3649300b4c233b10",
             "type": "switch",
             "z": "6e802f1553b18149",
             "name": "is array?",
             "property": "payload",
             "propertyType": "msg",
             "rules": [
                 {
                     "t": "istype",
                     "v": "array",
                     "vt": "array"
                 },
                 {
                     "t": "else"
                 }
             ],
             "checkall": "true",
             "repair": false,
             "outputs": 2,
             "x": 900,
             "y": 120,
             "wires": [
                 [
                     "bfce19b206660fbe"
                 ],
                 [
                     "3e11e8338f694832"
                 ]
             ]
         },
         {
             "id": "1b8480cd2df7ba3f",
             "type": "comment",
             "z": "6e802f1553b18149",
             "name": "Array",
             "info": "",
             "x": 600,
             "y": 280,
             "wires": []
         },
         {
             "id": "b3541807672be040",
             "type": "comment",
             "z": "6e802f1553b18149",
             "name": "object",
             "info": "",
             "x": 1340,
             "y": 100,
             "wires": []
         },
         {
             "id": "a4d1a5d04564dc77",
             "type": "switch",
             "z": "6e802f1553b18149",
             "name": "is type?",
             "property": "payload",
             "propertyType": "msg",
             "rules": [
                 {
                     "t": "istype",
                     "v": "object",
                     "vt": "object"
                 },
                 {
                     "t": "istype",
                     "v": "array",
                     "vt": "array"
                 },
                 {
                     "t": "else"
                 }
             ],
             "checkall": "true",
             "repair": false,
             "outputs": 3,
             "x": 1160,
             "y": 280,
             "wires": [
                 [
                     "3e11e8338f694832"
                 ],
                 [
                     "bfce19b206660fbe"
                 ],
                 [
                     "1a8c03d866b85b12"
                 ]
             ]
         },
         {
             "id": "74c895ce724750de",
             "type": "change",
             "z": "6e802f1553b18149",
             "name": "finalize msg.topic",
             "rules": [
                 {
                     "t": "set",
                     "p": "top",
                     "pt": "msg",
                     "to": "top",
                     "tot": "env"
                 },
                 {
                     "t": "set",
                     "p": "top",
                     "pt": "msg",
                     "to": "'0_userdata.0.' & top",
                     "tot": "jsonata"
                 },
                 {
                     "t": "set",
                     "p": "topic",
                     "pt": "msg",
                     "to": "top & '.' & topic",
                     "tot": "jsonata"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 2170,
             "y": 320,
             "wires": [
                 [
                     "0962842ebd23e0d7"
                 ]
             ]
         },
         {
             "id": "554b8c663bcb46c2",
             "type": "switch",
             "z": "6e802f1553b18149",
             "name": "",
             "property": "keepTopic",
             "propertyType": "env",
             "rules": [
                 {
                     "t": "true"
                 },
                 {
                     "t": "false"
                 }
             ],
             "checkall": "true",
             "repair": false,
             "outputs": 2,
             "x": 170,
             "y": 160,
             "wires": [
                 [
                     "e30ba9f0483285e4"
                 ],
                 [
                     "e023fe88445ce43e"
                 ]
             ]
         },
         {
             "id": "e30ba9f0483285e4",
             "type": "change",
             "z": "6e802f1553b18149",
             "name": "",
             "rules": [
                 {
                     "t": "change",
                     "p": "topic",
                     "pt": "msg",
                     "from": "/",
                     "fromt": "str",
                     "to": ".",
                     "tot": "str"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 350,
             "y": 120,
             "wires": [
                 [
                     "c863dd7d651b2272"
                 ]
             ]
         },
         {
             "id": "0962842ebd23e0d7",
             "type": "change",
             "z": "6e802f1553b18149",
             "name": "translate invalid chars in topic",
             "rules": [
                 {
                     "t": "change",
                     "p": "topic",
                     "pt": "msg",
                     "from": "..",
                     "fromt": "str",
                     "to": ".",
                     "tot": "str"
                 },
                 {
                     "t": "change",
                     "p": "topic",
                     "pt": "msg",
                     "from": "€",
                     "fromt": "str",
                     "to": "EUR",
                     "tot": "str"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 2430,
             "y": 280,
             "wires": [
                 []
             ]
         },
         {
             "id": "df544262fde22aca",
             "type": "subflow:6e802f1553b18149",
             "z": "393214410c8f2f15",
             "name": "",
             "x": 910,
             "y": 580,
             "wires": [
                 []
             ]
         }
      ]
      

      Für alle die, die Node bereits benutzen - wie folgt vorgehen.

      1. Den Code normal in die Zwischenablage kopieren und dann importieren.
      2. Da das System erkennst, dass es diesen Subflow/Nodes bereits gibt - bitte auf "Zeige Nodes ... " gehen.

      07910a9e-986e-4d20-aa8a-694cf1a0a62e-image.png

      1. Anschließend braucht man nur den Subflow ersetzen.

      0861d7e5-b997-4960-b83c-309033d5015b-image.png

      1. Nach dem man auf "Importiere Auswahl" geklickt hat, wird einem angezeigt, wieviele Nodes ersetzt wurden. Dann noch auf Deploy.

      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.

      F 2 Antworten Letzte Antwort
      2
      • mickymM mickym

        @mickym So ich habe es nun selbst getestet und die Änderung durchgeführt.

        Hier ist nun eine neue Version des Subflows:

        090dce7d-22fb-4ee4-8f6f-61a0ad8e9227-image.png

        [
           {
               "id": "6e802f1553b18149",
               "type": "subflow",
               "name": "JSON or Obj to IOBroker",
               "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
               "category": "",
               "in": [
                   {
                       "x": 60,
                       "y": 160,
                       "wires": [
                           {
                               "id": "554b8c663bcb46c2"
                           }
                       ]
                   }
               ],
               "out": [
                   {
                       "x": 2620,
                       "y": 280,
                       "wires": [
                           {
                               "id": "0962842ebd23e0d7",
                               "port": 0
                           }
                       ]
                   }
               ],
               "env": [
                   {
                       "name": "top",
                       "type": "str",
                       "value": "objRoot"
                   },
                   {
                       "name": "keepTopic",
                       "type": "bool",
                       "value": "false"
                   }
               ],
               "meta": {},
               "color": "#E2D96E",
               "icon": "node-red/batch.svg"
           },
           {
               "id": "3e11e8338f694832",
               "type": "split",
               "z": "6e802f1553b18149",
               "name": "split object",
               "splt": "\\n",
               "spltType": "str",
               "arraySplt": 1,
               "arraySpltType": "len",
               "stream": false,
               "addname": "key",
               "x": 1370,
               "y": 160,
               "wires": [
                   [
                       "0562a4249c8b856b"
                   ]
               ]
           },
           {
               "id": "0562a4249c8b856b",
               "type": "change",
               "z": "6e802f1553b18149",
               "name": "add key to topic",
               "rules": [
                   {
                       "t": "set",
                       "p": "stateName",
                       "pt": "msg",
                       "to": "key",
                       "tot": "msg"
                   },
                   {
                       "t": "set",
                       "p": "topic",
                       "pt": "msg",
                       "to": "topic  & '.' & key",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 1560,
               "y": 160,
               "wires": [
                   [
                       "ddc90985bef0fafa"
                   ]
               ]
           },
           {
               "id": "ddc90985bef0fafa",
               "type": "switch",
               "z": "6e802f1553b18149",
               "name": "is type?",
               "property": "payload",
               "propertyType": "msg",
               "rules": [
                   {
                       "t": "istype",
                       "v": "array",
                       "vt": "array"
                   },
                   {
                       "t": "istype",
                       "v": "object",
                       "vt": "object"
                   },
                   {
                       "t": "else"
                   }
               ],
               "checkall": "true",
               "repair": false,
               "outputs": 3,
               "x": 1740,
               "y": 160,
               "wires": [
                   [
                       "bfce19b206660fbe"
                   ],
                   [
                       "3e11e8338f694832"
                   ],
                   [
                       "1a8c03d866b85b12"
                   ]
               ]
           },
           {
               "id": "bfce19b206660fbe",
               "type": "split",
               "z": "6e802f1553b18149",
               "name": "split array",
               "splt": "\\n",
               "spltType": "str",
               "arraySplt": 1,
               "arraySpltType": "len",
               "stream": false,
               "addname": "",
               "x": 780,
               "y": 280,
               "wires": [
                   [
                       "e89927810c6d75ec"
                   ]
               ]
           },
           {
               "id": "e89927810c6d75ec",
               "type": "change",
               "z": "6e802f1553b18149",
               "name": "add index to topic",
               "rules": [
                   {
                       "t": "set",
                       "p": "topic",
                       "pt": "msg",
                       "to": "topic  & '.' & parts.index",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 970,
               "y": 280,
               "wires": [
                   [
                       "a4d1a5d04564dc77"
                   ]
               ]
           },
           {
               "id": "f5d52c6a57d08904",
               "type": "change",
               "z": "6e802f1553b18149",
               "name": "finalize msg.topic",
               "rules": [
                   {
                       "t": "set",
                       "p": "top",
                       "pt": "msg",
                       "to": "'0_userdata.0.' & top",
                       "tot": "jsonata"
                   },
                   {
                       "t": "set",
                       "p": "topic",
                       "pt": "msg",
                       "to": "top & '.' & topic",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 2170,
               "y": 240,
               "wires": [
                   [
                       "0962842ebd23e0d7"
                   ]
               ]
           },
           {
               "id": "c863dd7d651b2272",
               "type": "switch",
               "z": "6e802f1553b18149",
               "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": 580,
               "y": 160,
               "wires": [
                   [
                       "158930afddd0780b"
                   ],
                   [
                       "3e11e8338f694832"
                   ],
                   [
                       "bfce19b206660fbe"
                   ],
                   [
                       "a4d1a5d04564dc77"
                   ]
               ]
           },
           {
               "id": "158930afddd0780b",
               "type": "json",
               "z": "6e802f1553b18149",
               "name": "",
               "property": "payload",
               "action": "",
               "pretty": false,
               "x": 770,
               "y": 120,
               "wires": [
                   [
                       "3649300b4c233b10"
                   ]
               ]
           },
           {
               "id": "1a8c03d866b85b12",
               "type": "switch",
               "z": "6e802f1553b18149",
               "name": "is msg.top != null",
               "property": "top",
               "propertyType": "msg",
               "rules": [
                   {
                       "t": "nnull"
                   },
                   {
                       "t": "null"
                   }
               ],
               "checkall": "true",
               "repair": false,
               "outputs": 2,
               "x": 1950,
               "y": 280,
               "wires": [
                   [
                       "f5d52c6a57d08904"
                   ],
                   [
                       "74c895ce724750de"
                   ]
               ]
           },
           {
               "id": "e023fe88445ce43e",
               "type": "change",
               "z": "6e802f1553b18149",
               "name": "",
               "rules": [
                   {
                       "t": "delete",
                       "p": "topic",
                       "pt": "msg"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 350,
               "y": 200,
               "wires": [
                   [
                       "c863dd7d651b2272"
                   ]
               ]
           },
           {
               "id": "3649300b4c233b10",
               "type": "switch",
               "z": "6e802f1553b18149",
               "name": "is array?",
               "property": "payload",
               "propertyType": "msg",
               "rules": [
                   {
                       "t": "istype",
                       "v": "array",
                       "vt": "array"
                   },
                   {
                       "t": "else"
                   }
               ],
               "checkall": "true",
               "repair": false,
               "outputs": 2,
               "x": 900,
               "y": 120,
               "wires": [
                   [
                       "bfce19b206660fbe"
                   ],
                   [
                       "3e11e8338f694832"
                   ]
               ]
           },
           {
               "id": "1b8480cd2df7ba3f",
               "type": "comment",
               "z": "6e802f1553b18149",
               "name": "Array",
               "info": "",
               "x": 600,
               "y": 280,
               "wires": []
           },
           {
               "id": "b3541807672be040",
               "type": "comment",
               "z": "6e802f1553b18149",
               "name": "object",
               "info": "",
               "x": 1340,
               "y": 100,
               "wires": []
           },
           {
               "id": "a4d1a5d04564dc77",
               "type": "switch",
               "z": "6e802f1553b18149",
               "name": "is type?",
               "property": "payload",
               "propertyType": "msg",
               "rules": [
                   {
                       "t": "istype",
                       "v": "object",
                       "vt": "object"
                   },
                   {
                       "t": "istype",
                       "v": "array",
                       "vt": "array"
                   },
                   {
                       "t": "else"
                   }
               ],
               "checkall": "true",
               "repair": false,
               "outputs": 3,
               "x": 1160,
               "y": 280,
               "wires": [
                   [
                       "3e11e8338f694832"
                   ],
                   [
                       "bfce19b206660fbe"
                   ],
                   [
                       "1a8c03d866b85b12"
                   ]
               ]
           },
           {
               "id": "74c895ce724750de",
               "type": "change",
               "z": "6e802f1553b18149",
               "name": "finalize msg.topic",
               "rules": [
                   {
                       "t": "set",
                       "p": "top",
                       "pt": "msg",
                       "to": "top",
                       "tot": "env"
                   },
                   {
                       "t": "set",
                       "p": "top",
                       "pt": "msg",
                       "to": "'0_userdata.0.' & top",
                       "tot": "jsonata"
                   },
                   {
                       "t": "set",
                       "p": "topic",
                       "pt": "msg",
                       "to": "top & '.' & topic",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 2170,
               "y": 320,
               "wires": [
                   [
                       "0962842ebd23e0d7"
                   ]
               ]
           },
           {
               "id": "554b8c663bcb46c2",
               "type": "switch",
               "z": "6e802f1553b18149",
               "name": "",
               "property": "keepTopic",
               "propertyType": "env",
               "rules": [
                   {
                       "t": "true"
                   },
                   {
                       "t": "false"
                   }
               ],
               "checkall": "true",
               "repair": false,
               "outputs": 2,
               "x": 170,
               "y": 160,
               "wires": [
                   [
                       "e30ba9f0483285e4"
                   ],
                   [
                       "e023fe88445ce43e"
                   ]
               ]
           },
           {
               "id": "e30ba9f0483285e4",
               "type": "change",
               "z": "6e802f1553b18149",
               "name": "",
               "rules": [
                   {
                       "t": "change",
                       "p": "topic",
                       "pt": "msg",
                       "from": "/",
                       "fromt": "str",
                       "to": ".",
                       "tot": "str"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 350,
               "y": 120,
               "wires": [
                   [
                       "c863dd7d651b2272"
                   ]
               ]
           },
           {
               "id": "0962842ebd23e0d7",
               "type": "change",
               "z": "6e802f1553b18149",
               "name": "translate invalid chars in topic",
               "rules": [
                   {
                       "t": "change",
                       "p": "topic",
                       "pt": "msg",
                       "from": "..",
                       "fromt": "str",
                       "to": ".",
                       "tot": "str"
                   },
                   {
                       "t": "change",
                       "p": "topic",
                       "pt": "msg",
                       "from": "€",
                       "fromt": "str",
                       "to": "EUR",
                       "tot": "str"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 2430,
               "y": 280,
               "wires": [
                   []
               ]
           },
           {
               "id": "df544262fde22aca",
               "type": "subflow:6e802f1553b18149",
               "z": "393214410c8f2f15",
               "name": "",
               "x": 910,
               "y": 580,
               "wires": [
                   []
               ]
           }
        ]
        

        Für alle die, die Node bereits benutzen - wie folgt vorgehen.

        1. Den Code normal in die Zwischenablage kopieren und dann importieren.
        2. Da das System erkennst, dass es diesen Subflow/Nodes bereits gibt - bitte auf "Zeige Nodes ... " gehen.

        07910a9e-986e-4d20-aa8a-694cf1a0a62e-image.png

        1. Anschließend braucht man nur den Subflow ersetzen.

        0861d7e5-b997-4960-b83c-309033d5015b-image.png

        1. Nach dem man auf "Importiere Auswahl" geklickt hat, wird einem angezeigt, wieviele Nodes ersetzt wurden. Dann noch auf Deploy.
        F Offline
        F Offline
        Frank579
        schrieb am zuletzt editiert von
        #65

        @mickym sagte in JSON oder JavaScript Objekt in iobroker Datenpunkte zerlegen:

        @mickym So ich habe es nun selbst getestet und die Änderung durchgeführt.
        Hier ist nun eine neue Version des Subflows:

        Wow vielen Dank, sorry war gestern nochmal unterwegs, habs gerade mal schnell getestet sieht auf den ersten Blick sehr gut aus, Danke :+1:

        1 Antwort Letzte Antwort
        0
        • mickymM mickym

          @frank579

          Hallo erstmal - ist immer bissi schwierig das herauszufinden, das herauszufinden.

          Habe jetzt den Flow mal soweit eingerichtet, läuft auch fast gut. Als Topic habe ich erstmal nur # genommen, macht das sinn?

          Vielleicht solltest Du auch nicht gleich mit # anfangen, um nicht gleich alles zu laden. Aber das nur am Rande.

          Ich gehe mal davon aus, dass Du einen mit # das Subscribe Pattern des mqtt Adapters mit einem externen Broker meinst? Oder nutzt Du die mqtt-Nodes ...

          Bekomme einige Fehler im Log da er alle States als readonly anlegt, das muss ich bestimmt irgendwo ändern, nur wo ?

          Nun das machst Du nur in der iobroker-Out Node - hat mit dem Flow selbst nichts zu tun.
          Einfach da fix eintragen. - Ich hätte das zwar auch in dem Flow machen können, aber so ist man ggf. flexibler:

          d81f0b2e-0500-4e02-91d4-0f363ca98f31-image.png

          dann habe ich bei den shellys ein komisches verhalten, da legt er 2 Ordner für jeden shelly an habe mal ein par Bilder angefügt wie es unter Userdata.0 aussieht und im MQTT Adapter.

          Ich hab den Flow überarbeitet, damit sollte der Fehler nicht mehr auftreten. Bitte die Node aus dem nachfolgenden Post importieren und den Subflow wie beschrieben ersetzen.

          @frank579 - also vielen Dank - für das Beschreiben des Bugs - das mit dem 2. Ordner sollte nicht mehr auftreten. So wird der Flow immer besser. ;) - Ich empfehle Dir nochmal den ganzen Objektbaum unter 0_userdata.0 zu löschen, der von dem Flow angelegt wurde und neu zu erstellen - auch wegen den Schreibrechten - ich werde solche Einstellungen aber nicht in dem Flow festlegen, so dass man selbst entscheiden kann über die iobroker-Out Node.

          F Offline
          F Offline
          Frank579
          schrieb am zuletzt editiert von
          #66

          @mickym sagte in JSON oder JavaScript Objekt in iobroker Datenpunkte zerlegen:

          Ich gehe mal davon aus, dass Du einen mit # das Subscribe Pattern des mqtt Adapters mit einem externen Broker meinst? Oder nutzt Du die mqtt-Nodes ...

          Ja genau habe einen Mosquitto server laufen, da laufen aktuell aber erst mal zum testen nur die drei Geräte.
          Aber hier komme ich jetzt erst mal weiter die Json zu zerlegen und ich alle Infos schon mal in eigenen Datenpunkten habe.
          Muss jetzt mal schauen wie ich das alles umsetze, auch nachher mit der Ansteuerung der Datenpunkte.

          1 Antwort Letzte Antwort
          0
          • mickymM mickym

            @mickym So ich habe es nun selbst getestet und die Änderung durchgeführt.

            Hier ist nun eine neue Version des Subflows:

            090dce7d-22fb-4ee4-8f6f-61a0ad8e9227-image.png

            [
               {
                   "id": "6e802f1553b18149",
                   "type": "subflow",
                   "name": "JSON or Obj to IOBroker",
                   "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
                   "category": "",
                   "in": [
                       {
                           "x": 60,
                           "y": 160,
                           "wires": [
                               {
                                   "id": "554b8c663bcb46c2"
                               }
                           ]
                       }
                   ],
                   "out": [
                       {
                           "x": 2620,
                           "y": 280,
                           "wires": [
                               {
                                   "id": "0962842ebd23e0d7",
                                   "port": 0
                               }
                           ]
                       }
                   ],
                   "env": [
                       {
                           "name": "top",
                           "type": "str",
                           "value": "objRoot"
                       },
                       {
                           "name": "keepTopic",
                           "type": "bool",
                           "value": "false"
                       }
                   ],
                   "meta": {},
                   "color": "#E2D96E",
                   "icon": "node-red/batch.svg"
               },
               {
                   "id": "3e11e8338f694832",
                   "type": "split",
                   "z": "6e802f1553b18149",
                   "name": "split object",
                   "splt": "\\n",
                   "spltType": "str",
                   "arraySplt": 1,
                   "arraySpltType": "len",
                   "stream": false,
                   "addname": "key",
                   "x": 1370,
                   "y": 160,
                   "wires": [
                       [
                           "0562a4249c8b856b"
                       ]
                   ]
               },
               {
                   "id": "0562a4249c8b856b",
                   "type": "change",
                   "z": "6e802f1553b18149",
                   "name": "add key to topic",
                   "rules": [
                       {
                           "t": "set",
                           "p": "stateName",
                           "pt": "msg",
                           "to": "key",
                           "tot": "msg"
                       },
                       {
                           "t": "set",
                           "p": "topic",
                           "pt": "msg",
                           "to": "topic  & '.' & key",
                           "tot": "jsonata"
                       }
                   ],
                   "action": "",
                   "property": "",
                   "from": "",
                   "to": "",
                   "reg": false,
                   "x": 1560,
                   "y": 160,
                   "wires": [
                       [
                           "ddc90985bef0fafa"
                       ]
                   ]
               },
               {
                   "id": "ddc90985bef0fafa",
                   "type": "switch",
                   "z": "6e802f1553b18149",
                   "name": "is type?",
                   "property": "payload",
                   "propertyType": "msg",
                   "rules": [
                       {
                           "t": "istype",
                           "v": "array",
                           "vt": "array"
                       },
                       {
                           "t": "istype",
                           "v": "object",
                           "vt": "object"
                       },
                       {
                           "t": "else"
                       }
                   ],
                   "checkall": "true",
                   "repair": false,
                   "outputs": 3,
                   "x": 1740,
                   "y": 160,
                   "wires": [
                       [
                           "bfce19b206660fbe"
                       ],
                       [
                           "3e11e8338f694832"
                       ],
                       [
                           "1a8c03d866b85b12"
                       ]
                   ]
               },
               {
                   "id": "bfce19b206660fbe",
                   "type": "split",
                   "z": "6e802f1553b18149",
                   "name": "split array",
                   "splt": "\\n",
                   "spltType": "str",
                   "arraySplt": 1,
                   "arraySpltType": "len",
                   "stream": false,
                   "addname": "",
                   "x": 780,
                   "y": 280,
                   "wires": [
                       [
                           "e89927810c6d75ec"
                       ]
                   ]
               },
               {
                   "id": "e89927810c6d75ec",
                   "type": "change",
                   "z": "6e802f1553b18149",
                   "name": "add index to topic",
                   "rules": [
                       {
                           "t": "set",
                           "p": "topic",
                           "pt": "msg",
                           "to": "topic  & '.' & parts.index",
                           "tot": "jsonata"
                       }
                   ],
                   "action": "",
                   "property": "",
                   "from": "",
                   "to": "",
                   "reg": false,
                   "x": 970,
                   "y": 280,
                   "wires": [
                       [
                           "a4d1a5d04564dc77"
                       ]
                   ]
               },
               {
                   "id": "f5d52c6a57d08904",
                   "type": "change",
                   "z": "6e802f1553b18149",
                   "name": "finalize msg.topic",
                   "rules": [
                       {
                           "t": "set",
                           "p": "top",
                           "pt": "msg",
                           "to": "'0_userdata.0.' & top",
                           "tot": "jsonata"
                       },
                       {
                           "t": "set",
                           "p": "topic",
                           "pt": "msg",
                           "to": "top & '.' & topic",
                           "tot": "jsonata"
                       }
                   ],
                   "action": "",
                   "property": "",
                   "from": "",
                   "to": "",
                   "reg": false,
                   "x": 2170,
                   "y": 240,
                   "wires": [
                       [
                           "0962842ebd23e0d7"
                       ]
                   ]
               },
               {
                   "id": "c863dd7d651b2272",
                   "type": "switch",
                   "z": "6e802f1553b18149",
                   "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": 580,
                   "y": 160,
                   "wires": [
                       [
                           "158930afddd0780b"
                       ],
                       [
                           "3e11e8338f694832"
                       ],
                       [
                           "bfce19b206660fbe"
                       ],
                       [
                           "a4d1a5d04564dc77"
                       ]
                   ]
               },
               {
                   "id": "158930afddd0780b",
                   "type": "json",
                   "z": "6e802f1553b18149",
                   "name": "",
                   "property": "payload",
                   "action": "",
                   "pretty": false,
                   "x": 770,
                   "y": 120,
                   "wires": [
                       [
                           "3649300b4c233b10"
                       ]
                   ]
               },
               {
                   "id": "1a8c03d866b85b12",
                   "type": "switch",
                   "z": "6e802f1553b18149",
                   "name": "is msg.top != null",
                   "property": "top",
                   "propertyType": "msg",
                   "rules": [
                       {
                           "t": "nnull"
                       },
                       {
                           "t": "null"
                       }
                   ],
                   "checkall": "true",
                   "repair": false,
                   "outputs": 2,
                   "x": 1950,
                   "y": 280,
                   "wires": [
                       [
                           "f5d52c6a57d08904"
                       ],
                       [
                           "74c895ce724750de"
                       ]
                   ]
               },
               {
                   "id": "e023fe88445ce43e",
                   "type": "change",
                   "z": "6e802f1553b18149",
                   "name": "",
                   "rules": [
                       {
                           "t": "delete",
                           "p": "topic",
                           "pt": "msg"
                       }
                   ],
                   "action": "",
                   "property": "",
                   "from": "",
                   "to": "",
                   "reg": false,
                   "x": 350,
                   "y": 200,
                   "wires": [
                       [
                           "c863dd7d651b2272"
                       ]
                   ]
               },
               {
                   "id": "3649300b4c233b10",
                   "type": "switch",
                   "z": "6e802f1553b18149",
                   "name": "is array?",
                   "property": "payload",
                   "propertyType": "msg",
                   "rules": [
                       {
                           "t": "istype",
                           "v": "array",
                           "vt": "array"
                       },
                       {
                           "t": "else"
                       }
                   ],
                   "checkall": "true",
                   "repair": false,
                   "outputs": 2,
                   "x": 900,
                   "y": 120,
                   "wires": [
                       [
                           "bfce19b206660fbe"
                       ],
                       [
                           "3e11e8338f694832"
                       ]
                   ]
               },
               {
                   "id": "1b8480cd2df7ba3f",
                   "type": "comment",
                   "z": "6e802f1553b18149",
                   "name": "Array",
                   "info": "",
                   "x": 600,
                   "y": 280,
                   "wires": []
               },
               {
                   "id": "b3541807672be040",
                   "type": "comment",
                   "z": "6e802f1553b18149",
                   "name": "object",
                   "info": "",
                   "x": 1340,
                   "y": 100,
                   "wires": []
               },
               {
                   "id": "a4d1a5d04564dc77",
                   "type": "switch",
                   "z": "6e802f1553b18149",
                   "name": "is type?",
                   "property": "payload",
                   "propertyType": "msg",
                   "rules": [
                       {
                           "t": "istype",
                           "v": "object",
                           "vt": "object"
                       },
                       {
                           "t": "istype",
                           "v": "array",
                           "vt": "array"
                       },
                       {
                           "t": "else"
                       }
                   ],
                   "checkall": "true",
                   "repair": false,
                   "outputs": 3,
                   "x": 1160,
                   "y": 280,
                   "wires": [
                       [
                           "3e11e8338f694832"
                       ],
                       [
                           "bfce19b206660fbe"
                       ],
                       [
                           "1a8c03d866b85b12"
                       ]
                   ]
               },
               {
                   "id": "74c895ce724750de",
                   "type": "change",
                   "z": "6e802f1553b18149",
                   "name": "finalize msg.topic",
                   "rules": [
                       {
                           "t": "set",
                           "p": "top",
                           "pt": "msg",
                           "to": "top",
                           "tot": "env"
                       },
                       {
                           "t": "set",
                           "p": "top",
                           "pt": "msg",
                           "to": "'0_userdata.0.' & top",
                           "tot": "jsonata"
                       },
                       {
                           "t": "set",
                           "p": "topic",
                           "pt": "msg",
                           "to": "top & '.' & topic",
                           "tot": "jsonata"
                       }
                   ],
                   "action": "",
                   "property": "",
                   "from": "",
                   "to": "",
                   "reg": false,
                   "x": 2170,
                   "y": 320,
                   "wires": [
                       [
                           "0962842ebd23e0d7"
                       ]
                   ]
               },
               {
                   "id": "554b8c663bcb46c2",
                   "type": "switch",
                   "z": "6e802f1553b18149",
                   "name": "",
                   "property": "keepTopic",
                   "propertyType": "env",
                   "rules": [
                       {
                           "t": "true"
                       },
                       {
                           "t": "false"
                       }
                   ],
                   "checkall": "true",
                   "repair": false,
                   "outputs": 2,
                   "x": 170,
                   "y": 160,
                   "wires": [
                       [
                           "e30ba9f0483285e4"
                       ],
                       [
                           "e023fe88445ce43e"
                       ]
                   ]
               },
               {
                   "id": "e30ba9f0483285e4",
                   "type": "change",
                   "z": "6e802f1553b18149",
                   "name": "",
                   "rules": [
                       {
                           "t": "change",
                           "p": "topic",
                           "pt": "msg",
                           "from": "/",
                           "fromt": "str",
                           "to": ".",
                           "tot": "str"
                       }
                   ],
                   "action": "",
                   "property": "",
                   "from": "",
                   "to": "",
                   "reg": false,
                   "x": 350,
                   "y": 120,
                   "wires": [
                       [
                           "c863dd7d651b2272"
                       ]
                   ]
               },
               {
                   "id": "0962842ebd23e0d7",
                   "type": "change",
                   "z": "6e802f1553b18149",
                   "name": "translate invalid chars in topic",
                   "rules": [
                       {
                           "t": "change",
                           "p": "topic",
                           "pt": "msg",
                           "from": "..",
                           "fromt": "str",
                           "to": ".",
                           "tot": "str"
                       },
                       {
                           "t": "change",
                           "p": "topic",
                           "pt": "msg",
                           "from": "€",
                           "fromt": "str",
                           "to": "EUR",
                           "tot": "str"
                       }
                   ],
                   "action": "",
                   "property": "",
                   "from": "",
                   "to": "",
                   "reg": false,
                   "x": 2430,
                   "y": 280,
                   "wires": [
                       []
                   ]
               },
               {
                   "id": "df544262fde22aca",
                   "type": "subflow:6e802f1553b18149",
                   "z": "393214410c8f2f15",
                   "name": "",
                   "x": 910,
                   "y": 580,
                   "wires": [
                       []
                   ]
               }
            ]
            

            Für alle die, die Node bereits benutzen - wie folgt vorgehen.

            1. Den Code normal in die Zwischenablage kopieren und dann importieren.
            2. Da das System erkennst, dass es diesen Subflow/Nodes bereits gibt - bitte auf "Zeige Nodes ... " gehen.

            07910a9e-986e-4d20-aa8a-694cf1a0a62e-image.png

            1. Anschließend braucht man nur den Subflow ersetzen.

            0861d7e5-b997-4960-b83c-309033d5015b-image.png

            1. Nach dem man auf "Importiere Auswahl" geklickt hat, wird einem angezeigt, wieviele Nodes ersetzt wurden. Dann noch auf Deploy.
            F Offline
            F Offline
            Frank579
            schrieb am zuletzt editiert von
            #67

            Hallo @mickym,

            bin endlich mal dazu gekommen hier weiter zu machen, mit Tasmota funktioniert es seit damals einwandfrei.
            Jetzt habe ich gerade mal versucht das gleiche mit meinem Shelly 3EM zu testen, da wirft er mir aber das log voll für jeden datenpunkt des 3EM.

            node-red.0
            2022-11-01 11:35:37.209	error	The id "0_userdata.0.MQTT.shellies.3EM_Hauptverteiler.emeter.0.total_returned." is invalid. Ids are not allowed to end in "."
            node-red.0
            2022-11-01 11:35:37.209	error	Error: The id "0_userdata.0.MQTT.shellies.3EM_Hauptverteiler.emeter.0.total_returned." is invalid. Ids are not allowed to end in "." at Utils.validateId (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/build/lib/adapter/utils.js:148:23) at Adapter.setForeignState (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/build/lib/adapter/adapter.js:6030:23) at /opt/iobroker/node_modules/@iobroker/js-controller-common/lib/common/tools.js:2116:16 at new Promise (<anonymous>) at Adapter.setForeignStateAsync (/opt/iobroker/node_modules/@iobroker/js-controller-common/lib/common/tools.js:2115:16) at Immediate.<anonymous> (/opt/iobroker/node_modules/iobroker.node-red/nodes/ioBroker.js:252:59)
            node-red.0
            2022-11-01 11:35:37.209	error	unhandled promise rejection: The id "0_userdata.0.MQTT.shellies.3EM_Hauptverteiler.emeter.0.total_returned." is invalid. Ids are not allowed to end in "."
            node-red.0
            2022-11-01 11:35:37.209	error	Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
            

            aus der debug node:

            1.11.2022, 13:01:42node: debug 1
            0_userdata.0.MQTT.shellies.3EM_Hauptverteiler.emeter.2.power. : msg.payload : string[5]
            "47.54"
            

            der "." ist also wirklich Zuviel wie bekomme ich den weg? :face_with_rolling_eyes:

            Gruß Frank

            mickymM 1 Antwort Letzte Antwort
            0
            • F Frank579

              Hallo @mickym,

              bin endlich mal dazu gekommen hier weiter zu machen, mit Tasmota funktioniert es seit damals einwandfrei.
              Jetzt habe ich gerade mal versucht das gleiche mit meinem Shelly 3EM zu testen, da wirft er mir aber das log voll für jeden datenpunkt des 3EM.

              node-red.0
              2022-11-01 11:35:37.209	error	The id "0_userdata.0.MQTT.shellies.3EM_Hauptverteiler.emeter.0.total_returned." is invalid. Ids are not allowed to end in "."
              node-red.0
              2022-11-01 11:35:37.209	error	Error: The id "0_userdata.0.MQTT.shellies.3EM_Hauptverteiler.emeter.0.total_returned." is invalid. Ids are not allowed to end in "." at Utils.validateId (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/build/lib/adapter/utils.js:148:23) at Adapter.setForeignState (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/build/lib/adapter/adapter.js:6030:23) at /opt/iobroker/node_modules/@iobroker/js-controller-common/lib/common/tools.js:2116:16 at new Promise (<anonymous>) at Adapter.setForeignStateAsync (/opt/iobroker/node_modules/@iobroker/js-controller-common/lib/common/tools.js:2115:16) at Immediate.<anonymous> (/opt/iobroker/node_modules/iobroker.node-red/nodes/ioBroker.js:252:59)
              node-red.0
              2022-11-01 11:35:37.209	error	unhandled promise rejection: The id "0_userdata.0.MQTT.shellies.3EM_Hauptverteiler.emeter.0.total_returned." is invalid. Ids are not allowed to end in "."
              node-red.0
              2022-11-01 11:35:37.209	error	Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
              

              aus der debug node:

              1.11.2022, 13:01:42node: debug 1
              0_userdata.0.MQTT.shellies.3EM_Hauptverteiler.emeter.2.power. : msg.payload : string[5]
              "47.54"
              

              der "." ist also wirklich Zuviel wie bekomme ich den weg? :face_with_rolling_eyes:

              Gruß Frank

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

              @frank579 Kannst Du mal den JSON des kompletten Datenpunktes posten und hier in CodeTags einbetten?

              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.

              F 1 Antwort Letzte Antwort
              0
              • mickymM mickym

                @frank579 Kannst Du mal den JSON des kompletten Datenpunktes posten und hier in CodeTags einbetten?

                F Offline
                F Offline
                Frank579
                schrieb am zuletzt editiert von
                #69

                @mickym
                sorry lag an mir hatte das ganze Topic drin wenn ich nur den /Info nehme klappte es bei den anderen ist es ja auch kein JSON :man-facepalming: :man-facepalming:

                Trotzdem danke :+1:

                mickymM 1 Antwort Letzte Antwort
                0
                • F Frank579

                  @mickym
                  sorry lag an mir hatte das ganze Topic drin wenn ich nur den /Info nehme klappte es bei den anderen ist es ja auch kein JSON :man-facepalming: :man-facepalming:

                  Trotzdem danke :+1:

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

                  @frank579 sagte in JSON oder JavaScript Objekt in iobroker Datenpunkte zerlegen:

                  @mickym
                  sorry lag an mir hatte das ganze Topic drin wenn ich nur den /Info nehme klappte es bei den anderen ist es ja auch kein JSON :man-facepalming: :man-facepalming:

                  Trotzdem danke :+1:

                  Hmm aber eigentlich darf es gar keine topics geben, die mit . enden. Was meinst Du mit ganzem topic?

                  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.

                  F 1 Antwort Letzte Antwort
                  0
                  • mickymM mickym

                    @frank579 sagte in JSON oder JavaScript Objekt in iobroker Datenpunkte zerlegen:

                    @mickym
                    sorry lag an mir hatte das ganze Topic drin wenn ich nur den /Info nehme klappte es bei den anderen ist es ja auch kein JSON :man-facepalming: :man-facepalming:

                    Trotzdem danke :+1:

                    Hmm aber eigentlich darf es gar keine topics geben, die mit . enden. Was meinst Du mit ganzem topic?

                    F Offline
                    F Offline
                    Frank579
                    schrieb am zuletzt editiert von
                    #71

                    @mickym
                    Ich hatte in er node shellies/3EM/# eingetragen teilweise legt der mqtt Adapter die aber selbst schon als datenpunkt an, dacht es läge daran.
                    so siehts im MQTT aus
                    mqtt 3em.PNG

                    mickymM 1 Antwort Letzte Antwort
                    0
                    • F Frank579

                      @mickym
                      Ich hatte in er node shellies/3EM/# eingetragen teilweise legt der mqtt Adapter die aber selbst schon als datenpunkt an, dacht es läge daran.
                      so siehts im MQTT aus
                      mqtt 3em.PNG

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

                      @frank579 Ich hab den Fehler schon gefunden - ich werkle gerade an einer neuen Version. ;)

                      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 Online
                        mickymM Online
                        mickym
                        Most Active
                        schrieb am zuletzt editiert von mickym
                        #73

                        So einen neue Version des Subflows - hat sich sogar vereinfacht.

                        Einfach mal testen:

                        [
                           {
                               "id": "6e802f1553b18149",
                               "type": "subflow",
                               "name": "JSON or Obj to IOBroker",
                               "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
                               "category": "",
                               "in": [
                                   {
                                       "x": 60,
                                       "y": 160,
                                       "wires": [
                                           {
                                               "id": "554b8c663bcb46c2"
                                           }
                                       ]
                                   }
                               ],
                               "out": [
                                   {
                                       "x": 2620,
                                       "y": 280,
                                       "wires": [
                                           {
                                               "id": "0962842ebd23e0d7",
                                               "port": 0
                                           }
                                       ]
                                   }
                               ],
                               "env": [
                                   {
                                       "name": "top",
                                       "type": "str",
                                       "value": "objRoot"
                                   },
                                   {
                                       "name": "keepTopic",
                                       "type": "bool",
                                       "value": "false"
                                   }
                               ],
                               "meta": {},
                               "color": "#E2D96E",
                               "icon": "node-red/batch.svg"
                           },
                           {
                               "id": "3e11e8338f694832",
                               "type": "split",
                               "z": "6e802f1553b18149",
                               "name": "split object",
                               "splt": "\\n",
                               "spltType": "str",
                               "arraySplt": 1,
                               "arraySpltType": "len",
                               "stream": false,
                               "addname": "key",
                               "x": 1370,
                               "y": 160,
                               "wires": [
                                   [
                                       "0562a4249c8b856b"
                                   ]
                               ]
                           },
                           {
                               "id": "0562a4249c8b856b",
                               "type": "change",
                               "z": "6e802f1553b18149",
                               "name": "add key to topic",
                               "rules": [
                                   {
                                       "t": "set",
                                       "p": "stateName",
                                       "pt": "msg",
                                       "to": "key",
                                       "tot": "msg"
                                   },
                                   {
                                       "t": "set",
                                       "p": "topic",
                                       "pt": "msg",
                                       "to": "topic  & '.' & key",
                                       "tot": "jsonata"
                                   }
                               ],
                               "action": "",
                               "property": "",
                               "from": "",
                               "to": "",
                               "reg": false,
                               "x": 1560,
                               "y": 160,
                               "wires": [
                                   [
                                       "ddc90985bef0fafa"
                                   ]
                               ]
                           },
                           {
                               "id": "ddc90985bef0fafa",
                               "type": "switch",
                               "z": "6e802f1553b18149",
                               "name": "is type?",
                               "property": "payload",
                               "propertyType": "msg",
                               "rules": [
                                   {
                                       "t": "istype",
                                       "v": "array",
                                       "vt": "array"
                                   },
                                   {
                                       "t": "istype",
                                       "v": "object",
                                       "vt": "object"
                                   },
                                   {
                                       "t": "else"
                                   }
                               ],
                               "checkall": "true",
                               "repair": false,
                               "outputs": 3,
                               "x": 1740,
                               "y": 160,
                               "wires": [
                                   [
                                       "bfce19b206660fbe"
                                   ],
                                   [
                                       "3e11e8338f694832"
                                   ],
                                   [
                                       "1a8c03d866b85b12"
                                   ]
                               ]
                           },
                           {
                               "id": "bfce19b206660fbe",
                               "type": "split",
                               "z": "6e802f1553b18149",
                               "name": "split array",
                               "splt": "\\n",
                               "spltType": "str",
                               "arraySplt": 1,
                               "arraySpltType": "len",
                               "stream": false,
                               "addname": "",
                               "x": 780,
                               "y": 280,
                               "wires": [
                                   [
                                       "e89927810c6d75ec"
                                   ]
                               ]
                           },
                           {
                               "id": "e89927810c6d75ec",
                               "type": "change",
                               "z": "6e802f1553b18149",
                               "name": "add index to topic",
                               "rules": [
                                   {
                                       "t": "set",
                                       "p": "topic",
                                       "pt": "msg",
                                       "to": "topic  & '.' & parts.index",
                                       "tot": "jsonata"
                                   }
                               ],
                               "action": "",
                               "property": "",
                               "from": "",
                               "to": "",
                               "reg": false,
                               "x": 970,
                               "y": 280,
                               "wires": [
                                   [
                                       "a4d1a5d04564dc77"
                                   ]
                               ]
                           },
                           {
                               "id": "f5d52c6a57d08904",
                               "type": "change",
                               "z": "6e802f1553b18149",
                               "name": "finalize msg.topic",
                               "rules": [
                                   {
                                       "t": "set",
                                       "p": "top",
                                       "pt": "msg",
                                       "to": "'0_userdata.0.' & top",
                                       "tot": "jsonata"
                                   },
                                   {
                                       "t": "set",
                                       "p": "topic",
                                       "pt": "msg",
                                       "to": "top & '.' & topic",
                                       "tot": "jsonata"
                                   }
                               ],
                               "action": "",
                               "property": "",
                               "from": "",
                               "to": "",
                               "reg": false,
                               "x": 2170,
                               "y": 240,
                               "wires": [
                                   [
                                       "0962842ebd23e0d7"
                                   ]
                               ]
                           },
                           {
                               "id": "158930afddd0780b",
                               "type": "json",
                               "z": "6e802f1553b18149",
                               "name": "",
                               "property": "payload",
                               "action": "obj",
                               "pretty": false,
                               "x": 550,
                               "y": 160,
                               "wires": [
                                   [
                                       "3649300b4c233b10"
                                   ]
                               ]
                           },
                           {
                               "id": "1a8c03d866b85b12",
                               "type": "switch",
                               "z": "6e802f1553b18149",
                               "name": "is msg.top != null",
                               "property": "top",
                               "propertyType": "msg",
                               "rules": [
                                   {
                                       "t": "nnull"
                                   },
                                   {
                                       "t": "null"
                                   }
                               ],
                               "checkall": "true",
                               "repair": false,
                               "outputs": 2,
                               "x": 1950,
                               "y": 280,
                               "wires": [
                                   [
                                       "f5d52c6a57d08904"
                                   ],
                                   [
                                       "74c895ce724750de"
                                   ]
                               ]
                           },
                           {
                               "id": "e023fe88445ce43e",
                               "type": "change",
                               "z": "6e802f1553b18149",
                               "name": "",
                               "rules": [
                                   {
                                       "t": "delete",
                                       "p": "topic",
                                       "pt": "msg"
                                   }
                               ],
                               "action": "",
                               "property": "",
                               "from": "",
                               "to": "",
                               "reg": false,
                               "x": 350,
                               "y": 200,
                               "wires": [
                                   [
                                       "158930afddd0780b"
                                   ]
                               ]
                           },
                           {
                               "id": "3649300b4c233b10",
                               "type": "switch",
                               "z": "6e802f1553b18149",
                               "name": "is type?",
                               "property": "payload",
                               "propertyType": "msg",
                               "rules": [
                                   {
                                       "t": "istype",
                                       "v": "array",
                                       "vt": "array"
                                   },
                                   {
                                       "t": "istype",
                                       "v": "object",
                                       "vt": "object"
                                   },
                                   {
                                       "t": "else"
                                   }
                               ],
                               "checkall": "true",
                               "repair": false,
                               "outputs": 3,
                               "x": 720,
                               "y": 160,
                               "wires": [
                                   [
                                       "bfce19b206660fbe"
                                   ],
                                   [
                                       "3e11e8338f694832"
                                   ],
                                   [
                                       "a096a93bb82b7a93"
                                   ]
                               ]
                           },
                           {
                               "id": "1b8480cd2df7ba3f",
                               "type": "comment",
                               "z": "6e802f1553b18149",
                               "name": "Array",
                               "info": "",
                               "x": 600,
                               "y": 280,
                               "wires": []
                           },
                           {
                               "id": "b3541807672be040",
                               "type": "comment",
                               "z": "6e802f1553b18149",
                               "name": "object",
                               "info": "",
                               "x": 1340,
                               "y": 100,
                               "wires": []
                           },
                           {
                               "id": "a4d1a5d04564dc77",
                               "type": "switch",
                               "z": "6e802f1553b18149",
                               "name": "is type?",
                               "property": "payload",
                               "propertyType": "msg",
                               "rules": [
                                   {
                                       "t": "istype",
                                       "v": "object",
                                       "vt": "object"
                                   },
                                   {
                                       "t": "istype",
                                       "v": "array",
                                       "vt": "array"
                                   },
                                   {
                                       "t": "else"
                                   }
                               ],
                               "checkall": "true",
                               "repair": false,
                               "outputs": 3,
                               "x": 1160,
                               "y": 280,
                               "wires": [
                                   [
                                       "3e11e8338f694832"
                                   ],
                                   [
                                       "bfce19b206660fbe"
                                   ],
                                   [
                                       "a096a93bb82b7a93"
                                   ]
                               ]
                           },
                           {
                               "id": "74c895ce724750de",
                               "type": "change",
                               "z": "6e802f1553b18149",
                               "name": "finalize msg.topic",
                               "rules": [
                                   {
                                       "t": "set",
                                       "p": "top",
                                       "pt": "msg",
                                       "to": "top",
                                       "tot": "env"
                                   },
                                   {
                                       "t": "set",
                                       "p": "top",
                                       "pt": "msg",
                                       "to": "'0_userdata.0.' & top",
                                       "tot": "jsonata"
                                   },
                                   {
                                       "t": "set",
                                       "p": "topic",
                                       "pt": "msg",
                                       "to": "top & '.' & topic",
                                       "tot": "jsonata"
                                   }
                               ],
                               "action": "",
                               "property": "",
                               "from": "",
                               "to": "",
                               "reg": false,
                               "x": 2170,
                               "y": 320,
                               "wires": [
                                   [
                                       "0962842ebd23e0d7"
                                   ]
                               ]
                           },
                           {
                               "id": "554b8c663bcb46c2",
                               "type": "switch",
                               "z": "6e802f1553b18149",
                               "name": "",
                               "property": "keepTopic",
                               "propertyType": "env",
                               "rules": [
                                   {
                                       "t": "true"
                                   },
                                   {
                                       "t": "false"
                                   }
                               ],
                               "checkall": "true",
                               "repair": false,
                               "outputs": 2,
                               "x": 170,
                               "y": 160,
                               "wires": [
                                   [
                                       "e30ba9f0483285e4"
                                   ],
                                   [
                                       "e023fe88445ce43e"
                                   ]
                               ]
                           },
                           {
                               "id": "e30ba9f0483285e4",
                               "type": "change",
                               "z": "6e802f1553b18149",
                               "name": "",
                               "rules": [
                                   {
                                       "t": "change",
                                       "p": "topic",
                                       "pt": "msg",
                                       "from": "/",
                                       "fromt": "str",
                                       "to": ".",
                                       "tot": "str"
                                   }
                               ],
                               "action": "",
                               "property": "",
                               "from": "",
                               "to": "",
                               "reg": false,
                               "x": 350,
                               "y": 120,
                               "wires": [
                                   [
                                       "158930afddd0780b"
                                   ]
                               ]
                           },
                           {
                               "id": "0962842ebd23e0d7",
                               "type": "change",
                               "z": "6e802f1553b18149",
                               "name": "translate invalid chars in topic",
                               "rules": [
                                   {
                                       "t": "change",
                                       "p": "topic",
                                       "pt": "msg",
                                       "from": "..",
                                       "fromt": "str",
                                       "to": ".",
                                       "tot": "str"
                                   },
                                   {
                                       "t": "change",
                                       "p": "topic",
                                       "pt": "msg",
                                       "from": "€",
                                       "fromt": "str",
                                       "to": "EUR",
                                       "tot": "str"
                                   }
                               ],
                               "action": "",
                               "property": "",
                               "from": "",
                               "to": "",
                               "reg": false,
                               "x": 2430,
                               "y": 280,
                               "wires": [
                                   []
                               ]
                           },
                           {
                               "id": "a096a93bb82b7a93",
                               "type": "junction",
                               "z": "6e802f1553b18149",
                               "x": 1380,
                               "y": 280,
                               "wires": [
                                   [
                                       "1a8c03d866b85b12"
                                   ]
                               ]
                           },
                           {
                               "id": "436b84bced4aeddd",
                               "type": "subflow:6e802f1553b18149",
                               "z": "393214410c8f2f15",
                               "name": "",
                               "x": 590,
                               "y": 840,
                               "wires": [
                                   []
                               ]
                           }
                        ]
                        

                        Dann wie unten vorgehen: https://forum.iobroker.net/post/856928

                        Dort ist ja auch noch die bisherige Version vorhanden.

                        EDIT: Sorry waren die Debug Nodes noch drin.

                        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.

                        F 1 Antwort Letzte Antwort
                        0
                        • mickymM mickym

                          So einen neue Version des Subflows - hat sich sogar vereinfacht.

                          Einfach mal testen:

                          [
                             {
                                 "id": "6e802f1553b18149",
                                 "type": "subflow",
                                 "name": "JSON or Obj to IOBroker",
                                 "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
                                 "category": "",
                                 "in": [
                                     {
                                         "x": 60,
                                         "y": 160,
                                         "wires": [
                                             {
                                                 "id": "554b8c663bcb46c2"
                                             }
                                         ]
                                     }
                                 ],
                                 "out": [
                                     {
                                         "x": 2620,
                                         "y": 280,
                                         "wires": [
                                             {
                                                 "id": "0962842ebd23e0d7",
                                                 "port": 0
                                             }
                                         ]
                                     }
                                 ],
                                 "env": [
                                     {
                                         "name": "top",
                                         "type": "str",
                                         "value": "objRoot"
                                     },
                                     {
                                         "name": "keepTopic",
                                         "type": "bool",
                                         "value": "false"
                                     }
                                 ],
                                 "meta": {},
                                 "color": "#E2D96E",
                                 "icon": "node-red/batch.svg"
                             },
                             {
                                 "id": "3e11e8338f694832",
                                 "type": "split",
                                 "z": "6e802f1553b18149",
                                 "name": "split object",
                                 "splt": "\\n",
                                 "spltType": "str",
                                 "arraySplt": 1,
                                 "arraySpltType": "len",
                                 "stream": false,
                                 "addname": "key",
                                 "x": 1370,
                                 "y": 160,
                                 "wires": [
                                     [
                                         "0562a4249c8b856b"
                                     ]
                                 ]
                             },
                             {
                                 "id": "0562a4249c8b856b",
                                 "type": "change",
                                 "z": "6e802f1553b18149",
                                 "name": "add key to topic",
                                 "rules": [
                                     {
                                         "t": "set",
                                         "p": "stateName",
                                         "pt": "msg",
                                         "to": "key",
                                         "tot": "msg"
                                     },
                                     {
                                         "t": "set",
                                         "p": "topic",
                                         "pt": "msg",
                                         "to": "topic  & '.' & key",
                                         "tot": "jsonata"
                                     }
                                 ],
                                 "action": "",
                                 "property": "",
                                 "from": "",
                                 "to": "",
                                 "reg": false,
                                 "x": 1560,
                                 "y": 160,
                                 "wires": [
                                     [
                                         "ddc90985bef0fafa"
                                     ]
                                 ]
                             },
                             {
                                 "id": "ddc90985bef0fafa",
                                 "type": "switch",
                                 "z": "6e802f1553b18149",
                                 "name": "is type?",
                                 "property": "payload",
                                 "propertyType": "msg",
                                 "rules": [
                                     {
                                         "t": "istype",
                                         "v": "array",
                                         "vt": "array"
                                     },
                                     {
                                         "t": "istype",
                                         "v": "object",
                                         "vt": "object"
                                     },
                                     {
                                         "t": "else"
                                     }
                                 ],
                                 "checkall": "true",
                                 "repair": false,
                                 "outputs": 3,
                                 "x": 1740,
                                 "y": 160,
                                 "wires": [
                                     [
                                         "bfce19b206660fbe"
                                     ],
                                     [
                                         "3e11e8338f694832"
                                     ],
                                     [
                                         "1a8c03d866b85b12"
                                     ]
                                 ]
                             },
                             {
                                 "id": "bfce19b206660fbe",
                                 "type": "split",
                                 "z": "6e802f1553b18149",
                                 "name": "split array",
                                 "splt": "\\n",
                                 "spltType": "str",
                                 "arraySplt": 1,
                                 "arraySpltType": "len",
                                 "stream": false,
                                 "addname": "",
                                 "x": 780,
                                 "y": 280,
                                 "wires": [
                                     [
                                         "e89927810c6d75ec"
                                     ]
                                 ]
                             },
                             {
                                 "id": "e89927810c6d75ec",
                                 "type": "change",
                                 "z": "6e802f1553b18149",
                                 "name": "add index to topic",
                                 "rules": [
                                     {
                                         "t": "set",
                                         "p": "topic",
                                         "pt": "msg",
                                         "to": "topic  & '.' & parts.index",
                                         "tot": "jsonata"
                                     }
                                 ],
                                 "action": "",
                                 "property": "",
                                 "from": "",
                                 "to": "",
                                 "reg": false,
                                 "x": 970,
                                 "y": 280,
                                 "wires": [
                                     [
                                         "a4d1a5d04564dc77"
                                     ]
                                 ]
                             },
                             {
                                 "id": "f5d52c6a57d08904",
                                 "type": "change",
                                 "z": "6e802f1553b18149",
                                 "name": "finalize msg.topic",
                                 "rules": [
                                     {
                                         "t": "set",
                                         "p": "top",
                                         "pt": "msg",
                                         "to": "'0_userdata.0.' & top",
                                         "tot": "jsonata"
                                     },
                                     {
                                         "t": "set",
                                         "p": "topic",
                                         "pt": "msg",
                                         "to": "top & '.' & topic",
                                         "tot": "jsonata"
                                     }
                                 ],
                                 "action": "",
                                 "property": "",
                                 "from": "",
                                 "to": "",
                                 "reg": false,
                                 "x": 2170,
                                 "y": 240,
                                 "wires": [
                                     [
                                         "0962842ebd23e0d7"
                                     ]
                                 ]
                             },
                             {
                                 "id": "158930afddd0780b",
                                 "type": "json",
                                 "z": "6e802f1553b18149",
                                 "name": "",
                                 "property": "payload",
                                 "action": "obj",
                                 "pretty": false,
                                 "x": 550,
                                 "y": 160,
                                 "wires": [
                                     [
                                         "3649300b4c233b10"
                                     ]
                                 ]
                             },
                             {
                                 "id": "1a8c03d866b85b12",
                                 "type": "switch",
                                 "z": "6e802f1553b18149",
                                 "name": "is msg.top != null",
                                 "property": "top",
                                 "propertyType": "msg",
                                 "rules": [
                                     {
                                         "t": "nnull"
                                     },
                                     {
                                         "t": "null"
                                     }
                                 ],
                                 "checkall": "true",
                                 "repair": false,
                                 "outputs": 2,
                                 "x": 1950,
                                 "y": 280,
                                 "wires": [
                                     [
                                         "f5d52c6a57d08904"
                                     ],
                                     [
                                         "74c895ce724750de"
                                     ]
                                 ]
                             },
                             {
                                 "id": "e023fe88445ce43e",
                                 "type": "change",
                                 "z": "6e802f1553b18149",
                                 "name": "",
                                 "rules": [
                                     {
                                         "t": "delete",
                                         "p": "topic",
                                         "pt": "msg"
                                     }
                                 ],
                                 "action": "",
                                 "property": "",
                                 "from": "",
                                 "to": "",
                                 "reg": false,
                                 "x": 350,
                                 "y": 200,
                                 "wires": [
                                     [
                                         "158930afddd0780b"
                                     ]
                                 ]
                             },
                             {
                                 "id": "3649300b4c233b10",
                                 "type": "switch",
                                 "z": "6e802f1553b18149",
                                 "name": "is type?",
                                 "property": "payload",
                                 "propertyType": "msg",
                                 "rules": [
                                     {
                                         "t": "istype",
                                         "v": "array",
                                         "vt": "array"
                                     },
                                     {
                                         "t": "istype",
                                         "v": "object",
                                         "vt": "object"
                                     },
                                     {
                                         "t": "else"
                                     }
                                 ],
                                 "checkall": "true",
                                 "repair": false,
                                 "outputs": 3,
                                 "x": 720,
                                 "y": 160,
                                 "wires": [
                                     [
                                         "bfce19b206660fbe"
                                     ],
                                     [
                                         "3e11e8338f694832"
                                     ],
                                     [
                                         "a096a93bb82b7a93"
                                     ]
                                 ]
                             },
                             {
                                 "id": "1b8480cd2df7ba3f",
                                 "type": "comment",
                                 "z": "6e802f1553b18149",
                                 "name": "Array",
                                 "info": "",
                                 "x": 600,
                                 "y": 280,
                                 "wires": []
                             },
                             {
                                 "id": "b3541807672be040",
                                 "type": "comment",
                                 "z": "6e802f1553b18149",
                                 "name": "object",
                                 "info": "",
                                 "x": 1340,
                                 "y": 100,
                                 "wires": []
                             },
                             {
                                 "id": "a4d1a5d04564dc77",
                                 "type": "switch",
                                 "z": "6e802f1553b18149",
                                 "name": "is type?",
                                 "property": "payload",
                                 "propertyType": "msg",
                                 "rules": [
                                     {
                                         "t": "istype",
                                         "v": "object",
                                         "vt": "object"
                                     },
                                     {
                                         "t": "istype",
                                         "v": "array",
                                         "vt": "array"
                                     },
                                     {
                                         "t": "else"
                                     }
                                 ],
                                 "checkall": "true",
                                 "repair": false,
                                 "outputs": 3,
                                 "x": 1160,
                                 "y": 280,
                                 "wires": [
                                     [
                                         "3e11e8338f694832"
                                     ],
                                     [
                                         "bfce19b206660fbe"
                                     ],
                                     [
                                         "a096a93bb82b7a93"
                                     ]
                                 ]
                             },
                             {
                                 "id": "74c895ce724750de",
                                 "type": "change",
                                 "z": "6e802f1553b18149",
                                 "name": "finalize msg.topic",
                                 "rules": [
                                     {
                                         "t": "set",
                                         "p": "top",
                                         "pt": "msg",
                                         "to": "top",
                                         "tot": "env"
                                     },
                                     {
                                         "t": "set",
                                         "p": "top",
                                         "pt": "msg",
                                         "to": "'0_userdata.0.' & top",
                                         "tot": "jsonata"
                                     },
                                     {
                                         "t": "set",
                                         "p": "topic",
                                         "pt": "msg",
                                         "to": "top & '.' & topic",
                                         "tot": "jsonata"
                                     }
                                 ],
                                 "action": "",
                                 "property": "",
                                 "from": "",
                                 "to": "",
                                 "reg": false,
                                 "x": 2170,
                                 "y": 320,
                                 "wires": [
                                     [
                                         "0962842ebd23e0d7"
                                     ]
                                 ]
                             },
                             {
                                 "id": "554b8c663bcb46c2",
                                 "type": "switch",
                                 "z": "6e802f1553b18149",
                                 "name": "",
                                 "property": "keepTopic",
                                 "propertyType": "env",
                                 "rules": [
                                     {
                                         "t": "true"
                                     },
                                     {
                                         "t": "false"
                                     }
                                 ],
                                 "checkall": "true",
                                 "repair": false,
                                 "outputs": 2,
                                 "x": 170,
                                 "y": 160,
                                 "wires": [
                                     [
                                         "e30ba9f0483285e4"
                                     ],
                                     [
                                         "e023fe88445ce43e"
                                     ]
                                 ]
                             },
                             {
                                 "id": "e30ba9f0483285e4",
                                 "type": "change",
                                 "z": "6e802f1553b18149",
                                 "name": "",
                                 "rules": [
                                     {
                                         "t": "change",
                                         "p": "topic",
                                         "pt": "msg",
                                         "from": "/",
                                         "fromt": "str",
                                         "to": ".",
                                         "tot": "str"
                                     }
                                 ],
                                 "action": "",
                                 "property": "",
                                 "from": "",
                                 "to": "",
                                 "reg": false,
                                 "x": 350,
                                 "y": 120,
                                 "wires": [
                                     [
                                         "158930afddd0780b"
                                     ]
                                 ]
                             },
                             {
                                 "id": "0962842ebd23e0d7",
                                 "type": "change",
                                 "z": "6e802f1553b18149",
                                 "name": "translate invalid chars in topic",
                                 "rules": [
                                     {
                                         "t": "change",
                                         "p": "topic",
                                         "pt": "msg",
                                         "from": "..",
                                         "fromt": "str",
                                         "to": ".",
                                         "tot": "str"
                                     },
                                     {
                                         "t": "change",
                                         "p": "topic",
                                         "pt": "msg",
                                         "from": "€",
                                         "fromt": "str",
                                         "to": "EUR",
                                         "tot": "str"
                                     }
                                 ],
                                 "action": "",
                                 "property": "",
                                 "from": "",
                                 "to": "",
                                 "reg": false,
                                 "x": 2430,
                                 "y": 280,
                                 "wires": [
                                     []
                                 ]
                             },
                             {
                                 "id": "a096a93bb82b7a93",
                                 "type": "junction",
                                 "z": "6e802f1553b18149",
                                 "x": 1380,
                                 "y": 280,
                                 "wires": [
                                     [
                                         "1a8c03d866b85b12"
                                     ]
                                 ]
                             },
                             {
                                 "id": "436b84bced4aeddd",
                                 "type": "subflow:6e802f1553b18149",
                                 "z": "393214410c8f2f15",
                                 "name": "",
                                 "x": 590,
                                 "y": 840,
                                 "wires": [
                                     []
                                 ]
                             }
                          ]
                          

                          Dann wie unten vorgehen: https://forum.iobroker.net/post/856928

                          Dort ist ja auch noch die bisherige Version vorhanden.

                          EDIT: Sorry waren die Debug Nodes noch drin.

                          F Offline
                          F Offline
                          Frank579
                          schrieb am zuletzt editiert von
                          #74

                          @mickym
                          Habe es mal schnell getestet irgend was passt jetzt nicht mehr, kann natürlich auch bei mir sein die Werte der Tasmota Steckdose werden nicht mehr aktualisiert...
                          aus der debug Node kommt

                          0_userdata.0.objRoot.ENERGY.Total : msg.payload : number
                          2.689
                          

                          ist das objRoot richtig da stand vorher der Name vom gerät ...

                          mickymM 1 Antwort Letzte Antwort
                          0
                          • F Frank579

                            @mickym
                            Habe es mal schnell getestet irgend was passt jetzt nicht mehr, kann natürlich auch bei mir sein die Werte der Tasmota Steckdose werden nicht mehr aktualisiert...
                            aus der debug Node kommt

                            0_userdata.0.objRoot.ENERGY.Total : msg.payload : number
                            2.689
                            

                            ist das objRoot richtig da stand vorher der Name vom gerät ...

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

                            @frank579 Na dann hast Du leider Deine ganze Node ersetzt - Du solltest eigentlich nur wie unter beschrieben den Subflow nehmen.

                            2f7f5dd2-198e-4a7f-8a55-c2e3f431860e-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.

                            F 1 Antwort Letzte Antwort
                            0
                            • mickymM mickym

                              @frank579 Na dann hast Du leider Deine ganze Node ersetzt - Du solltest eigentlich nur wie unter beschrieben den Subflow nehmen.

                              2f7f5dd2-198e-4a7f-8a55-c2e3f431860e-image.png

                              F Offline
                              F Offline
                              Frank579
                              schrieb am zuletzt editiert von
                              #76

                              @mickym hatte ich auch so gemacht, dacht ich ... :) schaue ich direkt mal nach

                              mickymM 1 Antwort Letzte Antwort
                              0
                              • F Frank579

                                @mickym hatte ich auch so gemacht, dacht ich ... :) schaue ich direkt mal nach

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

                                @frank579 sagte in JSON oder JavaScript Objekt in iobroker Datenpunkte zerlegen:

                                @mickym hatte ich auch so gemacht, dacht ich ... :) schaue ich direkt mal nach

                                Standardmässig steht in der Node

                                665e4a8d-64c4-43af-b044-e5aa4ed78211-image.png

                                Daher das objRoot.

                                Da musst Du wieder den eigenen Namen eintragen unter dem das unter 0_userdata.0 auftauchen soll und wenn Du einen ganzen Baum schreiben willst, muss das keepTopic auf true.

                                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
                                0
                                • F Offline
                                  F Offline
                                  Frank579
                                  schrieb am zuletzt editiert von
                                  #78

                                  @mickym genau so war es.
                                  wenn ich jetzt wieder den ganzen baum vom 3EM haben möchte bekomme ich immer den im log :

                                  	1 Nov 15:55:58 - [error] [json:6908c423c0496cdd] Unexpected token o in JSON at position 0
                                  

                                  hast du eine idee was das sein könnte komme aber auch so klar benötige ja eigentlich nicht den ganzen Baum ist ja in den Mqtt-Adapter Datenpunkten schon drin, aber evtl. käme ich dann ohne den für die shellies klar nur mit node red, evtl. nehme ich mir auch was viel vor :face_with_rolling_eyes:

                                  mickymM 2 Antworten Letzte Antwort
                                  0
                                  • F Frank579

                                    @mickym genau so war es.
                                    wenn ich jetzt wieder den ganzen baum vom 3EM haben möchte bekomme ich immer den im log :

                                    	1 Nov 15:55:58 - [error] [json:6908c423c0496cdd] Unexpected token o in JSON at position 0
                                    

                                    hast du eine idee was das sein könnte komme aber auch so klar benötige ja eigentlich nicht den ganzen Baum ist ja in den Mqtt-Adapter Datenpunkten schon drin, aber evtl. käme ich dann ohne den für die shellies klar nur mit node red, evtl. nehme ich mir auch was viel vor :face_with_rolling_eyes:

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

                                    @frank579 Ja hab noch einen Fehler gefunden - das Problem ist, dass er Zahlen als JSON Objekte erkennt, Strings aber nicht, da kommt dann dieser Fehler. Nächste Version folgt. ;)

                                    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
                                    • F Frank579

                                      @mickym genau so war es.
                                      wenn ich jetzt wieder den ganzen baum vom 3EM haben möchte bekomme ich immer den im log :

                                      	1 Nov 15:55:58 - [error] [json:6908c423c0496cdd] Unexpected token o in JSON at position 0
                                      

                                      hast du eine idee was das sein könnte komme aber auch so klar benötige ja eigentlich nicht den ganzen Baum ist ja in den Mqtt-Adapter Datenpunkten schon drin, aber evtl. käme ich dann ohne den für die shellies klar nur mit node red, evtl. nehme ich mir auch was viel vor :face_with_rolling_eyes:

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

                                      @frank579 So nächste Version. ;) - Ist wieder etwas komplexer, aber ich hoffe jetzt passt es:

                                      [
                                         {
                                             "id": "6e802f1553b18149",
                                             "type": "subflow",
                                             "name": "JSON or Obj to IOBroker",
                                             "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
                                             "category": "",
                                             "in": [
                                                 {
                                                     "x": 60,
                                                     "y": 160,
                                                     "wires": [
                                                         {
                                                             "id": "554b8c663bcb46c2"
                                                         }
                                                     ]
                                                 }
                                             ],
                                             "out": [
                                                 {
                                                     "x": 2620,
                                                     "y": 280,
                                                     "wires": [
                                                         {
                                                             "id": "0962842ebd23e0d7",
                                                             "port": 0
                                                         }
                                                     ]
                                                 }
                                             ],
                                             "env": [
                                                 {
                                                     "name": "top",
                                                     "type": "str",
                                                     "value": "objRoot"
                                                 },
                                                 {
                                                     "name": "keepTopic",
                                                     "type": "bool",
                                                     "value": "false"
                                                 }
                                             ],
                                             "meta": {},
                                             "color": "#E2D96E",
                                             "icon": "node-red/batch.svg"
                                         },
                                         {
                                             "id": "3e11e8338f694832",
                                             "type": "split",
                                             "z": "6e802f1553b18149",
                                             "name": "split object",
                                             "splt": "\\n",
                                             "spltType": "str",
                                             "arraySplt": 1,
                                             "arraySpltType": "len",
                                             "stream": false,
                                             "addname": "key",
                                             "x": 1370,
                                             "y": 160,
                                             "wires": [
                                                 [
                                                     "0562a4249c8b856b"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "0562a4249c8b856b",
                                             "type": "change",
                                             "z": "6e802f1553b18149",
                                             "name": "add key to topic",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "stateName",
                                                     "pt": "msg",
                                                     "to": "key",
                                                     "tot": "msg"
                                                 },
                                                 {
                                                     "t": "set",
                                                     "p": "topic",
                                                     "pt": "msg",
                                                     "to": "topic  & '.' & key",
                                                     "tot": "jsonata"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 1560,
                                             "y": 160,
                                             "wires": [
                                                 [
                                                     "ddc90985bef0fafa"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "ddc90985bef0fafa",
                                             "type": "switch",
                                             "z": "6e802f1553b18149",
                                             "name": "is type?",
                                             "property": "payload",
                                             "propertyType": "msg",
                                             "rules": [
                                                 {
                                                     "t": "istype",
                                                     "v": "array",
                                                     "vt": "array"
                                                 },
                                                 {
                                                     "t": "istype",
                                                     "v": "object",
                                                     "vt": "object"
                                                 },
                                                 {
                                                     "t": "else"
                                                 }
                                             ],
                                             "checkall": "true",
                                             "repair": false,
                                             "outputs": 3,
                                             "x": 1740,
                                             "y": 160,
                                             "wires": [
                                                 [
                                                     "bfce19b206660fbe"
                                                 ],
                                                 [
                                                     "3e11e8338f694832"
                                                 ],
                                                 [
                                                     "1a8c03d866b85b12"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "bfce19b206660fbe",
                                             "type": "split",
                                             "z": "6e802f1553b18149",
                                             "name": "split array",
                                             "splt": "\\n",
                                             "spltType": "str",
                                             "arraySplt": 1,
                                             "arraySpltType": "len",
                                             "stream": false,
                                             "addname": "",
                                             "x": 780,
                                             "y": 280,
                                             "wires": [
                                                 [
                                                     "e89927810c6d75ec"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "e89927810c6d75ec",
                                             "type": "change",
                                             "z": "6e802f1553b18149",
                                             "name": "add index to topic",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "topic",
                                                     "pt": "msg",
                                                     "to": "topic  & '.' & parts.index",
                                                     "tot": "jsonata"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 970,
                                             "y": 280,
                                             "wires": [
                                                 [
                                                     "a4d1a5d04564dc77"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "f5d52c6a57d08904",
                                             "type": "change",
                                             "z": "6e802f1553b18149",
                                             "name": "finalize msg.topic",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "top",
                                                     "pt": "msg",
                                                     "to": "'0_userdata.0.' & top",
                                                     "tot": "jsonata"
                                                 },
                                                 {
                                                     "t": "set",
                                                     "p": "topic",
                                                     "pt": "msg",
                                                     "to": "top & '.' & topic",
                                                     "tot": "jsonata"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 2170,
                                             "y": 240,
                                             "wires": [
                                                 [
                                                     "0962842ebd23e0d7"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "1a8c03d866b85b12",
                                             "type": "switch",
                                             "z": "6e802f1553b18149",
                                             "name": "is msg.top != null",
                                             "property": "top",
                                             "propertyType": "msg",
                                             "rules": [
                                                 {
                                                     "t": "nnull"
                                                 },
                                                 {
                                                     "t": "null"
                                                 }
                                             ],
                                             "checkall": "true",
                                             "repair": false,
                                             "outputs": 2,
                                             "x": 1950,
                                             "y": 280,
                                             "wires": [
                                                 [
                                                     "f5d52c6a57d08904"
                                                 ],
                                                 [
                                                     "74c895ce724750de"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "e023fe88445ce43e",
                                             "type": "change",
                                             "z": "6e802f1553b18149",
                                             "name": "",
                                             "rules": [
                                                 {
                                                     "t": "delete",
                                                     "p": "topic",
                                                     "pt": "msg"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 350,
                                             "y": 200,
                                             "wires": [
                                                 [
                                                     "3649300b4c233b10"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "3649300b4c233b10",
                                             "type": "switch",
                                             "z": "6e802f1553b18149",
                                             "name": "is type?",
                                             "property": "payload",
                                             "propertyType": "msg",
                                             "rules": [
                                                 {
                                                     "t": "istype",
                                                     "v": "json",
                                                     "vt": "json"
                                                 },
                                                 {
                                                     "t": "istype",
                                                     "v": "array",
                                                     "vt": "array"
                                                 },
                                                 {
                                                     "t": "istype",
                                                     "v": "object",
                                                     "vt": "object"
                                                 },
                                                 {
                                                     "t": "else"
                                                 }
                                             ],
                                             "checkall": "true",
                                             "repair": false,
                                             "outputs": 4,
                                             "x": 600,
                                             "y": 160,
                                             "wires": [
                                                 [
                                                     "fc7913a8524badb7"
                                                 ],
                                                 [
                                                     "bfce19b206660fbe"
                                                 ],
                                                 [
                                                     "3e11e8338f694832"
                                                 ],
                                                 [
                                                     "9ac3cc3681e8b6c6"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "1b8480cd2df7ba3f",
                                             "type": "comment",
                                             "z": "6e802f1553b18149",
                                             "name": "Array",
                                             "info": "",
                                             "x": 600,
                                             "y": 280,
                                             "wires": []
                                         },
                                         {
                                             "id": "b3541807672be040",
                                             "type": "comment",
                                             "z": "6e802f1553b18149",
                                             "name": "object",
                                             "info": "",
                                             "x": 1340,
                                             "y": 100,
                                             "wires": []
                                         },
                                         {
                                             "id": "a4d1a5d04564dc77",
                                             "type": "switch",
                                             "z": "6e802f1553b18149",
                                             "name": "is type?",
                                             "property": "payload",
                                             "propertyType": "msg",
                                             "rules": [
                                                 {
                                                     "t": "istype",
                                                     "v": "object",
                                                     "vt": "object"
                                                 },
                                                 {
                                                     "t": "istype",
                                                     "v": "array",
                                                     "vt": "array"
                                                 },
                                                 {
                                                     "t": "else"
                                                 }
                                             ],
                                             "checkall": "true",
                                             "repair": false,
                                             "outputs": 3,
                                             "x": 1160,
                                             "y": 280,
                                             "wires": [
                                                 [
                                                     "3e11e8338f694832"
                                                 ],
                                                 [
                                                     "bfce19b206660fbe"
                                                 ],
                                                 [
                                                     "a096a93bb82b7a93"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "74c895ce724750de",
                                             "type": "change",
                                             "z": "6e802f1553b18149",
                                             "name": "finalize msg.topic",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "top",
                                                     "pt": "msg",
                                                     "to": "top",
                                                     "tot": "env"
                                                 },
                                                 {
                                                     "t": "set",
                                                     "p": "top",
                                                     "pt": "msg",
                                                     "to": "'0_userdata.0.' & top",
                                                     "tot": "jsonata"
                                                 },
                                                 {
                                                     "t": "set",
                                                     "p": "topic",
                                                     "pt": "msg",
                                                     "to": "top & '.' & topic",
                                                     "tot": "jsonata"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 2170,
                                             "y": 320,
                                             "wires": [
                                                 [
                                                     "0962842ebd23e0d7"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "554b8c663bcb46c2",
                                             "type": "switch",
                                             "z": "6e802f1553b18149",
                                             "name": "",
                                             "property": "keepTopic",
                                             "propertyType": "env",
                                             "rules": [
                                                 {
                                                     "t": "true"
                                                 },
                                                 {
                                                     "t": "false"
                                                 }
                                             ],
                                             "checkall": "true",
                                             "repair": false,
                                             "outputs": 2,
                                             "x": 170,
                                             "y": 160,
                                             "wires": [
                                                 [
                                                     "e30ba9f0483285e4"
                                                 ],
                                                 [
                                                     "e023fe88445ce43e"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "e30ba9f0483285e4",
                                             "type": "change",
                                             "z": "6e802f1553b18149",
                                             "name": "",
                                             "rules": [
                                                 {
                                                     "t": "change",
                                                     "p": "topic",
                                                     "pt": "msg",
                                                     "from": "/",
                                                     "fromt": "str",
                                                     "to": ".",
                                                     "tot": "str"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 350,
                                             "y": 120,
                                             "wires": [
                                                 [
                                                     "3649300b4c233b10"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "0962842ebd23e0d7",
                                             "type": "change",
                                             "z": "6e802f1553b18149",
                                             "name": "translate invalid chars in topic",
                                             "rules": [
                                                 {
                                                     "t": "change",
                                                     "p": "topic",
                                                     "pt": "msg",
                                                     "from": "..",
                                                     "fromt": "str",
                                                     "to": ".",
                                                     "tot": "str"
                                                 },
                                                 {
                                                     "t": "change",
                                                     "p": "topic",
                                                     "pt": "msg",
                                                     "from": "€",
                                                     "fromt": "str",
                                                     "to": "EUR",
                                                     "tot": "str"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 2430,
                                             "y": 280,
                                             "wires": [
                                                 []
                                             ]
                                         },
                                         {
                                             "id": "9ac3cc3681e8b6c6",
                                             "type": "change",
                                             "z": "6e802f1553b18149",
                                             "name": "set topic, if empty",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "topic",
                                                     "pt": "msg",
                                                     "to": "topic ? topic : $type(payload)\t",
                                                     "tot": "jsonata"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 950,
                                             "y": 200,
                                             "wires": [
                                                 [
                                                     "a096a93bb82b7a93"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "fc7913a8524badb7",
                                             "type": "json",
                                             "z": "6e802f1553b18149",
                                             "name": "",
                                             "property": "payload",
                                             "action": "obj",
                                             "pretty": false,
                                             "x": 750,
                                             "y": 100,
                                             "wires": [
                                                 [
                                                     "d9e7bdd4c48a8aa1"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "d9e7bdd4c48a8aa1",
                                             "type": "switch",
                                             "z": "6e802f1553b18149",
                                             "name": "is type?",
                                             "property": "payload",
                                             "propertyType": "msg",
                                             "rules": [
                                                 {
                                                     "t": "istype",
                                                     "v": "array",
                                                     "vt": "array"
                                                 },
                                                 {
                                                     "t": "istype",
                                                     "v": "object",
                                                     "vt": "object"
                                                 },
                                                 {
                                                     "t": "else"
                                                 }
                                             ],
                                             "checkall": "true",
                                             "repair": false,
                                             "outputs": 3,
                                             "x": 900,
                                             "y": 100,
                                             "wires": [
                                                 [
                                                     "1520be42bcc2145e"
                                                 ],
                                                 [
                                                     "1520be42bcc2145e"
                                                 ],
                                                 [
                                                     "9ac3cc3681e8b6c6"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "a096a93bb82b7a93",
                                             "type": "junction",
                                             "z": "6e802f1553b18149",
                                             "x": 1380,
                                             "y": 280,
                                             "wires": [
                                                 [
                                                     "1a8c03d866b85b12"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "1520be42bcc2145e",
                                             "type": "junction",
                                             "z": "6e802f1553b18149",
                                             "x": 480,
                                             "y": 20,
                                             "wires": [
                                                 [
                                                     "3649300b4c233b10"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "436b84bced4aeddd",
                                             "type": "subflow:6e802f1553b18149",
                                             "z": "393214410c8f2f15",
                                             "name": "",
                                             "x": 590,
                                             "y": 840,
                                             "wires": [
                                                 [
                                                     "624a03b2c28140de"
                                                 ]
                                             ]
                                         }
                                      ]
                                      

                                      Außerdem werden jetzt (!!!) wenn gar kein topic gesetzt ist, das topic gelöscht werden soll und von Anfang an skalare Werte übergeben werden, einfach als topic der Datentyp gesetzt. Damit sollte das mit dem . am Ende nicht mehr vorkommen. Das lag an skalaren Typen ohne topic.

                                      6a1af9c8-a604-4ba1-800a-cb9b3d07a2a5-image.png

                                      Ich hoffe passt jetzt.

                                      @Frank579 - eine kurze Rückmeldung wäre Klasse, dann ändere ich den Flow im 1. Post wieder.

                                      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.

                                      F 1 Antwort Letzte Antwort
                                      1
                                      • mickymM mickym

                                        @frank579 So nächste Version. ;) - Ist wieder etwas komplexer, aber ich hoffe jetzt passt es:

                                        [
                                           {
                                               "id": "6e802f1553b18149",
                                               "type": "subflow",
                                               "name": "JSON or Obj to IOBroker",
                                               "info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as `msg.payload` it is necessary to specify a `msg.top` properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting `msg.topic` entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs `msg.top` property isn't defined, the `top` property of the subflow-node is used. \n\nIn the properties of the subflow node a new property `keepTopic` has been added. Default is _false_ to keep the current behaviour. If set to _true_ then the originial topic will be placed between the `top` property of the subflow node and the property of the analyzed JSON object.\n\n**Attention:**\nIf msg.top and top is empty, all msg.topics (msg.topic) will be directly prefixed with 0_userdata.0. . \n\n**Update 13.09.2022:**\nSpaces in topics of objects are no longer replaced with underscores in objects. No differences between all data types.\n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in` msg.top` mitgegeben wurde. In der `msg.payload` befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende `msg.topic `Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls msg.top nicht definiert wurde, wird der `top`-Wert der Subflow-Node verwendet.\n\nIn den Eigenschaften der Subflow-Node wurde ein neuer Parameter `keepTopic` hinzugefügt. Standardwert ist _false_, um das bisherige Verhalten beizubehalten. Setzt man die Eigenschaft auf _true_, dann wird das originale Topic zwischen der `top` Eigenschaft der Subflow-Node und Eigenschaft des analysierten JSON Objektes eingefügt.\n\n**Achtung:**\nWenn top und msg.top leer ist, werden alle msg.topics (msg.topic) direkt unter dem Präfix 0_userdata.0., angelegt bzw. ausgegeben. \n\n**Update 13.09.2022:**\nLeerzeichen werden in Topics von Objekten nicht mehr durch Unterstriche ersetzt. Es gibt keine Unterschiede mehr zwischen den Datentypen.",
                                               "category": "",
                                               "in": [
                                                   {
                                                       "x": 60,
                                                       "y": 160,
                                                       "wires": [
                                                           {
                                                               "id": "554b8c663bcb46c2"
                                                           }
                                                       ]
                                                   }
                                               ],
                                               "out": [
                                                   {
                                                       "x": 2620,
                                                       "y": 280,
                                                       "wires": [
                                                           {
                                                               "id": "0962842ebd23e0d7",
                                                               "port": 0
                                                           }
                                                       ]
                                                   }
                                               ],
                                               "env": [
                                                   {
                                                       "name": "top",
                                                       "type": "str",
                                                       "value": "objRoot"
                                                   },
                                                   {
                                                       "name": "keepTopic",
                                                       "type": "bool",
                                                       "value": "false"
                                                   }
                                               ],
                                               "meta": {},
                                               "color": "#E2D96E",
                                               "icon": "node-red/batch.svg"
                                           },
                                           {
                                               "id": "3e11e8338f694832",
                                               "type": "split",
                                               "z": "6e802f1553b18149",
                                               "name": "split object",
                                               "splt": "\\n",
                                               "spltType": "str",
                                               "arraySplt": 1,
                                               "arraySpltType": "len",
                                               "stream": false,
                                               "addname": "key",
                                               "x": 1370,
                                               "y": 160,
                                               "wires": [
                                                   [
                                                       "0562a4249c8b856b"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "0562a4249c8b856b",
                                               "type": "change",
                                               "z": "6e802f1553b18149",
                                               "name": "add key to topic",
                                               "rules": [
                                                   {
                                                       "t": "set",
                                                       "p": "stateName",
                                                       "pt": "msg",
                                                       "to": "key",
                                                       "tot": "msg"
                                                   },
                                                   {
                                                       "t": "set",
                                                       "p": "topic",
                                                       "pt": "msg",
                                                       "to": "topic  & '.' & key",
                                                       "tot": "jsonata"
                                                   }
                                               ],
                                               "action": "",
                                               "property": "",
                                               "from": "",
                                               "to": "",
                                               "reg": false,
                                               "x": 1560,
                                               "y": 160,
                                               "wires": [
                                                   [
                                                       "ddc90985bef0fafa"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "ddc90985bef0fafa",
                                               "type": "switch",
                                               "z": "6e802f1553b18149",
                                               "name": "is type?",
                                               "property": "payload",
                                               "propertyType": "msg",
                                               "rules": [
                                                   {
                                                       "t": "istype",
                                                       "v": "array",
                                                       "vt": "array"
                                                   },
                                                   {
                                                       "t": "istype",
                                                       "v": "object",
                                                       "vt": "object"
                                                   },
                                                   {
                                                       "t": "else"
                                                   }
                                               ],
                                               "checkall": "true",
                                               "repair": false,
                                               "outputs": 3,
                                               "x": 1740,
                                               "y": 160,
                                               "wires": [
                                                   [
                                                       "bfce19b206660fbe"
                                                   ],
                                                   [
                                                       "3e11e8338f694832"
                                                   ],
                                                   [
                                                       "1a8c03d866b85b12"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "bfce19b206660fbe",
                                               "type": "split",
                                               "z": "6e802f1553b18149",
                                               "name": "split array",
                                               "splt": "\\n",
                                               "spltType": "str",
                                               "arraySplt": 1,
                                               "arraySpltType": "len",
                                               "stream": false,
                                               "addname": "",
                                               "x": 780,
                                               "y": 280,
                                               "wires": [
                                                   [
                                                       "e89927810c6d75ec"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "e89927810c6d75ec",
                                               "type": "change",
                                               "z": "6e802f1553b18149",
                                               "name": "add index to topic",
                                               "rules": [
                                                   {
                                                       "t": "set",
                                                       "p": "topic",
                                                       "pt": "msg",
                                                       "to": "topic  & '.' & parts.index",
                                                       "tot": "jsonata"
                                                   }
                                               ],
                                               "action": "",
                                               "property": "",
                                               "from": "",
                                               "to": "",
                                               "reg": false,
                                               "x": 970,
                                               "y": 280,
                                               "wires": [
                                                   [
                                                       "a4d1a5d04564dc77"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "f5d52c6a57d08904",
                                               "type": "change",
                                               "z": "6e802f1553b18149",
                                               "name": "finalize msg.topic",
                                               "rules": [
                                                   {
                                                       "t": "set",
                                                       "p": "top",
                                                       "pt": "msg",
                                                       "to": "'0_userdata.0.' & top",
                                                       "tot": "jsonata"
                                                   },
                                                   {
                                                       "t": "set",
                                                       "p": "topic",
                                                       "pt": "msg",
                                                       "to": "top & '.' & topic",
                                                       "tot": "jsonata"
                                                   }
                                               ],
                                               "action": "",
                                               "property": "",
                                               "from": "",
                                               "to": "",
                                               "reg": false,
                                               "x": 2170,
                                               "y": 240,
                                               "wires": [
                                                   [
                                                       "0962842ebd23e0d7"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "1a8c03d866b85b12",
                                               "type": "switch",
                                               "z": "6e802f1553b18149",
                                               "name": "is msg.top != null",
                                               "property": "top",
                                               "propertyType": "msg",
                                               "rules": [
                                                   {
                                                       "t": "nnull"
                                                   },
                                                   {
                                                       "t": "null"
                                                   }
                                               ],
                                               "checkall": "true",
                                               "repair": false,
                                               "outputs": 2,
                                               "x": 1950,
                                               "y": 280,
                                               "wires": [
                                                   [
                                                       "f5d52c6a57d08904"
                                                   ],
                                                   [
                                                       "74c895ce724750de"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "e023fe88445ce43e",
                                               "type": "change",
                                               "z": "6e802f1553b18149",
                                               "name": "",
                                               "rules": [
                                                   {
                                                       "t": "delete",
                                                       "p": "topic",
                                                       "pt": "msg"
                                                   }
                                               ],
                                               "action": "",
                                               "property": "",
                                               "from": "",
                                               "to": "",
                                               "reg": false,
                                               "x": 350,
                                               "y": 200,
                                               "wires": [
                                                   [
                                                       "3649300b4c233b10"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "3649300b4c233b10",
                                               "type": "switch",
                                               "z": "6e802f1553b18149",
                                               "name": "is type?",
                                               "property": "payload",
                                               "propertyType": "msg",
                                               "rules": [
                                                   {
                                                       "t": "istype",
                                                       "v": "json",
                                                       "vt": "json"
                                                   },
                                                   {
                                                       "t": "istype",
                                                       "v": "array",
                                                       "vt": "array"
                                                   },
                                                   {
                                                       "t": "istype",
                                                       "v": "object",
                                                       "vt": "object"
                                                   },
                                                   {
                                                       "t": "else"
                                                   }
                                               ],
                                               "checkall": "true",
                                               "repair": false,
                                               "outputs": 4,
                                               "x": 600,
                                               "y": 160,
                                               "wires": [
                                                   [
                                                       "fc7913a8524badb7"
                                                   ],
                                                   [
                                                       "bfce19b206660fbe"
                                                   ],
                                                   [
                                                       "3e11e8338f694832"
                                                   ],
                                                   [
                                                       "9ac3cc3681e8b6c6"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "1b8480cd2df7ba3f",
                                               "type": "comment",
                                               "z": "6e802f1553b18149",
                                               "name": "Array",
                                               "info": "",
                                               "x": 600,
                                               "y": 280,
                                               "wires": []
                                           },
                                           {
                                               "id": "b3541807672be040",
                                               "type": "comment",
                                               "z": "6e802f1553b18149",
                                               "name": "object",
                                               "info": "",
                                               "x": 1340,
                                               "y": 100,
                                               "wires": []
                                           },
                                           {
                                               "id": "a4d1a5d04564dc77",
                                               "type": "switch",
                                               "z": "6e802f1553b18149",
                                               "name": "is type?",
                                               "property": "payload",
                                               "propertyType": "msg",
                                               "rules": [
                                                   {
                                                       "t": "istype",
                                                       "v": "object",
                                                       "vt": "object"
                                                   },
                                                   {
                                                       "t": "istype",
                                                       "v": "array",
                                                       "vt": "array"
                                                   },
                                                   {
                                                       "t": "else"
                                                   }
                                               ],
                                               "checkall": "true",
                                               "repair": false,
                                               "outputs": 3,
                                               "x": 1160,
                                               "y": 280,
                                               "wires": [
                                                   [
                                                       "3e11e8338f694832"
                                                   ],
                                                   [
                                                       "bfce19b206660fbe"
                                                   ],
                                                   [
                                                       "a096a93bb82b7a93"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "74c895ce724750de",
                                               "type": "change",
                                               "z": "6e802f1553b18149",
                                               "name": "finalize msg.topic",
                                               "rules": [
                                                   {
                                                       "t": "set",
                                                       "p": "top",
                                                       "pt": "msg",
                                                       "to": "top",
                                                       "tot": "env"
                                                   },
                                                   {
                                                       "t": "set",
                                                       "p": "top",
                                                       "pt": "msg",
                                                       "to": "'0_userdata.0.' & top",
                                                       "tot": "jsonata"
                                                   },
                                                   {
                                                       "t": "set",
                                                       "p": "topic",
                                                       "pt": "msg",
                                                       "to": "top & '.' & topic",
                                                       "tot": "jsonata"
                                                   }
                                               ],
                                               "action": "",
                                               "property": "",
                                               "from": "",
                                               "to": "",
                                               "reg": false,
                                               "x": 2170,
                                               "y": 320,
                                               "wires": [
                                                   [
                                                       "0962842ebd23e0d7"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "554b8c663bcb46c2",
                                               "type": "switch",
                                               "z": "6e802f1553b18149",
                                               "name": "",
                                               "property": "keepTopic",
                                               "propertyType": "env",
                                               "rules": [
                                                   {
                                                       "t": "true"
                                                   },
                                                   {
                                                       "t": "false"
                                                   }
                                               ],
                                               "checkall": "true",
                                               "repair": false,
                                               "outputs": 2,
                                               "x": 170,
                                               "y": 160,
                                               "wires": [
                                                   [
                                                       "e30ba9f0483285e4"
                                                   ],
                                                   [
                                                       "e023fe88445ce43e"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "e30ba9f0483285e4",
                                               "type": "change",
                                               "z": "6e802f1553b18149",
                                               "name": "",
                                               "rules": [
                                                   {
                                                       "t": "change",
                                                       "p": "topic",
                                                       "pt": "msg",
                                                       "from": "/",
                                                       "fromt": "str",
                                                       "to": ".",
                                                       "tot": "str"
                                                   }
                                               ],
                                               "action": "",
                                               "property": "",
                                               "from": "",
                                               "to": "",
                                               "reg": false,
                                               "x": 350,
                                               "y": 120,
                                               "wires": [
                                                   [
                                                       "3649300b4c233b10"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "0962842ebd23e0d7",
                                               "type": "change",
                                               "z": "6e802f1553b18149",
                                               "name": "translate invalid chars in topic",
                                               "rules": [
                                                   {
                                                       "t": "change",
                                                       "p": "topic",
                                                       "pt": "msg",
                                                       "from": "..",
                                                       "fromt": "str",
                                                       "to": ".",
                                                       "tot": "str"
                                                   },
                                                   {
                                                       "t": "change",
                                                       "p": "topic",
                                                       "pt": "msg",
                                                       "from": "€",
                                                       "fromt": "str",
                                                       "to": "EUR",
                                                       "tot": "str"
                                                   }
                                               ],
                                               "action": "",
                                               "property": "",
                                               "from": "",
                                               "to": "",
                                               "reg": false,
                                               "x": 2430,
                                               "y": 280,
                                               "wires": [
                                                   []
                                               ]
                                           },
                                           {
                                               "id": "9ac3cc3681e8b6c6",
                                               "type": "change",
                                               "z": "6e802f1553b18149",
                                               "name": "set topic, if empty",
                                               "rules": [
                                                   {
                                                       "t": "set",
                                                       "p": "topic",
                                                       "pt": "msg",
                                                       "to": "topic ? topic : $type(payload)\t",
                                                       "tot": "jsonata"
                                                   }
                                               ],
                                               "action": "",
                                               "property": "",
                                               "from": "",
                                               "to": "",
                                               "reg": false,
                                               "x": 950,
                                               "y": 200,
                                               "wires": [
                                                   [
                                                       "a096a93bb82b7a93"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "fc7913a8524badb7",
                                               "type": "json",
                                               "z": "6e802f1553b18149",
                                               "name": "",
                                               "property": "payload",
                                               "action": "obj",
                                               "pretty": false,
                                               "x": 750,
                                               "y": 100,
                                               "wires": [
                                                   [
                                                       "d9e7bdd4c48a8aa1"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "d9e7bdd4c48a8aa1",
                                               "type": "switch",
                                               "z": "6e802f1553b18149",
                                               "name": "is type?",
                                               "property": "payload",
                                               "propertyType": "msg",
                                               "rules": [
                                                   {
                                                       "t": "istype",
                                                       "v": "array",
                                                       "vt": "array"
                                                   },
                                                   {
                                                       "t": "istype",
                                                       "v": "object",
                                                       "vt": "object"
                                                   },
                                                   {
                                                       "t": "else"
                                                   }
                                               ],
                                               "checkall": "true",
                                               "repair": false,
                                               "outputs": 3,
                                               "x": 900,
                                               "y": 100,
                                               "wires": [
                                                   [
                                                       "1520be42bcc2145e"
                                                   ],
                                                   [
                                                       "1520be42bcc2145e"
                                                   ],
                                                   [
                                                       "9ac3cc3681e8b6c6"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "a096a93bb82b7a93",
                                               "type": "junction",
                                               "z": "6e802f1553b18149",
                                               "x": 1380,
                                               "y": 280,
                                               "wires": [
                                                   [
                                                       "1a8c03d866b85b12"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "1520be42bcc2145e",
                                               "type": "junction",
                                               "z": "6e802f1553b18149",
                                               "x": 480,
                                               "y": 20,
                                               "wires": [
                                                   [
                                                       "3649300b4c233b10"
                                                   ]
                                               ]
                                           },
                                           {
                                               "id": "436b84bced4aeddd",
                                               "type": "subflow:6e802f1553b18149",
                                               "z": "393214410c8f2f15",
                                               "name": "",
                                               "x": 590,
                                               "y": 840,
                                               "wires": [
                                                   [
                                                       "624a03b2c28140de"
                                                   ]
                                               ]
                                           }
                                        ]
                                        

                                        Außerdem werden jetzt (!!!) wenn gar kein topic gesetzt ist, das topic gelöscht werden soll und von Anfang an skalare Werte übergeben werden, einfach als topic der Datentyp gesetzt. Damit sollte das mit dem . am Ende nicht mehr vorkommen. Das lag an skalaren Typen ohne topic.

                                        6a1af9c8-a604-4ba1-800a-cb9b3d07a2a5-image.png

                                        Ich hoffe passt jetzt.

                                        @Frank579 - eine kurze Rückmeldung wäre Klasse, dann ändere ich den Flow im 1. Post wieder.

                                        F Offline
                                        F Offline
                                        Frank579
                                        schrieb am zuletzt editiert von
                                        #81

                                        @mickym
                                        Auf den ersten Blick sieht alles gut aus, log bleibt sauber :)
                                        Top Arbeit von dir :+1:

                                        mickymM 1 Antwort Letzte Antwort
                                        1
                                        • F Frank579

                                          @mickym
                                          Auf den ersten Blick sieht alles gut aus, log bleibt sauber :)
                                          Top Arbeit von dir :+1:

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

                                          @frank579 Gut, dann übernehm ich diese Version mal in den ersten Post - Historie hab ich schon geändert.

                                          Danke für Rückmeldung.

                                          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
                                          0
                                          Antworten
                                          • In einem neuen Thema antworten
                                          Anmelden zum Antworten
                                          • Älteste zuerst
                                          • Neuste zuerst
                                          • Meiste Stimmen


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          799

                                          Online

                                          32.4k

                                          Benutzer

                                          81.4k

                                          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