From 0ac4bb494769798a2e005d45457a466ddad0cc76 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Wed, 17 Apr 2024 20:19:22 +0000 Subject: [PATCH] 76_SolarForecast: possible Illegal division by zero if Battery SOC management is activated git-svn-id: https://svn.fhem.de/fhem/trunk@28804 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/76_SolarForecast.pm | 6 +++--- fhem/contrib/DS_Starter/76_SolarForecast.pm | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/76_SolarForecast.pm b/fhem/FHEM/76_SolarForecast.pm index 929327681..108a1f8bc 100644 --- a/fhem/FHEM/76_SolarForecast.pm +++ b/fhem/FHEM/76_SolarForecast.pm @@ -8148,16 +8148,16 @@ sub _batSocTarget { my $oldd2care = CircularVal ($hash, 99, 'days2care', 0); my $ltsmsr = CircularVal ($hash, 99, 'lastTsMaxSocRchd', undef); my $batcharge = CurrentVal ($hash, 'batcharge', 0); # aktuelle Ladung in % - my $batinstcap = CurrentVal ($hash, 'batinstcap', 0); # installierte Batteriekapazität Wh + my $batinstcap = CurrentVal ($hash, 'batinstcap', 0); # installierte Batteriekapazität Wh + my $cgbt = AttrVal ($name, 'ctrlBatSocManagement', undef); - if (!$batinstcap) { + if ($cgbt && !$batinstcap) { Log3 ($name, 1, "$name - WARNING - Attribute ctrlBatSocManagement is active, but the required key 'cap' is not setup in currentBatteryDev. Exit."); return; } __batSaveSocKeyFigures ($paref) if(!$ltsmsr || $batcharge >= $maxSoCdef || $oldd2care < 0); - my $cgbt = AttrVal ($name, 'ctrlBatSocManagement', undef); my ($lowSoc, $upSoc, $maxsoc, $careCycle) = __parseAttrBatSoc ($name, $cgbt); return if(!$lowSoc ||!$upSoc); diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index 929327681..108a1f8bc 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -8148,16 +8148,16 @@ sub _batSocTarget { my $oldd2care = CircularVal ($hash, 99, 'days2care', 0); my $ltsmsr = CircularVal ($hash, 99, 'lastTsMaxSocRchd', undef); my $batcharge = CurrentVal ($hash, 'batcharge', 0); # aktuelle Ladung in % - my $batinstcap = CurrentVal ($hash, 'batinstcap', 0); # installierte Batteriekapazität Wh + my $batinstcap = CurrentVal ($hash, 'batinstcap', 0); # installierte Batteriekapazität Wh + my $cgbt = AttrVal ($name, 'ctrlBatSocManagement', undef); - if (!$batinstcap) { + if ($cgbt && !$batinstcap) { Log3 ($name, 1, "$name - WARNING - Attribute ctrlBatSocManagement is active, but the required key 'cap' is not setup in currentBatteryDev. Exit."); return; } __batSaveSocKeyFigures ($paref) if(!$ltsmsr || $batcharge >= $maxSoCdef || $oldd2care < 0); - my $cgbt = AttrVal ($name, 'ctrlBatSocManagement', undef); my ($lowSoc, $upSoc, $maxsoc, $careCycle) = __parseAttrBatSoc ($name, $cgbt); return if(!$lowSoc ||!$upSoc);