mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
76_SMAInverter: change the etoday management
git-svn-id: https://svn.fhem.de/fhem/trunk@23909 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
0d046cd8a6
commit
9b692d28ae
@ -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_SMAInverter: change the etoday management
|
||||||
- change: 48_MieleAtHome: add readings to show token-refresh-count
|
- change: 48_MieleAtHome: add readings to show token-refresh-count
|
||||||
- change: 93_DbRep: attribute sqlCmdVars is now working with sqlCmdBlocking
|
- change: 93_DbRep: attribute sqlCmdVars is now working with sqlCmdBlocking
|
||||||
- feature: 93_DbLog: new attr cacheOverflowThreshold
|
- feature: 93_DbLog: new attr cacheOverflowThreshold
|
||||||
|
@ -32,6 +32,7 @@ eval "use FHEM::Meta;1" or my $modMetaAbsent = 1;
|
|||||||
|
|
||||||
# Versions History by DS_Starter
|
# Versions History by DS_Starter
|
||||||
our %SMAInverter_vNotesIntern = (
|
our %SMAInverter_vNotesIntern = (
|
||||||
|
"2.14.1" => "27.02.2021 change save .etotal_yesterday, Forum: https://forum.fhem.de/index.php/topic,56080.msg1134664.html#msg1134664 ",
|
||||||
"2.14.0" => "08.10.2019 readings bat_loadtotal (BAT_LOADTOTAL), bat_loadtoday (BAT_LOADTODAY) included by 300P, Forum: #topic,56080.msg986302.html#msg986302",
|
"2.14.0" => "08.10.2019 readings bat_loadtotal (BAT_LOADTOTAL), bat_loadtoday (BAT_LOADTODAY) included by 300P, Forum: #topic,56080.msg986302.html#msg986302",
|
||||||
"2.13.4" => "30.08.2019 STP10.0-3AV-40 298 included into %SMAInverter_devtypes ",
|
"2.13.4" => "30.08.2019 STP10.0-3AV-40 298 included into %SMAInverter_devtypes ",
|
||||||
"2.13.3" => "28.08.2019 commandref revised ",
|
"2.13.3" => "28.08.2019 commandref revised ",
|
||||||
@ -570,9 +571,10 @@ sub SMAInverter_getstatusDoParse($) {
|
|||||||
my ($sunrise_h,$sunrise_m,$sunrise_s) = split(":",sunrise_abs('-'.$offset));
|
my ($sunrise_h,$sunrise_m,$sunrise_s) = split(":",sunrise_abs('-'.$offset));
|
||||||
my ($sunset_h,$sunset_m,$sunset_s) = split(":",sunset_abs('+'.$offset));
|
my ($sunset_h,$sunset_m,$sunset_s) = split(":",sunset_abs('+'.$offset));
|
||||||
|
|
||||||
my $oper_start = DateTime->new(year=>$year+1900,month=>$mon+1,day=>$mday,hour=>$sunrise_h,minute=>$sunrise_m,second=>$sunrise_s,time_zone=>'local');
|
my $oper_start = DateTime->new(year=>$year+1900,month=>$mon+1,day=>$mday,hour=>$sunrise_h,minute=>$sunrise_m,second=>$sunrise_s,time_zone=>'local');
|
||||||
my $oper_stop = DateTime->new(year=>$year+1900,month=>$mon+1,day=>$mday,hour=>$sunset_h,minute=>$sunset_m,second=>$sunset_s,time_zone=>'local');
|
my $oper_stop = DateTime->new(year=>$year+1900,month=>$mon+1,day=>$mday,hour=>$sunset_h,minute=>$sunset_m,second=>$sunset_s,time_zone=>'local');
|
||||||
my $dt_now = DateTime->now(time_zone=>'local');
|
my $oper_start_d = DateTime->new(year=>$year+1900,month=>$mon+1,day=>$mday,hour=>00,minute=>10,second=>00,time_zone=>'local');
|
||||||
|
my $dt_now = DateTime->now(time_zone=>'local');
|
||||||
|
|
||||||
Log3 $name, 4, "$name - current time: ".$dt_now->dmy('.')." ".$dt_now->hms;
|
Log3 $name, 4, "$name - current time: ".$dt_now->dmy('.')." ".$dt_now->hms;
|
||||||
Log3 $name, 4, "$name - operation time begin: ".$oper_start->dmy('.')." ".$oper_start->hms;
|
Log3 $name, 4, "$name - operation time begin: ".$oper_start->dmy('.')." ".$oper_start->hms;
|
||||||
@ -582,7 +584,7 @@ sub SMAInverter_getstatusDoParse($) {
|
|||||||
my $opertime_stop = $oper_stop->dmy('.')." ".$oper_stop->hms;
|
my $opertime_stop = $oper_stop->dmy('.')." ".$oper_stop->hms;
|
||||||
|
|
||||||
# ETOTAL speichern für ETODAY-Berechnung wenn WR ETODAY nicht liefert
|
# ETOTAL speichern für ETODAY-Berechnung wenn WR ETODAY nicht liefert
|
||||||
if ($dt_now >= $oper_stop) {
|
if ($dt_now <= $oper_start_d) { # V2.14.1, Forum: https://forum.fhem.de/index.php/topic,56080.msg1134664.html#msg1134664
|
||||||
my $val = 0;
|
my $val = 0;
|
||||||
$val = ReadingsNum($name, "etotal", 0)*1000 if (exists $defs{$name}{READINGS}{etotal});
|
$val = ReadingsNum($name, "etotal", 0)*1000 if (exists $defs{$name}{READINGS}{etotal});
|
||||||
$val = ReadingsNum($name, "SPOT_ETOTAL", 0) if (exists $defs{$name}{READINGS}{SPOT_ETOTAL});
|
$val = ReadingsNum($name, "SPOT_ETOTAL", 0) if (exists $defs{$name}{READINGS}{SPOT_ETOTAL});
|
||||||
@ -590,10 +592,10 @@ sub SMAInverter_getstatusDoParse($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# BATTERYLOAD_TOTAL speichern für BAT_LOADTODAY-Berechnung wenn WR BAT_LOADTODAY nicht liefert
|
# BATTERYLOAD_TOTAL speichern für BAT_LOADTODAY-Berechnung wenn WR BAT_LOADTODAY nicht liefert
|
||||||
if ($dt_now >= $oper_stop) {
|
if ($dt_now <= $oper_start_d) { # V2.14.1, Forum: https://forum.fhem.de/index.php/topic,56080.msg1134664.html#msg1134664
|
||||||
my $val = 0;
|
my $val = 0;
|
||||||
$val = ReadingsNum($name, "bat_loadtotal", 0)*1000 if (exists $defs{$name}{READINGS}{bat_loadtotal});
|
$val = ReadingsNum($name, "bat_loadtotal", 0)*1000 if (exists $defs{$name}{READINGS}{bat_loadtotal});
|
||||||
$val = ReadingsNum($name, "BAT_LOADTOTAL", 0) if (exists $defs{$name}{READINGS}{BAT_LOADTOTAL});
|
$val = ReadingsNum($name, "BAT_LOADTOTAL", 0) if (exists $defs{$name}{READINGS}{BAT_LOADTOTAL});
|
||||||
BlockingInformParent("SMAInverter_setReadingFromBlocking", [$name, ".bat_loadtotal_yesterday", $val], 0);
|
BlockingInformParent("SMAInverter_setReadingFromBlocking", [$name, ".bat_loadtotal_yesterday", $val], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,27 +1183,30 @@ sub SMAInverter_SMAcommand($$$$$) {
|
|||||||
|
|
||||||
# Check the data identifier
|
# Check the data identifier
|
||||||
$data_ID = unpack("v*", substr $data, 55, 2);
|
$data_ID = unpack("v*", substr $data, 55, 2);
|
||||||
Log3 $name, 5, "$name - Data identifier $data_ID";
|
Log3 ($name, 5, "$name - Data identifier $data_ID");
|
||||||
|
|
||||||
if($data_ID eq 0x2601) {
|
if($data_ID eq 0x2601) {
|
||||||
if (length($data) >= 66) {
|
if (length($data) >= 66) {
|
||||||
$inv_SPOT_ETOTAL = unpack("V*", substr($data, 62, 4));
|
$inv_SPOT_ETOTAL = unpack("V*", substr($data, 62, 4));
|
||||||
} else {
|
} else {
|
||||||
Log3 $name, 3, "$name - WARNING - ETOTAL wasn't deliverd ... set it to \"0\" !";
|
Log3 ($name, 3, "$name - WARNING - ETOTAL wasn't deliverd ... set it to \"0\" !");
|
||||||
$inv_SPOT_ETOTAL = 0;
|
$inv_SPOT_ETOTAL = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length($data) >= 82) {
|
if (length($data) >= 82) {
|
||||||
$inv_SPOT_ETODAY = unpack("V*", substr ($data, 78, 4));
|
$inv_SPOT_ETODAY = unpack("V*", substr ($data, 78, 4));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
# ETODAY wurde vom WR nicht geliefert, es wird versucht ihn zu berechnen
|
# ETODAY wurde vom WR nicht geliefert, es wird versucht ihn zu berechnen
|
||||||
Log3 $name, 3, "$name - ETODAY wasn't delivered from inverter, try to calculate it ...";
|
Log3 ($name, 3, "$name - ETODAY wasn't delivered from inverter, try to calculate it ...");
|
||||||
my $etotold = ReadingsNum($name, ".etotal_yesterday", undef);
|
my $etotold = ReadingsNum($name, ".etotal_yesterday", undef);
|
||||||
|
|
||||||
if(defined $etotold && $inv_SPOT_ETOTAL > $etotold) {
|
if(defined $etotold && $inv_SPOT_ETOTAL > $etotold) {
|
||||||
$inv_SPOT_ETODAY = $inv_SPOT_ETOTAL - $etotold;
|
$inv_SPOT_ETODAY = $inv_SPOT_ETOTAL - $etotold;
|
||||||
Log3 $name, 3, "$name - ETODAY calculated successfully !";
|
Log3 ($name, 3, "$name - ETODAY calculated successfully !");
|
||||||
} else {
|
}
|
||||||
Log3 $name, 3, "$name - WARNING - unable to calculate ETODAY ... set it to \"0\" !";
|
else {
|
||||||
|
Log3 ($name, 3, "$name - WARNING - unable to calculate ETODAY ... set it to \"0\" !");
|
||||||
$inv_SPOT_ETODAY = 0;
|
$inv_SPOT_ETODAY = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user