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

77_SMAEM: contrib 3.5.0

git-svn-id: https://svn.fhem.de/fhem/trunk@20721 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2019-12-12 20:41:28 +00:00
parent 1fe47cd221
commit cc20c5daed

View File

@ -334,6 +334,7 @@ sub SMAEM_Read ($) {
Log3 ($name, 4, "SMAEM $name - ### Begin of new SMA Energymeter $smaserial get data cycle ###"); Log3 ($name, 4, "SMAEM $name - ### Begin of new SMA Energymeter $smaserial get data cycle ###");
Log3 ($name, 4, "SMAEM $name - ###############################################################"); Log3 ($name, 4, "SMAEM $name - ###############################################################");
Log3 ($name, 4, "SMAEM $name - discarded cycles since module start: $hash->{HELPER}{FAULTEDCYCLES}"); Log3 ($name, 4, "SMAEM $name - discarded cycles since module start: $hash->{HELPER}{FAULTEDCYCLES}");
Log3 ($name, 1, "SMAEM $name - Buffer length ".$dl." ready to parse:\n".$hex);
if($hash->{HELPER}{RUNNING_PID}) { if($hash->{HELPER}{RUNNING_PID}) {
Log3 ($name, 3, "SMAEM $name - WARNING - old process $hash->{HELPER}{RUNNING_PID}{pid} has been killed to start a new BlockingCall"); Log3 ($name, 3, "SMAEM $name - WARNING - old process $hash->{HELPER}{RUNNING_PID}{pid} has been killed to start a new BlockingCall");
@ -366,7 +367,7 @@ sub SMAEM_DoParse ($) {
my $data = decode_base64($dataenc); my $data = decode_base64($dataenc);
my $discycles = $hash->{HELPER}{FAULTEDCYCLES}; my $discycles = $hash->{HELPER}{FAULTEDCYCLES};
my $diffaccept = AttrVal($name, "diffAccept", 10); my $diffaccept = AttrVal($name, "diffAccept", 10);
my $fw = $hash->{FIRMWARE}; # my $fw = $hash->{FIRMWARE};
my ($error,@row_array,@array); my ($error,@row_array,@array);
Log3 ($name, 4, "SMAEM $name -> Start BlockingCall SMAEM_DoParse"); Log3 ($name, 4, "SMAEM $name -> Start BlockingCall SMAEM_DoParse");
@ -398,6 +399,15 @@ sub SMAEM_DoParse ($) {
# unpack big-endian to 2-digit hex (bin2hex) # unpack big-endian to 2-digit hex (bin2hex)
my $hex = unpack('H*', $data); my $hex = unpack('H*', $data);
# Entscheidung ob EM/HM2.0 mit Firmware >= 2.03.4.R
my $offset = 0;
my $grid_freq;
$hex =~ /.*000d04.{11}(000e04)(.*)(001504).*/;
if($1 eq "000e04") {
$grid_freq = hex($2)/1000;
$offset = 16;
}
################ Aufbau Ergebnis-Array #################### ################ Aufbau Ergebnis-Array ####################
# Extract datasets from hex: # Extract datasets from hex:
# Generic: # Generic:
@ -406,11 +416,11 @@ sub SMAEM_DoParse ($) {
# Prestring with SMAEM and SERIALNO or not # Prestring with SMAEM and SERIALNO or not
my $ps = (!AttrVal($name, "disableSernoInReading", undef)) ? "SMAEM".$smaserial."_" : ""; my $ps = (!AttrVal($name, "disableSernoInReading", undef)) ? "SMAEM".$smaserial."_" : "";
# Entscheidung ob EM/HM2.0 mit Firmware >= 2.03.4.R # # Entscheidung ob EM/HM2.0 mit Firmware >= 2.03.4.R
my $offset = 0; # my $offset = 0;
if ($fw eq ">= 2.03.4.R") { # if ($fw eq ">= 2.03.4.R") {
$offset = 16; # $offset = 16;
} # }
# Counter Divisor: [Hex-Value]=Ws => Ws/1000*3600=kWh => divide by 3600000 # Counter Divisor: [Hex-Value]=Ws => Ws/1000*3600=kWh => divide by 3600000
# Sum L1-3 # Sum L1-3
@ -528,6 +538,8 @@ sub SMAEM_DoParse ($) {
my $cosphi=hex(substr($hex,304,8))/1000; my $cosphi=hex(substr($hex,304,8))/1000;
push(@row_array, $ps."CosPhi ".sprintf("%.3f",$cosphi)."\n"); push(@row_array, $ps."CosPhi ".sprintf("%.3f",$cosphi)."\n");
push(@row_array, $ps."GridFreq ".$grid_freq."\n") if($grid_freq);
# L1 # L1
my $l1_bezug_wirk = hex(substr($hex,320+$offset,8))/10; my $l1_bezug_wirk = hex(substr($hex,320+$offset,8))/10;
my $l1_bezug_wirk_count = hex(substr($hex,336+$offset,16))/3600000; my $l1_bezug_wirk_count = hex(substr($hex,336+$offset,16))/3600000;