mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-20 19:36:02 +00:00
95_Astro.pm: Neue Version, u.a. mit Mondphasenbildern
95_YAAHM.pm: Neue Version mit verbesserter Weckzeitanzeige git-svn-id: https://svn.fhem.de/fhem/trunk@15430 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
27fc994ed2
commit
3b73225236
@ -1,4 +1,3 @@
|
|||||||
#2017.07.31 08:04:33 1: PERL WARNING: Use of uninitialized value $Astro{"MoonPhaseS"} in sprintf at /opt/fhem/FHEM/95_Astro.pm line 1302.
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
#
|
#
|
||||||
# 95_Astro.pm
|
# 95_Astro.pm
|
||||||
@ -48,7 +47,7 @@ my $deltaT = 65; # Correction time in s
|
|||||||
my %Astro;
|
my %Astro;
|
||||||
my %Date;
|
my %Date;
|
||||||
|
|
||||||
my $astroversion = 1.35;
|
my $astroversion = 1.37;
|
||||||
|
|
||||||
#-- These we may get on request
|
#-- These we may get on request
|
||||||
my %gets = (
|
my %gets = (
|
||||||
@ -265,7 +264,10 @@ sub Astro_Initialize ($) {
|
|||||||
$hash->{GetFn} = "Astro_Get";
|
$hash->{GetFn} = "Astro_Get";
|
||||||
$hash->{UndefFn} = "Astro_Undef";
|
$hash->{UndefFn} = "Astro_Undef";
|
||||||
$hash->{AttrFn} = "Astro_Attr";
|
$hash->{AttrFn} = "Astro_Attr";
|
||||||
$hash->{AttrList} = "interval longitude latitude altitude horizon";
|
$hash->{AttrList} = "interval longitude latitude altitude horizon ".$readingFnAttributes;;
|
||||||
|
|
||||||
|
$data{FWEXT}{"/Astro_moonwidget"}{FUNC} = "Astro_moonwidget";
|
||||||
|
$data{FWEXT}{"/Astr_moonwidget"}{FORKABLE} = 0;
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -348,6 +350,13 @@ sub Astro_mod($$) { my ($a,$b)=@_;if( $a =~ /\d*\.\d*/){return($a-floor($a/$b)*$
|
|||||||
sub Astro_mod2Pi($) { my ($x)=@_;$x = Astro_mod($x, 2.*pi);return($x); }
|
sub Astro_mod2Pi($) { my ($x)=@_;$x = Astro_mod($x, 2.*pi);return($x); }
|
||||||
sub Astro_round($$) { my ($x,$n)=@_; return int(10**$n*$x+0.5)/10**$n};
|
sub Astro_round($$) { my ($x,$n)=@_; return int(10**$n*$x+0.5)/10**$n};
|
||||||
|
|
||||||
|
sub Astro_tzoffset($) {
|
||||||
|
my ($t) = @_;
|
||||||
|
my $utc = mktime(gmtime($t));
|
||||||
|
my $local = mktime(localtime($t));
|
||||||
|
return (($local - $utc)/36);
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################################################
|
########################################################################################################
|
||||||
#
|
#
|
||||||
# time fragments into minutes, seconds
|
# time fragments into minutes, seconds
|
||||||
@ -1189,6 +1198,54 @@ sub Astro_Compute($){
|
|||||||
return( undef );
|
return( undef );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
########################################################################################
|
||||||
|
#
|
||||||
|
# Astro_moonwidget - SVG picture of the moon
|
||||||
|
#
|
||||||
|
# Parameter hash = hash of the bus master a = argument array
|
||||||
|
#
|
||||||
|
########################################################################################
|
||||||
|
|
||||||
|
sub Astro_moonwidget($){
|
||||||
|
my ($arg) = @_;
|
||||||
|
my $name = $FW_webArgs{name};
|
||||||
|
$name =~ s/'//g;
|
||||||
|
my $hash = $defs{$name};
|
||||||
|
|
||||||
|
my @size=split('x',($FW_webArgs{size} ? $FW_webArgs{size} : '400x400'));
|
||||||
|
|
||||||
|
$FW_RETTYPE = "image/svg+xml";
|
||||||
|
$FW_RET="";
|
||||||
|
FW_pO '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800" width="'.$size[0].'px" height="'.$size[1].'px">';
|
||||||
|
my $ma = Astro_Get($hash,("","text","MoonAge"));
|
||||||
|
|
||||||
|
my ($radius,$axis,$dir,$start,$middle);
|
||||||
|
my $radius = 250;
|
||||||
|
my $axis = sin(($ma+90)*$DEG)*$radius;
|
||||||
|
$axis = -$axis
|
||||||
|
if ($axis < 0);
|
||||||
|
|
||||||
|
if( (0.0 <= $ma && $ma <= 90) || (270.0 < $ma && $ma <= 360.0) ){
|
||||||
|
$dir = 1;
|
||||||
|
}else{
|
||||||
|
$dir = 0;
|
||||||
|
}
|
||||||
|
if( 0.0 < $ma && $ma <= 180 ){
|
||||||
|
$start = $radius;
|
||||||
|
$middle = -$radius;
|
||||||
|
}else{
|
||||||
|
$start = -$radius;
|
||||||
|
$middle = $radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
FW_pO '<g transform="translate(400,400) scale(-1,1)">';
|
||||||
|
FW_pO '<circle cx="0" cy="0" r="250" fill="rgb(70,70,100)"/>';
|
||||||
|
FW_pO '<path d="M 0 '.$start.' A '.$axis.' '.$radius.' 0 0 '.$dir.' 0 '.$middle.' A '.$radius.' '.$radius.' 0 0 0 0 '.$start.' Z" fill="rgb(255,220,100)"/>';
|
||||||
|
FW_pO '</g>';
|
||||||
|
FW_pO '</svg>';
|
||||||
|
return ($FW_RETTYPE, $FW_RET);
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
#
|
#
|
||||||
# Astro_Update - Update readings
|
# Astro_Update - Update readings
|
||||||
@ -1217,8 +1274,11 @@ sub Astro_Update($@) {
|
|||||||
$Date{hour} = $hour;
|
$Date{hour} = $hour;
|
||||||
$Date{min} = $min;
|
$Date{min} = $min;
|
||||||
$Date{sec} = $sec;
|
$Date{sec} = $sec;
|
||||||
$Date{zonedelta} = (strftime "%z", localtime)/100;
|
#-- broken on windows
|
||||||
$Date{dayofyear} = strftime("%-j", localtime);
|
#$Date{zonedelta} = (strftime "%z", localtime)/100;
|
||||||
|
$Date{zonedelta} = Astro_tzoffset(time)/100;
|
||||||
|
#-- half broken in windows
|
||||||
|
$Date{dayofyear} = 1*strftime("%j", localtime);
|
||||||
|
|
||||||
Astro_Compute($hash);
|
Astro_Compute($hash);
|
||||||
|
|
||||||
@ -1260,8 +1320,11 @@ sub Astro_Get($@) {
|
|||||||
$Date{min} = (defined($6)) ? $6 : 0;
|
$Date{min} = (defined($6)) ? $6 : 0;
|
||||||
$Date{sec} = (defined($8)) ? $8 : 0;
|
$Date{sec} = (defined($8)) ? $8 : 0;
|
||||||
my $fTot = timelocal($Date{sec},$Date{min},$Date{hour},$Date{day},$Date{month}-1,$Date{year});
|
my $fTot = timelocal($Date{sec},$Date{min},$Date{hour},$Date{day},$Date{month}-1,$Date{year});
|
||||||
$Date{zonedelta} = (strftime "%z", localtime($fTot))/100;
|
#-- broken on windows
|
||||||
$Date{dayofyear} = strftime("%-j", localtime($fTot));
|
#$Date{zonedelta} = (strftime "%z", localtime($fTot))/100;
|
||||||
|
$Date{zonedelta} = Astro_tzoffset($fTot)/100;
|
||||||
|
#-- half broken in windows
|
||||||
|
$Date{dayofyear} = 1*strftime("%j", localtime($fTot));
|
||||||
}else{
|
}else{
|
||||||
return "[Astro_Get] $name has improper time specification, use YYYY-MM-DD HH:MM:SS";
|
return "[Astro_Get] $name has improper time specification, use YYYY-MM-DD HH:MM:SS";
|
||||||
}
|
}
|
||||||
@ -1276,8 +1339,11 @@ sub Astro_Get($@) {
|
|||||||
$Date{hour} = $hour;
|
$Date{hour} = $hour;
|
||||||
$Date{min} = $min;
|
$Date{min} = $min;
|
||||||
$Date{sec} = $sec;
|
$Date{sec} = $sec;
|
||||||
$Date{zonedelta} = (strftime "%z", localtime)/100;
|
#-- broken on windows
|
||||||
$Date{dayofyear} = strftime("%-j", localtime);
|
#$Date{zonedelta} = (strftime "%z", localtime)/100;
|
||||||
|
$Date{zonedelta} = Astro_tzoffset(time)/100;
|
||||||
|
#-- half broken in windows
|
||||||
|
$Date{dayofyear} = 1*strftime("%j", localtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $a[1] eq "version") {
|
if( $a[1] eq "version") {
|
||||||
@ -1322,8 +1388,6 @@ sub Astro_Get($@) {
|
|||||||
$ret .= sprintf("%s %2.1f', %s %2.1f°, %s %1.2f = %s, %s %s\n",$astro_tt->{"diameter"},
|
$ret .= sprintf("%s %2.1f', %s %2.1f°, %s %1.2f = %s, %s %s\n",$astro_tt->{"diameter"},
|
||||||
$Astro{MoonDiameter},$astro_tt->{"age"},$Astro{MoonAge},$astro_tt->{"phase"},$Astro{MoonPhaseN},$Astro{MoonPhaseS},$astro_tt->{"sign"},$Astro{MoonSign});
|
$Astro{MoonDiameter},$astro_tt->{"age"},$Astro{MoonAge},$astro_tt->{"phase"},$Astro{MoonPhaseN},$Astro{MoonPhaseS},$astro_tt->{"sign"},$Astro{MoonSign});
|
||||||
|
|
||||||
#$ret .="\ndistance=".$moonCoor->{distance}." test=".sqrt( ($xm)**2 + ($ym)**2 + ($zm)**2 )." $xm $ym $zm";
|
|
||||||
#$ret .="\ndistance=".$radius." test=".sqrt( ($x)**2 + ($y)**2 + ($z)**2 )." $x $y $z";
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
@ -1372,6 +1436,10 @@ sub Astro_Get($@) {
|
|||||||
<li><i>Time,Timezone</i> obvious meaning</li>
|
<li><i>Time,Timezone</i> obvious meaning</li>
|
||||||
<li><i>GMST,ÖMST</i> = Greenwich and Local Mean Sidereal Time (in HH:MM)</li>
|
<li><i>GMST,ÖMST</i> = Greenwich and Local Mean Sidereal Time (in HH:MM)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p>
|
||||||
|
An SVG image of the current moon phase may be obtained under the link
|
||||||
|
<code><ip address of fhem>/fhem/Astro_moonwidget?name='<device name>'&size='<width>x<height>'</code>
|
||||||
|
<p>
|
||||||
Notes: <ul>
|
Notes: <ul>
|
||||||
<li>Calculations are only valid between the years 1900 and 2100</li>
|
<li>Calculations are only valid between the years 1900 and 2100</li>
|
||||||
<li>Attention: Timezone is taken from the local Perl settings, NOT automatically defined for a location</li>
|
<li>Attention: Timezone is taken from the local Perl settings, NOT automatically defined for a location</li>
|
||||||
@ -1437,6 +1505,6 @@ sub Astro_Get($@) {
|
|||||||
|
|
||||||
<a name="Astro"></a>
|
<a name="Astro"></a>
|
||||||
<h3>Astro</h3>
|
<h3>Astro</h3>
|
||||||
Absichtlich keine deutsche Dokumentation vorhanden, die englische Version gibt es hier: <a href="/fhem/commandref.html#Astro">Astro</a>
|
Absichtlich keine deutsche Dokumentation vorhanden, die englische Version gibt es hier: <a href="/fhem/docs/commandref.html#Astro">Astro</a>
|
||||||
=end html_DE
|
=end html_DE
|
||||||
=cut
|
=cut
|
@ -48,7 +48,7 @@ my $yaahmname;
|
|||||||
my $yaahmlinkname = "Profile"; # link text
|
my $yaahmlinkname = "Profile"; # link text
|
||||||
my $yaahmhiddenroom = "ProfileRoom"; # hidden room
|
my $yaahmhiddenroom = "ProfileRoom"; # hidden room
|
||||||
my $yaahmpublicroom = "Unsorted"; # public room
|
my $yaahmpublicroom = "Unsorted"; # public room
|
||||||
my $yaahmversion = "1.16";
|
my $yaahmversion = "1.17";
|
||||||
my $firstcall = 1;
|
my $firstcall = 1;
|
||||||
|
|
||||||
my %yaahm_transtable_EN = (
|
my %yaahm_transtable_EN = (
|
||||||
@ -898,7 +898,7 @@ sub YAAHM_restore($$) {
|
|||||||
my ($hash,$doit) = @_;
|
my ($hash,$doit) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my ($error,$jhash0) = FileRead("YAAHMFILE");
|
my ($error,$jhash0) = FileRead("YAAHMFILE");
|
||||||
if( defined($error) ){
|
if( defined($error) && $error ne "" ){
|
||||||
Log3 $name,1,"[YAAHM_restore] read error=$error";
|
Log3 $name,1,"[YAAHM_restore] read error=$error";
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1708,14 +1708,28 @@ sub YAAHM_setWeeklyTime($) {
|
|||||||
}else{
|
}else{
|
||||||
#-- "next" after current time => we mean today
|
#-- "next" after current time => we mean today
|
||||||
if( $nga > $lga ){
|
if( $nga > $lga ){
|
||||||
$sg0mod = "$ng (man)";
|
#-- only restore standard setting
|
||||||
$ring_0 = $ng;
|
if( $ng eq $sg0 ){
|
||||||
|
$sg0mod = $sg0;
|
||||||
|
$ring_0 = $sg0;
|
||||||
|
$hash->{DATA}{"WT"}[$i]{ "next" } = "";
|
||||||
|
}else{
|
||||||
|
$sg0mod = "$ng (man)";
|
||||||
|
$ring_0 = $ng;
|
||||||
|
}
|
||||||
$ring_1 = $sg1;
|
$ring_1 = $sg1;
|
||||||
#-- "next" before current time => we mean tomorrow
|
#-- "next" before current time => we mean tomorrow
|
||||||
}else{
|
}else{
|
||||||
$sg1mod = "$ng (man)";
|
#-- only restore standard setting
|
||||||
|
if( $ng eq $sg1 ){
|
||||||
|
$sg0mod = $sg1;
|
||||||
|
$ring_1 = $sg1;
|
||||||
|
$hash->{DATA}{"WT"}[$i]{ "next" } = "";
|
||||||
|
}else{
|
||||||
|
$sg1mod = "$ng (man)";
|
||||||
|
$ring_1 = "$sg1 ($ng)";
|
||||||
|
}
|
||||||
$ring_0 = $sg0;
|
$ring_0 = $sg0;
|
||||||
$ring_1 = "$sg1 ($ng)";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#-- notation:
|
#-- notation:
|
||||||
@ -1782,7 +1796,7 @@ sub YAAHM_sayWeeklyTime($$$) {
|
|||||||
if( ($ton =~ /(\d?\d):(\d\d)(:(\d\d))?/) && ($tom ne $ton) ){
|
if( ($ton =~ /(\d?\d):(\d\d)(:(\d\d))?/) && ($tom ne $ton) ){
|
||||||
$hw = $1*1;
|
$hw = $1*1;
|
||||||
$mw = $2*1;
|
$mw = $2*1;
|
||||||
$pt = sprintf("%d:%02d",$hw,$mw);
|
$pt = sprintf("%d:%02d",$hw,$mw)." ".tolower($yaahm_tt->{"today"});
|
||||||
|
|
||||||
$msg .= " ".tolower($yaahm_tt->{"tomorrow"})." ".$yaahm_tt->{"exceptly"}." $hw ".$yaahm_tt->{"clock"};
|
$msg .= " ".tolower($yaahm_tt->{"tomorrow"})." ".$yaahm_tt->{"exceptly"}." $hw ".$yaahm_tt->{"clock"};
|
||||||
$msg .=" $mw"
|
$msg .=" $mw"
|
||||||
@ -2594,10 +2608,6 @@ sub YAAHM_timewidget($){
|
|||||||
$name =~ s/'//g;
|
$name =~ s/'//g;
|
||||||
|
|
||||||
my @size=split('x',($FW_webArgs{size} ? $FW_webArgs{size} : '400x400'));
|
my @size=split('x',($FW_webArgs{size} ? $FW_webArgs{size} : '400x400'));
|
||||||
#Log 1,"++++++++++++++++++++++++++++++++++++++++++++";
|
|
||||||
#Log 1,"YAAHM_timewidget type $type (subtype $subtype) called with $arg";
|
|
||||||
#Log 1,"YAAHM_timewidget has size ".$size[0]."x".$size[1];
|
|
||||||
#Log 1,"++++++++++++++++++++++++++++++++++++++++++++";
|
|
||||||
|
|
||||||
$FW_RETTYPE = "image/svg+xml";
|
$FW_RETTYPE = "image/svg+xml";
|
||||||
$FW_RET="";
|
$FW_RET="";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user