mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
76_SolarForecast.pm: contrib 0.63.1
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@26068 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8e44b63ac8
commit
f615cb2288
@ -849,7 +849,7 @@ sub _setconsumerImmediatePlanning { ## no critic "not used"
|
|||||||
$paref->{startts} = $startts; # Unix Timestamp für geplanten Switch on
|
$paref->{startts} = $startts; # Unix Timestamp für geplanten Switch on
|
||||||
$paref->{stopts} = $stopts; # Unix Timestamp für geplanten Switch off
|
$paref->{stopts} = $stopts; # Unix Timestamp für geplanten Switch off
|
||||||
|
|
||||||
___setPlanningState ($paref);
|
___setConsumerPlanningState ($paref);
|
||||||
|
|
||||||
my $planstate = ConsumerVal ($hash, $c, "planstate", "");
|
my $planstate = ConsumerVal ($hash, $c, "planstate", "");
|
||||||
my $calias = ConsumerVal ($hash, $c, "alias", "");
|
my $calias = ConsumerVal ($hash, $c, "alias", "");
|
||||||
@ -2900,8 +2900,8 @@ sub _manageConsumerData {
|
|||||||
__planSwitchTimes ($paref); # Consumer Switch Zeiten planen
|
__planSwitchTimes ($paref); # Consumer Switch Zeiten planen
|
||||||
__switchConsumer ($paref); # Consumer schalten
|
__switchConsumer ($paref); # Consumer schalten
|
||||||
|
|
||||||
## Consumer Schaltstatus und Schaltzeit ermitteln
|
## Consumer Schaltstatus und Schaltzeit für Readings ermitteln
|
||||||
###################################################
|
################################################################
|
||||||
# my $rswstate = ConsumerVal ($hash, $c, "rswstate", "state"); # Reading mit Schaltstatus
|
# my $rswstate = ConsumerVal ($hash, $c, "rswstate", "state"); # Reading mit Schaltstatus
|
||||||
# my $costate = ReadingsVal ($consumer, $rswstate, ""); # Schaltstatus
|
# my $costate = ReadingsVal ($consumer, $rswstate, ""); # Schaltstatus
|
||||||
my $costate = isConsumerOn ($hash, $c) ? "on" :
|
my $costate = isConsumerOn ($hash, $c) ? "on" :
|
||||||
@ -3196,7 +3196,7 @@ sub __planSwitchTimes {
|
|||||||
$paref->{startts} = $startts;
|
$paref->{startts} = $startts;
|
||||||
$paref->{stopts} = $startts + $stopdiff;
|
$paref->{stopts} = $startts + $stopdiff;
|
||||||
|
|
||||||
___setPlanningState ($paref);
|
___setConsumerPlanningState ($paref);
|
||||||
|
|
||||||
delete $paref->{ps};
|
delete $paref->{ps};
|
||||||
delete $paref->{startts};
|
delete $paref->{startts};
|
||||||
@ -3207,7 +3207,7 @@ sub __planSwitchTimes {
|
|||||||
else {
|
else {
|
||||||
$paref->{ps} = "no planning: the max expected surplus is less $epiece1";
|
$paref->{ps} = "no planning: the max expected surplus is less $epiece1";
|
||||||
|
|
||||||
___setPlanningState ($paref);
|
___setConsumerPlanningState ($paref);
|
||||||
|
|
||||||
delete $paref->{ps};
|
delete $paref->{ps};
|
||||||
}
|
}
|
||||||
@ -3245,9 +3245,9 @@ return;
|
|||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Planungsdaten setzen
|
# Planungsdaten bzw. aktuelle Schaltzustände setzen
|
||||||
################################################################
|
################################################################
|
||||||
sub ___setPlanningState {
|
sub ___setConsumerPlanningState {
|
||||||
my $paref = shift;
|
my $paref = shift;
|
||||||
my $hash = $paref->{hash};
|
my $hash = $paref->{hash};
|
||||||
my $c = $paref->{consumer};
|
my $c = $paref->{consumer};
|
||||||
@ -3270,6 +3270,17 @@ sub ___setPlanningState {
|
|||||||
$data{$type}{$name}{consumers}{$c}{planswitchoff} = $stopts;
|
$data{$type}{$name}{consumers}{$c}{planswitchoff} = $stopts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#my $pstate = simplifyCstate ($ps);
|
||||||
|
#my $swtime = "";
|
||||||
|
#if ($pstate eq "started") {
|
||||||
|
# ($swtime, $startts) = lastConsumerSwitchtime ($hash, $c);
|
||||||
|
# Log3 ($hash->{NAME}, 1, "$hash->{NAME} - $c, swtime: $swtime, startts: $startts");
|
||||||
|
#}
|
||||||
|
#elsif ($pstate eq "finished") {
|
||||||
|
# ($swtime, $stopts) = lastConsumerSwitchtime ($hash, $c);
|
||||||
|
# Log3 ($hash->{NAME}, 1, "$hash->{NAME} - $c, swtime: $swtime, stopts:$stopts ");
|
||||||
|
#}
|
||||||
|
|
||||||
$ps .= " " if ($starttime || $stoptime);
|
$ps .= " " if ($starttime || $stoptime);
|
||||||
$ps .= $starttime if ($starttime);
|
$ps .= $starttime if ($starttime);
|
||||||
$ps .= $stoptime if (!$starttime && $stoptime);
|
$ps .= $stoptime if (!$starttime && $stoptime);
|
||||||
@ -3311,7 +3322,7 @@ sub ___planMust {
|
|||||||
$paref->{startts} = $startts; # Unix Timestamp für geplanten Switch on
|
$paref->{startts} = $startts; # Unix Timestamp für geplanten Switch on
|
||||||
$paref->{stopts} = $stopts; # Unix Timestamp für geplanten Switch off
|
$paref->{stopts} = $stopts; # Unix Timestamp für geplanten Switch off
|
||||||
|
|
||||||
___setPlanningState ($paref);
|
___setConsumerPlanningState ($paref);
|
||||||
|
|
||||||
delete $paref->{ps};
|
delete $paref->{ps};
|
||||||
delete $paref->{startts};
|
delete $paref->{startts};
|
||||||
@ -3447,7 +3458,7 @@ sub ___switchConsumerOn {
|
|||||||
if ($mode eq "can" && !$enable) { # Batterieladung - keine Verbraucher "Einschalten" Freigabe
|
if ($mode eq "can" && !$enable) { # Batterieladung - keine Verbraucher "Einschalten" Freigabe
|
||||||
$paref->{ps} = "priority charging battery";
|
$paref->{ps} = "priority charging battery";
|
||||||
|
|
||||||
___setPlanningState ($paref);
|
___setConsumerPlanningState ($paref);
|
||||||
|
|
||||||
delete $paref->{ps};
|
delete $paref->{ps};
|
||||||
}
|
}
|
||||||
@ -3459,7 +3470,7 @@ sub ___switchConsumerOn {
|
|||||||
$paref->{startts} = $t;
|
$paref->{startts} = $t;
|
||||||
$paref->{stopts} = $t + $stopdiff;
|
$paref->{stopts} = $t + $stopdiff;
|
||||||
|
|
||||||
___setPlanningState ($paref);
|
___setConsumerPlanningState ($paref);
|
||||||
|
|
||||||
delete $paref->{ps};
|
delete $paref->{ps};
|
||||||
delete $paref->{startts};
|
delete $paref->{startts};
|
||||||
@ -3513,7 +3524,7 @@ sub ___switchConsumerOff {
|
|||||||
$paref->{ps} = "switched off:";
|
$paref->{ps} = "switched off:";
|
||||||
$paref->{stopts} = $t;
|
$paref->{stopts} = $t;
|
||||||
|
|
||||||
___setPlanningState ($paref);
|
___setConsumerPlanningState ($paref);
|
||||||
|
|
||||||
delete $paref->{ps};
|
delete $paref->{ps};
|
||||||
delete $paref->{stopts};
|
delete $paref->{stopts};
|
||||||
@ -3559,29 +3570,12 @@ sub __getPlanningStateAndTimes {
|
|||||||
my $hash = $paref->{hash};
|
my $hash = $paref->{hash};
|
||||||
my $c = $paref->{consumer};
|
my $c = $paref->{consumer};
|
||||||
|
|
||||||
my $pstate = ConsumerVal ($hash, $c, "planstate", "");
|
my $pstate = ConsumerVal ($hash, $c, "planstate", "");
|
||||||
|
$pstate = simplifyCstate ($pstate);
|
||||||
$pstate = $pstate =~ /planned/xs ? "planned" :
|
|
||||||
$pstate =~ /switching\son/xs ? "starting" :
|
|
||||||
$pstate =~ /switched\son/xs ? "started" :
|
|
||||||
$pstate =~ /switching\soff/xs ? "stopping" :
|
|
||||||
$pstate =~ /switched\soff/xs ? "finished" :
|
|
||||||
$pstate =~ /priority/xs ? $pstate :
|
|
||||||
"unknown";
|
|
||||||
|
|
||||||
my $startts = ConsumerVal ($hash, $c, "planswitchon", "");
|
my $startts = ConsumerVal ($hash, $c, "planswitchon", "");
|
||||||
my $stopts = ConsumerVal ($hash, $c, "planswitchoff", "");
|
my $stopts = ConsumerVal ($hash, $c, "planswitchoff", "");
|
||||||
|
|
||||||
#my $swtime = "";
|
|
||||||
#if ($pstate eq "started") {
|
|
||||||
# ($swtime, $startts) = lastConsumerSwitchtime ($hash, $c);
|
|
||||||
# Log3 ($hash->{NAME}, 1, "$hash->{NAME} - $c, swtime: $swtime, startts: $startts");
|
|
||||||
#}
|
|
||||||
#elsif ($pstate eq "finished") {
|
|
||||||
# ($swtime, $stopts) = lastConsumerSwitchtime ($hash, $c);
|
|
||||||
# Log3 ($hash->{NAME}, 1, "$hash->{NAME} - $c, swtime: $swtime, stopts:$stopts ");
|
|
||||||
#}
|
|
||||||
|
|
||||||
my $starttime = '';
|
my $starttime = '';
|
||||||
my $stoptime = '';
|
my $stoptime = '';
|
||||||
$starttime = timestampToTimestring ($startts) if($startts);
|
$starttime = timestampToTimestring ($startts) if($startts);
|
||||||
@ -7358,6 +7352,24 @@ sub isAddSwitchOffCond {
|
|||||||
return (0, $info, $err);
|
return (0, $info, $err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# transformiert den ausführlichen Consumerstatus in eine
|
||||||
|
# einfache Form
|
||||||
|
################################################################
|
||||||
|
sub simplifyCstate {
|
||||||
|
my $ps = shift;
|
||||||
|
|
||||||
|
$ps = $ps =~ /planned/xs ? "planned" :
|
||||||
|
$ps =~ /switching\son/xs ? "starting" :
|
||||||
|
$ps =~ /switched\son/xs ? "started" :
|
||||||
|
$ps =~ /switching\soff/xs ? "stopping" :
|
||||||
|
$ps =~ /switched\soff/xs ? "finished" :
|
||||||
|
$ps =~ /priority/xs ? $ps :
|
||||||
|
"unknown";
|
||||||
|
|
||||||
|
return $ps;
|
||||||
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Wert des pvhist-Hash zurückliefern
|
# Wert des pvhist-Hash zurückliefern
|
||||||
# Usage:
|
# Usage:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user