mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
76_SolarForecast: reduce cpu utilization
git-svn-id: https://svn.fhem.de/fhem/trunk@28468 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
39326a0808
commit
7bebc27d25
@ -157,6 +157,7 @@ BEGIN {
|
|||||||
|
|
||||||
# Versions History intern
|
# Versions History intern
|
||||||
my %vNotesIntern = (
|
my %vNotesIntern = (
|
||||||
|
"1.15.0" => "03.02.2024 reduce cpu utilization ",
|
||||||
"1.14.3" => "02.02.2024 _transferWeatherValues: first step of multi weather device merger ",
|
"1.14.3" => "02.02.2024 _transferWeatherValues: first step of multi weather device merger ",
|
||||||
"1.14.2" => "02.02.2024 fix warning, _transferAPIRadiationValues: Consider upper and lower deviation limit AI to API forecast ",
|
"1.14.2" => "02.02.2024 fix warning, _transferAPIRadiationValues: Consider upper and lower deviation limit AI to API forecast ",
|
||||||
"1.14.1" => "01.02.2024 language support for ___setConsumerPlanningState -> supplement, fix setting 'swoncond not met' ",
|
"1.14.1" => "01.02.2024 language support for ___setConsumerPlanningState -> supplement, fix setting 'swoncond not met' ",
|
||||||
@ -555,8 +556,8 @@ my %hqtxt = (
|
|||||||
DE => qq{swoncond erfüllt} },
|
DE => qq{swoncond erfüllt} },
|
||||||
swofmt => { EN => qq{swoffcond met},
|
swofmt => { EN => qq{swoffcond met},
|
||||||
DE => qq{swoffcond erfüllt} },
|
DE => qq{swoffcond erfüllt} },
|
||||||
emsple => { EN => qq{expected max surplus less than},
|
emsple => { EN => qq{max surplus forecast too low},
|
||||||
DE => qq{erwarteter max Überschuss weniger als} },
|
DE => qq{max Überschußprognose zu gering} },
|
||||||
nmspld => { EN => qq{no max surplus found for current day},
|
nmspld => { EN => qq{no max surplus found for current day},
|
||||||
DE => qq{kein max Überschuss für den aktuellen Tag gefunden} },
|
DE => qq{kein max Überschuss für den aktuellen Tag gefunden} },
|
||||||
state => { EN => qq{Status},
|
state => { EN => qq{Status},
|
||||||
@ -4182,6 +4183,11 @@ sub __updWriteFile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# Attr
|
||||||
|
# $cmd can be "del" or "set"
|
||||||
|
# $name is device name
|
||||||
|
# aName and aVal are Attribute name and value
|
||||||
################################################################
|
################################################################
|
||||||
sub Attr {
|
sub Attr {
|
||||||
my $cmd = shift;
|
my $cmd = shift;
|
||||||
@ -4193,19 +4199,19 @@ sub Attr {
|
|||||||
my $type = $hash->{TYPE};
|
my $type = $hash->{TYPE};
|
||||||
|
|
||||||
my ($do,$val, $err);
|
my ($do,$val, $err);
|
||||||
|
|
||||||
# $cmd can be "del" or "set"
|
|
||||||
# $name is device name
|
|
||||||
# aName and aVal are Attribute name and value
|
|
||||||
|
|
||||||
|
### nicht mehr benötigte Daten löschen - Bereich kann später wieder raus !!
|
||||||
|
##########################################################################################
|
||||||
if ($cmd eq 'set' && $aName eq 'affectNumHistDays') {
|
if ($cmd eq 'set' && $aName eq 'affectNumHistDays') {
|
||||||
if (!$init_done) {
|
if (!$init_done) {
|
||||||
return qq{Device "$name" -> The attribute 'affectNumHistDays' is obsolete and will be deleted soon. Please press "save config" when restart is finished.};
|
return qq{Device "$name" -> The attribute '$aName' is obsolete and will be deleted soon. Please press "save config" when restart is finished.};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return qq{The attribute 'affectNumHistDays' is obsolete and will be deleted soon.};
|
return qq{The attribute '$aName' is obsolete and will be deleted soon.};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
if ($aName eq 'disable') {
|
if ($aName eq 'disable') {
|
||||||
if($cmd eq 'set') {
|
if($cmd eq 'set') {
|
||||||
@ -4914,24 +4920,30 @@ return @pvconf;
|
|||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# centralTask Start Management
|
# centralTask Start Management
|
||||||
|
# Achtung: relevant für CPU Auslastung!
|
||||||
################################################################
|
################################################################
|
||||||
sub runCentralTask {
|
sub runCentralTask {
|
||||||
my $hash = shift;
|
my $hash = shift;
|
||||||
|
|
||||||
return if(!$init_done);
|
return if(!$init_done || CurrentVal ($hash, 'ctrunning', 0));
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $t = time;
|
||||||
my $type = $hash->{TYPE};
|
my $ms = strftime "%M:%S", localtime($t);
|
||||||
|
my ($min, $sec) = split ':', $ms; # aktuelle Minute (00-59), aktuelle Sekunde (00-61)
|
||||||
|
$min = int $min;
|
||||||
|
$sec = int $sec;
|
||||||
|
|
||||||
_addDynAttr ($hash);
|
if ($sec > 10) { # Attribute zur Laufzeit hinzufügen
|
||||||
|
if (!exists $hash->{HELPER}{S10DONE}) {
|
||||||
return if(CurrentVal ($hash, 'ctrunning', 0));
|
$hash->{HELPER}{S10DONE} = 1;
|
||||||
|
_addDynAttr ($hash); # relevant für CPU Auslastung!!
|
||||||
my $debug;
|
}
|
||||||
my $t = time;
|
}
|
||||||
my $second = int (strftime "%S", localtime($t)); # aktuelle Sekunde (00-61)
|
else {
|
||||||
my $minute = int (strftime "%M", localtime($t)); # aktuelle Minute (00-59)
|
delete $hash->{HELPER}{S10DONE};
|
||||||
|
}
|
||||||
|
|
||||||
|
my $name = $hash->{NAME};
|
||||||
my ($interval, $disabled, $inactive) = controller ($name);
|
my ($interval, $disabled, $inactive) = controller ($name);
|
||||||
|
|
||||||
if (!$interval) {
|
if (!$interval) {
|
||||||
@ -4956,42 +4968,42 @@ sub runCentralTask {
|
|||||||
my $new = $t + $interval; # nächste Wiederholungszeit
|
my $new = $t + $interval; # nächste Wiederholungszeit
|
||||||
$hash->{MODE} = 'Automatic - next Cycletime: '.FmtTime($new);
|
$hash->{MODE} = 'Automatic - next Cycletime: '.FmtTime($new);
|
||||||
|
|
||||||
$data{$type}{$name}{current}{nextCycleTime} = $new;
|
$data{$hash->{TYPE}}{$name}{current}{nextCycleTime} = $new;
|
||||||
|
|
||||||
storeReading ('nextCycletime', FmtTime($new));
|
storeReading ('nextCycletime', FmtTime($new));
|
||||||
centralTask ($hash, 1);
|
centralTask ($hash, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($minute == 59 && $second > 48 && $second < 58) {
|
if ($min == 59 && $sec > 48) {
|
||||||
if (!exists $hash->{HELPER}{S58DONE}) {
|
if (!exists $hash->{HELPER}{S48DONE}) {
|
||||||
$debug = getDebug ($hash);
|
my $debug = getDebug ($hash);
|
||||||
$hash->{HELPER}{S58DONE} = 1;
|
$hash->{HELPER}{S48DONE} = 1;
|
||||||
|
|
||||||
if ($debug =~ /collectData/x) {
|
if ($debug =~ /collectData/x) {
|
||||||
Log3 ($name, 1, "$name DEBUG> Start of unscheduled data collection at the end of an hour");
|
Log3 ($name, 1, "$name DEBUG> INFO - Start of unscheduled data collection at the end of an hour");
|
||||||
}
|
}
|
||||||
|
|
||||||
centralTask ($hash, 1);
|
centralTask ($hash, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delete $hash->{HELPER}{S58DONE};
|
delete $hash->{HELPER}{S48DONE};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($minute == 0 && $second > 3 && $second < 20) {
|
if ($min == 0 && $sec > 3) {
|
||||||
if (!exists $hash->{HELPER}{S20DONE}) {
|
if (!exists $hash->{HELPER}{S03DONE}) {
|
||||||
$debug = getDebug ($hash);
|
my $debug = getDebug ($hash);
|
||||||
$hash->{HELPER}{S20DONE} = 1;
|
$hash->{HELPER}{S03DONE} = 1;
|
||||||
|
|
||||||
if ($debug =~ /collectData/x) {
|
if ($debug =~ /collectData/x) {
|
||||||
Log3 ($name, 1, "$name DEBUG> Start of unscheduled data collection at the beginning of an hour");
|
Log3 ($name, 1, "$name DEBUG> INFO - Start of unscheduled data collection at the beginning of an hour");
|
||||||
}
|
}
|
||||||
|
|
||||||
centralTask ($hash, 1);
|
centralTask ($hash, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delete $hash->{HELPER}{S20DONE};
|
delete $hash->{HELPER}{S03DONE};
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -5051,7 +5063,7 @@ sub centralTask {
|
|||||||
RemoveInternalTimer ($hash, 'FHEM::SolarForecast::centralTask');
|
RemoveInternalTimer ($hash, 'FHEM::SolarForecast::centralTask');
|
||||||
RemoveInternalTimer ($hash, 'FHEM::SolarForecast::singleUpdateState');
|
RemoveInternalTimer ($hash, 'FHEM::SolarForecast::singleUpdateState');
|
||||||
|
|
||||||
### nicht mehr benötigte Readings/Daten löschen - Bereich kann später wieder raus !!
|
### nicht mehr benötigte Daten löschen - Bereich kann später wieder raus !!
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
## nicht-Bin Werte löschen
|
## nicht-Bin Werte löschen
|
||||||
my $ra = '0|5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95|100|percentile';
|
my $ra = '0|5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95|100|percentile';
|
||||||
@ -7620,7 +7632,7 @@ sub ___doPlanning {
|
|||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$paref->{supplement} = encode('utf8', $hqtxt{emsple}{$lang}).' '.$epiece1; # 'erwarteter max Überschuss weniger als'
|
$paref->{supplement} = encode('utf8', $hqtxt{emsple}{$lang}); # 'erwarteter max Überschuss weniger als'
|
||||||
$paref->{ps} = 'suspended:';
|
$paref->{ps} = 'suspended:';
|
||||||
|
|
||||||
___setConsumerPlanningState ($paref);
|
___setConsumerPlanningState ($paref);
|
||||||
@ -9673,7 +9685,7 @@ sub _checkSetupNotComplete {
|
|||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $type = $hash->{TYPE};
|
my $type = $hash->{TYPE};
|
||||||
|
|
||||||
### nicht mehr benötigte Readings/Daten löschen - Bereich kann später wieder raus !!
|
### nicht mehr benötigte Daten löschen - Bereich kann später wieder raus !!
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
## currentWeatherDev in Attr umsetzen
|
## currentWeatherDev in Attr umsetzen
|
||||||
## currentWeatherDev in Attr umsetzen
|
## currentWeatherDev in Attr umsetzen
|
||||||
|
Loading…
x
Reference in New Issue
Block a user