Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. [gelöst] Auf json von Dateisystem zugreifen

    NEWS

    • Neues Video über Aliase, virtuelle Geräte und Kategorien

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    [gelöst] Auf json von Dateisystem zugreifen

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

      Hallo,
      wollte mal fragen ob es möglich ist, mit Blockly auf eine json auf dem Dateisystem zuzugreifen.

      Mir geht's im speziellen um die

      opt/iobroker/node_modules/iobroker.xxxxx/io-package.json
      
      1 Reply Last reply Reply Quote 0
      • mkshb
        mkshb last edited by

        Moin @david-g,

        geht es um ein Skript? Dann kannst Du die Datei mit den JS Funktionen fs.readFile() und/oder fs.readFileSync() lesen.

        1 Reply Last reply Reply Quote 0
        • David G.
          David G. last edited by

          @mkshb

          Genau.
          Möchte in einer Schleife meine Adapter abarbeiten und einen Wert aus den jsons holen.

          Leider bin ich in js noch nicht ganz so fit.
          Wie müsste der JS Baustein aussehen, wenn ich den Text der json in eine Variable (bild) schreiben möchte?
          Der Pfad zur json wird vorher auch per Skript generiert und in eine Variable (pfad) geschrieben.

          paul53 1 Reply Last reply Reply Quote 0
          • mkshb
            mkshb last edited by mkshb

            @david-g sagte in Auf json von Dateisystem zugreifen:

            Wie müsste der JS Baustein aussehen, wenn ich den Text der json in eine Variable (bild) schreiben möchte?

            Was meinst Du mit "(bild)"?

            Ansonsten sind die Funktionen hier ganz gut beschrieben: https://nodejs.dev/learn/reading-files-with-nodejs

            1 Reply Last reply Reply Quote 0
            • paul53
              paul53 @David G. last edited by paul53

              @david-g sagte: Der Pfad zur json wird vorher auch per Skript generiert und in eine Variable (pfad) geschrieben.

              Javascript-Funktion mit Ergebnis mit Parameter path:

              const fs = require('fs');
              return fs.readFileSync(path, 'utf8');
              

              gibt den Inhalt der Datei zurück.

              Bild_2022-05-16_230132837.png

              David G. 1 Reply Last reply Reply Quote 0
              • David G.
                David G. @paul53 last edited by

                @paul53

                Danke, das klappt.
                Irgendwie ist Paul immer der Retter in der Not 🍻

                Kannst mir bestimmt auch sagen, warum der Debug undefined ausgibt^^

                Screenshot_20220516-231937_Chrome.jpg

                paul53 1 Reply Last reply Reply Quote 0
                • paul53
                  paul53 @David G. last edited by

                  @david-g sagte: Danke, das klappt.

                  Wirklich? Die Funktion darf nicht den gleichen Bezeichner haben wie die Variable.

                  Was ergibt das im Log?

                  Bild_2022-05-16_233906364.png

                  Die Umwandlung "JSON nach Objekt" ist nicht erforderlich, da dies der Block "Attribut" macht.

                  David G. 1 Reply Last reply Reply Quote 0
                  • David G.
                    David G. @paul53 last edited by David G.

                    @paul53

                    Ja, das klappt (hab die Funktion trotzdem mal umbenannt(noch nicht im Screenshot)). Zumindest die json einzulesen.
                    Den gewünschten Wert bekomme ich aber nicht.
                    Hab es jetzt so:

                    Screenshot_20220516-234413_Chrome.jpg

                    Der Debug:

                    javascript.0
                    2022-05-16 23:43:40.475	error	script.js.Eigene_Scripte.VIS.Tabelle_Adapter: undefined
                    
                    javascript.0
                    2022-05-16 23:43:40.473	error	script.js.Eigene_Scripte.VIS.Tabelle_Adapter: { "common": { "name": "cloud", "version": "4.1.1", "title": "Cloud connection", "titleLang": { "en": "Cloud connection", "de": "Cloud-Verbindung", "ru": "Облачное соединение", "pt": "Conexão em nuvem", "nl": "Cloud verbinding", "fr": "Connexion au cloud", "it": "Connessione cloud", "es": "Conexión a la nube", "pl": "Połączenie w chmurze", "zh-cn": "云连接" }, "desc": { "en": "Connects your ioBroker server to the ioBroker cloud", "de": "Verbindet Ihren ioBroker-Server mit der ioBroker-Cloud", "ru": "Подключает сервер ioBroker к облаку ioBroker", "pt": "Conecta seu servidor ioBroker à nuvem ioBroker", "nl": "Verbindt uw ioBroker-server met de ioBroker-cloud", "fr": "Connecte votre serveur ioBroker au cloud ioBroker", "it": "Collega il tuo server ioBroker al cloud ioBroker", "es": "Conecta tu ioBroker servidor a la ioBroker en la nube", "pl": "Łączy serwer ioBroker na ioBroker chmura", "zh-cn": "连接你的ioBroker服务器的ioBroker云" }, "news": { "4.1.1": { "en": "Important: Requires js-controller 3.1 at least!\nAdd some checks to prevent issues with missing data\nFIx some crash cases reported by Sentry\npass HEAD requests without body (Sentry IOBROKER-CLOUD-14)", "de": "Wichtig: Benötigt mindestens js-controller 3.1!\nFügen Sie einige Überprüfungen hinzu, um Probleme mit fehlenden Daten zu vermeiden\nBehebung einiger von Sentry gemeldeter Absturzfälle\nHEAD-Anfragen ohne Text weitergeben (Sentry IOBROKER-CLOUD-14)", "ru": "Важно: Требуется js-контроллер версии не ниже 3.1!\nДобавьте некоторые проверки, чтобы предотвратить проблемы с отсутствующими данными\nИсправьте некоторые случаи сбоев, о которых сообщил Sentry.\nпередавать запросы HEAD без тела (Sentry IOBROKER-CLOUD-14)", "pt": "Importante: Requer js-controller 3.1 pelo menos!\nAdicione algumas verificações para evitar problemas com dados ausentes\nCorrigir alguns casos de travamento relatados pelo Sentinela\npassar solicitações HEAD sem corpo (Sentry IOBROKER-CLOUD-14)", "nl": "Belangrijk: vereist minimaal js-controller 3.1!\nVoeg enkele controles toe om problemen met ontbrekende gegevens te voorkomen\nRepareer enkele crashgevallen gemeld door Sentry\npass HEAD-verzoeken zonder hoofdtekst (Sentry IOBROKER-CLOUD-14)", "fr": "Important : Nécessite au moins js-controller 3.1 !\nAjoutez quelques vérifications pour éviter les problèmes de données manquantes\nCorrection de certains cas de plantage signalés par Sentry\npasser les requêtes HEAD sans corps (Sentry IOBROKER-CLOUD-14)", "it": "Importante: richiede almeno js-controller 3.1!\nAggiungi alcuni controlli per evitare problemi con i dati mancanti\nRisolvi alcuni casi di crash segnalati da Sentry\nsupera le richieste HEAD senza corpo (Sentry IOBROKER-CLOUD-14)", "es": "Importante: ¡Requiere js-controller 3.1 al menos!\nAgregue algunas comprobaciones para evitar problemas con datos faltantes\nSolucionar algunos casos de fallas informados por Sentry\npasar solicitudes HEAD sin cuerpo (Sentry IOBROKER-CLOUD-14)", "pl": "Ważne: Wymaga przynajmniej js-controller 3.1!\nDodaj kilka testów, aby zapobiec problemom z brakującymi danymi\nNapraw niektóre przypadki awarii zgłoszone przez Sentry\nprzekazać żądania HEAD bez treści (Sentry IOBROKER-CLOUD-14)", "zh-cn": "重要提示:至少需要 js-controller 3.1!\n添加一些检查以防止丢失数据的问题\n修复了 Sentry 报告的一些崩溃案例\n传递没有正文的 HEAD 请求 (Sentry IOBROKER-CLOUD-14)" }, "4.1.0": { "en": "Added support for new javascript", "de": "Unterstützung für neues Javascript hinzugefügt", "ru": "Добавлена поддержка нового javascript.", "pt": "Adicionado suporte para novo javascript", "nl": "Ondersteuning toegevoegd voor nieuw javascript", "fr": "Ajout du support pour le nouveau javascript", "it": "Aggiunto supporto per il nuovo javascript", "es": "Soporte agregado para nuevo javascript", "pl": "Dodano wsparcie dla nowego javascript", "zh-cn": "添加了对新 javascript 的支持" }, "4.0.11": { "en": "Fixed the connection issue with the cloud\nAdded support for Admin5", "de": "Das Verbindungsproblem mit der Cloud wurde behoben\nUnterstützung für Admin5 hinzugefügt", "ru": "Исправлена проблема с подключением к облаку\nДобавлена поддержка Admin5", "pt": "Corrigido o problema de conexão com a nuvem\nAdicionado suporte para Admin5", "nl": "Het verbindingsprobleem met de cloud opgelost\nOndersteuning toegevoegd voor Admin5", "fr": "Correction du problème de connexion avec le cloud\nAjout du support pour Admin5", "it": "Risolto il problema di connessione con il cloud\nAggiunto supporto per Admin5", "es": "Se solucionó el problema de conexión con la nube.\nSoporte agregado para Admin5", "pl": "Naprawiono problem z połączeniem z chmurą\nDodano wsparcie dla Admin5", "zh-cn": "修复了与云的连接问题\n添加了对Admin5的支持" }, "4.0.10": { "en": "Fix crash case (Sentry IOBROKER-CLOUD-X)", "de": "Absturz behoben (Sentry IOBROKER-CLOUD-X)", "ru": "Исправить сбой (Sentry IOBROKER-CLOUD-X)", "pt": "Corrigir caso de falha (Sentry IOBROKER-CLOUD-X)", "nl": "Crashcase repareren (Sentry IOBROKER-CLOUD-X)", "fr": "Correction d'un cas de crash (Sentry IOBROKER-CLOUD-X)", "it": "Risolto il problema di crash (Sentry IOBROKER-CLOUD-X)", "es": "Reparar caso de bloqueo (Sentry IOBROKER-CLOUD-X)", "pl": "Napraw przypadek awarii (Sentry IOBROKER-CLOUD-X)", "zh-cn": "修复崩溃情况(Sentry IOBROKER-CLOUD-X)" }, "4.0.9": { "en": "Support of lovelace via ioBroker.pro\nFixed error with the admin", "de": "Unterstützung von Lovelace über ioBroker.pro\nFehler beim Admin behoben", "ru": "Поддержка ловеласа через ioBroker.pro\nИсправлена ошибка с админкой", "pt": "Suporte de lovelace via ioBroker.pro\nErro corrigido com o administrador", "nl": "Ondersteuning van lovelace via ioBroker.pro\nFout opgelost met de admin", "fr": "Prise en charge de lovelace via ioBroker.pro\nCorrection d'une erreur avec l'administrateur", "it": "Supporto di lovelace tramite ioBroker.pro\nRisolto errore con l'amministratore", "es": "Soporte de lovelace a través de ioBroker.pro\nError solucionado con el administrador.", "pl": "Wsparcie lovelace przez ioBroker.pro\nNaprawiono błąd z administratorem", "zh-cn": "通过ioBroker.pro支持lovelace\n修复了管理员的错误" }, "4.0.8": { "en": "Prevent crash case (Sentry IOBROKER-CLOUD-S)\nfix usage of credentials", "de": "Absturz verhindern (Sentry IOBROKER-CLOUD-S)\nKorrektur der Verwendung von Anmeldeinformationen", "ru": "Предотвращение сбоя (Sentry IOBROKER-CLOUD-S)\nисправить использование учетных данных", "pt": "Evitar caso de travamento (Sentry IOBROKER-CLOUD-S)\ncorrigir o uso de credenciais", "nl": "Voorkom crash case (Sentry IOBROKER-CLOUD-S)\ngebruik van inloggegevens repareren", "fr": "Prévenir les cas de crash (Sentry IOBROKER-CLOUD-S)\ncorriger l'utilisation des informations d'identification", "it": "Prevenire il crash case (Sentry IOBROKER-CLOUD-S)\ncorreggere l'utilizzo delle credenziali", "es": "Caso de prevención de accidentes (Sentry IOBROKER-CLOUD-S)\ncorregir el uso de credenciales", "pl": "Zapobiegaj awariom (Sentry IOBROKER-CLOUD-S)\nnaprawić użycie poświadczeń", "zh-cn": "防止发生崩溃情况(Sentry IOBROKER-CLOUD-S)\n修复凭证的使用" }, "4.0.7": { "en": "Show the invalid authentication message", "de": "Zeigen Sie die ungültige Authentifizierungsnachricht an", "ru": "Показать неверное сообщение аутентификации", "pt": "Mostra a mensagem de autenticação inválida", "nl": "Toon het ongeldige authenticatiebericht", "fr": "Afficher le message d'authentification non valide", "it": "Mostra il messaggio di autenticazione non valido", "es": "Mostrar el mensaje de autenticación no válido", "pl": "Pokaż nieprawidłową wiadomość uwierzytelniającą", "zh-cn": "显示无效的验证消息" } }, "authors": [ "bluefox <dogafox@gmail.com>" ], "license": "MIT", "platform": "Javascript/Node.js", "mode": "daemon", "loglevel": "info", "readme": "https://github.com/ioBroker/ioBroker.cloud/blob/master/README.md", "icon": "cloud.png", "keywords": [ "web", "Cloud", "communication" ], "compact": true, "enabled": false, "extIcon": "https://raw.githubusercontent.com/ioBroker/ioBroker.cloud/master/admin/cloud.png", "type": "communication", "messagebox": true, "stopBeforeUpdate": true, "materialize": true, "dependencies": [ { "js-controller": ">=3.1.3" } ], "preserveSettings": "smartName", "blockly": true, "logTransporter": true, "adminUI": { "config": "json" }, "connectionType": "cloud", "dataSource": "push", "plugins": { "sentry": { "dsn": "https://4e98835e3b074c49a3e31d51a46801a2@sentry.iobroker.net/33" } }, "installedFrom": "iobroker.cloud@4.1.1" }, "protectedNative": [ "login", "pass", "apikey" ], "encryptedNative": [ "pass" ], "native": { "language": "", "login": "email.com", "pass": "", "server": "iobroker.pro", "apikey": "", "instance": "web.0", "cloudUrl": "https://iobroker.net:10555", "connectionTimeout": 10000, "allowSelfSignedCertificate": true, "functionFirst": false, "concatWord": "", "responseOID": "", "restartOnDisconnect": false, "pingTimeout": 5000, "iftttKey": "", "replaces": "", "allowedServices": "", "text2command": "0", "allowAdmin": "", "lovelace": "", "noCommon": false, "useCredentials": true }, "objects": [], "instanceObjects": [ { "_id": "info", "type": "channel", "common": { "name": "Information" }, "native": {} }, { "_id": "info.connection", "type": "state", "common": { "role": "indicator.connected", "name": "If connected to cloud", "type": "boolean", "read": true, "write": false, "def": false }, "native": {} }, { "_id": "info.userOnCloud", "type": "state", "common": { "role": "indicator.connected", "name": "If user is connected over cloud", "type": "boolean", "read": true, "write": false, "def": false }, "native": {} }, { "_id": "info.remoteTill", "type": "state", "common": { "role": "state", "name": "Time till pro access is available", "type": "string", "read": true, "write": false }, "native": {} }, { "_id": "services", "type": "channel", "common": { "name": "Information" }, "native": {} } ]}
                    

                    paul53 1 Reply Last reply Reply Quote 0
                    • paul53
                      paul53 @David G. last edited by paul53

                      @david-g sagte: Den gewünschten Wert bekomme ich aber nicht.

                      Versuche es mal mit "common.icon" oder mit "common.extIcon".

                      David G. 1 Reply Last reply Reply Quote 1
                      • David G.
                        David G. @paul53 last edited by

                        @paul53

                        Das klappt.
                        Dank dir.

                        Muss ich morgen mal meine Adaptertabelle umbauen.
                        War nicht so schön gelöst, da manche Icons nicht den selben Namen wie die Adapter haben.

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        838
                        Online

                        32.0k
                        Users

                        80.5k
                        Topics

                        1.3m
                        Posts

                        3
                        10
                        438
                        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