Jump to content
Visit us at IFA2024 / Besuche uns auf der IFA2024 06.-10.09.2024 Stand H1.2-420 ×
Shelly wiring diagram Now LIVE ×

http.get getting stuck


Recommended Posts

Hello,

I am trying to get the sun position with a script. This did work properly last year. Since this year my script isn't working any more. What could be the failure?

 

function SunPos() {
	//Sonnenposition mittels ipgeolocation API zum aktuellen Zeitpunkt prüfen
	print("SunPos gestartet");
	Shelly.call(
	"http.get", 
	{url: "http://api.ipgeolocation.io/astronomy?apiKey=myKey&lat=49.1877&long=8.16339"}, 
		function (response, error_code, error_message) {
		  //print("http.get gestartet");
		  if (error_code === 0) {
			let sonne = JSON.parse(response.body);
            let azimuth = Math.round(sonne.sun_azimuth);
			let altitude = Math.round(sonne.sun_altitude);
                    print("Azimuth :", azimuth);
	                print("Altitude :", altitude);				

				//Beschattung Süd-Fenster An
				//Ergänzt am 28.01.2023 " && altitude >= 12"
				if (azimuth > 100 && azimuth < 245) {
					//Aktionen
					print("Beschattung Süd AN"); 
                    
                    Shelly.call("Switch.set", {'id': 0, 'on': true});
                    
					//Ausgang 1 einschalten
				}
                        
				//Beschattung Süd-Fenster aufheben
				if (azimuth > 245) {
					//Aktionen
					print("Beschattung Süd AUS Azimuth");
                    
                    Shelly.call("Switch.set", {'id': 0, 'on': false});				

				}
				if (altitude < 12) {
					//Aktionen
					print("Beschattung Süd AUS Altitude");
                    
                    Shelly.call("Switch.set", {'id': 0, 'on': false});				

				}
		} else {
                    print("Fehler:", error_message); 
		   }
		},			               
    );	
}

The JSON returned looks like this:

{"location":{"latitude":49.1877,"longitude":8.16339},"date":"2024-06-24","current_time":"08:06:20.788","sunrise":"05:23","sunset":"21:36","sun_status":"-","solar_noon":"13:29","day_length":"16:13","sun_altitude":23.298918681102815,"sun_distance":152049111.66664976,"sun_azimuth":80.62990251132766,"moonrise":"-:-","moonset":"07:26","moon_status":"-","moon_altitude":-4.919695650588063,"moon_distance":373453.9905188856,"moon_azimuth":237.68901808084172,"moon_parallactic_angle":37.338065434948206}

Can anyone please help?

 

Link to comment
Share on other sites

Something is wrong with this call:

https://api.ipgeolocation.io/astronomy?apiKey=myKey&lat=49.1877&long=8.16339

because it returns an error:

{
"message": "Provided API key is not valid. Contact technical support for assistance at support@ipgeolocation.io"
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Erstelle neue...