mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-23 20:52:13 +00:00
76_SolarForecast.pm: contrib 0.62.0
git-svn-id: https://svn.fhem.de/fhem/trunk@26051 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
0d89fcc733
commit
50fcb2e91c
@ -120,6 +120,7 @@ BEGIN {
|
|||||||
|
|
||||||
# Versions History intern
|
# Versions History intern
|
||||||
my %vNotesIntern = (
|
my %vNotesIntern = (
|
||||||
|
"0.62.0 "=> "16.05.2022 new key 'swoffcond' in consumer attributes ",
|
||||||
"0.61.0 "=> "15.05.2022 limit PV forecast to inverter capacity ",
|
"0.61.0 "=> "15.05.2022 limit PV forecast to inverter capacity ",
|
||||||
"0.60.1 "=> "15.05.2022 consumerHash -> new key avgruntime, don't modify mintime by avgruntime by default anymore ".
|
"0.60.1 "=> "15.05.2022 consumerHash -> new key avgruntime, don't modify mintime by avgruntime by default anymore ".
|
||||||
"debug switch conditions ",
|
"debug switch conditions ",
|
||||||
@ -3371,6 +3372,8 @@ sub __switchConsumer {
|
|||||||
my $calias = ConsumerVal ($hash, $c, "alias", ""); # Consumer Device Alias
|
my $calias = ConsumerVal ($hash, $c, "alias", ""); # Consumer Device Alias
|
||||||
my $debug = AttrVal ($name, "debug", 0);
|
my $debug = AttrVal ($name, "debug", 0);
|
||||||
|
|
||||||
|
my ($swoncond,$swoffcond,$info,$err);
|
||||||
|
|
||||||
## Ist Verbraucher empfohlen ?
|
## Ist Verbraucher empfohlen ?
|
||||||
################################
|
################################
|
||||||
if ($startts && $t >= $startts && $stopts && $t <= $stopts) {
|
if ($startts && $t >= $startts && $stopts && $t <= $stopts) {
|
||||||
@ -3384,7 +3387,7 @@ sub __switchConsumer {
|
|||||||
############################
|
############################
|
||||||
my $oncom = ConsumerVal ($hash, $c, "oncom", ""); # Set Command für "on"
|
my $oncom = ConsumerVal ($hash, $c, "oncom", ""); # Set Command für "on"
|
||||||
my $auto = ConsumerVal ($hash, $c, "auto", 1);
|
my $auto = ConsumerVal ($hash, $c, "auto", 1);
|
||||||
my ($swoncond,$info,$err) = isAddSwitchOnCond ($hash, $c); # zusätzliche Switch on Bedingung
|
($swoncond,$info,$err) = isAddSwitchOnCond ($hash, $c); # zusätzliche Switch on Bedingung
|
||||||
|
|
||||||
Log3 ($name, 1, "$name - $err") if($err);
|
Log3 ($name, 1, "$name - $err") if($err);
|
||||||
|
|
||||||
@ -3437,16 +3440,19 @@ sub __switchConsumer {
|
|||||||
## Verbraucher ausschalten
|
## Verbraucher ausschalten
|
||||||
############################
|
############################
|
||||||
my $offcom = ConsumerVal ($hash, $c, "offcom", ""); # Set Command für "off"
|
my $offcom = ConsumerVal ($hash, $c, "offcom", ""); # Set Command für "off"
|
||||||
|
($swoffcond,$info,$err) = isAddSwitchOffCond ($hash, $c); # zusätzliche Switch on Bedingung
|
||||||
|
|
||||||
|
Log3 ($name, 1, "$name - $err") if($err);
|
||||||
|
|
||||||
if($debug) { # nur für Debugging
|
if($debug) { # nur für Debugging
|
||||||
Log (1, qq{DEBUG> $name - Parameters for switch off decision consumer "$c": }.
|
Log (1, qq{DEBUG> $name - Parameters for switch off decision consumer "$c": }.
|
||||||
qq{auto mode: $auto, off-command: $offcom, }.
|
qq{swoffcond: $swoffcond, auto mode: $auto, off-command: $offcom, }.
|
||||||
qq{planning state: $pstate, stop timestamp: }.($stopts ? $stopts : "undef").", ".
|
qq{planning state: $pstate, stop timestamp: }.($stopts ? $stopts : "undef").", ".
|
||||||
qq{timestamp: $t}
|
qq{timestamp: $t}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($auto && $offcom && $pstate !~ /switched\soff/xs && $stopts && $t >= $stopts) { # Verbraucher nicht switched off && Stopzeit überschritten
|
if(($swoffcond || ($stopts && $t >= $stopts)) && ($auto && $offcom && $pstate !~ /switched\soff/xs)) {
|
||||||
CommandSet(undef,"$cname $offcom");
|
CommandSet(undef,"$cname $offcom");
|
||||||
|
|
||||||
$paref->{ps} = "switched off:";
|
$paref->{ps} = "switched off:";
|
||||||
@ -4178,6 +4184,11 @@ sub collectAllRegConsumers {
|
|||||||
($dswoncond,$rswoncond,$swoncondregex) = split ":", $hc->{swoncond};
|
($dswoncond,$rswoncond,$swoncondregex) = split ":", $hc->{swoncond};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my ($dswoffcond,$rswoffcond,$swoffcondregex);
|
||||||
|
if(exists $hc->{swoffcond}) { # vorrangige Ausschaltbedingung
|
||||||
|
($dswoffcond,$rswoffcond,$swoffcondregex) = split ":", $hc->{swoffcond};
|
||||||
|
}
|
||||||
|
|
||||||
my $rauto = $hc->{auto} // q{};
|
my $rauto = $hc->{auto} // q{};
|
||||||
my $ctype = $hc->{type} // $defctype;
|
my $ctype = $hc->{type} // $defctype;
|
||||||
my $hours = ($hc->{mintime} // $hef{$ctype}{mt}) / 60;
|
my $hours = ($hc->{mintime} // $hef{$ctype}{mt}) / 60;
|
||||||
@ -4210,6 +4221,9 @@ sub collectAllRegConsumers {
|
|||||||
$data{$type}{$name}{consumers}{$c}{dswoncond} = $dswoncond // q{}; # Device zur Lieferung einer zusätzliche Einschaltbedingung
|
$data{$type}{$name}{consumers}{$c}{dswoncond} = $dswoncond // q{}; # Device zur Lieferung einer zusätzliche Einschaltbedingung
|
||||||
$data{$type}{$name}{consumers}{$c}{rswoncond} = $rswoncond // q{}; # Reading zur Lieferung einer zusätzliche Einschaltbedingung
|
$data{$type}{$name}{consumers}{$c}{rswoncond} = $rswoncond // q{}; # Reading zur Lieferung einer zusätzliche Einschaltbedingung
|
||||||
$data{$type}{$name}{consumers}{$c}{swoncondregex} = $swoncondregex // q{}; # Regex einer zusätzliche Einschaltbedingung
|
$data{$type}{$name}{consumers}{$c}{swoncondregex} = $swoncondregex // q{}; # Regex einer zusätzliche Einschaltbedingung
|
||||||
|
$data{$type}{$name}{consumers}{$c}{dswoffcond} = $dswoffcond // q{}; # Device zur Lieferung einer vorrangigen Ausschaltbedingung
|
||||||
|
$data{$type}{$name}{consumers}{$c}{rswoffcond} = $rswoffcond // q{}; # Reading zur Lieferung einer vorrangigen Ausschaltbedingung
|
||||||
|
$data{$type}{$name}{consumers}{$c}{swoffcondregex} = $swoffcondregex // q{}; # Regex einer vorrangigen Ausschaltbedingung
|
||||||
}
|
}
|
||||||
|
|
||||||
Log3 ($name, 5, "$name - all registered consumers:\n".Dumper $data{$type}{$name}{consumers});
|
Log3 ($name, 5, "$name - all registered consumers:\n".Dumper $data{$type}{$name}{consumers});
|
||||||
@ -7184,8 +7198,8 @@ return;
|
|||||||
# Funktion liefert "1" wenn die zusätzliche Einschaltbedingung
|
# Funktion liefert "1" wenn die zusätzliche Einschaltbedingung
|
||||||
# aus dem Schlüssel "swoncond" im Consumer Attribut wahr ist
|
# aus dem Schlüssel "swoncond" im Consumer Attribut wahr ist
|
||||||
#
|
#
|
||||||
#
|
# $info - den Info-Status
|
||||||
#
|
# $err - einen Error-Status
|
||||||
#
|
#
|
||||||
################################################################
|
################################################################
|
||||||
sub isAddSwitchOnCond {
|
sub isAddSwitchOnCond {
|
||||||
@ -7215,6 +7229,41 @@ sub isAddSwitchOnCond {
|
|||||||
return (0, $info, $err);
|
return (0, $info, $err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# Funktion liefert "1" wenn die vorrangige Ausschaltbedingung
|
||||||
|
# aus dem Schlüssel "swoffcond" im Consumer Attribut wahr ist
|
||||||
|
#
|
||||||
|
# $info - den Info-Status
|
||||||
|
# $err - einen Error-Status
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
sub isAddSwitchOffCond {
|
||||||
|
my $hash = shift;
|
||||||
|
my $c = shift;
|
||||||
|
|
||||||
|
my $info = q{};
|
||||||
|
my $err = q{};
|
||||||
|
|
||||||
|
my $dswoffcond = ConsumerVal ($hash, $c, "dswoffcond", ""); # Device zur Lieferung einer vorrangigen Ausschaltbedingung
|
||||||
|
|
||||||
|
if($dswoffcond && !$defs{$dswoffcond}) {
|
||||||
|
$err = qq{ERROR - the device "$dswoffcond" doesn't exist! Check the key "swoffcond" in attribute "consumer${c}"};
|
||||||
|
return (0, $info, $err);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $rswoffcond = ConsumerVal ($hash, $c, "rswoffcond", ""); # Reading zur Lieferung einer vorrangigen Ausschaltbedingung
|
||||||
|
my $swoffcondregex = ConsumerVal ($hash, $c, "swoffcondregex", ""); # Regex einer vorrangigen Ausschaltbedingung
|
||||||
|
my $condstate = ReadingsVal ($dswoffcond, $rswoffcond, "");
|
||||||
|
|
||||||
|
if ($condstate =~ m/^$swoffcondregex$/x) {
|
||||||
|
return (1, $info, $err);
|
||||||
|
}
|
||||||
|
|
||||||
|
$info = qq{The device "$dswoffcond", reading "$rswoffcond" doen't match the Regex "$swoffcondregex"};
|
||||||
|
|
||||||
|
return (0, $info, $err);
|
||||||
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Wert des pvhist-Hash zurückliefern
|
# Wert des pvhist-Hash zurückliefern
|
||||||
# Usage:
|
# Usage:
|
||||||
@ -7450,6 +7499,9 @@ return $def;
|
|||||||
# dswoncond - Device zur Lieferung einer zusätzliche Einschaltbedingung
|
# dswoncond - Device zur Lieferung einer zusätzliche Einschaltbedingung
|
||||||
# rswoncond - Reading zur Lieferung einer zusätzliche Einschaltbedingung
|
# rswoncond - Reading zur Lieferung einer zusätzliche Einschaltbedingung
|
||||||
# swoncondregex - Regex einer zusätzliche Einschaltbedingung
|
# swoncondregex - Regex einer zusätzliche Einschaltbedingung
|
||||||
|
# dswoffcond - Device zur Lieferung einer vorrangige Ausschaltbedingung
|
||||||
|
# rswoffcond - Reading zur Lieferung einer vorrangige Ausschaltbedingung
|
||||||
|
# swoffcondregex - Regex einer einer vorrangige Ausschaltbedingung
|
||||||
#
|
#
|
||||||
# $def: Defaultwert
|
# $def: Defaultwert
|
||||||
#
|
#
|
||||||
@ -8215,17 +8267,27 @@ Ein/Ausschaltzeiten sowie deren Ausführung vom SolarForecast Modul übernehmen
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a id="SolarForecast-attr-consumer" data-pattern="consumer.*"></a>
|
<a id="SolarForecast-attr-consumer" data-pattern="consumer.*"></a>
|
||||||
<li><b>consumerXX <Device Name> type=<type> power=<power> [mode=<mode>] [icon=<Icon>] [mintime=<minutes>] [on=<Kommando>] [off=<Kommando>] [swstate=<Readingname>:<on-Regex>:<off-Regex>] [notbefore=<Stunde>] [notafter=<Stunde>] [auto=<Readingname>] [pcurr=<Readingname>:<Einheit>] [etotal=<Readingname>:<Einheit>[:<Schwellenwert>]] [swoncond=<Device>:<Reading>:<Regex>] </b><br><br>
|
<li><b>consumerXX <Device Name> type=<type> power=<power> [mode=<mode>] [icon=<Icon>] [mintime=<minutes>] <br>
|
||||||
|
[on=<Kommando>] [off=<Kommando>] [swstate=<Readingname>:<on-Regex>:<off-Regex>] [notbefore=<Stunde>] [notafter=<Stunde>] <br>
|
||||||
|
[auto=<Readingname>] [pcurr=<Readingname>:<Einheit>] [etotal=<Readingname>:<Einheit>[:<Schwellenwert>]] <br>
|
||||||
|
[swoncond=<Device>:<Reading>:<Regex>] [swoffcond=<Device>:<Reading>:<Regex>]</b><br><br>
|
||||||
|
|
||||||
Registriert einen Verbraucher <Device Name> beim SolarForecast Device. Dabei ist <Device Name>
|
Registriert einen Verbraucher <Device Name> beim SolarForecast Device. Dabei ist <Device Name>
|
||||||
ein in FHEM bereits angelegtes Verbraucher Device, z.B. eine Schaltsteckdose. Die meisten Schlüssel sind optional,
|
ein in FHEM bereits angelegtes Verbraucher Device, z.B. eine Schaltsteckdose. Die meisten Schlüssel sind optional,
|
||||||
sind aber für bestimmte Funktionalitäten Voraussetzung und werden mit default-Werten besetzt. <br>
|
sind aber für bestimmte Funktionalitäten Voraussetzung und werden mit default-Werten besetzt. <br>
|
||||||
Ist der Schüssel "auto" definiert, kann der Automatikmodus in der integrierten Verbrauchergrafik mit den
|
Ist der Schüssel "auto" definiert, kann der Automatikmodus in der integrierten Verbrauchergrafik mit den
|
||||||
entsprechenden Drucktasten umgeschaltet werden. Das angegebene Reading wird ggf. im Consumer Device angelegt falls
|
entsprechenden Drucktasten umgeschaltet werden. Das angegebene Reading wird ggf. im Consumer Device angelegt falls
|
||||||
es nicht vorhanden ist. <br>
|
es nicht vorhanden ist. <br><br>
|
||||||
|
|
||||||
Mit dem optionalen Schlüssel <b>swoncond</b> kann eine <b>zusätzliche externe Bedingung</b> definiert werden um den Einschaltvorgang des
|
Mit dem optionalen Schlüssel <b>swoncond</b> kann eine <b>zusätzliche externe Bedingung</b> definiert werden um den Einschaltvorgang des
|
||||||
Consumers freizugeben. Ist die Bedingung (Regex) nicht erfüllt, erfolgt kein Einschalten des Verbrauchers auch wenn die
|
Consumers freizugeben. Ist die Bedingung (Regex) nicht erfüllt, erfolgt kein Einschalten des Verbrauchers auch wenn die
|
||||||
sonstigen Voraussetzungen wie Zeitplanung, mode, vorhandene PV-Leistung usw. gegeben sind.
|
sonstigen Voraussetzungen wie Zeitplanung, on-Schlüssel, auto-Mode und aktuelle PV-Leistung gegeben sind. Es erfolgt somit eine
|
||||||
|
<b>UND-Verknüpfung</b> des Schlüssels swoncond mit den weiteren Einschaltbedingungen. <br><br>
|
||||||
|
|
||||||
|
Der optionale Schlüssel <b>swoffcond</b> definiert eine <b>vorrangige Ausschaltbedingung</b> (Regex). Sobald diese
|
||||||
|
Bedingung erfüllt ist, wird der Consumer ausgeschaltet auch wenn die geplante Endezeit (consumerXX_planned_stop)
|
||||||
|
noch nicht erreicht ist (<b>ODER-Verknüpfung</b>). Weitere Bedingungen wie off-Schlüssel und auto-Mode müssen
|
||||||
|
zum automatischen Ausschalten erfüllt sein.
|
||||||
<br><br>
|
<br><br>
|
||||||
<ul>
|
<ul>
|
||||||
<table>
|
<table>
|
||||||
@ -8258,6 +8320,10 @@ Ein/Ausschaltzeiten sowie deren Ausführung vom SolarForecast Modul übernehmen
|
|||||||
<tr><td> </td><td><b>Device</b> - Device zur Lieferung der zusätzlichen Einschaltbedingung </td></tr>
|
<tr><td> </td><td><b>Device</b> - Device zur Lieferung der zusätzlichen Einschaltbedingung </td></tr>
|
||||||
<tr><td> </td><td><b>Reading</b> - Reading zur Lieferung der zusätzlichen Einschaltbedingung </td></tr>
|
<tr><td> </td><td><b>Reading</b> - Reading zur Lieferung der zusätzlichen Einschaltbedingung </td></tr>
|
||||||
<tr><td> </td><td><b>Regex</b> - regulärer Ausdruck der für die Einschaltbedingung erfüllt sein muß </td></tr>
|
<tr><td> </td><td><b>Regex</b> - regulärer Ausdruck der für die Einschaltbedingung erfüllt sein muß </td></tr>
|
||||||
|
<tr><td> <b>swoffcond</b> </td><td>vorrangige Bedingung um den Verbraucher auszuschalten (optional). </td></tr>
|
||||||
|
<tr><td> </td><td><b>Device</b> - Device zur Lieferung der vorrangigen Ausschaltbedingung </td></tr>
|
||||||
|
<tr><td> </td><td><b>Reading</b> - Reading zur Lieferung der vorrangigen Ausschaltbedingung </td></tr>
|
||||||
|
<tr><td> </td><td><b>Regex</b> - regulärer Ausdruck der für die Ausschaltbedingung erfüllt sein muß </td></tr>
|
||||||
</table>
|
</table>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user