From d404e40245027350fde1260ed72d16ef8a5b0b8a Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sat, 28 Oct 2023 15:10:22 +0000 Subject: [PATCH] 76_SolarForecast: contrib 1.0.8 git-svn-id: https://svn.fhem.de/fhem/trunk@28099 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/76_SolarForecast.pm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index dfae9dc6d..be29d29bc 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -9101,15 +9101,28 @@ sub __createOwnSpec { ($v->{2}, $u->{2}) = split /\s+/, ReadingsVal ($name, $h->{2}{rdg}, ''); ($v->{3}, $u->{3}) = split /\s+/, ReadingsVal ($name, $h->{3}{rdg}, ''); - if ($uatr eq 'kWh') { + if ($uatr eq 'kWh') { for (my $r = 0 ; $r < $vinr; $r++) { - if ($u->{$r} && $u->{$r} =~ /Wh/xs) { + next if(!$u->{$r}); + + if ($u->{$r} =~ /^Wh/xs) { $v->{$r} = sprintf "%.1f",($v->{$r} / 1000); $u->{$r} = 'kWh'; } } } + if ($uatr eq 'Wh') { + for (my $r = 0 ; $r < $vinr; $r++) { + next if(!$u->{$r}); + + if ($u->{$r} =~ /^kWh/xs) { + $v->{$r} = sprintf "%.0f",($v->{$r} * 1000); + $u->{$r} = 'Wh'; + } + } + } + $ownv .= ""; $ownv .= "".($cats[$i-1] ? ''.$cats[$i-1].'' : '').""; $ownv .= "".$h->{0}{label}.": ".$v->{0}." ".$u->{0}."" if($h->{0}{label});