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.
    • A
      Ace-k last edited by

      ok, ich verstehe leider nur das ich die Moon Illumination brauche.

      Aber wie ich das eintrage ins Script.. keine Ahnung.

      Hab leider nicht wirklich erfahrung damit. 😐

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

        Vorschlag:

        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 Minuten
        
        1 Reply Last reply Reply Quote 0
        • A
          Ace-k last edited by

          Vielen Dank .

          Es scheint zu klappen …. versuche das mal nachzuvollziehen Und werde mich morgen mal dran setzen , wie ich die vis Darstellung mit Bildern mache [emoji41][emoji106][emoji106][emoji106]

          1 Reply Last reply Reply Quote 0
          • A
            Ace-k last edited by

            funktioniert super. und gelöst habe ich das mit dem Widget Image 8.

            für jede Phase ein Bild erstellt und dann eingestellt.

            gibt es evtl eine % anzeige!? also ein script was den Mond in % Anzeigt!?

            1 Reply Last reply Reply Quote 0
            • C
              cbs last edited by

              Im oben genannten Script hast du an der Stelle

              var mond = suncalc.getMoonIllumination(new Date());
              

              in mond.phase die aktuelle Mondphase in Dezimalzahlen zwischen 0.0 und 1.0 stehen, wobei 0 Neumond und 0.5 Vollmond ist. Wenn du dahingegen den aktuellen Prozentwert der beleuchteten Mondfläche (egal ob abnehmend oder zunehmend) suchst, kannst du dir diesen aus mond.fraction auslesen. Hier ist dann 0.0 Neumond, 0.5 Halbmond und 1.0 Vollmond. (siehe Doku unter https://www.npmjs.com/package/suncalc#moon-illumination)

              1 Reply Last reply Reply Quote 0
              • C
                chriwo last edited by

                Ich habe noch eine Frage dazu. Kann ich auch irgendwie das Datum des nächsten Vollmondes berechnen und ausgeben lassen?

                Danke 🙂

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

                  Das ist ein perfektes Script und auch eine Klasse Idee.

                  Gibt es für die Mondphasen auch irgendwo ein Iconset? Das wäre noch perfekt.

                  1 Reply Last reply Reply Quote 0
                  • L
                    Linedancer last edited by

                    Die Icons stecken im icons-mfd-png Adapter.

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

                      Danke.

                      Die habe ich gefunden.

                      Schade das scheinbar keine weiteren Iconsets existieren. Muss ich mir wohl selber was basteln

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

                        Ok, schnell mal selber zurechtgeschnibbelt. Falls die jemand brauchen sollte.

                        Die anderen gefallen mir nicht so sehr.
                        5779_voll4.png
                        5779_viertelab7.png
                        5779_halbab6.png
                        5779_dreiviertelab5.png
                        5779_dreiviertelzu3.png
                        5779_halbzu2.png
                        5779_viertelzu1.png
                        5779_neumond0.png

                        1 Reply Last reply Reply Quote 0
                        • Dutchman
                          Dutchman Developer Most Active Administrators last edited by

                          Selber Ausscheiden 😛

                          ~~![](</s><URL url=)<link_text text="https://uploads.tapatalk-cdn.com/201809 ... 5ddbd0.jpg">https://uploads.tapatalk-cdn.com/20180930/a91f2a644e35db5f47a5b1f55a5ddbd0.jpg</link_text>" />

                          Sent from my iPhone using Tapatalk~~

                          1 Reply Last reply Reply Quote 0
                          • C
                            chriwo last edited by

                            Eine Frage zum Skript: Bei mir zeigt er in der VIS beim Einfügen der Variable Vis.Mondphase statt der Mondphase nur die Zahl an. Kann ich irgendwie einstellen, dass hier der Text angezeigt wird?

                            1 Reply Last reply Reply Quote 0
                            • A
                              Annuit20 last edited by

                              Hallo,

                              ich nutze die images aus dem VClouds Weahter 2: https://www.deviantart.com/vclouds/art/ … -179058977
                              1662_moonimages.zip
                              1662_3.png

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

                                So siehts bei uns aus…

                                4229_moon.jpg

                                1 Reply Last reply Reply Quote 0
                                • 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
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            734
                                            Online

                                            31.7k
                                            Users

                                            79.6k
                                            Topics

                                            1.3m
                                            Posts

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