yes i experienced appr. 5 minutes differences. but that does not matter anyways.
allright guys - go ahead and use this new device for your needs
Sunrise and Sunset device via shellsensor plugin
yes i experienced appr. 5 minutes differences. but that does not matter anyways.
allright guys - go ahead and use this new device for your needs
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebook
make it so !
That’s the way I like, perfekt work for me!
A few minutes difference don’t matter for me, more difference in light is from the weather itself
OK why parse an xml and make your system dependend from another source?
Try this. Create an php make it executable and then you are on your own system without external sources.
#!/usr/bin/php
<?php
$zenith=90+50/60;
$lat = 52.19;
$long = 10.33;
function calcSunPos( $iYear, $iMonth, $iDay, $dHours, $dMinutes, $dSeconds, $dLongitude, $dLatitude){
$sunpos;
$pi = 3.14159265358979323846;
$twopi = (2*$pi);
$rad = ($pi/180);
$dEarthMeanRadius = 6371.01; // In km
$dAstronomicalUnit = 149597890; // In km
// Calculate difference in days between the current Julian Day
// and JD 2451545.0, which is noon 1 January 2000 Universal Time
// Calculate time of the day in UT decimal hours
$dDecimalHours = floatval($dHours) + (floatval($dMinutes) + floatval($dSeconds) / 60.0 ) / 60.0;
// Calculate current Julian Day
$iYfrom2000 = $iYear;//expects now as YY ;
$iA= (14 - ($iMonth)) / 12;
$iM= ($iMonth) + 12 * $iA -3;
$liAux3=(153 * $iM + 2)/5;
$liAux4= 365 * ($iYfrom2000 - $iA);
$liAux5= ( $iYfrom2000 - $iA)/4;
$dElapsedJulianDays= floatval(($iDay + $liAux3 + $liAux4 + $liAux5 + 59)+ -0.5 + $dDecimalHours/24.0);
// Calculate ecliptic coordinates (ecliptic longitude and obliquity of the
// ecliptic in radians but without limiting the angle to be less than 2*Pi
// (i.e., the result may be greater than 2*Pi)
$dOmega= 2.1429 - 0.0010394594 * $dElapsedJulianDays;
$dMeanLongitude = 4.8950630 + 0.017202791698 * $dElapsedJulianDays; // Radians
$dMeanAnomaly = 6.2400600 + 0.0172019699 * $dElapsedJulianDays;
$dEclipticLongitude = $dMeanLongitude + 0.03341607 * sin( $dMeanAnomaly ) + 0.00034894 * sin( 2 * $dMeanAnomaly ) -0.0001134 -0.0000203 * sin($dOmega);
$dEclipticObliquity = 0.4090928 - 6.2140e-9 * $dElapsedJulianDays +0.0000396 * cos($dOmega);
// Calculate celestial coordinates ( right ascension and declination ) in radians
// but without limiting the angle to be less than 2*Pi (i.e., the result may be
// greater than 2*Pi)
$dSin_EclipticLongitude = sin( $dEclipticLongitude );
$dY1 = cos( $dEclipticObliquity ) * $dSin_EclipticLongitude;
$dX1 = cos( $dEclipticLongitude );
$dRightAscension = atan2( $dY1,$dX1 );
if( $dRightAscension < 0.0 ) $dRightAscension = $dRightAscension + $twopi;
$dDeclination = asin( sin( $dEclipticObliquity )* $dSin_EclipticLongitude );
// Calculate local coordinates ( azimuth and zenith angle ) in degrees
$dGreenwichMeanSiderealTime = 6.6974243242 + 0.0657098283 * $dElapsedJulianDays + $dDecimalHours;
$dLocalMeanSiderealTime = ($dGreenwichMeanSiderealTime*15 + $dLongitude)* $rad;
$dHourAngle = $dLocalMeanSiderealTime - $dRightAscension;
$dLatitudeInRadians = $dLatitude * $rad;
$dCos_Latitude = cos( $dLatitudeInRadians );
$dSin_Latitude = sin( $dLatitudeInRadians );
$dCos_HourAngle= cos( $dHourAngle );
$dZenithAngle = (acos( $dCos_Latitude * $dCos_HourAngle * cos($dDeclination) + sin( $dDeclination )* $dSin_Latitude));
$dY = -sin( $dHourAngle );
$dX = tan( $dDeclination )* $dCos_Latitude - $dSin_Latitude * $dCos_HourAngle;
$dAzimuth = atan2( $dY, $dX );
if ( $dAzimuth < 0.0 )
$dAzimuth = $dAzimuth + $twopi;
$dAzimuth = $dAzimuth / $rad;
// Parallax Correction
$dParallax = ($dEarthMeanRadius / $dAstronomicalUnit) * sin( $dZenithAngle);
$dZenithAngle = ($dZenithAngle + $dParallax) / $rad;
$dElevation = 90 - $dZenithAngle;
// Save Azimuth and Elevation as Float values
//echo $dAzimuth."<br />";
//echo $dElevation."<br />";
// Save Azimuth and Elevation as Integer values
$sunpos[] = intval($dAzimuth);
$sunpos[] = intval($dElevation);
return $sunpos;
}
$sunpos = calcSunPos( gmdate(“y”), gmdate(“m”), gmdate(“d”), gmdate(“H”), gmdate(“i”), 0, $long, $lat);
$sunrise = date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, date(“O”)/100);
$sunset = date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, date(“O”)/100);
if(isset($argv[1])){
if($argv[1] == “riseset”){
echo "Sunrise: “.$sunrise.”, Sunset: ".$sunset;
}
if($argv[1] == “pos”){
echo "Azimuth: ".$sunpos[0]."°, Elevation: ".$sunpos[1].“°”;
}
}else{
echo “Please use riseset or pos”;
}
?>
You can get sunset and sunrise via sun.php riseset or the position of sun with sun.php pos.
thx for your workaround!
as part of the recently upgraded sunrise plugin, the new suntime device is working very well, even without any external source parsing.
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebook
make it so !
OK, but how does it work? Are this inside of sunrise plugin?
it’s using suncalc.
have a look at the code from @mwittig
https://github.com/pimatic/pimatic-sunrise/commit/35b26092b2885357477a43e675ba8887f2634c91
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebook
make it so !
Yes, i know this plugin. But i dont understand how to create a device to see this in my GUI.
I don’t find any documentations about this.
We are talking about this plugin???
absolutely yes!
check here for some more info. guess the plugin site has to be updated to get the latest release news.
https://github.com/pimatic/pimatic-sunrise
you can use it like follows :
{
"id": "sunrise-1",
"class": "SunriseDevice",
"name": "Sunrise",
"latitude": 52.5072111,
"longitude": 13.1449592,
"attributes": [
{
"name": "sunrise",
"label": "Sunrise Time"
},
{
"name": "sunset",
"label": "Sunset Time"
}
]
}
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebook
make it so !
@Swen said:
Are this inside of sunrise plugin
Yes, as @leader21 said I have implemented it as part of the pimatic-sunrise plugin which is based on suncalc - a package, which implements algorithms to calculate sun position, sunlight phases, moon position and lunar phase for the given location and time. See also:
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
Excellent! Now its clear to understand for me. Thanks!