Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Visualisierung
    4. [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable

    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

    [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable

    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Pistus @chka last edited by Pistus

      @chka Die Daten für Azimuth und Elevation kommen doch aus der Systemkonfiguration.

      Bei diesem Skript für den Sonnenstand gibt es keine Fehlermeldung und Warnungen.

      const suncalc = require('suncalc2');
      const result = getObject('system.config');
      const lat = result.common.latitude;
      const long = result.common.longitude;
       
      //const result = getObject("system.adapter.javascript.0");
      //const lat = result.native.latitude;
      //const long = result.native.longitude;
      const idEle = 'Sonnenstand.Elevation';
      const idAzi = 'Sonnenstand.Azimuth';
       
      createState(idEle, 0, {type: 'number', unit: '°'});
      createState(idAzi, 0, {type: 'number', unit: '°'});
       
      function Sonnenstand_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(idEle, Math.round(10 * h) / 10, true);
          //setState(idAzi, Math.round(a), true);
       
          setState(idAzi, Math.round(Math.round(10 * a) / 10), true);
      }
      schedule("* * * * *", Sonnenstand_berechnen);
      
      

      Hier wird aber im Skript der Typ number programmiert

      createState(idEle, 0, {type: 'number', unit: '°'});
      createState(idAzi, 0, {type: 'number', unit: '°'});
      
      
      C 1 Reply Last reply Reply Quote 0
      • C
        chka @Pistus last edited by

        @pistus dies script läuft bei mir seit jahren

        /* System Sonnenstand
        
        Sonne Azimut und Elevation in Variablen schreiben
        
        erstellt: 06.07.2015 nach ioBroker Forum http://forum.iobroker.net/viewtopic.php?f=21&t=975&sid=6f0ba055de5f82eed6809424f49ca93b#p7635
        */
        var suncalc = require('suncalc'),
            result = getObject("system.adapter.javascript.0"),
            lat = result.native.latitude,
            long = result.native.longitude;
        
        createState('Sonnenstand.Elevation', 0, {unit: '°'});
        createState('Sonnenstand.Azimut', 0, {unit: '°'});
        createState('Sonnenstand.X', 0, {unit: 'px'});
        createState('Sonnenstand.Y', 0, {unit: 'px'});
        createState('Sonnenstand.HTML');
        
        //Hier die Koordinaten einstellen
        var Xm = 500; //500
        var Ym = 250; // 250
        var rot = 90; // Winkel in dem Grundriss gegenüber Nord verdreht ist
        var r  = 250;
        
        
        function Sonnenstand_berechnen () {
            var now = new Date();
                
            //log("-----------------------------------------------");
           // log("latitude : " + result.native.latitude,'info');
           // log("longitude: " + result.native.longitude,'info');
        
            var sunpos = suncalc.getPosition(now, lat, long);
           // log("sunpos: " + sunpos,'info');
        
            var h = sunpos.altitude * 180 / Math.PI,
                 a = sunpos.azimuth * 180 / Math.PI + 180;
            /**
            Formel: https://www-user.tu-chemnitz.de/~heha/viewchm.php/hs/SelfDXD.chm/directxgraphics/theorie/dg_ber.html
            radWinkel:= 40 / 180 * Pi;            // radWinkel = 0.698131...
            x_koordinate:= cos( radWinkel ) * 5;  // x_koordinate = 3,830222...
            y_koordinate:= sin( radWinkel ) * 5;  // y_koordinate = 3,213938...
            **/
          
            var azimuth = a.toFixed();//sunpos.azimuth;
            var radWinkel =( azimuth -90 - rot )/ 180 * Math.PI; 
            
            var x = (Math.cos(radWinkel)* r)+Xm;
            
            var y = (Math.sin(radWinkel) * r)+Ym;
            
             
             
            setState("javascript.0.Sonnenstand.Elevation",h.toFixed(1));
            setState("javascript.0.Sonnenstand.Azimut",a.toFixed());
        
            setState("javascript.0.Sonnenstand.X",x.toFixed());
            setState("javascript.0.Sonnenstand.Y",y.toFixed());
            
          setState("javascript.0.Sonnenstand.HTML",'<img src="/vis/img/10_sun.png" height="50" width="50" style="float: left; margin: '+ y.toFixed() +'px 0px 0px '+x.toFixed()+'px;" >');
          
           // setState("javascript.0.Sonnenstand.HTML",'<img src="/vis/img/Weather-Sun-icon.png" height="50" width="50" vspace="'+ y.toFixed() +'" hspace="'+x.toFixed()+'">');
        }
        
        schedule("*/1 * * * *", Sonnenstand_berechnen);
        Sonnenstand_berechnen(); // bei Scriptstart
        

        mehr kann ich dazu nicht sagen

        P 1 Reply Last reply Reply Quote 0
        • P
          Pistus @chka last edited by

          @chka Deshalb habe ich ja versucht Dein Skript bei mir zu installieren.

          Ich muss passen, weil ich einfach nicht weiter komme.

          DJMarc75 1 Reply Last reply Reply Quote 0
          • DJMarc75
            DJMarc75 @Pistus last edited by

            @pistus sagte in [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable:

            Dein Skript bei mir zu installieren.

            Ein Skript wird nicht installiert sondern im JavaSkriptAdapter angelegt.

            Zusätzlich dann folgendes beachten:

            https://forum.iobroker.net/topic/5190/gelöst-x-y-koordinaten-eines-bildes-in-vis-abhängig-einer-ccu-variable/12

            P 1 Reply Last reply Reply Quote 0
            • P
              Pistus @DJMarc75 last edited by

              @djmarc75 Das Skript wurde im JavaSkriptAdapter angelegt.
              in Vis muss das Widget basic string genommen werden und und als QuellID javascript.0.Sonnenstand.HTML.
              Im Widget steht aber eine hm Id. Ich habe aber kein hm.

              C 1 Reply Last reply Reply Quote 0
              • C
                chka @Pistus last edited by

                @pistus dann ignoriere die id einfach was steht denn beid dir in der
                javascript.0.Sonnenstand.HTML

                <img src="/vis/img/10_sun.png" height="50" width="50" style="float: left; margin: 125px 0px 0px 717px;" >
                
                P 1 Reply Last reply Reply Quote 0
                • P
                  Pistus @chka last edited by Pistus

                  @chka

                  <img src="/vis-2.0/main/10_sun.png" height="100" width="100" style="float: left; margin: 156px 0px 0px 732px;">
                  

                  Edit: Die URL ist

                  http://192.168.178.64:8082/vis-2/?main#Sonnenstand
                  
                  C 1 Reply Last reply Reply Quote 0
                  • C
                    chka @Pistus last edited by

                    @pistus wenn der wert sich jetzt ändert dann passt das doch.
                    Dein Problem ist jetzt das es in vis2 nicht angezeigt wird?

                    P 1 Reply Last reply Reply Quote 0
                    • P
                      Pistus @chka last edited by

                      @chka Die Sonne wird angezeigt, ändert aber nicht Ihre Position. Dazu kommen die unzähligen Warnmeldungen in der Protokolldatei.

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

                        @pistus sagte in [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable:

                        die unzähligen Warnmeldungen in der Protokolldatei.

                        liegen an dem falschen Datentyp deines Datenpunktes.
                        Zeig doch bitte mal die Objektdaten davon.

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

                          @homoran o.png

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

                            @pistus

                            • Expertenmodus an
                            • dann rechts auf den dann erscheinenden Bleistift
                            • Reiter Objektdaten
                            • den Inhalt hier in code-tags posten.
                            P 1 Reply Last reply Reply Quote 0
                            • P
                              Pistus @Homoran last edited by

                              @homoran

                              {
                                "common": {
                                  "unit": "°",
                                  "name": "Sonnenstand.Azimut",
                                  "role": "state",
                                  "type": "mixed"
                                },
                                "native": {
                                  "unit": "°",
                                  "name": "Sonnenstand.Azimut",
                                  "role": "state",
                                  "type": "mixed"
                                },
                                "type": "state",
                                "from": "system.adapter.javascript.0",
                                "user": "system.user.admin",
                                "ts": 1713353051011,
                                "_id": "javascript.0.Sonnenstand.Azimut",
                                "acl": {
                                  "object": 1636,
                                  "state": 1636,
                                  "owner": "system.user.admin",
                                  "ownerGroup": "system.group.administrator"
                                }
                              }
                              
                              {
                                "common": {
                                  "type": "number",
                                  "unit": "°",
                                  "name": "Sonnenstand.Elevation",
                                  "role": "state"
                                },
                                "native": {
                                  "type": "number",
                                  "unit": "°",
                                  "name": "Sonnenstand.Elevation",
                                  "role": "state"
                                },
                                "type": "state",
                                "from": "system.adapter.javascript.0",
                                "user": "system.user.admin",
                                "ts": 1711981079388,
                                "_id": "javascript.0.Sonnenstand.Elevation",
                                "acl": {
                                  "object": 1636,
                                  "state": 1636,
                                  "owner": "system.user.admin",
                                  "ownerGroup": "system.group.administrator"
                                }
                              }
                              
                              {
                                "common": {
                                  "name": "Sonnenstand.HTML",
                                  "role": "state",
                                  "type": "mixed"
                                },
                                "native": {},
                                "type": "state",
                                "from": "system.adapter.javascript.0",
                                "user": "system.user.admin",
                                "ts": 1713353051014,
                                "_id": "javascript.0.Sonnenstand.HTML",
                                "acl": {
                                  "object": 1636,
                                  "state": 1636,
                                  "owner": "system.user.admin",
                                  "ownerGroup": "system.group.administrator"
                                }
                              }
                              
                              Homoran 1 Reply Last reply Reply Quote 0
                              • Homoran
                                Homoran Global Moderator Administrators @Pistus last edited by Homoran

                                @pistus Danke!
                                Azimut ist mixed, Elevation ist Number.
                                Und genau dort kommt doch die Meldung

                                @pistus sagte in [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable:

                                2024-04-17 16:11:00.043 - info: javascript.0 (19119) State value to set for "javascript.0.Sonnenstand.Elevation" has to be type "number" but received type "string

                                Das Script scheint da einen String hineinzuschreiben

                                @chka sagte in [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable:

                                setState("javascript.0.Sonnenstand.Elevation",h.toFixed(1));

                                ich kann kein Javascript, aber das dürfte einen String ergeben

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

                                  einfach alles auf mixed und gut so wird es normalerweise auch angelegt

                                  P 1 Reply Last reply Reply Quote 0
                                  • P
                                    Pistus @chka last edited by

                                    @chka Was muss ich im Skript ändern?

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

                                      @pistus sagte in [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable:

                                      @chka Was muss ich im Skript ändern?

                                      ich kann kein Javascript, aber eine Wandlung in Zahl, sollte helfen.

                                      Oder am anderen Ende angreifen und

                                      @chka sagte in [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable:

                                      einfach alles auf mixed und gut

                                      (wobei ich gar nicht weiss ob es mixed offiziell überhaupt noch gibt)

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

                                        @homoran Schau bitte mal hier
                                        link text

                                        C Homoran 2 Replies Last reply Reply Quote 0
                                        • C
                                          chka @Pistus last edited by

                                          @pistus änder doch bitte einfach das objet in den type mixed oder number
                                          Bildschirmfoto 2024-04-20 um 17.15.20.png

                                          M 1 Reply Last reply Reply Quote 1
                                          • Homoran
                                            Homoran Global Moderator Administrators @Pistus last edited by

                                            @pistus sagte in [gelöst] X/Y Koordinaten eines Bildes in VIS abhängig einer CCU Variable:

                                            @homoran Schau bitte mal hier
                                            link text

                                            sag ich doch

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            699
                                            Online

                                            31.9k
                                            Users

                                            80.2k
                                            Topics

                                            1.3m
                                            Posts

                                            13
                                            91
                                            9689
                                            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