Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Zeichenketten mit Umlauten an KNX senden UTF8 <-> ISO-8859

    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

    Zeichenketten mit Umlauten an KNX senden UTF8 <-> ISO-8859

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

      Re: Zeichenketten mit Umlauten an KNX senden UTF8 <-> ISO-8859

      Problem gelöst - Hab's endlich hinbekommen Umlaute zu meinen KNX-MDT-Glastastern senden zu können 🙂

      Wichtig ist, dass man nach dem Import des ETS-Projekts, den Datentyp auf mixed ändert - Dann funktioniert das Senden der Umlaute über den iconv-Weg (siehe alte oben verlinkte Topic).

      Bei mir existiert nun in den JavaScript-Objekten ein State vom Typ String - Sobald irgendeine Quelle hier eine Nachricht reinschreibt, propagiere ich diese Nachricht mit dem folgenden Skript an alle gewünschten Ziele (eMail, What'sApp, KNX):

      var Msg = "javascript.0.variables.NotifyMessage";
      var KnxMsg = "knx.0.Hauptgruppe.System.Textmeldung";
      
      if ($("state[id=" + Msg + "]").length == 0) { 
          createState(Msg, "", {"type": "string", "read": true, "write": true, "def": ""});
          console.log("Created variable to save messages for Notify-Events (" + Msg + ")");
      }
      
      on({id: Msg, change: "ne"}, function (obj) {
          if (getObject(KnxMsg).common.type != "mixed") {
              console.error("State for saving KNX-Messages has wrong datatype (" + getObject(KnxMsg).common.type + "). Remember to change datatype into 'mixed' after importing ETS-Project! Otherwise KNX will not receive any notifications!");
          }
      
          var value = obj.state.val;
          if (value) {
      
              // Send E-Mail-Notification
              var firstline = (value.indexOf("\n")==-1) ? value : value.substring(0,value.indexOf("\n"));
              sendTo("email", "send", {
                  to: "<E-Mail-Recipient>",
                  subject: ("ioBroker: " + firstline),
                  text: value
              });
      
              // Send What's-App-Notification
              // To active CallMeBot send "I allow callmebot to send me messages" to "+34 644 263377" via What's-App. CallMeBot will return API-Key after activation.
              var recipients = {};
              recipients["+49...WhatsAppHandyNr1"]="API-Key for WhatsAppHandyNr1";
              recipients["+49...WhatsAppHandyNr1"]="API-Key for WhatsAppHandyNr2";
              for (var recipient in recipients){
                  var request = require('request');
                  var options = { url: "https://api.callmebot.com/whatsapp.php?phone=" + recipient + "&apikey=" + recipients[recipient] + "&text=" + encodeURIComponent(value),
                                  method: 'GET',
                                  headers: { 'User-Agent': 'request' }
                                };
                  request(options)
              }
      
              // Send KNX-Notification
              if (getObject(KnxMsg).common.type == "mixed") {
                  var iconv = require('iconv-lite');
                  var output = iconv.encode(value + String.fromCharCode(0), "ISO-8859-1");
                  setStateDelayed(KnxMsg, output, false, 0, false);
              }
         
          } else {
      
              // Clear KNX-Notification
              if (getObject(KnxMsg).common.type == "mixed") {
                  setStateDelayed(KnxMsg, "", false, 0, false);
              }
      
          }
      
      });
      

      Bitte die Zeilen

      • #2 (Hier steht das KNX-Objekt, das Eure KNX-Aktoren abonnieren. Es wird nach dem ETS-Projektimport vom Typ '''string''' sein. Das vorstehende Skript wirft dann bei jedem Meldungsversand einen Fehler, dass man den Objekt-Typ manuell auf mixed ändern soll.)
      • #20 (E-Mail-Empfänger hinterlegen - Dazu muss der Adapter "email" installiert sein)
      • #28- #29 (Liste von What's-App-Empfängern hinterlegen)

      nach Euren Vorgaben anpassen.

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

      Support us

      ioBroker
      Community Adapters
      Donate
      FAQ Cloud / IOT
      HowTo: Node.js-Update
      HowTo: Backup/Restore
      Downloads
      BLOG

      766
      Online

      31.9k
      Users

      80.2k
      Topics

      1.3m
      Posts

      codepage iso-8859 iso8859 knx konvertieren senden text umlaute utf-8 utf8
      1
      1
      173
      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