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.
    • 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
                              • M
                                MartyBr @chka last edited by

                                @chka
                                Ich habe das Script komplett auf Zahlen (numbers) umgestellt. Vor dem Start bitte die alten Datenpunkte löschen, da sie nun neu als Typ Number angelegt werden.

                                //    setState("javascript.0.Sonnenstand.HTML",'<img src="/vis.0/icons/Images/sun.png" height="50" width="50" style="float: left; margin: '+ y.toFixed() +'px 0px 0px '+x.toFixed()+'px;" >');
                                //
                                /* System Sonnenstand
                                {1}
                                Sonne Azimut und Elevation in Variablen schreiben
                                {1}
                                erstellt: 06.07.2015 nach ioBroker Forum http://forum.iobroker.net/viewtopic.php?f=21&amp;t=975&amp;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, {type: 'number', unit: '°'});
                                createState('Sonnenstand.Azimut', 0, {type: 'number', unit: '°'});
                                createState('Sonnenstand.X', 0, {type: 'number', unit: 'px'});
                                createState('Sonnenstand.Y', 0, {type: 'number', 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",parseFloat(h.toFixed(1)),true);
                                    setState("javascript.0.Sonnenstand.Azimut",parseFloat(a.toFixed()),true);
                                 
                                    setState("javascript.0.Sonnenstand.X",parseFloat(x.toFixed()),true);
                                    setState("javascript.0.Sonnenstand.Y",parseFloat(y.toFixed()),true);
                                    
                                  // 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("* * * * *", Sonnenstand_berechnen);
                                Sonnenstand_berechnen(); // bei Scriptstart
                                
                                
                                C Homoran 2 Replies Last reply Reply Quote 2
                                • C
                                  chka @MartyBr last edited by

                                  @martybr jup type anpassen

                                  type type: 'number',
                                  

                                  bringt das gleiche ergebniss nur wie du geschrieben hast muss die datenpunkte gelöscht werden davor..

                                  M 1 Reply Last reply Reply Quote 0
                                  • M
                                    MartyBr @chka last edited by

                                    @chka Ich bekomme nur beim ersten Start des Skriptes Fehlermeldungen. Danach läuft es ohne Fehler durch und erzeugt fleißig die Datenpunkte.

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

                                      @martybr einmal ist keinmal ...

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

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

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

                                        jepp!
                                        wandeln in Zahl

                                        👍

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

                                          @homoran @MartyBr
                                          komplett auf Zahlen (numbers) umgestellt, hatte ich auch schon.

                                          Die Warnungen bleiben aber
                                          Z.B ist diese Codezeile vermutlich auch nicht korrekt.

                                          setState("javascript.0.Sonnenstand.Elevation",h.toFixed(1));
                                          
                                          Homoran M 2 Replies 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:

                                            B ist diese Codezeile vermutlich auch nicht korrekt.

                                            natürlich nicht!
                                            hast du nicht das komplette Skript von @MartyBr übernommen?

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

                                            Die Warnungen bleiben aber

                                            dann steht da auch drin um welchen State es geht

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            899
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

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