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. payload TRUE als string hinzufuegen: geloest

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    payload TRUE als string hinzufuegen: geloest

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

      Hallo ,
      ich lerne immer noch mit diesen Objekten in NODE RED.
      Habe den Telegram bot installiert und mit PING ueberpruefe ich zb. einen Switch

      jetzt hab ich verschiedene Messages geschrieben fuer false und true, haette gerne den Status aber zu dem Object Content hinzugefuegt.

      Aus einem Video habe ich gefunden wie man die Message zusammenbaut.

      hier der Flow:
      a7668079-6180-4c1d-aeb6-4833c49d109a-image.png

      und die Message sieht so aus:

      let payload: {
          chatId: number;
          type: string;
          content: string;
      }
      

      fuer True habe ich zb. diese Funktion:
      747ca108-4ab3-44b2-9b00-3f8c780e5a9b-image.png

      jetzt wuerde ich gerne nur eine Message haben wo der Content sich zusammensetzt aus "Switch " + ???? True oder False von hier 3fabc7dc-4332-4c91-a3ea-b99d3b68299c-image.png

      vielleicht koennt ihr mir dabei helfen, also meine Loesung mit zwei Messages funktioniert natuerlich auch aber nur um es zu lernen wuerde mich interessieren wie das geht .
      Leider komme ich mit node red arbeiten mit Messages nicht weiter.
      Danke.

      Fred Freund mickym 2 Replies Last reply Reply Quote 0
      • Fred Freund
        Fred Freund @Fred Freund last edited by

        @fred-freund
        sorry schon gefunden:
        03219fcf-3e53-4549-9e1c-4d35cdba13c1-image.png
        7c679eb5-695b-4e9b-bfa9-5c8c982ddd4e-image.png

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

          Du brauchst das nicht mit einer Switch Node aufteilen, wenn Du nur den Status einer Node mitgeben willst:

          b826bc89-fdfb-415b-a6dc-27dc36c611af-image.png

          [
             {
                 "id": "56f404f7c15d5c33",
                 "type": "inject",
                 "z": "289f539dcc33814e",
                 "name": "",
                 "props": [
                     {
                         "p": "payload"
                     }
                 ],
                 "repeat": "",
                 "crontab": "",
                 "once": false,
                 "onceDelay": 0.1,
                 "topic": "",
                 "payload": "true",
                 "payloadType": "bool",
                 "x": 330,
                 "y": 2940,
                 "wires": [
                     [
                         "2025494d51d15491"
                     ]
                 ]
             },
             {
                 "id": "083ba3f90e7f21c5",
                 "type": "inject",
                 "z": "289f539dcc33814e",
                 "name": "",
                 "props": [
                     {
                         "p": "payload"
                     }
                 ],
                 "repeat": "",
                 "crontab": "",
                 "once": false,
                 "onceDelay": 0.1,
                 "topic": "",
                 "payload": "false",
                 "payloadType": "bool",
                 "x": 330,
                 "y": 2980,
                 "wires": [
                     [
                         "2025494d51d15491"
                     ]
                 ]
             },
             {
                 "id": "2025494d51d15491",
                 "type": "function",
                 "z": "289f539dcc33814e",
                 "name": "function 3",
                 "func": "var res = msg.payload ? \"true\" : \"false\" ;\nmsg.payload = {\n    chatId: 0,\n    type: \"message\",\n    content: \"Switch2 \" + (msg.payload ? \"true\" : \"false\")\n}\nreturn msg;",
                 "outputs": 1,
                 "noerr": 0,
                 "initialize": "",
                 "finalize": "",
                 "libs": [],
                 "x": 540,
                 "y": 2960,
                 "wires": [
                     [
                         "d39ccfade21e9af9"
                     ]
                 ]
             },
             {
                 "id": "d39ccfade21e9af9",
                 "type": "debug",
                 "z": "289f539dcc33814e",
                 "name": "Ausgabe function Node",
                 "active": true,
                 "tosidebar": true,
                 "console": false,
                 "tostatus": false,
                 "complete": "payload",
                 "targetType": "msg",
                 "statusVal": "",
                 "statusType": "auto",
                 "x": 790,
                 "y": 2960,
                 "wires": []
             },
             {
                 "id": "5c49d395696a09ad",
                 "type": "inject",
                 "z": "289f539dcc33814e",
                 "name": "",
                 "props": [
                     {
                         "p": "payload"
                     }
                 ],
                 "repeat": "",
                 "crontab": "",
                 "once": false,
                 "onceDelay": 0.1,
                 "topic": "",
                 "payload": "true",
                 "payloadType": "bool",
                 "x": 330,
                 "y": 3080,
                 "wires": [
                     [
                         "164e171f33620d6f"
                     ]
                 ]
             },
             {
                 "id": "1b100fe6f9f24f87",
                 "type": "inject",
                 "z": "289f539dcc33814e",
                 "name": "",
                 "props": [
                     {
                         "p": "payload"
                     }
                 ],
                 "repeat": "",
                 "crontab": "",
                 "once": false,
                 "onceDelay": 0.1,
                 "topic": "",
                 "payload": "false",
                 "payloadType": "bool",
                 "x": 330,
                 "y": 3120,
                 "wires": [
                     [
                         "164e171f33620d6f"
                     ]
                 ]
             },
             {
                 "id": "06e93592b88d844b",
                 "type": "debug",
                 "z": "289f539dcc33814e",
                 "name": "Ausgabe Change Node",
                 "active": true,
                 "tosidebar": true,
                 "console": false,
                 "tostatus": false,
                 "complete": "payload",
                 "targetType": "msg",
                 "statusVal": "",
                 "statusType": "auto",
                 "x": 790,
                 "y": 3100,
                 "wires": []
             },
             {
                 "id": "164e171f33620d6f",
                 "type": "change",
                 "z": "289f539dcc33814e",
                 "name": "",
                 "rules": [
                     {
                         "t": "set",
                         "p": "payload",
                         "pt": "msg",
                         "to": "{\t   \"chatId\": 0,\t   \"type\": \"message\",\t   \"content\": \"Switch2 \" & (payload ? \"true\" : \"false\")\t}",
                         "tot": "jsonata"
                     }
                 ],
                 "action": "",
                 "property": "",
                 "from": "",
                 "to": "",
                 "reg": false,
                 "x": 530,
                 "y": 3100,
                 "wires": [
                     [
                         "06e93592b88d844b"
                     ]
                 ]
             }
          ]
          

          Zum Importieren. 😉 - vorausgesetzt aus Deinem Datenpunkt kommt auch ein Boolean raus.

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

            @fred-freund sagte in payload TRUE als string hinzufuegen:

            @fred-freund
            sorry schon gefunden:
            03219fcf-3e53-4549-9e1c-4d35cdba13c1-image.png
            7c679eb5-695b-4e9b-bfa9-5c8c982ddd4e-image.png

            In diesem Fall geht es, weil Dein boolean implizit zu einem String umgewandelt wird - ansonsten habe ich Dir die Alternative gepostet - damit könntest Du dann auch das true und false entsprechend übersetzen.

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

              @mickym Danke!
              kann man den Spoiler importieren das man das anders sieht? sorry bin total NEW.

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

                @fred-freund Einfach aufmachen - dann in die Zwischenablage kopieren und den Inhalt über Import importieren.

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

                  @mickym das hat mich gewundert das das funktioniert...
                  habs aus diesem Video: link text

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

                    @mickym Nochmal Danke!

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

                      Ja ist eigentlich eine generelle Funktion von JS oder JSONATA - das mit einem String implizit andere Datentypen bei Verkettung ebenfalls versucht wird in einen String zu konvertieren.

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

                      Support us

                      ioBroker
                      Community Adapters
                      Donate

                      968
                      Online

                      31.9k
                      Users

                      80.2k
                      Topics

                      1.3m
                      Posts

                      2
                      9
                      325
                      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