mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
Another try to fix the midsummer problem.
git-svn-id: https://svn.fhem.de/fhem/trunk@1621 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
0dac5a502a
commit
0cd9f17fec
@ -192,10 +192,10 @@ sub Twilight_GetUpdate{
|
|||||||
($sunrise_set[$i]{RISE},$sunrise_set[$i]{SET})=
|
($sunrise_set[$i]{RISE},$sunrise_set[$i]{SET})=
|
||||||
twilight_calc($latitude,$longitude,$sunrise_set[$i]{DEGREE},$declination,$timezone,$midseconds,$timediff);
|
twilight_calc($latitude,$longitude,$sunrise_set[$i]{DEGREE},$declination,$timezone,$midseconds,$timediff);
|
||||||
readingsUpdate($hash, $sunrise_set[$i]{SR_NAME},
|
readingsUpdate($hash, $sunrise_set[$i]{SR_NAME},
|
||||||
$sunrise_set[$i]{RISE} eq "nan" ? "undefined" :
|
$sunrise_set[$i]{RISE} eq "0" ? "undefined" :
|
||||||
strftime("%H:%M:%S",localtime($sunrise_set[$i]{RISE})));
|
strftime("%H:%M:%S",localtime($sunrise_set[$i]{RISE})));
|
||||||
readingsUpdate($hash, $sunrise_set[$i]{SS_NAME},
|
readingsUpdate($hash, $sunrise_set[$i]{SS_NAME},
|
||||||
$sunrise_set[$i]{SET} eq "nan" ? "undefined" :
|
$sunrise_set[$i]{SET} eq "2000000000" ? "undefined" :
|
||||||
strftime("%H:%M:%S",localtime($sunrise_set[$i]{SET})));
|
strftime("%H:%M:%S",localtime($sunrise_set[$i]{SET})));
|
||||||
}
|
}
|
||||||
my $k=0;
|
my $k=0;
|
||||||
@ -204,7 +204,6 @@ sub Twilight_GetUpdate{
|
|||||||
my $licht;
|
my $licht;
|
||||||
for(my $i=0;$i < 12;$i++){
|
for(my $i=0;$i < 12;$i++){
|
||||||
$nexttime=$sunrise_set[6-abs($i-6)-$k]{$half};
|
$nexttime=$sunrise_set[6-abs($i-6)-$k]{$half};
|
||||||
next if($nexttime eq "undefined");
|
|
||||||
if($nexttime > $now && $nexttime!=2000000000){
|
if($nexttime > $now && $nexttime!=2000000000){
|
||||||
readingsUpdate($hash,"light", 6-abs($i-6));
|
readingsUpdate($hash,"light", 6-abs($i-6));
|
||||||
if($i<6){
|
if($i<6){
|
||||||
@ -219,24 +218,25 @@ sub Twilight_GetUpdate{
|
|||||||
$nexttime=900 if($nexttime>900);
|
$nexttime=900 if($nexttime>900);
|
||||||
}else{
|
}else{
|
||||||
$nexttime = $nexttime-$now+10;
|
$nexttime = $nexttime-$now+10;
|
||||||
}
|
}
|
||||||
if(!$hash->{LOCAL}) {
|
if(!$hash->{LOCAL}) {
|
||||||
InternalTimer(sprintf("%.0f",$now+$nexttime), "Twilight_GetUpdate", $hash, 0);
|
InternalTimer(sprintf("%.0f",$now+$nexttime), "Twilight_GetUpdate", $hash, 0);
|
||||||
readingsUpdate($hash,"nextUpdate",strftime("%H:%M:%S",localtime($now+$nexttime)));
|
readingsUpdate($hash,"nextUpdate",strftime("%H:%M:%S",localtime($now+$nexttime)));
|
||||||
}
|
}
|
||||||
$hash->{STATE}=$i;
|
$hash->{STATE}=$i;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
if ($i == 5){
|
|
||||||
$k=1;
|
if ($i == 5){
|
||||||
$half="SET";
|
$k=1;
|
||||||
}
|
$half="SET";
|
||||||
if($nexttime<$now && $i==11){
|
}
|
||||||
if(!$hash->{LOCAL}) {
|
if($nexttime<$now && $i==11){
|
||||||
InternalTimer($now+900, "Twilight_GetUpdate", $hash, 0);
|
if(!$hash->{LOCAL}) {
|
||||||
}
|
InternalTimer($now+900, "Twilight_GetUpdate", $hash, 0);
|
||||||
readingsUpdate($hash,"light", 0);
|
}
|
||||||
$hash->{STATE}=0;
|
readingsUpdate($hash,"light", 0);
|
||||||
|
$hash->{STATE}=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,6 +264,8 @@ sub twilight_calc {
|
|||||||
$sunrise=0;
|
$sunrise=0;
|
||||||
$sunset=2000000000;
|
$sunset=2000000000;
|
||||||
}
|
}
|
||||||
|
$sunrise = 0 if($sunrise eq "nan");
|
||||||
|
$sunset = 2000000000 if($sunset eq "nan");
|
||||||
return $sunrise, $sunset;
|
return $sunrise, $sunset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user