From 24de0ff609b5599f12f9bc80654c7a199fbadba0 Mon Sep 17 00:00:00 2001 From: herrmannj <> Date: Fri, 29 Jan 2016 20:44:30 +0000 Subject: [PATCH] 32_TechemWZ.pm: fix for event-on git-svn-id: https://svn.fhem.de/fhem/trunk@10661 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/32_TechemWZ.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/32_TechemWZ.pm b/fhem/FHEM/32_TechemWZ.pm index 05e479866..aac3e0257 100644 --- a/fhem/FHEM/32_TechemWZ.pm +++ b/fhem/FHEM/32_TechemWZ.pm @@ -146,11 +146,15 @@ TechemWZ_Receive(@) { $ats = ReadingsTimestamp($hash->{NAME},"current_period", "0"); $ts = sprintf ("%02d-%02d-%02d 00:00:00", $msg->{actual}->{year}, $msg->{actual}->{month}, $msg->{actual}->{day}); if ($ats ne $ts) { + my $i; readingsBeginUpdate($hash); $hash->{".updateTimestamp"} = $ts; + $i = $#{ $hash->{CHANGED} }; readingsBulkUpdate($hash, "meter", $msg->{meter}); + $hash->{CHANGETIME}->[$#{ $hash->{CHANGED} }] = $ts if ($#{ $hash->{CHANGED} } != $i ); # only add ts if there is a event to + $i = $#{ $hash->{CHANGED} }; readingsBulkUpdate($hash, "current_period", $msg->{actualVal}); - $hash->{CHANGETIME}->[$#{ $hash->{CHANGED} }] = $ts; + $hash->{CHANGETIME}->[$#{ $hash->{CHANGED} }] = $ts if ($#{ $hash->{CHANGED} } != $i ); # only add ts if there is a event to readingsEndUpdate($hash, 1); } @@ -160,8 +164,9 @@ TechemWZ_Receive(@) { if ($ats ne $ts) { readingsBeginUpdate($hash); $hash->{".updateTimestamp"} = $ts; + $i = $#{ $hash->{CHANGED} }; readingsBulkUpdate($hash, "previous_period", $msg->{lastVal}); - $hash->{CHANGETIME}->[$#{ $hash->{CHANGED} }] = $ts; + $hash->{CHANGETIME}->[$#{ $hash->{CHANGED} }] = $ts if ($#{ $hash->{CHANGED} } != $i ); # only add ts if there is a event to readingsEndUpdate($hash, 1); }