Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. value in true oder false

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    value in true oder false

    This topic has been deleted. Only users with topic management privileges can see it.
    • Homoran
      Homoran Global Moderator Administrators @janwed last edited by

      @janwed sagte in value in true oder false:

      Zum Beispiel value=open

      ist das wirklich so?

      Wie sieht denn as RAW von dem Datenpunkt aus
      Oder: was sit das für ein Datenpunkt?

      J 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @janwed last edited by

        @janwed sagte: Beispiel value=open, daraus möchte ich dann value=true oder value=closed, daraus dann value=false.

        Also String ("closed"/"open") in Logikwert wandeln? Das geht mit Alias.

        J 1 Reply Last reply Reply Quote 0
        • J
          janwed @Homoran last edited by

          @homoran Screenshot_49.png

          1 Reply Last reply Reply Quote 0
          • J
            janwed @paul53 last edited by

            @paul53 wie genau geht das in Blockly?

            paul53 1 Reply Last reply Reply Quote 0
            • paul53
              paul53 @janwed last edited by

              @janwed sagte: wie genau geht das in Blockly?

              Das hat mit Blockly nichts zu tun.

              J 1 Reply Last reply Reply Quote 0
              • J
                janwed @paul53 last edited by

                @paul53 und wie kriege ich dass dann richtig hin?

                paul53 1 Reply Last reply Reply Quote 0
                • paul53
                  paul53 @janwed last edited by paul53

                  @janwed sagte: wie kriege ich dass dann richtig hin?

                  Zum Erzeugen des Alias im folgenden Script idOrigin, idAlias und nameAlias anpassen und das Script einmal kurz starten:

                  // Original-Datenpunkt
                  const idOrigin = 'xyz.status'; 
                  // Optional: Status-Datenpunkt, wenn Kommando und Status getrennt.
                  // Bei Nicht-Verwendung Leerstring '' zuweisen
                  const idRead = '';
                   
                  // Alias-Datenpunkt
                  const idAlias = 'Wohnen.Fenster.Status';
                  var typeAlias, read, write, nameAlias, role, desc, min, max, unit, states, custom, raum, gewerk;
                  
                  // Folgende kommentieren, wenn keine Änderung der Eigenschaft erforderlich
                  nameAlias = 'Fenster xyz';
                  desc = 'per Script erstellt';
                  typeAlias = 'boolean'; // oder 'number'
                  read = "val == 'open'"; // Erkennung "Aus" --> false erfolgt automatisch  
                  // write = "val ? 'ON' : 'OFF'";
                  role = 'indicator';
                  // min = 0; // nur Zahlen
                  // max = 100; // nur Zahlen
                  // unit = '%'; // nur für Zahlen
                  states = {false: 'geschlossen', true: 'offen'}; // Zahlen (Multistate) oder Logikwert (z.B. Aus/Ein)
                  custom = []; // verhindert doppelte Ausführung von history, ...
                  // raum = 'EG_Flur'; // Groß-/Kleinschreibung in der ID beachten !
                  // gewerk = 'Licht'; // Groß-/Kleinschreibung in der ID beachten !
                  
                  // Ab hier nichts ändern !!
                  function createAlias(idDst, idSrc, idRd) {
                     if(existsState(idDst)) log(idDst + ' schon vorhanden !', 'warn');
                     else {
                        var obj = {};
                        obj.type = 'state';
                        obj.common = getObject(idSrc).common;
                        obj.common.alias = {};
                        if(idRd) {
                            obj.common.alias.id = {};
                            obj.common.alias.id.read = idRd;
                            obj.common.alias.id.write = idSrc;
                            obj.common.read = true;
                        } else obj.common.alias.id = idSrc;
                        if(typeAlias) obj.common.type = typeAlias;
                        if(obj.common.read !== false && read) obj.common.alias.read = read;
                        if(obj.common.write !== false && write) obj.common.alias.write = write;
                        if(nameAlias) obj.common.name = nameAlias;
                        if(role) obj.common.role = role;
                        if(desc) obj.common.desc = desc;
                        if(obj.common.type == 'number') {
                           if(min !== undefined) obj.common.min = min;
                           if(max !== undefined) obj.common.max = max;
                           if(unit) obj.common.unit = unit;
                        } else {
                           if(obj.common.min !== undefined) delete obj.common.min;
                           if(obj.common.max !== undefined) delete obj.common.max;
                           if(obj.common.unit) delete obj.common.unit;
                        }
                        if(states) obj.common.states = states;
                        if(custom && obj.common.custom) obj.common.custom = custom;
                        obj.native = {};
                        setObject(idDst, obj, function() {
                           if(idRd) setState(idRd, getState(idRd).val, true);
                           else setState(idSrc, getState(idSrc).val, true); 
                        });
                        if(raum && existsObject('enum.rooms.' + raum)) {
                           let obj = getObject('enum.rooms.' + raum)
                           obj.common.members.push(idDst);
                           setObject('enum.rooms.' + raum, obj);
                        }
                        if(gewerk && existsObject('enum.functions.' + gewerk)) {
                           let obj = getObject('enum.functions.' + gewerk)
                           obj.common.members.push(idDst);
                           setObject('enum.functions.' + gewerk, obj);
                        }
                     } 
                  }
                   
                  createAlias('alias.0.' + idAlias, idOrigin, idRead);
                  
                  J 1 Reply Last reply Reply Quote 0
                  • J
                    janwed @paul53 last edited by

                    @paul53 Was ist dieser Alias datenpunkt?

                    paul53 1 Reply Last reply Reply Quote 0
                    • paul53
                      paul53 @janwed last edited by

                      @janwed sagte: Was ist dieser Alias datenpunkt?

                      Die Doku zum Alias hatte ich oben bereits verlinkt.

                      J 2 Replies Last reply Reply Quote 0
                      • J
                        janwed @paul53 last edited by

                        @paul53 Wie binde Ich jetzt den Alias in Blockly ein?

                        1 Reply Last reply Reply Quote 0
                        • J
                          janwed @paul53 last edited by

                          @paul53 Hat funktioniert, jetzt ist das Problem(siehe Bild) dass ich kein wahr oder falsch dahinter als block einsetzen kann? Screenshot_50.png

                          paul53 1 Reply Last reply Reply Quote 0
                          • paul53
                            paul53 @janwed last edited by paul53

                            @janwed sagte: dass ich kein wahr oder falsch dahinter als block einsetzen kann?

                            Die "Objekt ID" ist auch ein String. Du möchtest sicherlich den "Wert vom Objekt" vergleichen?
                            Da der Wert schon false oder true liefert, ist ein Vergleich mit "wahr" unnötig.

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

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            424
                            Online

                            32.0k
                            Users

                            80.4k
                            Topics

                            1.3m
                            Posts

                            3
                            13
                            265
                            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