2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 13:24:56 +00:00

76_SolarForecast.pm: contrib 0.58.0

git-svn-id: https://svn.fhem.de/fhem/trunk@25979 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2022-04-18 19:14:31 +00:00
parent 158f895289
commit f9897b61c1

View File

@ -120,6 +120,7 @@ BEGIN {
# Versions History intern # Versions History intern
my %vNotesIntern = ( my %vNotesIntern = (
"0.58.0 "=> "10.04.2022 new setter consumerImmediatePlanning ",
"0.57.3 "=> "10.04.2022 some fixes (\$eavg in ___csmSpecificEpieces, useAutoCorrection switch to regex) ", "0.57.3 "=> "10.04.2022 some fixes (\$eavg in ___csmSpecificEpieces, useAutoCorrection switch to regex) ",
"0.57.2 "=> "03.04.2022 area factor for 25° added ", "0.57.2 "=> "03.04.2022 area factor for 25° added ",
"0.57.1 "=> "28.02.2022 new attr flowGraphicShowConsumerPower and flowGraphicShowConsumerRemainTime (Consumer remainTime in flowGraphic)", "0.57.1 "=> "28.02.2022 new attr flowGraphicShowConsumerPower and flowGraphicShowConsumerRemainTime (Consumer remainTime in flowGraphic)",
@ -240,39 +241,40 @@ my %vNotesIntern = (
# Voreinstellungen # Voreinstellungen
my %hset = ( # Hash der Set-Funktion my %hset = ( # Hash der Set-Funktion
currentForecastDev => { fn => \&_setcurrentForecastDev }, consumerImmediatePlanning => { fn => \&_setconsumerImmediatePlanning },
currentRadiationDev => { fn => \&_setcurrentRadiationDev }, currentForecastDev => { fn => \&_setcurrentForecastDev },
modulePeakString => { fn => \&_setmodulePeakString }, currentRadiationDev => { fn => \&_setcurrentRadiationDev },
inverterStrings => { fn => \&_setinverterStrings }, modulePeakString => { fn => \&_setmodulePeakString },
consumerAction => { fn => \&_setconsumerAction }, inverterStrings => { fn => \&_setinverterStrings },
currentInverterDev => { fn => \&_setinverterDevice }, consumerAction => { fn => \&_setconsumerAction },
currentMeterDev => { fn => \&_setmeterDevice }, currentInverterDev => { fn => \&_setinverterDevice },
currentBatteryDev => { fn => \&_setbatteryDevice }, currentMeterDev => { fn => \&_setmeterDevice },
energyH4Trigger => { fn => \&_setenergyH4Trigger }, currentBatteryDev => { fn => \&_setbatteryDevice },
plantConfiguration => { fn => \&_setplantConfiguration }, energyH4Trigger => { fn => \&_setenergyH4Trigger },
powerTrigger => { fn => \&_setpowerTrigger }, plantConfiguration => { fn => \&_setplantConfiguration },
pvCorrectionFactor_05 => { fn => \&_setpvCorrectionFactor }, powerTrigger => { fn => \&_setpowerTrigger },
pvCorrectionFactor_06 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_05 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_07 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_06 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_08 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_07 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_09 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_08 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_10 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_09 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_11 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_10 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_12 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_11 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_13 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_12 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_14 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_13 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_15 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_14 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_16 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_15 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_17 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_16 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_18 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_17 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_19 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_18 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_20 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_19 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_21 => { fn => \&_setpvCorrectionFactor }, pvCorrectionFactor_20 => { fn => \&_setpvCorrectionFactor },
pvCorrectionFactor_Auto => { fn => \&_setpvCorrectionFactorAuto }, pvCorrectionFactor_21 => { fn => \&_setpvCorrectionFactor },
reset => { fn => \&_setreset }, pvCorrectionFactor_Auto => { fn => \&_setpvCorrectionFactorAuto },
moduleTiltAngle => { fn => \&_setmoduleTiltAngle }, reset => { fn => \&_setreset },
moduleDirection => { fn => \&_setmoduleDirection }, moduleTiltAngle => { fn => \&_setmoduleTiltAngle },
writeHistory => { fn => \&_setwriteHistory }, moduleDirection => { fn => \&_setmoduleDirection },
writeHistory => { fn => \&_setwriteHistory },
); );
my %hget = ( # Hash für Get-Funktion (needcred => 1: Funktion benötigt gesetzte Credentials) my %hget = ( # Hash für Get-Funktion (needcred => 1: Funktion benötigt gesetzte Credentials)
@ -737,8 +739,8 @@ sub Set {
return if(IsDisabled($name)); return if(IsDisabled($name));
my ($setlist,@fcdevs,@cfs); my ($setlist,@fcdevs,@cfs,@condevs);
my ($fcd,$ind,$med,$cf) = ("","","",""); my ($fcd,$ind,$med,$cf,$cons) = ("","","","","noArg");
my @re = qw( ConsumerMaster my @re = qw( ConsumerMaster
consumerPlanning consumerPlanning
@ -762,7 +764,15 @@ sub Set {
} }
$cf = join " ", @cfs if(@cfs); $cf = join " ", @cfs if(@cfs);
my $type = $hash->{TYPE};
for my $c (sort{$a<=>$b} keys %{$data{$type}{$name}{consumers}}) {
push @condevs, $c if($c);
}
$cons = join ",", @condevs if(@condevs);
$setlist = "Unknown argument $opt, choose one of ". $setlist = "Unknown argument $opt, choose one of ".
"consumerImmediatePlanning:$cons ".
"currentForecastDev:$fcd ". "currentForecastDev:$fcd ".
"currentRadiationDev:$fcd ". "currentRadiationDev:$fcd ".
"currentBatteryDev:textField-long ". "currentBatteryDev:textField-long ".
@ -784,6 +794,7 @@ sub Set {
my $params = { my $params = {
hash => $hash, hash => $hash,
name => $name, name => $name,
type => $type,
opt => $opt, opt => $opt,
arg => $arg, arg => $arg,
argsref => \@args, argsref => \@args,
@ -801,6 +812,38 @@ sub Set {
return "$setlist"; return "$setlist";
} }
################################################################
# Setter consumerImmediatePlanning
################################################################
sub _setconsumerImmediatePlanning { ## no critic "not used"
my $paref = shift;
my $hash = $paref->{hash};
my $name = $paref->{name};
my $type = $paref->{type};
my $opt = $paref->{opt};
my $c = $paref->{arg};
return qq{no consumer number specified} if(!$c);
return qq{no valid consumer id "$c"} if(!ConsumerVal ($hash, $c, "name", ""));
my $startts = time;
my (undef,undef,undef,$starttime) = timestampToTimestring ($startts);
my $mintime = ConsumerVal ($hash, $c, "mintime", $defmintime);
my $stopdiff = ceil ($mintime * 60);
my $stopts = $startts + $stopdiff;
my (undef,undef,undef,$stoptime) = timestampToTimestring ($stopts);
$data{$type}{$name}{consumers}{$c}{planstate} = "planned: ".$starttime." - ".$stoptime;
$data{$type}{$name}{consumers}{$c}{planswitchon} = $startts; # Unix Timestamp für geplanten Switch on
$data{$type}{$name}{consumers}{$c}{planswitchoff} = $stopts; # Unix Timestamp für geplanten Switch off
_getdata ($paref);
return;
}
################################################################ ################################################################
# Setter currentForecastDev # Setter currentForecastDev
################################################################ ################################################################
@ -1427,8 +1470,6 @@ sub _setconsumerAction { ## no critic "not used"
Log3($name, 4, qq{$name - Consumer Action received / executed: "$action $cname $tail"}); Log3($name, 4, qq{$name - Consumer Action received / executed: "$action $cname $tail"});
centralTask ($hash); centralTask ($hash);
# RemoveInternalTimer($hash, "FHEM::SolarForecast::centralTask");
# InternalTimer (gettimeofday()+0.5, "FHEM::SolarForecast::centralTask", $hash, 0);
return; return;
} }
@ -3212,12 +3253,12 @@ sub ___switchonTimelimits {
if($notbefore && int $starthour < int $notbefore) { if($notbefore && int $starthour < int $notbefore) {
$starthour = $notbefore; $starthour = $notbefore;
$change = "notbefore"; $change = "notbefore";
} }
if($notafter && int $starthour > int $notafter) { if($notafter && int $starthour > int $notafter) {
$starthour = $notafter; $starthour = $notafter;
$change = "notafter"; $change = "notafter";
} }
$starthour = sprintf("%02d", $starthour); $starthour = sprintf("%02d", $starthour);
@ -4521,12 +4562,13 @@ sub _showConsumerInGraphicBeam {
my @consumers = sort{$a<=>$b} keys %{$data{$type}{$name}{consumers}}; # definierte Verbraucher ermitteln my @consumers = sort{$a<=>$b} keys %{$data{$type}{$name}{consumers}}; # definierte Verbraucher ermitteln
for (@consumers) { for (@consumers) {
next if(!$_);
my ($itemName, undef) = split(':',$_); my ($itemName, undef) = split(':',$_);
$itemName =~ s/^\s+|\s+$//gx; # trim it, if blanks were used $itemName =~ s/^\s+|\s+$//gx; # trim it, if blanks were used
$_ =~ s/^\s+|\s+$//gx; # trim it, if blanks were used $_ =~ s/^\s+|\s+$//gx; # trim it, if blanks were used
#check if listed device is planned # check if listed device is planned
################################## ####################################
if (ReadingsVal($name, $itemName."_Planned", "no") eq "yes") { if (ReadingsVal($name, $itemName."_Planned", "no") eq "yes") {
#get start and end hour #get start and end hour
my ($start, $end); # werden auf Balken Pos 0 - 23 umgerechnet, nicht auf Stunde !!, Pos = 24 -> ungültige Pos = keine Anzeige my ($start, $end); # werden auf Balken Pos 0 - 23 umgerechnet, nicht auf Stunde !!, Pos = 24 -> ungültige Pos = keine Anzeige
@ -4636,7 +4678,7 @@ sub _graphicConsumerLegend {
my $offcom = ConsumerVal ($hash, $c, "offcom", ""); # Consumer Ausschaltkommando my $offcom = ConsumerVal ($hash, $c, "offcom", ""); # Consumer Ausschaltkommando
my $autord = ConsumerVal ($hash, $c, "autoreading", ""); # Readingname f. Automatiksteuerung my $autord = ConsumerVal ($hash, $c, "autoreading", ""); # Readingname f. Automatiksteuerung
my $auto = ConsumerVal ($hash, $c, "auto", 1); # Automatic Mode my $auto = ConsumerVal ($hash, $c, "auto", 1); # Automatic Mode
my $iscrecomm = ConsumerVal ($hash, $c, "isConsumptionRecommended", 0); # ist einschalten Vervracher empfohlen my $iscrecomm = ConsumerVal ($hash, $c, "isConsumptionRecommended", 0); # ist einschalten Verbraucher empfohlen
my $cmdon = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name consumerAction set $cname $oncom')"}; my $cmdon = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name consumerAction set $cname $oncom')"};
my $cmdoff = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name consumerAction set $cname $offcom')"}; my $cmdoff = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name consumerAction set $cname $offcom')"};
@ -7252,6 +7294,23 @@ Ein/Ausschaltzeiten sowie deren Ausführung vom SolarForecast Modul übernehmen
<b>Set</b> <b>Set</b>
<ul> <ul>
<ul>
<a id="SolarForecast-set-consumerImmediatePlanning"></a>
<li><b>consumerImmediatePlanning &lt;Verbrauchernummer&gt; </b> <br><br>
Es wird das sofortige Einschalten des Verbrauchers zur aktuellen Zeit eingeplant.
Eventuell im consumerXX Attribut gesetzte Schlüssel <b>notbefore</b>, <b>notafter</b> bzw. <b>mode</b> werden nicht
beachtet. <br>
<br>
<ul>
<b>Beispiel: </b> <br>
set &lt;name&gt; consumerImmediatePlanning 01 <br>
</ul>
</li>
</ul>
<br>
<ul> <ul>
<a id="SolarForecast-set-currentBatteryDev"></a> <a id="SolarForecast-set-currentBatteryDev"></a>
<li><b>currentBatteryDev &lt;Meter Device Name&gt; pin=&lt;Readingname&gt;:&lt;Einheit&gt; pout=&lt;Readingname&gt;:&lt;Einheit&gt; [intotal=&lt;Readingname&gt;:&lt;Einheit&gt;] [outtotal=&lt;Readingname&gt;:&lt;Einheit&gt;] [charge=&lt;Readingname&gt;] </b> <br><br> <li><b>currentBatteryDev &lt;Meter Device Name&gt; pin=&lt;Readingname&gt;:&lt;Einheit&gt; pout=&lt;Readingname&gt;:&lt;Einheit&gt; [intotal=&lt;Readingname&gt;:&lt;Einheit&gt;] [outtotal=&lt;Readingname&gt;:&lt;Einheit&gt;] [charge=&lt;Readingname&gt;] </b> <br><br>