Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Error/Bug
    4. [Gelöst] - JS Skripte mit setInterval laufen nicht neu an

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [Gelöst] - JS Skripte mit setInterval laufen nicht neu an

    This topic has been deleted. Only users with topic management privileges can see it.
    • haus-automatisierung
      haus-automatisierung Developer Most Active @pandel last edited by

      @pandel sagte in Javascript - Skripte mit setInterval laufen nicht neu an:

      Woran kann das liegen? Kann ja nicht sein, dass ich bei jeder Timeränderung den iobroker durchstarten muss.

      Ne, das sollte natürlich nicht so sein. Aber bevor wir hier raten, teil doch gerne ein Debug-Log mit mehr Infos und stell das Script auf verbose um. Sonst kann man nur schätzen was da intern genau passiert.

      An einem fehlenden nodejs Update wird es jedenfalls nicht liegen 🙂

      Thomas Braun 1 Reply Last reply Reply Quote 0
      • Thomas Braun
        Thomas Braun Most Active @haus-automatisierung last edited by

        @haus-automatisierung sagte in Javascript - Skripte mit setInterval laufen nicht neu an:

        An einem fehlenden nodejs Update wird es jedenfalls nicht liegen

        Das nicht. Das ist aber vollkommen unabhängig vom Problem auf Stand zu bringen.

        1 Reply Last reply Reply Quote 0
        • P
          pandel @MartinP last edited by pandel

          @martinp
          Also, das letzte "apt full-upgrade" war vor ca. 10 Sek. - zur Sicherheit. Nix. Unterbau ist ein Debian bullseye mit allen aktuellen Patches.

          Aber in der Tat, bei deinem Screenshot lagst du nicht falsch. Da sind beide Versionen lt. ioBroker zu alt - ganz ehrlich, da hab ich nicht drauf geschaut - einfach, weil ioBroker noch nie wirklich Probleme gemacht hat.

          Das aktualisiere ich erstmal und beobachte was passiert, bevor ich hier weiter aushole. Dann bin ich wenigstens auf dem korrekten Stand.

          Danke für's drauf bringen!

          EDIT:
          Tja, also "iob nodejs-update 18" bringt nix, der versucht das gleiche zu installieren, was schon drauf ist. Ein neueres bekomme ich nicht.

          Thomas Braun 1 Reply Last reply Reply Quote 0
          • Thomas Braun
            Thomas Braun Most Active @pandel last edited by Thomas Braun

            @pandel sagte in Javascript - Skripte mit setInterval laufen nicht neu an:

            Tja, also "iob nodejs-update 18" bringt nix, der versucht das gleiche zu installieren, was schon drauf ist. Ein neueres bekomme ich nicht.

            Kann/soll eigentlich nicht sein.
            Es kommt eine Meldung, dass Version xx.yy läuft und ob die neuste Version aus dem Zweig 18 installiert werden soll. Dies dann bestätigen.

            Meldungen nach einem

            sudo apt update
            apt policy nodejs
            
            1 Reply Last reply Reply Quote 0
            • liv-in-sky
              liv-in-sky @pandel last edited by

              @pandel zeigt doch mal zur sicherheit ein beispiel script von dir, welches nicht läuft

              P 1 Reply Last reply Reply Quote 0
              • P
                pandel @liv-in-sky last edited by

                So...

                iob diag

                ======================= SUMMARY =======================
                                        v.2023-10-10
                
                
                   Static hostname: iobroker
                         Icon name: computer-vm
                           Chassis: vm
                    Virtualization: kvm
                  Operating System: Debian GNU/Linux 11 (bullseye)
                            Kernel: Linux 5.10.0-28-amd64
                      Architecture: x86-64
                
                Installation:           kvm
                Kernel:                 x86_64
                Userland:               amd64
                Timezone:               Europe/Berlin (CET, +0100)
                User-ID:                1000
                X-Server:               false
                Boot Target:            graphical.target
                
                Pending OS-Updates:     0
                Pending iob updates:    0
                
                Nodejs-Installation:    /usr/bin/nodejs         v18.17.1
                                        /usr/bin/node           v18.17.1
                                        /usr/bin/npm            9.6.7
                                        /usr/bin/npx            9.6.7
                                        /usr/bin/corepack       0.18.0
                
                Recommended versions are nodejs 18.19.1 and npm 10.2.4
                Your nodejs installation is correct
                
                MEMORY:
                               total        used        free      shared  buff/cache   available
                Mem:            5.9G        1.9G        2.8G        0.0K        1.3G        3.8G
                Swap:           2.0G         47M        2.0G
                Total:          8.0G        1.9G        4.8G
                
                Active iob-Instances:   21
                Active repo(s): stable
                
                ioBroker Core:          js-controller           5.0.19
                                        admin                   6.13.16
                
                ioBroker Status:        iobroker is running on this host.
                
                
                Objects type: jsonl
                States  type: redis
                
                Status admin and web instance:
                + system.adapter.admin.0                  : admin                 : iobroker                                 -  enabled, port: 8081, bind: 0.0.0.0, run as: admin
                  system.adapter.web.0                    : web                   : iobroker                                 - disabled, port: 8082, bind: 0.0.0.0, run as: admin
                
                Objects:                12497
                States:                 6473
                
                Size of iob-Database:
                
                26M     /opt/iobroker/iobroker-data/objects.jsonl
                12M     /opt/iobroker/iobroker-data/objects.json.migrated
                12M     /opt/iobroker/iobroker-data/objects.json.bak.migrated
                13M     /opt/iobroker/iobroker-data/states.jsonl
                7.6M    /opt/iobroker/iobroker-data/states.json.migrated
                7.6M    /opt/iobroker/iobroker-data/states.json.bak.migrated
                
                
                
                =================== END OF SUMMARY ====================
                

                sudo apt update
                apt policy nodejs

                iouser@iobroker:~$ sudo apt update
                OK:1 http://security.debian.org/debian-security bullseye-security/updates InRelease
                OK:2 http://ftp.gwdg.de/pub/linux/debian/debian bullseye InRelease
                OK:3 http://deb.debian.org/debian bullseye-backports InRelease
                OK:4 http://ftp.gwdg.de/pub/linux/debian/debian bullseye-updates InRelease
                Holen:5 https://deb.nodesource.com/node_18.x bullseye InRelease [4.586 B]
                Es wurden 4.586 B in 1 s geholt (8.092 B/s).
                Paketlisten werden gelesen… Fertig
                Abhängigkeitsbaum wird aufgebaut… Fertig
                Statusinformationen werden eingelesen… Fertig
                Alle Pakete sind aktuell.
                iouser@iobroker:~$ apt policy nodejs
                nodejs:
                  Installiert:           18.17.1-deb-1nodesource1
                  Installationskandidat: 18.17.1-deb-1nodesource1
                  Versionstabelle:
                 *** 18.17.1-deb-1nodesource1 500
                        500 https://deb.nodesource.com/node_18.x bullseye/main amd64 Packages
                        100 /var/lib/dpkg/status
                     12.22.12~dfsg-1~deb11u4 500
                        500 http://ftp.gwdg.de/pub/linux/debian/debian bullseye/main amd64 Packages
                        500 http://security.debian.org/debian-security bullseye-security/updates/main amd64 Packages
                

                @liv-in-sky

                Ich weiss zwar, warum du fragst, aber... Das Skript läuft ja! Darum geht es nicht. Es geht nur darum, dass es nicht wieder anläuft, sobald man es einmal stoppt. Sofern ich dann den iob komplett durchstarte, ist wieder alles gut.

                // create some global vars
                var run;
                var reso;
                var hdr;
                var hdr_state = "true";
                
                on({id:"denon.0.zoneMain.powerZone"}, function (obj) {
                    if (obj.state.val === true || obj.state.val === "true") {
                        log("Interval gestartet",'info');
                        run = setInterval(function() {
                            setHDRMode();
                        }, 15000);
                    } else {
                        log("Interval gestoppt",'info');
                        clearInterval(run)
                    }
                });
                
                function setHDRMode() {
                    const request = require('request');
                    var parseString = require('xml2js').parseString;
                
                    const options = {
                        url: 'https://marantz-sr5015.fritz.box:10443/ajax/general/get_config?type=12',
                        agentOptions: {
                            strictSSL: false,
                            rejectUnauthorized: false
                        }
                    };
                
                    request.get(options, function (error, response, body) {
                        if (error) log(error, 'error'); // Print the error if one occurred
                        //log('statusCode:'+ response && response.statusCode, 'debug'); // Print the response status code if a response was received
                        //log(body, 'debug');
                        parseString(body, function(err, result) {
                            //log(result, 'info');
                            reso = result.Information.Video[0].HDMISignalInfo[0].Resolution[0];
                            hdr = result.Information.Video[0].HDMISignalInfo[0].HDR[0];
                            log('Current resolution: ' + reso, 'debug');
                            log('Current HDR status: ' + hdr, 'debug');
                            // HDR off: ' --- -> --- '
                            // HDR on: 'HDR10 -> HDR10'
                            if (hdr.includes("HDR")) {
                                switchHDR("true");
                            } else {
                                switchHDR("false");
                            }
                        });
                    });
                    // HDR on: http://mediapc.fritz.box:8090/json-rpc?request=%7B%22command%22:%22componentstate%22,%22componentstate%22:%7B%22component%22:%22HDR%22,%22state%22:true%7D%7D
                };
                
                function switchHDR(mode) {
                    if (mode !== hdr_state ) {
                        try {
                            require("request")('http://mediapc.fritz.box:8090/json-rpc?request=%7B%22command%22:%22componentstate%22,%22componentstate%22:%7B%22component%22:%22HDR%22,%22state%22:'+mode+'%7D%7D').on("error", function (e) {console.error(e);});
                            hdr_state = mode;
                            log("Switched HDR mode to:"+hdr_state, 'info');
                        } catch (e) { console.error(e); }
                    }
                };
                
                Thomas Braun 1 Reply Last reply Reply Quote 1
                • Thomas Braun
                  Thomas Braun Most Active @pandel last edited by

                  @pandel sagte in Javascript - Skripte mit setInterval laufen nicht neu an:

                  Holen:5 https://deb.nodesource.com/node_18.x bullseye InRelease [4.586 B]

                  Ist das alte, aufgegebene Repo. Die nodesource.list muss neuangelegt werden. Das macht aber ein

                  iob nodejs-update 18
                  

                  wenn man das entsprechend bestätigt.

                  P 1 Reply Last reply Reply Quote 0
                  • P
                    pandel @Thomas Braun last edited by

                    @thomas-braun
                    Oh Mann! Mache ich sofort! Wann hat sich das denn geändert? Das war doch schon seit Äonen so... Moment, ich kümmere mich...

                    Thomas Braun 1 Reply Last reply Reply Quote 0
                    • Thomas Braun
                      Thomas Braun Most Active @pandel last edited by

                      @pandel sagte in Javascript - Skripte mit setInterval laufen nicht neu an:

                      Das war doch schon seit Äonen so...

                      Und ungefähr auch seit 'Äonen' wurde das umgestellt...

                      P 1 Reply Last reply Reply Quote 0
                      • P
                        pandel @Thomas Braun last edited by

                        @thomas-braun
                        Na, das sieht man nur nicht auf den ersten Blick, wenn im Grunde alles läuft. Wenn ich ein normales Update von iobroker und System mache, gehe ich ja nicht erst ins Forum und schaue nach Hinweisen. Vielleicht bin ich dazu zu bequem, mag sein...

                        @all
                        Nichtsdestotrotz, ganz herzlichen Dank für die schnelle Hilfe. Ein kurzer Test mit einem Skript (stoppen, Zeitsteuerung ändern, wieder starten) hat gezeigt, dass es wieder funktioniert.

                        Danke danke!

                        Thomas Braun 1 Reply Last reply Reply Quote 0
                        • Thomas Braun
                          Thomas Braun Most Active @pandel last edited by

                          @pandel

                          Dafür wird ja auch die installierte und die aktuelle Version von nodejs im Admin angezeigt. Bei dauerhafter Abweichung zwischen den Versionen hat man ein Thema.

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

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          795
                          Online

                          31.7k
                          Users

                          79.8k
                          Topics

                          1.3m
                          Posts

                          5
                          14
                          483
                          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