2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

76_SolarForecast: minor code changes ones more

git-svn-id: https://svn.fhem.de/fhem/trunk@28643 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2024-03-12 17:33:28 +00:00
parent f0d1422616
commit 50300fc3d9
2 changed files with 19 additions and 11 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- change: 76_SolarForecast: minor code changes ones more
- bufgix: 72_FRITZBOX: Fehlerbehandlung verbessert - bufgix: 72_FRITZBOX: Fehlerbehandlung verbessert
- change: 72_FRITZBOX: commandRef ergänzt - change: 72_FRITZBOX: commandRef ergänzt
- change: 76_SolarForecast: minor code changes - change: 76_SolarForecast: minor code changes

View File

@ -158,6 +158,7 @@ BEGIN {
# Versions History intern # Versions History intern
my %vNotesIntern = ( my %vNotesIntern = (
"1.16.7" => "12.03.2024 prevent duplicates in NOTIFYDEV, Forum: https://forum.fhem.de/index.php?msg=1306875 ",
"1.16.6" => "11.03.2024 plantConfigCheck: join forecastProperties with ',' ", "1.16.6" => "11.03.2024 plantConfigCheck: join forecastProperties with ',' ",
"1.16.5" => "04.03.2024 setPVhistory: code changes, plantConfigCheck: check forecastRefresh ". "1.16.5" => "04.03.2024 setPVhistory: code changes, plantConfigCheck: check forecastRefresh ".
"check age of weather data according to used MOSMIX variant ", "check age of weather data according to used MOSMIX variant ",
@ -14929,8 +14930,8 @@ sub createAssociatedWith {
RemoveInternalTimer($hash, "FHEM::SolarForecast::createAssociatedWith"); RemoveInternalTimer($hash, "FHEM::SolarForecast::createAssociatedWith");
if ($init_done) { if ($init_done) {
my (@cd,@nd); my (@cd, @nd);
my ($afc,$ara,$ain,$ame,$aba,$h); my ($afc, $ara, $ain, $ame, $aba, $h);
my $fcdev1 = AttrVal ($name, 'ctrlWeatherDev1', ''); # Weather forecast Device 1 my $fcdev1 = AttrVal ($name, 'ctrlWeatherDev1', ''); # Weather forecast Device 1
($afc,$h) = parseParams ($fcdev1); ($afc,$h) = parseParams ($fcdev1);
@ -14963,12 +14964,9 @@ sub createAssociatedWith {
for my $c (sort{$a<=>$b} keys %{$data{$type}{$name}{consumers}}) { # Consumer Devices for my $c (sort{$a<=>$b} keys %{$data{$type}{$name}{consumers}}) { # Consumer Devices
my $consumer = AttrVal($name, "consumer${c}", ""); my $consumer = AttrVal($name, "consumer${c}", "");
my ($ac,$hc) = parseParams ($consumer); my ($ac,$hc) = parseParams ($consumer);
my $codev = $ac->[0] // ''; my $codev = $ac->[0] // '';
my $dswitch = $hc->{switchdev} // ''; # alternatives Schaltdevice
push @cd, $codev if($codev); push @cd, $codev if($codev);
my $dswitch = $hc->{switchdev} // ''; # alternatives Schaltdevice
push @cd, $dswitch if($dswitch); push @cd, $dswitch if($dswitch);
} }
@ -14988,9 +14986,18 @@ sub createAssociatedWith {
next if($e ~~ @ndn); next if($e ~~ @ndn);
push @ndn, $e; push @ndn, $e;
} }
$hash->{NOTIFYDEV} = join ",", @cd if(@cd); my %seen;
readingsSingleUpdate ($hash, ".associatedWith", join(" ",@ndn), 0) if(@ndn);
if (@cd) {
$hash->{NOTIFYDEV} = join ",", grep { !$seen{$_ }++ } @cd;
}
if (@nd) {
undef %seen;
my $asw = join " ", grep { !$seen{$_ }++ } @nd;
readingsSingleUpdate ($hash, ".associatedWith", $asw, 0);
}
} }
else { else {
InternalTimer(gettimeofday()+3, "FHEM::SolarForecast::createAssociatedWith", $hash, 0); InternalTimer(gettimeofday()+3, "FHEM::SolarForecast::createAssociatedWith", $hash, 0);