Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Prüfen ob Wechselrichter verbunden

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Prüfen ob Wechselrichter verbunden

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

      @stefan-falt
      Das scheint zu funktionieren. Ich werde Morgen Berichten 🙂 Danke für den Support.

      Homoran 1 Reply Last reply Reply Quote 0
      • Homoran
        Homoran Global Moderator Administrators @Stefan Falt last edited by

        @stefan-falt sagte in Prüfen ob Wechselrichter verbunden:

        @stefan-falt
        Das scheint zu funktionieren. Ich werde Morgen Berichten 🙂 Danke für den Support.

        nein!

        nach dem request den result im debug, damit wir wissen was zurückkomt, undxes abfangen können

        Stefan Falt 1 Reply Last reply Reply Quote 0
        • Stefan Falt
          Stefan Falt @Homoran last edited by

          @homoran
          Ah, verstehe:
          4fcf66ec-c070-4130-aee4-eb388ce64bea-grafik.png

          Stefan Falt Homoran 2 Replies Last reply Reply Quote 0
          • Stefan Falt
            Stefan Falt @Stefan Falt last edited by

            @stefan-falt
            Ich sollte wohl nur auswerten, wenn der Wert NICHT "undefined" ist ...

            1 Reply Last reply Reply Quote 0
            • Homoran
              Homoran Global Moderator Administrators @Stefan Falt last edited by

              @stefan-falt möglicherweise auf undefined prüfen, und nur dann weitermachen.
              ich fürchte aber der EHOSTUNREACH kommt trotzdem.

              Vielleicht hat @paul53 einen weiteren Geistesblitz

              Stefan Falt paul53 2 Replies Last reply Reply Quote 0
              • Stefan Falt
                Stefan Falt @Homoran last edited by

                @homoran

                Augenblicklich schauts so aus. Ich nehme an um auf undefined zu prüfen muss ich solche eine Variable erstellen?
                Ich bin dann mal im Bett. Muss morgen früh raus.

                Danke + MfG
                Stefan

                c2c84574-2e7d-4bbd-9162-b13ad53cdabc-grafik.png

                paul53 Homoran 2 Replies Last reply Reply Quote 0
                • paul53
                  paul53 @Stefan Falt last edited by

                  @stefan-falt sagte: Ich nehme an um auf undefined zu prüfen muss ich solche eine Variable erstellen?

                  Nein, einfach püfen: falls result

                  1 Reply Last reply Reply Quote 1
                  • Homoran
                    Homoran Global Moderator Administrators @Stefan Falt last edited by

                    @stefan-falt sagte in Prüfen ob Wechselrichter verbunden:

                    Augenblicklich schauts so aus.

                    nee, warte mal bis morgen

                    @homoran sagte in Prüfen ob Wechselrichter verbunden:

                    der EHOSTUNREACH kommt trotzdem.

                    und müllt dir doch das log zu, oder?

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

                      @homoran sagte: EHOSTUNREACH kommt trotzdem.

                      Das müsste sich doch mit Hilfe des Ping-Adapters abfangen lassen?

                      1 Reply Last reply Reply Quote 0
                      • Schmakus
                        Schmakus Developer last edited by Schmakus

                        Ich würde das mit Javascript machen und ein try/catch drumherum bauen. damit ist das Problem gelöst.
                        Gleichzeitig würde ich auf Axios umstellen, da request deprecated ist und der Standard beim JS-Adapter Axios wird. (Je nach JS-Adapter Version musst noch axios als Modul in den Instanzeinstellungen des JS-Adapters definieren).
                        Gleichzeitig ein timeout anstatt ein Intervall. Problem ist, dass Intervalle immer laufen, auch wenn der Code darin noch nicht abgeschlossen ist. Mit einem timeout welches die Funktion selbst nach Ablauf des codes wieder aufruft, passiert das nicht.

                        Ich habe es natürlich nicht getestet.

                        const axios = require('axios').default;
                        axios.defaults.timeout = 1000; // timeout der Anfrage
                        const timeout = null; // timeout für neue Anfrage
                        
                        async function getInfo() {
                            try {
                                const url = 'http://192.168.178.24:8484/getdevdata.cgi?.....'; // richtige URL eintragen
                                const response = await axios.get(url);
                        
                                if (response.status === 200) {
                                    const result = response.data;
                                    await setStateAsync('VAR_PowerOfAC', result.pac, true);
                                    // usw....
                                }
                            } catch (error) {
                                if (error.code === 'EHOSTUNREACH') {
                                    log('WR is sleeping...', 'warn');
                                } else if (error.code === 'ECONNABORTED') {
                                    log('Request timeout... Error: ${error}'. 'error');
                                } else {
                                    log(`Error by request WR. Error: ${error}`, ''error);
                                }
                            }
                        
                            if (timeout) clearTimeout(timeout), (timeout = null);
                            timeout = setTimeout(() => {
                                getInfo();
                            }, 10000);
                        }
                        
                        getInfo();
                        
                        Stefan Falt 1 Reply Last reply Reply Quote 1
                        • Stefan Falt
                          Stefan Falt @Schmakus last edited by

                          @schmakus
                          Dankeschön ... ich bin schon so von Blockly durchdrungen dass man nicht mehr auf die einfachsten Lösungen kommt ... Danke.

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

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          685
                          Online

                          31.7k
                          Users

                          79.8k
                          Topics

                          1.3m
                          Posts

                          9
                          27
                          973
                          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