From 379b2575aa5a53d6c767683dbea6b8db261e97f8 Mon Sep 17 00:00:00 2001 From: mgernoth <> Date: Fri, 11 Aug 2017 09:53:02 +0000 Subject: [PATCH] 00_HMUARTLGW.pm: fix errors on rename, add model git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@14875 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/00_HMUARTLGW.pm | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/FHEM/00_HMUARTLGW.pm b/FHEM/00_HMUARTLGW.pm index 9c2e434af..bd4d097a5 100644 --- a/FHEM/00_HMUARTLGW.pm +++ b/FHEM/00_HMUARTLGW.pm @@ -146,6 +146,7 @@ sub HMUARTLGW_Initialize($) $hash->{SetFn} = "HMUARTLGW_Set"; $hash->{GetFn} = "HMUARTLGW_Get"; $hash->{AttrFn} = "HMUARTLGW_Attr"; + $hash->{RenameFn} = "HMUARTLGW_Rename"; $hash->{ShutdownFn}= "HMUARTLGW_Shutdown"; @@ -171,6 +172,7 @@ sub HMUARTLGW_GetSetParameterReq($); sub HMUARTLGW_getAesKeys($); sub HMUARTLGW_updateMsgLoad($$); sub HMUARTLGW_Read($); +sub HMUARTLGW_RemoveHMPair($); sub HMUARTLGW_send($$$;$); sub HMUARTLGW_send_frame($$); sub HMUARTLGW_crc16($;$); @@ -265,9 +267,10 @@ sub HMUARTLGW_Define($$) $dev .= "\@115200"; } $hash->{DevType} = "UART"; + $hash->{model} = "HM-MOD-UART"; readingsBeginUpdate($hash); delete($hash->{READINGS}{"D-LANfirmware"}); - readingsBulkUpdate($hash, "D-type", "HM-MOD-UART"); + readingsBulkUpdate($hash, "D-type", $hash->{model}); readingsEndUpdate($hash, 1); } @@ -288,6 +291,7 @@ sub HMUARTLGW_Undefine($$;$) RemoveInternalTimer($hash); RemoveInternalTimer("HMUARTLGW_CheckCredits:$name"); + RemoveInternalTimer("hmPairForSec:$name"); if ($hash->{keepAlive}) { RemoveInternalTimer($hash->{keepAlive}); DevIo_CloseDev($hash->{keepAlive}); @@ -339,6 +343,21 @@ sub HMUARTLGW_Ready($) return 0; } +sub HMUARTLGW_Rename($$) +{ + my ($name, $old_name) = @_; + my $hash = $defs{$name}; + + if (defined($hash->{Helper}{Initialized})) { + RemoveInternalTimer("HMUARTLGW_CheckCredits:${old_name}"); + InternalTimer(gettimeofday()+1, "HMUARTLGW_CheckCredits", "HMUARTLGW_CheckCredits:${name}", 1); + } + + if ($hash->{hmPair}) { + HMUARTLGW_RemoveHMPair("hmPairForSec:${old_name}"); + } +} + sub HMUARTLGW_Shutdown($) { my ($hash) = @_; @@ -374,6 +393,7 @@ sub HMUARTLGW_LGW_Init($) $hash->{CNT} = hex($1); if ($hash->{DevType} eq "LGW") { + $hash->{model} = $2; readingsBeginUpdate($hash); readingsBulkUpdate($hash, "D-type", $2); readingsBulkUpdate($hash, "D-serialNr", $4);