Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Gesucht: Script: Sonnenwinkel berechnen?

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    Gesucht: Script: Sonnenwinkel berechnen?

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

      @ice987 said in Gesucht: Script: Sonnenwinkel berechnen?:

      @cainam

      Die Frage hatte ich auch bereits: https://github.com/ioBroker/ioBroker.javascript/issues/800

      versuch mal so: https://forum.iobroker.net/topic/43018/gelöst-längen-und-breitengrade/13?_=1622041737554

      genau... das wars... jetzt geht es

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

        @cainam sagte:

        setState(Elevation,h.toFixed(1)); /*sonne_elevation*/ 
        setState(Azimut,a.toFixed());  /*sonne_azimut*/
        

        toFixed() erzeugt einen String. Ändere es in

        setState(Elevation, Math.round(h * 10) / 10, true; /*sonne_elevation*/ 
        setState(Azimut, Math.round(a), true);  /*sonne_azimut*/
        
        S 1 Reply Last reply Reply Quote 0
        • S
          stenmic @paul53 last edited by stenmic

          ich hab auch mal ein Blockly erstellt um die Sonnenkurve (Höhe) zu berechnen.
          Passt sehr gut mit meinem LUX–Sensor zusammen:)

          Leider sieht man damit auch gut wie schlecht das Wetter bei uns ist.

          36903FC0-EAA8-4D85-9CFA-B61601954F77.jpeg

          ich nutze diese Kurve um Level und Kelvin meiner HUE Lampen zu steuern.

          6871C072-1789-4D72-829D-C80F9E4A7465.jpeg

          1 Reply Last reply Reply Quote 0
          • T. C. 0
            T. C. 0 @derAuge last edited by

            @derauge said in Gesucht: Script: Sonnenwinkel berechnen?:

            wollte hier mal meine Lösung des heutigen Tages zeigen:

            es gibt dort zwei (etwas) unterschiedliche Scripte

            1.)

            /*
            Sonnenstand.SonneHöhe
            */
            var suncalc = require('suncalc');
            var result = getObject("system.adapter.javascript.0");
            var lat = result.native.latitude;
            var long = result.native.longitude;
            
                createState('Sonnenstand.Sonne:Höhe', 0, {unit: '°'});
                createState('Sonnenstand.Sonne:Azimut', 0, {unit: '°'});
            
                schedule("*/1 * * * *", function () {
                    var now = new Date();
            //        log("-----------------------------------------------");
            //        log("latitude : " + result.native.latitude,'warn');
            //        log("longitude: " + result.native.longitude,'warn');
            
                    var sunpos = suncalc.getPosition(now, lat, long);
            
            //        log("sunpos: " + JSON.stringify(sunpos),'warn');
            
                    var h = sunpos.altitude * 180 / Math.PI;
                    var a = sunpos.azimuth * 180 / Math.PI + 180;
            
                    setState("javascript.0.Sonnenstand.Sonne:Höhe",h.toFixed(1));
                    setState("javascript.0.Sonnenstand.Sonne:Azimut",a.toFixed());
            
                });
            
            

            Gruß

            Jürgen

            Hallo, ich hab das Skript 1 bei mir verwendet. Es werden auch Variablen erstellt die ich auslesen kann. Allerdings steht bei mir bei Azimut = 28° zur jetzigen Zeit müsste es laut Sunearthtools.com aber 184° sein. Kann mir jemand sagen warum das nicht so ist ?

            Gruß
            Thiemo

            paul53 1 Reply Last reply Reply Quote 0
            • paul53
              paul53 @T. C. 0 last edited by

              @t-c-0
              Stimmen die Ortskoordinaten? Hänge mal an das Skriptende eine Log-Ausgabe dran:

              log('Lat: ' + lat + ' °, Long: ' + long + ' °');
              
              T. C. 0 1 Reply Last reply Reply Quote 0
              • T. C. 0
                T. C. 0 @paul53 last edited by

                @paul53 said in Gesucht: Script: Sonnenwinkel berechnen?:

                log('Lat: ' + lat + ' °, Long: ' + long + ' °');

                Hallo Paul, heraus kommt:

                2021-07-04 14:02:13.669 - info: javascript.0 (2557) Start javascript script.js.common.Steuerung.Astroskript
                2021-07-04 14:02:13.677 - info: javascript.0 (2557) script.js.common.Steuerung.Astroskript: registered 0 subscriptions and 1 schedule
                2021-07-04 14:03:00.004 - info: javascript.0 (2557) script.js.common.Steuerung.Astroskript: Lat: °, Long: °

                Wo kann man die Koordinaten angeben ? Wenn ich in den Instanzen von javascript schaue, ist zumindest meine Adresse angezeigt.

                Gruß
                Thiemo

                paul53 1 Reply Last reply Reply Quote 0
                • paul53
                  paul53 @T. C. 0 last edited by paul53

                  @t-c-0 sagte: ist zumindest meine Adresse angezeigt.

                  Dann verwende die Daten aus der System-Konfiguration (Ersatz für Zeilen 5 bis 7):

                  const config = getObject('system.config');
                  const lat = config.common.latitude;
                  const long = config.common.longitude;
                  
                  T. C. 0 1 Reply Last reply Reply Quote 1
                  • T. C. 0
                    T. C. 0 @paul53 last edited by

                    @paul53

                    Hallo! es scheint nun mehr zu stimmen, wobei mir auf der oben genannten Seite 265° angezeigt wird.
                    Aus IOBroker nun 254°

                    Dennoch besser als vorher 🙂

                    Danke

                    T. C. 0 1 Reply Last reply Reply Quote 0
                    • T. C. 0
                      T. C. 0 @T. C. 0 last edited by

                      @t-c-0

                      Alles klar, beim aktualisieren hat sich die GMT verstellt. Also stimmen die Werte nun überein, danke!

                      1 Reply Last reply Reply Quote 0
                      • K
                        klassisch Most Active @Homoran last edited by klassisch

                        @homoran sagte in Gesucht: Script: Sonnenwinkel berechnen?:

                        habe ich in die Skriptsammlung eingefügt:

                        http://www.iobroker.net/docu/?page_id=57&lang=de

                        ERROR
                        Cannot GET /docu/
                        

                        Umgezogen?

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

                          @klassisch sagte in Gesucht: Script: Sonnenwinkel berechnen?:

                          Umgezogen?

                          nicht wirlich! seit 2018/2020 offline und noch kein neues Zuhause

                          1 Reply Last reply Reply Quote 0
                          • bahnuhr
                            bahnuhr Forum Testing Most Active last edited by

                            anbei mal ein Script von ursprünglich pix; was ich dann erweitert habe mit den Monddaten:

                            
                            // Sonnenstand Script von pix
                            // erweitert mit Moon durch bahnuhr
                            
                            const suncalc = require('suncalc');
                            const result = getObject("system.adapter.javascript.0");
                            const lat = result.native.latitude;
                            const long = result.native.longitude;
                            const idSonneEle = 'javascript.0.System.Sonne_Mond.Sonne_Elevation';
                            const idSonneAzi = 'javascript.0.System.Sonne_Mond.Sonne_Azimut';
                            const idMondEle = 'javascript.0.System.Sonne_Mond.Mond_Elevation';
                            const idMondAzi = 'javascript.0.System.Sonne_Mond.Mond_Azimut';
                             
                            createState(idSonneEle, 0, {type: 'number', unit: '°'});
                            createState(idSonneAzi, 0, {type: 'number', unit: '°'});
                            createState(idMondEle, 0, {type: 'number', unit: '°'});
                            createState(idMondAzi, 0, {type: 'number', unit: '°'});
                            
                            function Stand_berechnen () {
                                var now = new Date();
                                var sunpos = suncalc.getPosition(now, lat, long);
                                var h = sunpos.altitude * 180 / Math.PI;
                                var a = sunpos.azimuth * 180 / Math.PI + 180;
                                setState(idSonneEle, Math.round(10 * h) / 10, true);
                                setState(idSonneAzi, Math.round(Math.round(10 * a) / 10), true);
                             
                                var moonpos = suncalc.getMoonPosition(now, lat, long);
                                var h = moonpos.altitude * 180 / Math.PI;
                                var a = moonpos.azimuth * 180 / Math.PI + 180;
                                setState(idMondEle, Math.round(10 * h) / 10, true);
                                setState(idMondAzi, Math.round(Math.round(10 * a) / 10), true);
                             
                                log ("Sonne: Azimut: " + getState(idSonneAzi).val + "° / Sonne: Elevation: " + getState(idSonneEle).val + "° / Mond: Azimut: " + getState(idMondAzi).val + "° / Mond: Elevation: " + getState(idMondEle).val + "°");
                            }
                             
                            schedule('23 */4 * * * *', Stand_berechnen); // jede 4. Minute
                            
                            

                            Für alle die es gebrauchen wollen.

                            1 Reply Last reply Reply Quote 2
                            • bahnuhr
                              bahnuhr Forum Testing Most Active last edited by

                              und in vis dann so:

                              881a46f8-d7bf-4754-a009-e45b85c6a0eb-image.png

                              K 1 Reply Last reply Reply Quote 1
                              • K
                                klassisch Most Active @bahnuhr last edited by

                                @bahnuhr cool, Vielen Dank!

                                bahnuhr 1 Reply Last reply Reply Quote 1
                                • bahnuhr
                                  bahnuhr Forum Testing Most Active @klassisch last edited by

                                  @klassisch sagte in Gesucht: Script: Sonnenwinkel berechnen?:

                                  @bahnuhr cool, Vielen Dank!

                                  wenn du was brauchst, sag Bescheid.

                                  cash K 2 Replies Last reply Reply Quote 0
                                  • cash
                                    cash Most Active @bahnuhr last edited by

                                    @bahnuhr wofür kann man den denn stand des mondes gebrauchen? Den Sonnenstand für Licht oder Rollos ist soweit klar aber Mond? Kann ich daraus noch etwas schließen oder ist es nur für die Visualisierung?

                                    bahnuhr 1 Reply Last reply Reply Quote 0
                                    • K
                                      klassisch Most Active @bahnuhr last edited by

                                      @bahnuhr sagte in Gesucht: Script: Sonnenwinkel berechnen?:

                                      @klassisch sagte in Gesucht: Script: Sonnenwinkel berechnen?:
                                      wenn du was brauchst, sag Bescheid.

                                      Vielen Dank, scheint zu laufen. Ich vergleche mal mit https://www.sonnenverlauf.de/

                                      1 Reply Last reply Reply Quote 0
                                      • bahnuhr
                                        bahnuhr Forum Testing Most Active @cash last edited by

                                        @cash sagte in Gesucht: Script: Sonnenwinkel berechnen?:

                                        wofür kann man den denn stand des mondes gebrauchen?

                                        Damit ich immer weiß in welche Richtung in schauen muss 😉

                                        O 1 Reply Last reply Reply Quote 0
                                        • O
                                          oFbEQnpoLKKl6mbY5e13 @bahnuhr last edited by

                                          @bahnuhr

                                          Woher bekommst du denn die anderen Informationen wie Sonnenaufgang usw.?

                                          bahnuhr K 2 Replies Last reply Reply Quote 0
                                          • bahnuhr
                                            bahnuhr Forum Testing Most Active @oFbEQnpoLKKl6mbY5e13 last edited by

                                            @ofbeqnpolkkl6mby5e13 sagte in Gesucht: Script: Sonnenwinkel berechnen?:

                                            @bahnuhr

                                            Woher bekommst du denn die anderen Informationen wie Sonnenaufgang usw.?

                                            Adapter: dasWetter

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            681
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

                                            27
                                            101
                                            22301
                                            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