From 9458c1d94be0f81e9c3b6c775a57f9a84299e9d0 Mon Sep 17 00:00:00 2001 From: MadMax <> Date: Sun, 8 Oct 2023 13:56:55 +0000 Subject: [PATCH] 76_SMAInverter.pm:add BAT_P_Charge/Discarge git-svn-id: https://svn.fhem.de/fhem/trunk@28031 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/76_SMAInverter.pm | 43 +++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/76_SMAInverter.pm b/fhem/FHEM/76_SMAInverter.pm index 2b6d81c53..ff08f3e8c 100644 --- a/fhem/FHEM/76_SMAInverter.pm +++ b/fhem/FHEM/76_SMAInverter.pm @@ -32,6 +32,7 @@ eval "use FHEM::Meta;1" or my $modMetaAbsent = 1; # Versions History by DS_Starter our %SMAInverter_vNotesIntern = ( + "2.23.6" => "24.09.2023 add BAT_P_Charge/Discarge", "2.23.5" => "25.06.2023 buxfix line 1267", "2.23.4" => "20.06.2023 buxfix DC-Power 2.0", "2.23.3" => "19.06.2023 buxfix DC-Power", @@ -704,6 +705,7 @@ sub SMAInverter_getstatusDoParse($) { $sup_BatteryInfo_IDC, $sup_BatteryInfo_Capacity, $sup_BatteryInfo_Capac, + $sup_BatteryInfo_Charge, $sup_SpotGridFrequency, $sup_TypeLabel, $sup_OperationTime, @@ -743,6 +745,7 @@ sub SMAInverter_getstatusDoParse($) { $inv_SPOT_CosPhi, $inv_BAT_UDC, $inv_BAT_UDC_A, $inv_BAT_UDC_B, $inv_BAT_UDC_C, $inv_BAT_IDC, $inv_BAT_IDC_A, $inv_BAT_IDC_B, $inv_BAT_IDC_C, + $inv_BAT_P_Charge, $inv_BAT_P_Discharge, $inv_BAT_CYCLES, $inv_BAT_CYCLES_A, $inv_BAT_CYCLES_B, $inv_BAT_CYCLES_C, $inv_BAT_TEMP, $inv_BAT_TEMP_A, $inv_BAT_TEMP_B, $inv_BAT_TEMP_C, $inv_BAT_LOADTODAY, $inv_BAT_LOADTOTAL, $inv_BAT_CAPACITY,$inv_BAT_UNLOADTODAY,$inv_BAT_UNLOADTOTAL, @@ -926,6 +929,7 @@ sub SMAInverter_getstatusDoParse($) { elsif ($INVTYPE_NAME =~ /SBS(1\.5|2\.0|2\.5)/xs || $INVCLASS eq "8009") { push(@commands, "sup_BatteryInfo_2"); # Check BatteryInfo Voltage + push(@commands, "sup_BatteryInfo_Charge"); } elsif($INVCLASS eq "8009" || $INVCLASS eq "8007") { @@ -957,7 +961,7 @@ sub SMAInverter_getstatusDoParse($) { push(@commands, "sup_BatteryInfo_Capacity") if($readParameter == 1); # Check BatteryInfo capacity #push(@commands, "sup_BatteryInfo_3"); push(@commands, "sup_BatteryInfo_4") if($readParameter == 1); # Check BatteryInfo rated apacity - #push(@commands, "sup_BatteryInfo_5"); + #push(@commands, "sup_BatteryInfo_5"); } #push(@commands, "sup_Insulation_1"); # Isolationsüberwachung @@ -1043,6 +1047,10 @@ sub SMAInverter_getstatusDoParse($) { Log3 $name, 5, "$name -> sup_BatteryInfo_IDC"; ($sup_BatteryInfo_IDC,$inv_BAT_IDC,$inv_BAT_IDC_A,$inv_BAT_IDC_B,$inv_BAT_IDC_C,$inv_susyid,$inv_serial) = SMAInverter_SMAcommand($hash, $hash->{HOST}, 0x51000200, 0x00495D00, 0x00495D10); } + elsif ($i eq "sup_BatteryInfo_Charge") { + Log3 $name, 5, "$name -> sup_BatteryInfo_Charge"; + ($sup_BatteryInfo_Charge,$inv_BAT_P_Charge,$inv_BAT_P_Discharge,$inv_susyid,$inv_serial) = SMAInverter_SMAcommand($hash, $hash->{HOST}, 0x51000200, 0x00496900, 0x00496AFF); + } elsif ($i eq "sup_BatteryInfo_Capacity") { Log3 $name, 5, "$name -> sup_BatteryInfo_Capacity"; ($sup_BatteryInfo_Capacity,$inv_BAT_CAPACITY,$inv_susyid,$inv_serial) = SMAInverter_SMAcommand($hash, $hash->{HOST}, 0x51000200, 0x00696E00, 0x00696E10); @@ -1141,7 +1149,7 @@ sub SMAInverter_getstatusDoParse($) { } elsif ($i eq "sup_Insulation_1") { Log3 ($name, 4, "$name -> sup_Insulation_1"); - ($sup_Insulation_1,$inv_DC_Residual_Current,$inv_susyid,$inv_serial) = SMAInverter_SMAcommand($hash, $hash->{HOST}, 0x51020200, 0x40254E00, 0x40254EFF); + ($sup_Insulation_1,$inv_DC_Residual_Current,$inv_susyid,$inv_serial) = SMAInverter_SMAcommand($hash, $hash->{HOST}, 0x51020200, 0x40254E00, 0x40254FFF); } elsif ($i eq "sup_Insulation_2") { Log3 ($name, 4, "$name -> sup_Insulation_2"); @@ -1362,6 +1370,10 @@ sub SMAInverter_getstatusDoParse($) { if($sup_BatteryInfo_Capacity) { push(@row_array, "bat_capacity ".$inv_BAT_CAPACITY."\n"); #TTT } + if($sup_BatteryInfo_Charge) { + push(@row_array, "bat_p_charge ".($inv_BAT_P_Charge/1000)."\n"); #TTT + push(@row_array, "bat_p_discharge ".($inv_BAT_P_Discharge/1000)."\n"); #TTT + } } if($detail_level > 1) { @@ -1573,6 +1585,11 @@ sub SMAInverter_getstatusDoParse($) { if($sup_BatteryInfo_Capacity) { push(@row_array, "BAT_CAPACITY ".$inv_BAT_CAPACITY."\n") if ($inv_BAT_CAPACITY ne "-"); #TTT } + + if($sup_BatteryInfo_Charge) { + push(@row_array, "BAT_P_CHARGE ".$inv_BAT_P_Charge."\n"); #TTT + push(@row_array, "BAT_P_DISCHARGE ".$inv_BAT_P_Discharge."\n"); #TTT + } } if($detail_level > 1) { @@ -1790,6 +1807,7 @@ sub SMAInverter_SMAcommand($$$$$) { $inv_SPOT_CosPhi, $inv_BAT_UDC, $inv_BAT_UDC_A, $inv_BAT_UDC_B, $inv_BAT_UDC_C, $inv_BAT_IDC, $inv_BAT_IDC_A, $inv_BAT_IDC_B, $inv_BAT_IDC_C, + $inv_BAT_P_Charge, $inv_BAT_P_Discharge, $inv_BAT_CYCLES, $inv_BAT_CYCLES_A, $inv_BAT_CYCLES_B, $inv_BAT_CYCLES_C, $inv_BAT_TEMP, $inv_BAT_TEMP_A, $inv_BAT_TEMP_B, $inv_BAT_TEMP_C, $inv_BAT_LOADTODAY, $inv_BAT_LOADTOTAL, $inv_BAT_CAPACITY,$inv_BAT_UNLOADTODAY,$inv_BAT_UNLOADTOTAL, @@ -2334,7 +2352,16 @@ sub SMAInverter_SMAcommand($$$$$) { return (1,$inv_BAT_rated_capacity,$inv_susyid,$inv_serial); } - if ($data_ID eq 0x495B && $INVTYPE_NAME =~ /STP(5\.0|6\.0|8\.0|10\.0)SE/xs) { + if ($data_ID eq 0x4969) { + + $inv_BAT_P_Charge = unpack("V*", substr $data, 62, 4); + $inv_BAT_P_Discharge = unpack("V*", substr $data, 90, 4); + + Log3 $name, 5, "$name - Found Data inv_BAT_P_Charge=$inv_BAT_P_Charge and inv_BAT_P_Discharge=$inv_BAT_P_Discharge"; + return (1,$inv_BAT_P_Charge,$inv_BAT_P_Discharge,$inv_susyid,$inv_serial); + } + + if ($data_ID eq 0x495B && $INVTYPE_NAME =~ /STP(5\.0|6\.0|8\.0|10\.0)SE/xs) { $inv_BAT_TEMP = unpack("V*", substr $data, 62, 4) / 10; $inv_BAT_UDC = unpack("V*", substr $data, 90, 4) / 100; @@ -3106,7 +3133,9 @@ The retrieval of the inverter will be executed non-blocking. You can adjust the