Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Adresse aus GPS Koordinaten ermitteln ?

    NEWS

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    • Neues Video über Aliase, virtuelle Geräte und Kategorien

    • Wir empfehlen: Node.js 22.x

    Adresse aus GPS Koordinaten ermitteln ?

    This topic has been deleted. Only users with topic management privileges can see it.
    • bahnuhr
      bahnuhr Forum Testing Most Active @Razer2412 last edited by

      @razer2412
      Suche benutzen, da gibt es gefühlt 100er Beiträge.

      Stichwort wie im log: httpGet

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

        @razer2412 sagte in Adresse aus GPS Koordinaten ermitteln ?:

        Ich würde mich ebenfalls über eine Lösung freuen - Danke!

        und die helfenden würden sich über dein Skript freuen.
        Oder eine stärkere Glaskugel

        1 Reply Last reply Reply Quote 0
        • Codierknecht
          Codierknecht Developer Most Active @Razer2412 last edited by

          @razer2412

          Da wurde hier schon X mal besprochen.

          Falls die Forensuche zu viel Aufwand bedeutet: Ich habe da mal was vorbereitet ...
          https://forum.iobroker.net/search?term=request httpget&in=titlesposts&matchWords=all&sortBy=timestamp&sortDirection=desc&showAs=posts

          M 1 Reply Last reply Reply Quote 1
          • M
            Micha 3 @Codierknecht last edited by Micha 3

            Geht trotzdem nicht.

            Beim ersten

            	2025-09-13 19:19:24.405	warn	script.js.common.GPS: request package is deprecated - please use httpGet (or a stable lib like axios) instead!
            

            Wenn wir schon dabei sind, beim Warmwasser sogar die Meldung.

            	2025-09-13 19:16:21.923	error	script.js.Zentrale.Warmwassersteuerung: httpGet(url=http://192.168.178.136/cm?cmnd=counter1%200, error=timeout of 1500ms exceeded)
            

            das blockly-skript

            <xml xmlns="https://developers.google.com/blockly/xml">
              <variables>
                <variable type="timeout" id="timeout">timeout</variable>
                <variable id="t{9+flX*7=dsZdJ6pUDs">Position</variable>
                <variable id="InM51wH+hhRZ1K}Uo6R:">result</variable>
              </variables>
              <block type="http_get" id="m-)iMJC?nyP-2Z{jK*{S" x="338" y="502">
                <field name="TIMEOUT">2000</field>
                <field name="UNIT">ms</field>
                <field name="TYPE">arraybuffer</field>
                <value name="URL">
                  <shadow type="text" id="mtY5?0cuLz,.0t!EWqIB">
                    <field name="TEXT">http://</field>
                  </shadow>
                  <block type="text_join" id="%AIgcwHNe/@sw*U01y$j">
                    <mutation items="2"></mutation>
                    <value name="ADD0">
                      <block type="text" id="w`-_6V`Q}otb@4S:2plf">
                        <field name="TEXT">https://dataservice.accuweather.com/locations/v1/cities/geoposition/search?apikey=xxxxxxxxxxxxx=</field>
                      </block>
                    </value>
                    <value name="ADD1">
                      <block type="get_value" id="SKOaXNue28T!,3USSm[}">
                        <field name="ATTR">val</field>
                        <field name="OID">0_userdata.0.GPS.accuweather_GPS</field>
                      </block>
                    </value>
                  </block>
                </value>
                <statement name="STATEMENT">
                  <block type="variables_set" id="B.8O%)EDl50Pxp@#{+%.">
                    <field name="VAR" id="t{9+flX*7=dsZdJ6pUDs">Position</field>
                    <value name="VALUE">
                      <block type="text_getSubstring" id="owiE8!SuQ*Q%@^B#G8=2">
                        <mutation at1="true" at2="true"></mutation>
                        <field name="WHERE1">FROM_START</field>
                        <field name="WHERE2">FROM_START</field>
                        <value name="STRING">
                          <block type="variables_get" id="e4z]G)3d#LQfW2QN0ZM!">
                            <field name="VAR" id="InM51wH+hhRZ1K}Uo6R:">result</field>
                          </block>
                        </value>
                        <value name="AT1">
                          <block type="math_number" id="/`f+By;MjuAQu~YW(O(4">
                            <field name="NUM">21</field>
                          </block>
                        </value>
                        <value name="AT2">
                          <block type="math_number" id="6!?5#)73q+T{zE_B].7O">
                            <field name="NUM">27</field>
                          </block>
                        </value>
                      </block>
                    </value>
                    <next>
                      <block type="update" id="{b$:l~qpE|8N{)e*U6~I">
                        <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                        <field name="OID">0_userdata.0.GPS.accuweather_Position</field>
                        <field name="WITH_DELAY">FALSE</field>
                        <value name="VALUE">
                          <block type="convert_tonumber" id="QWY0%hWvBuBR#=3oK=L*">
                            <value name="VALUE">
                              <block type="variables_get" id="AMy:l(Q?52+HV;3@1K@N">
                                <field name="VAR" id="t{9+flX*7=dsZdJ6pUDs">Position</field>
                              </block>
                            </value>
                          </block>
                        </value>
                      </block>
                    </next>
                  </block>
                </statement>
              </block>
              <block type="on" id="Oa.K#_8v*gk[2_8:{/hf" x="338" y="738">
                <field name="OID">hm-rpc.2.00021BE99E2EFA.3.STATE</field>
                <field name="CONDITION">false</field>
                <field name="ACK_CONDITION"></field>
                <statement name="STATEMENT">
                  <block type="timeouts_settimeout" id="OVb_d2mk9).9s77}ZxLm">
                    <field name="NAME">timeout</field>
                    <field name="DELAY">2000</field>
                    <field name="UNIT">ms</field>
                    <statement name="STATEMENT">
                      <block type="http_get" id="n$[MBQ:|r$H4L_Fm0-9u">
                        <field name="TIMEOUT">1500</field>
                        <field name="UNIT">ms</field>
                        <field name="TYPE">arraybuffer</field>
                        <value name="URL">
                          <shadow type="text" id="jy.JTwBxm9C)KyeVI`--">
                            <field name="TEXT">http://192.168.178.136/cm?cmnd=counter1%200</field>
                          </shadow>
                        </value>
                      </block>
                    </statement>
                  </block>
                </statement>
              </block>
            </xml>
            
            Homoran 1 Reply Last reply Reply Quote 0
            • Homoran
              Homoran Global Moderator Administrators @Micha 3 last edited by

              @micha-3 bitte das Blockly zeigen!
              https://forum.iobroker.net/topic/51555/hinweise-für-gute-forenbeiträge/1

              @micha-3 sagte in Adresse aus GPS Koordinaten ermitteln ?:

              <variable id="InM51wH+hhRZ1K}Uo6R:">result</variable>
              

              und

              @micha-3 sagte in Adresse aus GPS Koordinaten ermitteln ?:

              TYPE">arraybuffer

              sieht für mich nicht korrekt aus

              1 Reply Last reply Reply Quote 0
              • M
                Micha 3 last edited by Micha 3

                Geht mit "text" aber auch nicht.

                EDIT/ Jetzt hab ich den Fehler. Aber wie beheb ich das? ich kann kein JS, das ist alles nur zusammen kopiert.

                var request =require('request');
                let result;
                const options = {
                    url: 'https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon + '&zoom=18',
                    method: 'GET',
                    headers: {
                        'Accept': 'application/json',
                        'Accept-Charset': 'utf-8',
                        'User-Agent': 'iobroker script'
                    }
                }
                
                request(options, function(err,response,body){
                    result = JSON.parse(body);
                })
                await wait(1000);
                return result;
                
                1 Reply Last reply Reply Quote 0
                • bahnuhr
                  bahnuhr Forum Testing Most Active last edited by bahnuhr

                  Hab das ganze mal schnell mit "httpget" umgesetzt, anbei:

                      var lat = "51.4";
                      var lon = "9.5";
                  httpGet('https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon + '&zoom=18', { timeout: 1000 }, (error, response) => {
                      if (!error) {
                          //console.log(response.statusCode);
                          //console.log(response.data);
                          var result = JSON.parse(response.data);
                          //log (result.display_name);        
                          log (result.address.road + " " + result.address.house_number); 
                          log (result.address.postcode + " " + result.address.municipality); 
                      } else {
                          console.error(error);
                      }
                  });
                  
                  M 1 Reply Last reply Reply Quote 0
                  • R
                    Razer2412 last edited by

                    Hallo zusammen,

                    vielen Dank für die schnellen Rückmeldungen.

                    @Homoran Ich habe das Script von @David-G verwendet.

                    @bahnuhr und @Codierknecht
                    natürlich habe ich versucht das ganze mithilfe der Suche und anderen Hilfsmitteln (ChatGPT) selbst zu lösen. Leider ohne Erfolg.

                    Mein bisheriges Script:

                    var lat, lon, result, hausnummer, strasse, plz, ort, ort2, kreis, bundesland, land, stadt, stadtteil;
                    
                    // Beschreibe diese Funktion …
                    async function OSM(lat, lon) {
                        var request =require('request');
                        let result;
                        const options = {
                           url: 'https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon + '&zoom=18',
                           method: 'GET',
                           headers: {
                               'Accept': 'application/json',
                               'Accept-Charset': 'utf-8',
                               'User-Agent': 'iobroker script'
                           }
                        }
                         
                        request(options, function(err,response,body){
                           result = JSON.parse(body);
                        })
                        await wait(1000);
                        return result;
                    }
                    
                    
                    schedule("* * * * *", async () => {
                      lat = getState('vw-connect.0.xyz.parkingposition.lat').val;
                      lon = getState('vw-connect.0.xyz.parkingposition.lon').val;
                      result = await OSM(lat, lon);
                      hausnummer = '';
                      strasse = '';
                      plz = '';
                      ort = '';
                      ort2 = '';
                      kreis = '';
                      bundesland = '';
                      land = '';
                      hausnummer = getAttr(result, 'address.house_number');
                      strasse = getAttr(result, 'address.road');
                      plz = getAttr(result, 'address.postcode');
                      stadt = getAttr(result, 'address.town');
                      stadtteil = getAttr(result, 'address.village');
                      kreis = getAttr(result, 'address.county');
                      bundesland = getAttr(result, 'address.state');
                      land = getAttr(result, 'address.country');
                      setState('0_userdata.0.Helfer.Position_Auto' /* Position Auto */, ([strasse ? strasse : null,hausnummer ? [' ',hausnummer,''].join('') : null,strasse ? ', ' : null,plz ? String(plz) + ' ' : null,stadt ? String(stadt) + '' : null,stadtteil ? [' (',stadtteil,')'].join('') : null,kreis ? ', ' + String(kreis) : null,bundesland ? ', ' + String(bundesland) : null,land ? ', ' + String(land) : null,!land ? 'Keine Adressen verfügbar.' : null].join('')), true);
                    });
                    
                    

                    Über weitere Tipps/Hilfe würde ich mich sehr freuen!

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

                      @razer2412
                      Warum nimmst du nicht das Script was ich 1 Beitrag vor deinem gesendet habe ?
                      Funktioniert einwandfrei.
                      Und benutzt httpget.

                      Komisch.
                      Warum stell ich hier was ein ?

                      1 Reply Last reply Reply Quote 0
                      • Codierknecht
                        Codierknecht Developer Most Active @Razer2412 last edited by

                        @razer2412

                        Ich hätte da auch noch 'ne Variante.
                        Benötigt allerdings einen (kostenlosen) API-Key:

                        async function getAddress(latitude, longitude) {
                            const url = `https://geocode.maps.co/reverse?lat=${latitude}&lon=${longitude}&api_key=${key}`;
                            httpGet(url, {timeout: 20000}, function(err, response) {
                                if (err) {
                                    console.log(err);
                                } else if (response.statusCode == 200) {
                                    return response.data.display_name;
                                };
                            });
                        }
                        

                        Im Übrigen finde ich das bisherige Script reichlich spooky.
                        Warum wird da jede Minute die Position bestimmt, wenn das Auto geparkt ist?
                        Die wird sich wohl kaum verändern. Es sei denn, jemand schraubt am Raum-Zeit-Kontinuum.
                        Das Auto wird doch mit ziemlicher Sicherheit den Status (fährt, steht, geparkt, lädt) übermitteln. Dann muss man die Position doch nur bei Statusänderungen ermitteln.

                        @bahnuhr Ist doch viel einfacher, wenn einem jemand das mundgerecht zurechtlegt 😀

                        Ne, im Ernst:
                        @Razer2412 Wir leisten hier "Hilfe zur Selbsthilfe". Da Eine oder Andere muss man sich dann schon noch selbst zurechfummeln. Das übt 😁

                        1 Reply Last reply Reply Quote 1
                        • M
                          Micha 3 @bahnuhr last edited by

                          @bahnuhr sagte in Adresse aus GPS Koordinaten ermitteln ?:

                                                                                                                                                          var lat = "51.4";                                                                                                                                                                                var lon = "9.5";                                                                                                                                                                            httpGet('https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon + '&zoom=18', { timeout: 1000 }, (error, response) => {                                                                                                                                                                                if (!error) {                                                                                                                                                                                    //console.log(response.statusCode);                                                                                                                                                                                    //console.log(response.data);                                                                                                                                                                                    var result = JSON.parse(response.data);                                                                                                                                                                                    //log (result.display_name);                                                                                                                                                                                            log (result.address.road + " " + result.address.house_number);                                                                                                                                                                                     log (result.address.postcode + " " + result.address.municipality);                                                                                                                                                                                 } else {                                                                                                                                                                                    console.error(error);                                                                                                                                                                                }                                                                                                                                                                            });                                            
                          

                          Dankeschön. aber nun kommt wieder was neues. Ich kann es nicht speichern.

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

                            @micha-3 sagte in Adresse aus GPS Koordinaten ermitteln ?:

                            Ich kann es nicht speichern.

                            ???

                            1 Reply Last reply Reply Quote 0
                            • M
                              Micha 3 last edited by Micha 3

                              <block xmlns="https://developers.google.com/blockly/xml" type="procedures_defcustomreturn" id="?;wMWdJ!vB8:m#;$39f@" x="-537" y="213">
                                <mutation statements="false">
                                  <arg name="lat" varid="QN!T6w6a-/l=eT]qb^[m"></arg>
                                  <arg name="lon" varid=";AX~{zgT$/kdtN6_QqtB"></arg>
                                </mutation>
                                <field name="NAME">OSM</field>
                                <field name="SCRIPT">dmFyIHJlcXVlc3QgPXJlcXVpcmUoJ3JlcXVlc3QnKTsNCmxldCByZXN1bHQ7DQpjb25zdCBvcHRpb25zID0gew0KICAgIHVybDogJ2h0dHBzOi8vbm9taW5hdGltLm9wZW5zdHJlZXRtYXAub3JnL3JldmVyc2UucGhwP2Zvcm1hdD1qc29uJmxhdD0nICsgbGF0ICsgJyZsb249JyArIGxvbiArICcmem9vbT0xOCcsDQogICAgbWV0aG9kOiAnR0VUJywNCiAgICBoZWFkZXJzOiB7DQogICAgICAgICdBY2NlcHQnOiAnYXBwbGljYXRpb24vanNvbicsDQogICAgICAgICdBY2NlcHQtQ2hhcnNldCc6ICd1dGYtOCcsDQogICAgICAgICdVc2VyLUFnZW50JzogJ2lvYnJva2VyIHNjcmlwdCcNCiAgICB9DQp9DQoNCnJlcXVlc3Qob3B0aW9ucywgZnVuY3Rpb24oZXJyLHJlc3BvbnNlLGJvZHkpew0KICAgIHJlc3VsdCA9IEpTT04ucGFyc2UoYm9keSk7DQp9KQ0KYXdhaXQgd2FpdCgxMDAwKTsNCnJldHVybiByZXN1bHQ7</field>
                                <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                              </block>
                              

                              Ich bin echt zu doof. darin kommt das JS und das kann ich nicht speichern.

                              1 Reply Last reply Reply Quote 0
                              • M
                                Micha 3 last edited by

                                das JS was drin ist falls ich es nicht gepostet habe.

                                var request =require('request');
                                let result;
                                const options = {
                                    url: 'https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon + '&zoom=18',
                                    method: 'GET',
                                    headers: {
                                        'Accept': 'application/json',
                                        'Accept-Charset': 'utf-8',
                                        'User-Agent': 'iobroker script'
                                    }
                                }
                                
                                request(options, function(err,response,body){
                                    result = JSON.parse(body);
                                })
                                await wait(1000);
                                return result;
                                
                                bahnuhr 1 Reply Last reply Reply Quote 0
                                • bahnuhr
                                  bahnuhr Forum Testing Most Active @Micha 3 last edited by

                                  @micha-3

                                  Was machst du da ???

                                  Versuchst du ein JS in ein blockly rein zu tun ?

                                  Speichere das JS in ein JS; und nicht in ein blockly.

                                  1 Reply Last reply Reply Quote 0
                                  • M
                                    Micha 3 last edited by

                                    ich sag doch, ich kann das nicht. ich hab mir das von oben kopiert und es lief ja auch. nun hab ich die Fehlermeldung und festgestellt, es das JS in der Funktion. aber wie und was das alles macht weiß ich nicht.

                                    1 Reply Last reply Reply Quote 0
                                    • R
                                      Razer2412 last edited by

                                      @bahnuhr
                                      Danke für dein Skript! Leider habe ich das gleiche Problem welches auch @Micha-3 versucht zu erklären: Das Skript lässt sich im Javaskript Editor nicht speichern und damit auch nicht nutzen.

                                      @Codierknecht vielen Dank auch für deine Hilfe!
                                      Bitte beachte die Abfrage jede Minute nicht - die dient nur zu testzwecken.
                                      Das fertige Skript funktioniert dann wie das ursprüngliche Skript bei jeder Statusänderung. 🙂

                                      Ich habe schon weit über 30 Skripte (Blockly) zur Hausautomatisierung gebastelt, welche teilweise auch wirklich umfangreich sind. Sehr vieles habe ich über try and error herausgefunden.
                                      Auch hier habe ich Stunden selbst versucht ein lauffähiges Skript zu erhalten, bevor ich hier unnötig nachfrage!

                                      Ich möchte mich dafür entschuldigen, wenn meine Eigenleistung nicht den Erwartungen gerecht wird.

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

                                        @razer2412 sagte in Adresse aus GPS Koordinaten ermitteln ?:

                                        Das Skript lässt sich im Javaskript Editor nicht speichern und damit auch nicht nutzen.

                                        Wo seid ihr.
                                        Das Script läuft in JS einwandfrei.

                                        Seit ihr in VIS Editor ???

                                        R 1 Reply Last reply Reply Quote 0
                                        • R
                                          Razer2412 @bahnuhr last edited by

                                          @bahnuhr

                                          in Blockly:

                                          3e351285-c8f9-4df9-b653-33ec6f085450-{9E29512C-F672-4E17-87DC-D793AF1753C2}.png

                                          Das JS läuft in Blockly

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

                                            @razer2412

                                            Wie oft muss ichs das sagen !

                                            Es ist kein blockly !!

                                            Es ist ein stink normales JS.

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            714
                                            Online

                                            32.1k
                                            Users

                                            80.6k
                                            Topics

                                            1.3m
                                            Posts

                                            10
                                            59
                                            3070
                                            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