98_STOCKQUOTES: improved reading filtering

git-svn-id: https://svn.fhem.de/fhem/trunk@12272 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
vbs2 2016-10-04 16:15:45 +00:00
parent fc7cef4bf2
commit a4f3235df4

View File

@ -410,16 +410,19 @@ sub STOCKQUOTES_QueryQuotesFinished($)
readingsBulkUpdate($hash, $i . "_d_buy_quote", ($stockCount == 0) ? 0 : sprintf("%.2f", $stockBuyPrice / $stockCount)); readingsBulkUpdate($hash, $i . "_d_buy_quote", ($stockCount == 0) ? 0 : sprintf("%.2f", $stockBuyPrice / $stockCount));
# end # end
if (defined($stockValue) && defined($stockValuePrev)) if (defined($stockValue))
{ {
readingsBulkUpdate($hash, $i . "_d_cur_value_total", sprintf("%.2f", $stockValue)) if defined $stockValue; readingsBulkUpdate($hash, $i . "_d_cur_value_total", sprintf("%.2f", $stockValue));
readingsBulkUpdate($hash, $i . "_d_prev_value_total", sprintf("%.2f", $stockValuePrev)) if defined $stockValuePrev; readingsBulkUpdate($hash, $i . "_d_value_diff_total", sprintf("%.2f", $stockValue - $stockBuyPrice));
readingsBulkUpdate($hash, $i . "_d_value_diff_total", sprintf("%.2f", $stockValue - $stockBuyPrice)) if defined $stockValue; readingsBulkUpdate($hash, $i . "_d_p_change_total", ($stockBuyPrice == 0) ? 0 : sprintf("%.2f", 100.0 * (($stockValue / $stockBuyPrice) - 1 )));
readingsBulkUpdate($hash, $i . "_d_p_change_total", ($stockBuyPrice == 0) ? 0 : sprintf("%.2f", 100.0 * (($stockValue / $stockBuyPrice) - 1 ))) if defined $stockValue;
my $valueDiff = (defined $previous and defined $last) ? $stockCount * ($last - $previous) : undef; my $valueDiff = (defined $previous and defined $last) ? $stockCount * ($last - $previous) : undef;
readingsBulkUpdate($hash, $i . "_d_value_diff", sprintf("%.2f", $valueDiff)) if defined $valueDiff; readingsBulkUpdate($hash, $i . "_d_value_diff", sprintf("%.2f", $valueDiff)) if defined $valueDiff;
} }
if (defined($stockValuePrev))
{
readingsBulkUpdate($hash, $i . "_d_prev_value_total", sprintf("%.2f", $stockValuePrev));
}
} }
# update depot data # update depot data
@ -465,6 +468,9 @@ sub STOCKQUOTES_QueryQuotesFinished($)
1; 1;
=pod =pod
=item device
=item summary fetches stock quotes from data sources
=item summary_DE Kursdaten von Wertpapieren
=begin html =begin html
<a name="STOCKQUOTES"></a> <a name="STOCKQUOTES"></a>