mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-20 01:06:04 +00:00
Twilight
- some minor improvements Heating_Control - improvemts in autodetection (EnOcean) RandomTimer - improvemts when waking up all the timers by RandomTimer_Wakeup() git-svn-id: https://svn.fhem.de/fhem/trunk@5879 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
092d63bd2e
commit
80ee54cbb6
@ -146,7 +146,7 @@ sub Twilight_Define($$)
|
||||
$hash->{LATITUDE} = $latitude;
|
||||
$hash->{LONGITUDE} = $longitude;
|
||||
$hash->{WEATHER} = $weather;
|
||||
$hash->{SUNPOS_OFFSET} = 30;
|
||||
$hash->{SUNPOS_OFFSET} = 1;
|
||||
|
||||
Twilight_sunposTimerSet($hash);
|
||||
myRemoveInternalTimer("Midnight", $hash);
|
||||
@ -298,16 +298,18 @@ sub myGetHashIndirekt ($$) {
|
||||
}
|
||||
################################################################################
|
||||
sub Twilight_Midnight($) {
|
||||
my ($myHash) = @_;
|
||||
my $hash = $myHash->{HASH};
|
||||
my ($myHash) = @_;
|
||||
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||
return if (!defined($hash));
|
||||
|
||||
Twilight_TwilightTimes ($hash, "Mid");
|
||||
Twilight_StandardTimerSet ($hash);
|
||||
}
|
||||
################################ ################################################
|
||||
sub Twilight_WeatherTimerUpdate($) {
|
||||
my ($myHash) = @_;
|
||||
my $hash = $myHash->{HASH};
|
||||
my ($myHash) = @_;
|
||||
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||
return if (!defined($hash));
|
||||
|
||||
Twilight_TwilightTimes ($hash, "Wea");
|
||||
Twilight_StandardTimerSet ($hash);
|
||||
@ -347,7 +349,9 @@ sub Twilight_sunposTimerSet($) {
|
||||
sub Twilight_fireEvent($)
|
||||
{
|
||||
my ($myHash) = @_;
|
||||
my $hash = $myHash->{HASH};
|
||||
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||
return if (!defined($hash));
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
my $sx = $myHash->{MODIFIER};
|
||||
|
||||
@ -452,7 +456,9 @@ sub Twilight_getWeatherHorizon($)
|
||||
sub Twilight_sunpos($)
|
||||
{
|
||||
my ($myHash) = @_;
|
||||
my $hash = $myHash->{HASH};
|
||||
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||
return if (!defined($hash));
|
||||
|
||||
my $hashName = $hash->{NAME};
|
||||
|
||||
return "" if(AttrVal($hashName, "disable", undef));
|
||||
@ -461,7 +467,6 @@ sub Twilight_sunpos($)
|
||||
my ($dSeconds,$dMinutes,$dHours,$iDay,$iMonth,$iYear,$wday,$yday,$isdst) = gmtime(time);
|
||||
$iMonth++;
|
||||
$iYear += 100;
|
||||
$dSeconds = 0;
|
||||
|
||||
my $dLongitude = $hash->{LONGITUDE};
|
||||
my $dLatitude = $hash->{LATITUDE};
|
||||
@ -470,14 +475,14 @@ sub Twilight_sunpos($)
|
||||
my $pi=3.14159265358979323846;
|
||||
my $twopi=(2*$pi);
|
||||
my $rad=($pi/180);
|
||||
my $dEarthMeanRadius=6371.01; # In km
|
||||
my $dEarthMeanRadius=6371.01; # In km
|
||||
my $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
|
||||
my $dDecimalHours=$dHours + ($dMinutes + $dSeconds / 60.0 ) / 60.0;
|
||||
my $dDecimalHours=$dHours + $dMinutes/60.0 + $dSeconds/3600.0;
|
||||
|
||||
# Calculate current Julian Day
|
||||
my $iYfrom2000=$iYear;#expects now as YY ;
|
||||
@ -530,10 +535,6 @@ sub Twilight_sunpos($)
|
||||
$dZenithAngle=($dZenithAngle + $dParallax) / $rad;
|
||||
my $dElevation=90 - $dZenithAngle;
|
||||
|
||||
# set readings
|
||||
$dAzimuth = int(100*$dAzimuth )/100;
|
||||
$dElevation = int(100*$dElevation)/100;
|
||||
|
||||
my $twilight = int(($dElevation+12.0)/18.0 * 1000)/10;
|
||||
$twilight = 100 if ($twilight>100);
|
||||
$twilight = 0 if ($twilight< 0);
|
||||
@ -542,6 +543,10 @@ sub Twilight_sunpos($)
|
||||
$twilight_weather = 100 if ($twilight_weather>100);
|
||||
$twilight_weather = 0 if ($twilight_weather< 0);
|
||||
|
||||
# set readings
|
||||
$dAzimuth = int(100*$dAzimuth )/100;
|
||||
$dElevation = int(100*$dElevation)/100;
|
||||
|
||||
my $compassPoint = Twilight_CompassPoint($dAzimuth);
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
|
@ -261,7 +261,7 @@ sub Heating_Control_ParseSwitchingProfile($$$) {
|
||||
} elsif ($time =~ m/^[0-2][0-9](:[0-5][0-9]){2,2}$/g) { # HH:MM:SS
|
||||
; # ok.
|
||||
} else {
|
||||
Log3 $hash, 1, "[$name] invalid time in $name <$time> HH:MM[:SS]";
|
||||
Log3 $hash, 1, "[$name] invalid time <$time> HH:MM[:SS]";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -518,41 +518,45 @@ sub isHeizung($) {
|
||||
|
||||
my %setmodifiers =
|
||||
("FHT" => "desired-temp",
|
||||
#"EnOcean" => "desired-temp",
|
||||
"EnOcean" => { "mode" => "subType", "setModifier" => "desired-temp",
|
||||
"PID20" => "desired",
|
||||
"EnOcean" => { "subTypeReading" => "subType", "setModifier" => "desired-temp",
|
||||
"roomSensorControl.05" => 1,
|
||||
"hvac.01" => 1 },
|
||||
"PID20" => "desired",
|
||||
"MAX" => { "mode" => "type", "setModifier" => "desiredTemperature",
|
||||
"MAX" => { "subTypeReading" => "type", "setModifier" => "desiredTemperature",
|
||||
"HeatingThermostatPlus" => 1,
|
||||
"HeatingThermostat" => 1,
|
||||
"WallMountedThermostat" => 1 },
|
||||
"CUL_HM" => { "mode" => "model","setModifier" => "desired-temp",
|
||||
"CUL_HM" => { "subTypeReading" => "model","setModifier" => "desired-temp",
|
||||
"HM-CC-TC" => 1,
|
||||
"HM-TC-IT-WM-W-EU" => 1,
|
||||
"HM-CC-RT-DN" => 1 } );
|
||||
|
||||
my $dHash = $defs{$hash->{DEVICE}}; ###
|
||||
my $dType = $dHash->{TYPE};
|
||||
Log3 $hash, 5, "dType------------>$dType";
|
||||
return "" if (!defined($dType));
|
||||
|
||||
my $setModifier = $setmodifiers{$dType};
|
||||
$setModifier = "" if (!defined($setModifier));
|
||||
if (ref($setModifier)) {
|
||||
|
||||
my $mode = $setmodifiers{$dType}{mode};
|
||||
my $subTypeReading = $setmodifiers{$dType}{subTypeReading};
|
||||
Log3 $hash, 5, "subTypeReading------------>$subTypeReading";
|
||||
|
||||
my $model;
|
||||
if ($mode eq "model" ) {
|
||||
$model = AttrVal($hash->{DEVICE}, "model", "nF");
|
||||
} elsif ($mode eq "type") {
|
||||
if ($subTypeReading eq "type" ) {
|
||||
$model = $dHash->{type};
|
||||
}
|
||||
} else {
|
||||
$model = AttrVal($hash->{DEVICE}, $subTypeReading, "nF");
|
||||
}
|
||||
Log3 $hash, 5, "model------------>$model";
|
||||
|
||||
if (defined($setmodifiers{$dType}{$model})) {
|
||||
$setModifier = $setmodifiers{$dType}{setModifier}
|
||||
} else {
|
||||
$setModifier = "";
|
||||
}
|
||||
}
|
||||
Log3 $hash, 5, "setModifier------------>$setModifier";
|
||||
return $setModifier;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ sub RandomTimer_SetTimer($)
|
||||
|
||||
my $secToMidnight = 24*3600 -(3600*$hour + 60*$min + $sec);
|
||||
|
||||
my $setExecTime = max($now+1, $hash->{startTime});
|
||||
my $setExecTime = max($now, $hash->{startTime});
|
||||
myRemoveInternalTimer("Exec", $hash);
|
||||
myInternalTimer ("Exec", $setExecTime, "RandomTimer_Exec", $hash, 0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user