Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. (gelöst) Alias über Skript von ganzem Folder anlegen.

    NEWS

    • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?

    • Monatsrückblick – September 2025

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    (gelöst) Alias über Skript von ganzem Folder anlegen.

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

      Hallo.
      Eine Frage: Wie kann ich mit einem Skript automatisiert alle Datenpunkte in einem Folder (also z.B. in mqtt.1.nuk34444) als alias in "alias.0.Haustuer.nuki" anlegen. Nur alle darunter liegenden Datenpunkte, nicht die den Folder selbst.
      Geht das überhaupt?
      DANKE

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

        @manfredhi sagte: alle Datenpunkte in einem Folder (also z.B. in mqtt.1.nuk34444) als alias in "alias.0.Haustuer.nuki" anlegen.

        Wenn sich die Datenpunkte direkt unterhalb von "nuk34444" befinden, versuche es mal so:

        const src = $('mqtt.1.nuk34444.*');
        const dst = 'alias.0.Haustuer.nuki.';
        
        src.each(function(id) {
            const obj = {
                type: 'state',
                common: getObject(id).common,
                native: {}
            };
            const idDst = dst + id.split('.')[3];
            setObject(idDst, obj);
        });
        
        T 1 Reply Last reply Reply Quote 0
        • T
          ticaki @paul53 last edited by

          @paul53

          müsste da nicht noch der alias rein?

          const obj = {
                  type: 'state',
                  common: {
                      ...getObject(id).common,
                      alias: {
                         id
                      },
                  },
                  native: {}
              };
          
          paul53 1 Reply Last reply Reply Quote 0
          • paul53
            paul53 @ticaki last edited by paul53

            @ticaki sagte: müsste da nicht noch der alias rein?

            Ja, du hast recht.

            const src = $('mqtt.1.nuk34444.*');
            const dst = 'alias.0.Haustuer.nuki.';
            
            src.each(function(id) {
                const obj = {
                    type: 'state',
                    common: getObject(id).common,
                    native: {}
                };
                obj.common.alias = {
                    id: id
                };
                const idDst = dst + id.split('.')[3];
                setObject(idDst, obj);
            });
            
            M 1 Reply Last reply Reply Quote 0
            • M
              ManfredHi @paul53 last edited by

              @paul53 @ticaki

              vielen Dank ! Funktioniert.

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

              Support us

              ioBroker
              Community Adapters
              Donate

              999
              Online

              32.4k
              Users

              81.2k
              Topics

              1.3m
              Posts

              3
              5
              69
              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