// Définitions de variables perso : $LatObservateur = 50.12345678901234; $LongObservateur = -1.1234567890123456; setlocale(LC_TIME, 'fr','fr_FR','fr_FR@euro','fr_FR.utf8','fr-FR','fra'); // Indication de localité pour les dates et heures (GMT, etc.) /* Source : https://www.wxforum.net/index.php?topic=32204.0 Elle-même adaptée depuis : sunpath.php http://www.weather-watch.com/smf/index.php/topic,39197.0.html - Thanks Jozef (Pinto) Calculs de référence sur le NOAA Solar Calculator (https://www.esrl.noaa.gov/gmd/grad/solcalc/) */ function sun_pos($UnixTimestamp, $latitude, $longitude) { $year = date("Y",$UnixTimestamp); $month = date("n",$UnixTimestamp); $day = date("j",$UnixTimestamp); $UT = gmdate("H",$UnixTimestamp)+gmdate("i",$UnixTimestamp)/60+gmdate("s",$UnixTimestamp)/3600; $d = round(367 * $year - (7 * ($year + (($month + 9)/12)))/4 + (275 * $month)/9 + $day - 730530); $w = 282.9404 + 0.0000470935 * $d; $e = 0.016709 - 0.000000001151 * $d; $M = 356.0470 + 0.9856002585 * $d; $M = fmod($M , 360); if ($M < 0){$M = $M+360;} $L = $w + $M; $L = fmod($L , 360); $oblecl = 23.4393 - 0.0000003563 * $d ; $E = rad2deg(deg2rad($M) + (180/M_PI) * deg2rad($e) * sin(deg2rad($M)) * (1 + $e * cos(deg2rad($M)))); $x = cos(deg2rad($E)) - $e; $y = sin(deg2rad($E)) * sqrt(1 - $e*$e); $r = sqrt($x*$x + $y*$y); $v = rad2deg(atan2( deg2rad($y), deg2rad($x)) ); $lon = $v + $w; $lon = fmod($lon, 360); $x_rect = $r * cos(deg2rad($lon)); $y_rect = $r * sin(deg2rad($lon)); $z_rect = 0.0; $x_equat = $x_rect; $y_equat = $y_rect * cos(deg2rad($oblecl)) + $z * sin(deg2rad($oblecl)); $z_equat = $y_rect * sin(deg2rad($oblecl)) + $z * cos(deg2rad($oblecl)); $r = sqrt( $x_equat*$x_equat + $y_equat*$y_equat + $z_equat*$z_equat ); $RA = rad2deg(atan2( deg2rad($y_equat), deg2rad($x_equat) )); // Right Ascension (degrés) $Decl = rad2deg(atan2( deg2rad($z_equat), deg2rad(sqrt( $x_equat*$x_equat + $y_equat*$y_equat ))) ); // Déclinaison (degrés) $GMST0 = $L/15 + 12; $SIDTIME = $GMST0 + $UT + $longitude/15; $HA = $SIDTIME*15 - $RA; $x = cos(deg2rad($HA)) * cos(deg2rad($Decl)); $y = sin(deg2rad($HA)) * cos(deg2rad($Decl)); $z = sin(deg2rad($Decl)); $xhor = $x * cos(deg2rad(90) - deg2rad($latitude)) - $z * sin(deg2rad(90) - deg2rad($latitude)); $yhor = $y; $zhor = $x * sin(deg2rad(90) - deg2rad($latitude)) + $z * cos(deg2rad(90) - deg2rad($latitude)); $azimuth = round(rad2deg(atan2($yhor, $xhor)) + 180,2); // Azimuth du soleil en degrés $altitude = round(rad2deg(asin($zhor)),2); // Altitude (=élévation) en dégrés $pos = array($azimuth, $altitude,$Decl,$RA); return $pos; } $z = 0; // Initialisation de la variable z pour empêcher les erreurs sur les lignes '$y_equat' et '$z_equat' $Sun = sun_pos(time(),$LatObservateur,$LongObservateur); // On affecte à la variable Jeedom 'v_blablabla', le contenu de la variable PHP '$xxxxxxx', que l’on pourra afficher par exemple dans un virtuel : $scenario->setData('v_soleil_azimuth', $Sun[0]); $scenario->setData('v_soleil_altitude', $Sun[1]); $scenario->setData('v_soleil_declinaison', $Sun[2]); $scenario->setData('v_soleil_ra', $Sun[3]);