Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Node-Red
    5. korrektes Anlegen/Lesen von states aus node-red

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    korrektes Anlegen/Lesen von states aus node-red

    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rewenode last edited by rewenode

      Ich hab da mal ein Problem mit dem iob-Node-red Adapter, das ich nicht gelöst bekomme.
      Ich möchte aus node-red mit einem iob-state arbeiten, welcher ein Array of Object aufnimmt.

      Was gut ist, das klappt und ich arbeite seit langer Zeit problemlos damit.
      Was nicht so gut ist, ich mülle mir dabei das Log mit folgender Meldung zu:

      State value to set for "0_userdata.0.ArrayOfObjects" has to be stringified but received type "object"
      

      [
         {
             "id": "d527dcd47cd4eced",
             "type": "ioBroker out",
             "z": "0bb9d63c2142e02e",
             "name": "ArrayOfObjects",
             "topic": "",
             "ack": "true",
             "autoCreate": "true",
             "stateName": "ArrayOfObjectsList",
             "role": "list",
             "payloadType": "object",
             "readonly": "false",
             "stateUnit": "",
             "stateMin": "",
             "stateMax": "",
             "x": 300,
             "y": 220,
             "wires": []
         },
         {
             "id": "d7009d8b7b3cbbcf",
             "type": "inject",
             "z": "0bb9d63c2142e02e",
             "name": "inject Array and topic \\n topic = 0_userdata.0.ArrayOfObjects",
             "props": [
                 {
                     "p": "payload"
                 },
                 {
                     "p": "topic",
                     "vt": "str"
                 }
             ],
             "repeat": "",
             "crontab": "",
             "once": false,
             "onceDelay": 0.1,
             "topic": "0_userdata.0.ArrayOfObjects",
             "payload": "[{\"window\":\"Zwischentür_vorn\",\"status\":\"open\",\"ts\":\"21.04.25 08:46:31\",\"ort\":\"Aussen\"},{\"window\":\"Büro_WGn\",\"status\":\"open\",\"ts\":\"21.04.25 10:36:41\",\"ort\":\"EG\"}]",
             "payloadType": "json",
             "x": 360,
             "y": 120,
             "wires": [
                 [
                     "a0f7ee98683cb2e5",
                     "d527dcd47cd4eced"
                 ]
             ]
         },
         {
             "id": "a0f7ee98683cb2e5",
             "type": "debug",
             "z": "0bb9d63c2142e02e",
             "name": "plain msg",
             "active": true,
             "tosidebar": true,
             "console": false,
             "tostatus": false,
             "complete": "true",
             "targetType": "full",
             "statusVal": "",
             "statusType": "auto",
             "x": 640,
             "y": 120,
             "wires": []
         }
      ]
      

      2025-04-21_11-09-38.png

      Jetzt würde ich gern wissen, ob ich da was falsch mache bzw wie ich das vermeiden kann.
      Es ist egal, ob ich den Payload type dabei als Array oder Object einstelle.
      Natürlich kann ich das per stringify als String machen, aber das würde den Komplett flow unnötig vergrößern zumal der ja anstandslos das ArrayOfObjects speichert und ließt.

      Gruß und noch einen schönen Ostermontag

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

        @rewenode meines Erachtens war es schon immer so, dass du alle Objekte als JSON Strings im iob speichern bzw. auslesen musst. Deshalb halr einfach eine JSON Node vor die iobroker-out und hinter iobroker-in schalten. Das war meines Erachtens schon immer so.

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

          @mickym Ja, war schon immer so. Da es auch ohne stringify bis auf den Logeintrag klappt hatte ich gehofft, dass ist irgend eine Einstellungssache.
          Da werde ich meine Flows mal anpassen bevor die implizite Konvertierung in zukünftigen Versionen mal wegfällt.

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

          Support us

          ioBroker
          Community Adapters
          Donate

          989
          Online

          31.7k
          Users

          79.7k
          Topics

          1.3m
          Posts

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