mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-20 07:16:03 +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->{LATITUDE} = $latitude;
|
||||||
$hash->{LONGITUDE} = $longitude;
|
$hash->{LONGITUDE} = $longitude;
|
||||||
$hash->{WEATHER} = $weather;
|
$hash->{WEATHER} = $weather;
|
||||||
$hash->{SUNPOS_OFFSET} = 30;
|
$hash->{SUNPOS_OFFSET} = 1;
|
||||||
|
|
||||||
Twilight_sunposTimerSet($hash);
|
Twilight_sunposTimerSet($hash);
|
||||||
myRemoveInternalTimer("Midnight", $hash);
|
myRemoveInternalTimer("Midnight", $hash);
|
||||||
@ -299,7 +299,8 @@ sub myGetHashIndirekt ($$) {
|
|||||||
################################################################################
|
################################################################################
|
||||||
sub Twilight_Midnight($) {
|
sub Twilight_Midnight($) {
|
||||||
my ($myHash) = @_;
|
my ($myHash) = @_;
|
||||||
my $hash = $myHash->{HASH};
|
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||||
|
return if (!defined($hash));
|
||||||
|
|
||||||
Twilight_TwilightTimes ($hash, "Mid");
|
Twilight_TwilightTimes ($hash, "Mid");
|
||||||
Twilight_StandardTimerSet ($hash);
|
Twilight_StandardTimerSet ($hash);
|
||||||
@ -307,7 +308,8 @@ sub Twilight_Midnight($) {
|
|||||||
################################ ################################################
|
################################ ################################################
|
||||||
sub Twilight_WeatherTimerUpdate($) {
|
sub Twilight_WeatherTimerUpdate($) {
|
||||||
my ($myHash) = @_;
|
my ($myHash) = @_;
|
||||||
my $hash = $myHash->{HASH};
|
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||||
|
return if (!defined($hash));
|
||||||
|
|
||||||
Twilight_TwilightTimes ($hash, "Wea");
|
Twilight_TwilightTimes ($hash, "Wea");
|
||||||
Twilight_StandardTimerSet ($hash);
|
Twilight_StandardTimerSet ($hash);
|
||||||
@ -347,7 +349,9 @@ sub Twilight_sunposTimerSet($) {
|
|||||||
sub Twilight_fireEvent($)
|
sub Twilight_fireEvent($)
|
||||||
{
|
{
|
||||||
my ($myHash) = @_;
|
my ($myHash) = @_;
|
||||||
my $hash = $myHash->{HASH};
|
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||||
|
return if (!defined($hash));
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $sx = $myHash->{MODIFIER};
|
my $sx = $myHash->{MODIFIER};
|
||||||
|
|
||||||
@ -452,7 +456,9 @@ sub Twilight_getWeatherHorizon($)
|
|||||||
sub Twilight_sunpos($)
|
sub Twilight_sunpos($)
|
||||||
{
|
{
|
||||||
my ($myHash) = @_;
|
my ($myHash) = @_;
|
||||||
my $hash = $myHash->{HASH};
|
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||||
|
return if (!defined($hash));
|
||||||
|
|
||||||
my $hashName = $hash->{NAME};
|
my $hashName = $hash->{NAME};
|
||||||
|
|
||||||
return "" if(AttrVal($hashName, "disable", undef));
|
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);
|
my ($dSeconds,$dMinutes,$dHours,$iDay,$iMonth,$iYear,$wday,$yday,$isdst) = gmtime(time);
|
||||||
$iMonth++;
|
$iMonth++;
|
||||||
$iYear += 100;
|
$iYear += 100;
|
||||||
$dSeconds = 0;
|
|
||||||
|
|
||||||
my $dLongitude = $hash->{LONGITUDE};
|
my $dLongitude = $hash->{LONGITUDE};
|
||||||
my $dLatitude = $hash->{LATITUDE};
|
my $dLatitude = $hash->{LATITUDE};
|
||||||
@ -477,7 +482,7 @@ sub Twilight_sunpos($)
|
|||||||
# and JD 2451545.0, which is noon 1 January 2000 Universal Time
|
# and JD 2451545.0, which is noon 1 January 2000 Universal Time
|
||||||
|
|
||||||
# Calculate time of the day in UT decimal hours
|
# 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
|
# Calculate current Julian Day
|
||||||
my $iYfrom2000=$iYear;#expects now as YY ;
|
my $iYfrom2000=$iYear;#expects now as YY ;
|
||||||
@ -530,10 +535,6 @@ sub Twilight_sunpos($)
|
|||||||
$dZenithAngle=($dZenithAngle + $dParallax) / $rad;
|
$dZenithAngle=($dZenithAngle + $dParallax) / $rad;
|
||||||
my $dElevation=90 - $dZenithAngle;
|
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;
|
my $twilight = int(($dElevation+12.0)/18.0 * 1000)/10;
|
||||||
$twilight = 100 if ($twilight>100);
|
$twilight = 100 if ($twilight>100);
|
||||||
$twilight = 0 if ($twilight< 0);
|
$twilight = 0 if ($twilight< 0);
|
||||||
@ -542,6 +543,10 @@ sub Twilight_sunpos($)
|
|||||||
$twilight_weather = 100 if ($twilight_weather>100);
|
$twilight_weather = 100 if ($twilight_weather>100);
|
||||||
$twilight_weather = 0 if ($twilight_weather< 0);
|
$twilight_weather = 0 if ($twilight_weather< 0);
|
||||||
|
|
||||||
|
# set readings
|
||||||
|
$dAzimuth = int(100*$dAzimuth )/100;
|
||||||
|
$dElevation = int(100*$dElevation)/100;
|
||||||
|
|
||||||
my $compassPoint = Twilight_CompassPoint($dAzimuth);
|
my $compassPoint = Twilight_CompassPoint($dAzimuth);
|
||||||
|
|
||||||
readingsBeginUpdate($hash);
|
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
|
} elsif ($time =~ m/^[0-2][0-9](:[0-5][0-9]){2,2}$/g) { # HH:MM:SS
|
||||||
; # ok.
|
; # ok.
|
||||||
} else {
|
} 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,41 +518,45 @@ sub isHeizung($) {
|
|||||||
|
|
||||||
my %setmodifiers =
|
my %setmodifiers =
|
||||||
("FHT" => "desired-temp",
|
("FHT" => "desired-temp",
|
||||||
#"EnOcean" => "desired-temp",
|
"PID20" => "desired",
|
||||||
"EnOcean" => { "mode" => "subType", "setModifier" => "desired-temp",
|
"EnOcean" => { "subTypeReading" => "subType", "setModifier" => "desired-temp",
|
||||||
"roomSensorControl.05" => 1,
|
"roomSensorControl.05" => 1,
|
||||||
"hvac.01" => 1 },
|
"hvac.01" => 1 },
|
||||||
"PID20" => "desired",
|
"MAX" => { "subTypeReading" => "type", "setModifier" => "desiredTemperature",
|
||||||
"MAX" => { "mode" => "type", "setModifier" => "desiredTemperature",
|
|
||||||
"HeatingThermostatPlus" => 1,
|
"HeatingThermostatPlus" => 1,
|
||||||
"HeatingThermostat" => 1,
|
"HeatingThermostat" => 1,
|
||||||
"WallMountedThermostat" => 1 },
|
"WallMountedThermostat" => 1 },
|
||||||
"CUL_HM" => { "mode" => "model","setModifier" => "desired-temp",
|
"CUL_HM" => { "subTypeReading" => "model","setModifier" => "desired-temp",
|
||||||
"HM-CC-TC" => 1,
|
"HM-CC-TC" => 1,
|
||||||
"HM-TC-IT-WM-W-EU" => 1,
|
"HM-TC-IT-WM-W-EU" => 1,
|
||||||
"HM-CC-RT-DN" => 1 } );
|
"HM-CC-RT-DN" => 1 } );
|
||||||
|
|
||||||
my $dHash = $defs{$hash->{DEVICE}}; ###
|
my $dHash = $defs{$hash->{DEVICE}}; ###
|
||||||
my $dType = $dHash->{TYPE};
|
my $dType = $dHash->{TYPE};
|
||||||
|
Log3 $hash, 5, "dType------------>$dType";
|
||||||
return "" if (!defined($dType));
|
return "" if (!defined($dType));
|
||||||
|
|
||||||
my $setModifier = $setmodifiers{$dType};
|
my $setModifier = $setmodifiers{$dType};
|
||||||
$setModifier = "" if (!defined($setModifier));
|
$setModifier = "" if (!defined($setModifier));
|
||||||
if (ref($setModifier)) {
|
if (ref($setModifier)) {
|
||||||
|
|
||||||
my $mode = $setmodifiers{$dType}{mode};
|
my $subTypeReading = $setmodifiers{$dType}{subTypeReading};
|
||||||
|
Log3 $hash, 5, "subTypeReading------------>$subTypeReading";
|
||||||
|
|
||||||
my $model;
|
my $model;
|
||||||
if ($mode eq "model" ) {
|
if ($subTypeReading eq "type" ) {
|
||||||
$model = AttrVal($hash->{DEVICE}, "model", "nF");
|
|
||||||
} elsif ($mode eq "type") {
|
|
||||||
$model = $dHash->{type};
|
$model = $dHash->{type};
|
||||||
|
} else {
|
||||||
|
$model = AttrVal($hash->{DEVICE}, $subTypeReading, "nF");
|
||||||
}
|
}
|
||||||
|
Log3 $hash, 5, "model------------>$model";
|
||||||
|
|
||||||
if (defined($setmodifiers{$dType}{$model})) {
|
if (defined($setmodifiers{$dType}{$model})) {
|
||||||
$setModifier = $setmodifiers{$dType}{setModifier}
|
$setModifier = $setmodifiers{$dType}{setModifier}
|
||||||
} else {
|
} else {
|
||||||
$setModifier = "";
|
$setModifier = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Log3 $hash, 5, "setModifier------------>$setModifier";
|
||||||
return $setModifier;
|
return $setModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ sub RandomTimer_SetTimer($)
|
|||||||
|
|
||||||
my $secToMidnight = 24*3600 -(3600*$hour + 60*$min + $sec);
|
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);
|
myRemoveInternalTimer("Exec", $hash);
|
||||||
myInternalTimer ("Exec", $setExecTime, "RandomTimer_Exec", $hash, 0);
|
myInternalTimer ("Exec", $setExecTime, "RandomTimer_Exec", $hash, 0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user