Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Praktische Anwendungen (Showcase)
    4. [Javascript] Adapter-Instanzen überwachen

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [Javascript] Adapter-Instanzen überwachen

    This topic has been deleted. Only users with topic management privileges can see it.
    • Glasfaser
      Glasfaser @Acgua last edited by

      @acgua sagte in [Javascript] Adapter-Instanzen überwachen:

      Link: https://github.com/Acgua/ioBroker-Script-Adapter-Instances-Watcher

      3aa565e4-6fc3-406b-ba41-0a0964708b2d-grafik.png

      Acgua 1 Reply Last reply Reply Quote 0
      • Acgua
        Acgua @Glasfaser last edited by

        @glasfaser
        Danke, korrigiert, bzw. entfernt, da alles hier auch schon steht.

        1 Reply Last reply Reply Quote 0
        • W
          wilbur last edited by wilbur

          @acgua said in [Javascript] Adapter-Instanzen überwachen:

          Der Auslöser für mich für dieses Script war, dass ich zuverlässig Datenpunkte brauchte, die mir anzeigen, ob eine Adapter-Instanz "läuft".

          Ich hab dafür ein kleines Blockly nach diesem Muster: machs-smart.de
          Und das funktioniert bisher sehr zuverlässig.
          Das meldet, wenn eine Instanz nicht mehr läuft.

          T Acgua 2 Replies Last reply Reply Quote 1
          • david83
            david83 last edited by

            Hört sich interessant an, ich bin interessiert;-)

            Acgua 1 Reply Last reply Reply Quote 0
            • Acgua
              Acgua @david83 last edited by Acgua

              @david83

              Hier das Script:

              Github-Projekt, Anleitung: Acgua/ioBroker-Script-Adapter-Instances-Watcher

              JS in "Raw": https://raw.githubusercontent.com/Acgua/ioBroker-Script-Adapter-Instances-Watcher/main/adapter-instance-watcher.js

              1 Reply Last reply Reply Quote 0
              • frana120500
                frana120500 last edited by

                Vielen Dank für das Script.Das schaut wirklich klasse aus.

                Dann baue ich mir mal meine Telegram Benachrichtigung zusammen (mit Blockly) für den Fall, dass eine Instanz ausgfällt.

                Danke für deine Arbeit.

                Acgua 1 Reply Last reply Reply Quote 0
                • ?
                  A Former User last edited by A Former User

                  Danke für das Skript! Sehr ausführlich und sieht nach viel Arbeit aus. 🙂

                  Bei zwei Instanzen hat er ein Fehler ausgespuckt da er für den Datenpunkt connected_with_device_service einen String bekommt. Habe diese dann händisch von Boolean auf String geändert. Dann meckert er nicht mehr. Der Rest lief/läuft ohne Probleme.

                     2022-07-15 08:32:44.280	info	State value to set for "0_userdata.0.System.Adapter-Instanzen.mqtt_0.info.connected_with_device_service" has to be type "boolean" but received type "string"
                  
                  javascript.0
                  2022-07-15 08:32:44.213	warn	at AdapterInstance._initAdapterInstanceAsync (script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher:230:9)
                  
                  javascript.0
                  2022-07-15 08:32:44.213	warn	at processImmediate (node:internal/timers:437:9)
                  
                  javascript.0
                  2022-07-15 08:32:44.213	warn	at runNextTicks (node:internal/process/task_queues:61:5)
                  
                  javascript.0
                  2022-07-15 08:32:44.213	warn	at runMicrotasks (<anonymous>)
                  
                  javascript.0
                  2022-07-15 08:32:44.213	warn	at AdapterInstance.asyncUpdateStates (script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher:396:21)
                  
                  javascript.0
                  2022-07-15 08:32:44.213	warn	at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1532:20)
                  
                  javascript.0
                  2022-07-15 08:32:44.212	warn	You are assigning a string to the state "0_userdata.0.System.Adapter-Instanzen.mqtt_0.info.connected_with_device_service" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning might become an error in future versions.
                  
                  javascript.0
                  2022-07-15 08:32:44.074	info	State value to set for "0_userdata.0.System.Adapter-Instanzen.admin_0.info.connected_with_device_service" has to be type "boolean" but received type "string"
                  
                  javascript.0
                  2022-07-15 08:32:44.053	warn	at AdapterInstance._initAdapterInstanceAsync (script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher:230:9)
                  
                  javascript.0
                  2022-07-15 08:32:44.053	warn	at processImmediate (node:internal/timers:437:9)
                  
                  javascript.0
                  2022-07-15 08:32:44.053	warn	at runNextTicks (node:internal/process/task_queues:61:5)
                  
                  javascript.0
                  2022-07-15 08:32:44.053	warn	at runMicrotasks (<anonymous>)
                  
                  javascript.0
                  2022-07-15 08:32:44.053	warn	at AdapterInstance.asyncUpdateStates (script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher:396:21)
                  
                  javascript.0
                  2022-07-15 08:32:44.053	warn	at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1532:20)
                  
                  javascript.0
                  2022-07-15 08:32:44.052	warn	You are assigning a string to the state "0_userdata.0.System.Adapter-Instanzen.admin_0.info.connected_with_device_service" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning might become an error in future versions.
                  

                  Acgua 1 Reply Last reply Reply Quote 0
                  • Acgua
                    Acgua @Guest last edited by Acgua

                    Vielen Dank für euer Feedback @frana120500 und @ciddi89 !

                    @ciddi89
                    Danke für den Logauszug, Problem also bei den Instanzen "admin.0" und "mqtt.0" bezüglich String statt Boolean.
                    mqtt habe ich derzeit nicht im Einsatz, aber den admin zwangsläufig 😁

                    Leider kann ich den Fehler bei admin.0 und allen anderen Instanzen nicht reproduzieren.
                    Für sämtliche Instanzen bekomme ich mit einem log(), eine Zeile vor dem setState(), auf Prüfung der Variable immer ein Boolean, hier als Auszug für admin.0:

                    16:28:03.008	warn	javascript.0 (1047) script.js.System.Adapter-Instance-Watcher: [admin.0] Type=[boolean], Value stringified=[true]
                    

                    Könntest du mir bitte einen Gefallen tun und Zeile 396, also

                    setState(this.path + '.info.connected_with_device_service', {val:this.connected_with_device_service, ack:true});
                    

                    löschen und ersetzen mit:

                                        ///// - TEST 1 - 15.07.2022 - https://forum.iobroker.net/post/827939
                                        if (typeof this.connected_with_device_service !== 'boolean') {
                                            log(`[${this.id}] connected_with_device_service type error, boolean expected – Type=[${typeof this.connected_with_device_service}], Value stringified=[${JSON.stringify(this.connected_with_device_service)}]`, 'warn');
                                        } else {
                                            setState(this.path + '.info.connected_with_device_service', {val:this.connected_with_device_service, ack:true});
                                        }
                                        /////////////////////////////////////////////////////////////////
                    

                    Welche Log-Ausgabe bekommst du da? Da sollte jetzt für "admin.0" und "mqtt.0" jeweils eine warn-Logzeile kommen mit Datentyp und Wert.

                    Welche JavaScript-Adapter-Version setzt du denn ein? Ich aktuell 5.8.10, und bis vor kurzem 5.8.3 / 5.8.5.

                    Danke!

                    ? 1 Reply Last reply Reply Quote 0
                    • ?
                      A Former User @Acgua last edited by

                      @acgua ja bei allen anderen Instanzen ist es auch der Typ Boolean. Komischerweise hier aber nicht, dort steht auch ein String drin. Javascript Adapter Version ist die 5.7.0. Sollte also die stable sein. Hier die Ausgabe vom Log aus deinem Test:

                         2022-07-15 17:13:15.307	warn	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: [admin.0] connected_with_device_service type error, boolean expected – Type=[string], Value stringified=["[1]admin"]
                      
                      javascript.0
                      2022-07-15 17:13:06.405	warn	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: [mqtt.0] connected_with_device_service type error, boolean expected – Type=[string], Value stringified=["remeha logger,Klimastation_0"]
                      
                      javascript.0
                      2022-07-15 17:13:06.380	warn	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: [admin.0] connected_with_device_service type error, boolean expected – Type=[string], Value stringified=["[2]admin, javascript"]
                      
                      javascript.0
                      2022-07-15 17:13:06.118	info	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: ...Initialisierung erfolgreich abgeschlossen.
                      
                      javascript.0
                      2022-07-15 17:13:06.118	info	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: ...33 Adapter-Instanzen instanziiert: admin.0, alexa2.0, backitup.0, ble.0, chromecast.0, denon.0, device-reminder.0, device-watcher.0, discovery.0, fakeroku.0, harmony.0, hm-rega.0, hm-rpc.0, hm-rpc.1, influxdb.0, iot.0, javascript.0, logparser.0, lovelace.0, mihome-vacuum.0, mihome-vacuum.1, mqtt.0, net-tools.0, netatmo-crawler.0, pi-hole.0, pushover.0, sonos.0, switchbot-ble.0, tankerkoenig.0, unifi.0, web.0, yahka.0, zigbee.0
                      
                      javascript.0
                      2022-07-15 17:13:06.057	info	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: registered 0 subscriptions and 0 schedules
                      
                      javascript.0
                      2022-07-15 17:13:06.057	info	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: Initialisiere Adapter-Instanzen-Script...
                      
                      javascript.0
                      2022-07-15 17:13:06.046	info	Start javascript script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher
                      

                      Acgua 1 Reply Last reply Reply Quote 0
                      • Acgua
                        Acgua @frana120500 last edited by

                        @frana120500 said in [Javascript] Adapter-Instanzen überwachen:

                        Dann baue ich mir mal meine Telegram Benachrichtigung zusammen (mit Blockly) für den Fall, dass eine Instanz ausgfällt.

                        Sag gerne Bescheid, falls du noch zusätzliche Datenpunkte brauchst.
                        Ich überlege mir da auch noch was sinnvolles.
                        Gibt ja Adapter, die mal für paar Minuten keine Verbindung mit einem Service haben, aber da möchte man dann nicht ständig Telegram-Messages bekommen.
                        Außerdem wäre wohl eine Historie sinnvoll, um nachzuvollziehen, wann und wie lange pro Tag eine Instanz nicht "functioning" war.

                        frana120500 1 Reply Last reply Reply Quote 0
                        • Acgua
                          Acgua @Guest last edited by

                          @ciddi89
                          Danke. Ich wollte auf JS-Adapter 5.7.0 downgraden zum testen, aber bekomme diverse npm errors und klappt nicht... Ich bin immer im Latest unterwegs, mit derzeit Node.js v16.15.1, NPM: 8.11.0, JS-Controller 4.0.23

                          Seltsam jedenfalls, aber das könnte auch ein Bug der 5.7.0 sein, der in nachfolgenden Versionen behoben ist.

                          Die String-Ausgaben sind jedenfalls interessant, weil diese eigentlich nur boolean sein können:

                          [admin.0] Type=[string], Value stringified=["[1]admin"]
                          [mqtt.0] Type=[string], Value stringified=["remeha logger,Klimastation_0"]
                          [admin.0] Type=[string], Value stringified=["[2]admin, javascript"]
                          


                          Der Wert wird abgefragt von z.B. admin.0.info.connection, über

                                          if (await existsStateAsync(`${this.id}.info.connection`)) {
                                              const infConnObj = await getStateAsync(`${this.id}.info.connection`);
                                              this.connected_with_device_service = infConnObj.val;                    
                                          }
                          


                          Und admin.0.info.connection ist boolean.

                          ab568aef-d767-4933-8ef6-7d8e82d6a4ef-image.png

                          Muss mir mal was überlegen. Eigentlich nur eine Kleinigkeit, aber nervt jetzt grad 😂

                          ? 1 Reply Last reply Reply Quote 0
                          • frana120500
                            frana120500 @Acgua last edited by

                            @acgua Historie wäre geil, dann könnte man eventuelle Fehlerquellen zeitlich eingrenzen

                            Acgua 1 Reply Last reply Reply Quote 0
                            • Acgua
                              Acgua @frana120500 last edited by

                              @frana120500
                              cool, dachte ich mir auch, dann baue ich das noch ein.

                              Welche JS-Adapter-Version setzt du denn ein? Bekommst du evtl. auch Warnungen wie You are assigning a string to the state (...) which expects a boolean. im Log?

                              frana120500 1 Reply Last reply Reply Quote 0
                              • ?
                                A Former User @Acgua last edited by

                                @acgua ja deswegen hat es mich gewundert und darum habe ich den Fehler hier rein gestellt. Für mich persönlich nicht schlimm, wie gesagt hab die zwei Datenpunkte auf String umgeändert. Aber ich weiß wie es ist das so eine Kleinigkeit einen stören kann und man wissen will wieso weshalb warum. Wenn ich später mal Zeit habe schaue ich mir das Skript auch mal in Ruhe an, vielleicht finde ich auch selbst heraus woher es kommen könnte. 🙂

                                1 Reply Last reply Reply Quote 1
                                • frana120500
                                  frana120500 @Acgua last edited by

                                  @acgua Hi, ich nutze den Script Adapter in Version 5.8.10... also die letzte Beta

                                  Ich bekomme aufgrund des Sonoff und des MQTT Adapters die folgenden Fehlermeldungen:

                                  You are assigning a string to the state "0_userdata.0.System.Adapter-Instanzen.sonoff_0.info.connected_with_device_service" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning might become an error in future versions.

                                  You are assigning a string to the state "0_userdata.0.System.Adapter-Instanzen.mqtt_0.info.connected_with_device_service" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning might become an error in future versions.
                                  Acgua 1 Reply Last reply Reply Quote 0
                                  • Acgua
                                    Acgua @frana120500 last edited by Acgua

                                    @frana120500
                                    Danke. Auch noch mal an @ciddi89 für deine Rückinfo.

                                    Dann muss ich mir das die Tage mal näher ansehen, gerade weil es auch im Latest (5.8.10) vorkommt, das ist sehr wichtig zu wissen.
                                    Ich habe nur beschränkt Zeit, daher brauche ich ggf. ein paar Tage, also bitte nicht wundern, aber ich kümmere mich darum.
                                    Ist nur eine Kleinigkeit und eher ein "Schönheitsfehler", weil sonst ja alles läuft, aber nervt mich 😁 und werde ich lösen, also die Ursache.

                                    ? 1 Reply Last reply Reply Quote 0
                                    • ?
                                      A Former User @Acgua last edited by

                                      @acgua hehe ja gerne doch. Mach dir kein Stress, wie du schon sagst: es ist nur ein Schönheitsfehler. Und ich kenne das nur zu gut mit der Zeit. Das Problem habe ich und viele andere auch hier.😬 Falls ich vorher schon was finde, gebe ich dir natürlich Bescheid. 🙂

                                      Acgua 1 Reply Last reply Reply Quote 1
                                      • Acgua
                                        Acgua @Guest last edited by

                                        @ciddi89 und @frana120500
                                        Ich habe nun Version 0.0.2 veröffentlicht, Änderung:

                                        • Acgua – Workaround aufgrund Issue #1 eingebaut. In manchen ioBroker-Umgebungen scheint die Abfrage von admin.0.info.connection (sowie bisher identifizierte Adapter mqtt und sonoff) kein Boolean zurückzugeben, sondern ein String wie etwa [2]admin, javascript. Ich kann es nicht reproduzieren aber habe ein Workaround eingebaut. Bei Ausgabe eines Strings (Länge > 1) wird angenommen, dass eine Verbindung besteht.

                                        Hier übrigens die Änderungen im Script:
                                        https://github.com/Acgua/ioBroker-Script-Adapter-Instances-Watcher/commit/08b171e5a93995eab65d9400bc049cc25760e382

                                        Link zum Projekt: https://github.com/Acgua/ioBroker-Script-Adapter-Instances-Watcher

                                        0 Acgua committed to Acgua/ioBroker-Script-Adapter-Instances-Watcher
                                        Version 0.0.2
                                        
                                        Addressing issue #1 - https://github.com/Acgua/ioBroker-Script-Adapter-Instances-Watcher/issues/1
                                        ? JLeg 2 Replies Last reply Reply Quote 0
                                        • ?
                                          A Former User @Acgua last edited by

                                          @acgua danke, hab die neue Version gleich ausprobiert. 🙂 Vielen dank für die Arbeit. Das log sieht nun so aus:

                                             2022-07-18 20:16:51.686	warn	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: admin.0.info.connection returns String "[1]admin", but boolean expected. We assume connection is true and continue.
                                          
                                          javascript.0
                                          2022-07-18 20:16:07.087	warn	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: mqtt.0.info.connection returns String "remeha logger,Klimastation_0", but boolean expected. We assume connection is true and continue.
                                          
                                          javascript.0
                                          2022-07-18 20:16:07.051	warn	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: admin.0.info.connection returns String "[2]admin, javascript", but boolean expected. We assume connection is true and continue.
                                          
                                          javascript.0
                                          2022-07-18 20:16:06.973	info	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: ...Initialisierung erfolgreich abgeschlossen.
                                          
                                          javascript.0
                                          2022-07-18 20:16:06.973	info	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: ...33 Adapter-Instanzen instanziiert: admin.0, alexa2.0, backitup.0, ble.0, chromecast.0, denon.0, device-reminder.0, device-watcher.0, discovery.0, fakeroku.0, harmony.0, hm-rega.0, hm-rpc.0, hm-rpc.1, influxdb.0, iot.0, javascript.0, logparser.0, lovelace.0, mihome-vacuum.0, mihome-vacuum.1, mqtt.0, net-tools.0, netatmo-crawler.0, pi-hole.0, pushover.0, sonos.0, switchbot-ble.0, tankerkoenig.0, unifi.0, web.0, yahka.0, zigbee.0
                                          
                                          javascript.0
                                          2022-07-18 20:16:06.906	info	State value to set for "0_userdata.0.System.Adapter-Instanzen._all.notFunctioningList" has to be stringified but received type "object"
                                          
                                          javascript.0
                                          2022-07-18 20:16:06.895	warn	This object will not be created in future versions. Please report this to the developer.
                                          
                                          javascript.0
                                          2022-07-18 20:16:06.895	warn	Object 0_userdata.0.System.Adapter-Instanzen._all.notFunctioningList is invalid: Default value has to be stringified but received type "object"
                                          
                                          javascript.0
                                          2022-07-18 20:16:06.869	info	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: registered 0 subscriptions and 0 schedules
                                          
                                          javascript.0
                                          2022-07-18 20:16:06.868	info	script.js.Datenpunkte.ioBroker.Adapter-Instance-Watcher: Initialisiere Adapter-Instanzen-Script...
                                          

                                          Acgua 1 Reply Last reply Reply Quote 1
                                          • david83
                                            david83 last edited by david83

                                            @Acgua

                                            Hi, ich wollte das Script einmal ausprobieren und habe das npm Modul cron-parser aktiviert.
                                            Dann das Log kontrolliert. Folgende Meldungen:

                                            	2022-07-19 14:18:39.627	error	WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.626	error	npm
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.599	error	WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.598	error	npm
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.577	error	WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.576	error	npm
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.538	error	WARN deprecated node-inspect@2.0.0: This module is part of Node.js core and does not need to be installed separately. It is now unmaintained.
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.537	error	npm
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.480	error	WARN deprecated har-validator@5.1.5: this library is no longer supported
                                            
                                            javascript.0
                                            2022-07-19 14:18:39.479	error	npm
                                            
                                            javascript.0
                                            2022-07-19 14:18:37.412	error	WARN config production Use `--omit=dev` instead.
                                            
                                            javascript.0
                                            2022-07-19 14:18:37.411	error	npm
                                            

                                            Ist das so richtig?

                                            mikeal created this issue in request/request

                                            open Request’s Past, Present and Future #3142

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            1.1k
                                            Online

                                            31.7k
                                            Users

                                            79.7k
                                            Topics

                                            1.3m
                                            Posts

                                            12
                                            34
                                            3304
                                            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