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. ANSI Zeichen in Node-Red decodieren

    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

    ANSI Zeichen in Node-Red decodieren

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

      @mickym Ok Danke. Trotzdem schon mal Danke für die Hilfe und dann werde ich da wohl mal weiter stöbern müssen 🙂

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

        @_r_a_l_f_ Ja aber über eine HTTP Request Node?

        1931e2ed-3596-4bdd-93d2-a62f66547937-image.png

        Dann lass Dir das ggf. mal als Buffer ausgeben und schau, ob du mit den NodeJS Methoden konvertieren kannst. Oder Du kannst das bei deinem Request angeben, in welchem Format du das zurückbekommst.

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

          @mickym Ne kein http Request sondern eine http in Node:
          5076ae5c-2e35-40b0-9a4f-a3ad6ae14bdd-image.png

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

            @_r_a_l_f_ ok dann schau mal nach allgemeinen methoden und ob wir die dann in node-red anpassen können. es gibt auch noch so eine alte converter node, vielleicht hilfts, wenn du den output in einen buffer wandelst. aber ich glaub nicht.

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

              @mickym said in ANSI Zeichen in Node-Red decodieren:

              ok dann schau mal nach allgemeinen methoden und ob wir die dann in node-red anpassen können. es gibt auch noch so eine alte converter node, vielleicht hilfts, wenn du den output in einen buffer wandelst.

              Ok, dann schaue ich mal. Aber Danke 🙂

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

                @_r_a_l_f_ Ich weiß nicht ob ich eine Lösung habe, weil ich glaube, dass das Problem ist, dass ich nicht wirklich die Originalquelle habe. Vielleicht musst Du den Buffer exportieren.

                Ich hab hier trotzdem mal ein function Node - mit dem NodeJS Modul iconv erstellt:

                [
                   {
                       "id": "67ff42a946daac45",
                       "type": "inject",
                       "z": "94499721ca4a903a",
                       "name": "",
                       "props": [
                           {
                               "p": "payload"
                           },
                           {
                               "p": "topic",
                               "vt": "str"
                           }
                       ],
                       "repeat": "",
                       "crontab": "",
                       "once": false,
                       "onceDelay": 0.1,
                       "topic": "msgText",
                       "payload": "Au�entemperatur������� St�rung",
                       "payloadType": "str",
                       "x": 370,
                       "y": 580,
                       "wires": [
                           [
                               "6fbcd04977e304fd"
                           ]
                       ]
                   },
                   {
                       "id": "6fbcd04977e304fd",
                       "type": "function",
                       "z": "94499721ca4a903a",
                       "name": "function 2",
                       "func": "var Iconv = iconv.Iconv;\nvar conv = new Iconv('CP1250','UTF-8');\n// msg.payload = conv.convert(Buffer.from(msg.payload));\nmsg.payload = conv.convert(msg.payload).toString();\nreturn msg;",
                       "outputs": 1,
                       "timeout": 0,
                       "noerr": 0,
                       "initialize": "",
                       "finalize": "",
                       "libs": [
                           {
                               "var": "iconv",
                               "module": "iconv"
                           }
                       ],
                       "x": 520,
                       "y": 580,
                       "wires": [
                           [
                               "7aad120c21e94f8e"
                           ]
                       ]
                   },
                   {
                       "id": "7aad120c21e94f8e",
                       "type": "debug",
                       "z": "94499721ca4a903a",
                       "name": "debug 2",
                       "active": true,
                       "tosidebar": true,
                       "console": false,
                       "tostatus": false,
                       "complete": "false",
                       "statusVal": "",
                       "statusType": "auto",
                       "x": 680,
                       "y": 580,
                       "wires": []
                   }
                ]
                

                Du kannst ja mehrere Codepages verwenden, vielleicht funktioniert ja eine.
                https://www.npmjs.com/package/iconv

                var Iconv = iconv.Iconv;
                var conv = new Iconv('CP1250','UTF-8');
                // msg.payload = conv.convert(Buffer.from(msg.payload));
                msg.payload = conv.convert(msg.payload).toString();
                return msg;
                
                _ 1 Reply Last reply Reply Quote 0
                • _
                  _R_A_L_F_ @mickym last edited by _R_A_L_F_

                  @mickym said in ANSI Zeichen in Node-Red decodieren:

                  https://www.npmjs.com/package/iconv

                  Ah ok. Probiere ich mal. Muss ich dazu noch etwas nachinstallieren bei Iconv?:
                  f0b8bc30-f840-4ee0-8696-f36558e88928-image.png

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

                    @_r_a_l_f_ Du musst nur etwas warten, dann installiert sich die Bibliothek automatisch. NEIN - nicht manuell installieren.

                    Einfach den Flow importieren und ein paar Minuten warten.

                    Die Bibliothek installiert sich durch die function Node automatisch:

                    c74812c5-f6c1-4e1c-83f6-a3404d73fa59-image.png

                    Musst höchstens schauen, dass das Modul im Setup eingetragen ist.

                    _ 3 Replies Last reply Reply Quote 0
                    • _
                      _R_A_L_F_ @mickym last edited by

                      @mickym ok, ich kann es erst nächste Woche testen aber ich berichte über das Ergebnis. Danke 🙂

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

                        @mickym said in ANSI Zeichen in Node-Red decodieren:

                        Musst höchstens schauen, dass das Modul im Setup eingetragen ist.

                        Das war ein wertvoller Tipp :).

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

                          @mickym said in ANSI Zeichen in Node-Red decodieren:

                          Musst höchstens schauen, dass das Modul im Setup eingetragen ist.

                          Ich wollte gerade die Vorbereitungen für morgen treffen und die function node einbinden.
                          Dabei kam folgender Fehler:
                          f5f1b71a-90bf-4307-a84c-8e080f6a27fb-image.png

                          D.h. ich benötige auch Python auf dem Windows Rechner, damit das ganze läuft oder?

                          Oder mit folgendem Node könnte es evtl. auch noch klappen:
                          https://flows.nodered.org/node/node-red-contrib-iconv
                          Scheinbar sind es ANSI Zeichen, was wohl windows-1252 entspricht. Und das wäre in der Lite Variante auch enthalten. Aber das Paket ist wohl schon älter.

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

                            @_r_a_l_f_ Ok ja bei mir gings unter windows nicht.

                            Hier nochmal der flow mit iconv-lite:

                            [{"id":"7b0c89ea680be73e","type":"inject","z":"578345f4956c7a57","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"msgText","payload":"Au�entemperatur������� St�rung","payloadType":"str","x":330,"y":2940,"wires":[["e3deb08b1ecaef90"]]},{"id":"e3deb08b1ecaef90","type":"function","z":"578345f4956c7a57","name":"function 3","func":"msg.payload = iconv.decode(Buffer.from(msg.payload), 'win1251');\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"iconv","module":"iconv-lite"}],"x":480,"y":2940,"wires":[["3395014078e80eb5"]]},{"id":"3395014078e80eb5","type":"debug","z":"578345f4956c7a57","name":"iconv-lite","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":640,"y":2940,"wires":[]}]
                            

                            Das scheint zu gehen.

                            Die Node habe ich auch mal ausprobiert - die ist halt schon ziemlich alt.

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

                              @mickym Danke für die Info. Zumindest sieht der Zeichensatz jetzt anders aus 😄

                              598107c0-cc32-4080-95cf-6b364a1a7351-image.png

                              Jetzt müsste ich nur noch wissen, in welchem Format das ganze gesendet wird :(. Habe jetzt auch mal 1251-1258 durchprobiert und sich entsprechend immer andere Zeichen.

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

                                @_r_a_l_f_ ja ich hab da auch nichts vernünftiges rausgebracht. ich würde es halt mal direkt mit der http-in versuchen- ansonsten kann ich auch nicht helfen

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

                                Support us

                                ioBroker
                                Community Adapters
                                Donate

                                890
                                Online

                                31.9k
                                Users

                                80.1k
                                Topics

                                1.3m
                                Posts

                                2
                                20
                                678
                                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