Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Suche Skript für Mondphase

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Suche Skript für Mondphase

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

      und wie hast Du Dein Script und die VIS aufgebaut? 🙂

      1 Reply Last reply Reply Quote 0
      • Negalein
        Negalein Global Moderator last edited by

        Hallo

        Habe dank Sigi soeben diesen Thread entdeckt.

        Dazu hätt ich als Anfänger gleich mal eine Frage.

        Muss ich die Mondbilder in einen bestimmten Ordner geben, damit das Script darauf zugreifen kann?

        Danke

        1 Reply Last reply Reply Quote 0
        • Negalein
          Negalein Global Moderator last edited by

          Bins nochmal!

          Ich hab dieses Script als JS erstellt.

          [/const suncalc = require('suncalc');
          const idVis = 'Vis.Mondphase'; // Für Vis
          
          createState(idVis, 0, {
          type: 'number',
          min: 0,
          max: 7,
          role: 'level',
          states: {
          0: 'Neumond',
          1: 'Viertelmond zu',
          2: 'Halbmond zu',
          3: 'Dreiviertelmond zu',
          4: 'Vollmond',
          5: 'Dreiviertelmond ab',
          6: 'Halbmond ab',
          7: 'Viertelmond ab'
          } 
          });
          
          function mpVis() {
          var mond = suncalc.getMoonIllumination(new Date());
          var mp = mond.phase;
          var state = 0; 
          if(mp > 0.05) state = 1;
          if(mp > 0.2) state = 2;
          if(mp > 0.3) state = 3;
          if(mp > 0.45) state = 4;
          if(mp > 0.55) state = 5;
          if(mp > 0.7) state = 6;
          if(mp > 0.8) state = 7;
          if(mp > 0.95) state = 0;
          setState(idVis, state, true);
          }
          
          mpVis(); // Skriptstart
          
          schedule("*/10 * * * *", mpVis); // alle 10 Minutenspoiler]
          

          Wenn ich es starte, kommt folgende Fehlermeldung und ich seh nichts in den Objekten unter Javascript.0

          21:38:16.315	[info]	javascript.0 Start javascript script.js.common.Mondphasen
          21:38:16.315	[error]	javascript.0 script.js.common.Mondphasen compile failed: at script.js.common.Mondphasen:1
          

          Kenn mich als Anfänger noch nicht so mit JS & Co. aus.

          Danke

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

            Am Skriptanfang sind zwei störende Zeichen: [/

            Richtig:

            const suncalc = require('suncalc');
            
            1 Reply Last reply Reply Quote 0
            • Chaot
              Chaot last edited by

              Was sollen die beiden Zeichen am Anfang vom Script:

              `[/[/code]`
              
              Edit - Ok Paul ist eindeutig schneller  :D
              
              1 Reply Last reply Reply Quote 0
              • Negalein
                Negalein Global Moderator last edited by

                @paul53:

                Am Skriptanfang sind zwei störende Zeichen: [/

                Richtig:

                const suncalc = require('suncalc');
                ```` `  
                

                Danke, das wars!

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

                  @Annuit20:

                  Hallo,

                  ich nutze die images aus dem VClouds Weahter 2: https://www.deviantart.com/vclouds/art/ … -179058977 `

                  Hi,

                  sehr schöne Grafiken.

                  Leider sind nur 8 Bilder enthalten.

                  Hat jemand ähnliche Bilder für alle Mondphasen?

                  EDIT: Habe mir aus folgender Vorlage selber welche gebastelt.

                  ! 9039_alle_mondphasen.jpg

                  9039_mond_neu.zip

                  B spicer 2 Replies Last reply Reply Quote 0
                  • B
                    bitstorm66 @StM47 last edited by

                    @stm47

                    Ich habe mich an dem Script für die Mondphase versucht. Das ging auch ganz gut und ich habe es erweitert auf 28 Varianten.

                    Soweit so gut, ich habe nun das Script einem image8 Widget angehängt, aber wie krieg ich die Daten nun an das Widget. Die 28 Icons sind angehängt im Widget aber es verändert sich nichts.

                    Da ich ganz neuer iobroker User bin ist das ganze noch ein wenig Neuland und ich brauch einen Moment bis ich die Logik verstehe.

                    1. Habe ich das Script am richtigen Ort?
                    2. Wie krieg ich die Daten ins Widget?
                    3. Was muss in die Object ID des Widgets

                    Danke zum Voraus

                    spicer 1 Reply Last reply Reply Quote 0
                    • spicer
                      spicer @StM47 last edited by spicer

                      @stm47
                      Schöne Mondbilder. Aber hättest den Vollmond auch noch?
                      Das hier ist ein Blutmond (bei einer Mondfinsternis).

                      Edit:
                      Hab einen kreiert ^^
                      FullMoon2.png

                      spicer 1 Reply Last reply Reply Quote 0
                      • spicer
                        spicer @spicer last edited by spicer

                        @spicer
                        Habe noch ein paar Mondphasen hinzugefügt.

                        const suncalc = require('suncalc');
                        const idVis = 'Vis.Mondphase';  // Für Vis
                         
                        
                        createState(idVis, 0, {
                           type: 'number',
                           min: 0,
                           max: 15,
                           role: 'level',
                           states: {
                              0: 'Neumond',
                              1: 'Achtelmond zu',
                              2: 'Viertelmond zu',
                              3: 'DreiAchtelmond zu',
                              4: 'Halbmond zu',
                              5: 'FunfAchtelmond zu',
                              6: 'Dreiviertelmond zu',
                              7: 'SiebenAchtelmond zu',
                              8: 'Vollmond',
                              9: 'SiebenAchtelmond ab',
                              10: 'Dreiviertelmond ab',
                              11: 'FunfAchtelmond ab',
                              12: 'Halbmond ab',
                              13: 'DreiAchtelmond ab',
                              14: 'Viertelmond ab',
                              15: 'Achtelmond ab'
                           }   
                        });
                         
                        
                        function mpVis() {
                           var mond = suncalc.getMoonIllumination(new Date());
                           var mp = mond.phase;
                           var state = 0; 
                           if(mp > 0.04) state = 1;
                           if(mp > 0.10) state = 2;
                           if(mp > 0.20) state = 3;
                           if(mp > 0.25) state = 4;
                           if(mp > 0.30) state = 5;
                           if(mp > 0.38) state = 6;
                           if(mp > 0.43) state = 7;
                           if(mp > 0.49) state = 8;
                           if(mp > 0.55) state = 9;
                           if(mp > 0.62) state = 10;
                           if(mp > 0.70) state = 11;
                           if(mp > 0.75) state = 12;
                           if(mp > 0.80) state = 13;
                           if(mp > 0.86) state = 14;
                           if(mp > 0.92) state = 15;
                           if(mp > 0.97) state = 0;
                           setState(idVis, state, true);
                        }
                         
                        
                        mpVis(); // Skriptstart
                         
                        
                        schedule("*/10 * * * *", mpVis);  // alle 10 Minuten
                        
                        

                        Und die Mond-Icons etwas aufgeräumt.
                        mond_icons.zip

                        1 Reply Last reply Reply Quote 0
                        • spicer
                          spicer @bitstorm66 last edited by spicer

                          @bitstorm66
                          Etwas spät.
                          Du musst den Datenpunkt Vis.Mondphase löschen, damit dieser neu geschrieben wird.

                          1. Im root oder eigenen Verzeichnis bei den Skripten
                          2. Die werden über den Datenpunkt (Object ID) übergeben
                          3. javascript.0.Vis.Mondphase
                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          932
                          Online

                          31.6k
                          Users

                          79.6k
                          Topics

                          1.3m
                          Posts

                          14
                          31
                          7984
                          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