From b3b44462dd42bfda2ad75e93a05faed79b7cedb2 Mon Sep 17 00:00:00 2001 From: herrmannj <> Date: Fri, 29 Jan 2016 20:39:35 +0000 Subject: [PATCH] 32_TechemHKV.pm: fix for event-on git-svn-id: https://svn.fhem.de/fhem/trunk@10659 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/32_TechemHKV.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fhem/FHEM/32_TechemHKV.pm b/fhem/FHEM/32_TechemHKV.pm index 7bdce97a1..6ba06e3eb 100644 --- a/fhem/FHEM/32_TechemHKV.pm +++ b/fhem/FHEM/32_TechemHKV.pm @@ -98,11 +98,11 @@ TechemHKV_Notify (@) { TechemHKV_IOPatch($hash, $e[1]) if (($e[0] eq 'ATTR') && ($e[2] eq 'rfmode') && ($e[3] eq 'WMBus_T')); # disable receiver if (($e[0] eq 'ATTR') && ($e[2] eq 'rfmode') && ($e[3] ne 'WMBus_T')) { - readingsBeginUpdate($hash); - readingsBulkUpdate($hash, "state", "standby (IO missing)", 1); - readingsBulkUpdate($hash, "temp1", "--.--") if exists($hash->{READINGS}->{'temp1'}); # exlude versions without t1,t2 - readingsBulkUpdate($hash, "temp2", "--.--") if exists($hash->{READINGS}->{'temp2'}); - readingsEndUpdate($hash, 1); + readingsBeginUpdate($hash); + readingsBulkUpdate($hash, "state", "standby (IO missing)", 1); + readingsBulkUpdate($hash, "temp1", "--.--") if exists($hash->{READINGS}->{'temp1'}); # exlude versions without t1,t2 + readingsBulkUpdate($hash, "temp2", "--.--") if exists($hash->{READINGS}->{'temp2'}); + readingsEndUpdate($hash, 1); } } return undef; @@ -133,10 +133,12 @@ TechemHKV_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, "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); } @@ -144,10 +146,12 @@ TechemHKV_Receive(@) { $ats = ReadingsTimestamp($hash->{NAME},"previous_period", "0"); $ts = sprintf ("20%02d-%02d-%02d 00:00:00", $msg->{last}->{year}, $msg->{last}->{month}, $msg->{last}->{day}); if ($ats ne $ts) { + my $i; 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); } @@ -185,7 +189,7 @@ TechemHKV_Parse(@) { my ($message, $rssi); ($msg, $rssi) = split (/::/, $msg); $msg = TechemHKV_SanityCheck($msg); - return '' unless $msg; + return ('') unless $msg; my @m = ($msg =~ m/../g);