diff --git a/fhem/FHEM/00_CUL.pm b/fhem/FHEM/00_CUL.pm index cdf056ba1..451b67797 100755 --- a/fhem/FHEM/00_CUL.pm +++ b/fhem/FHEM/00_CUL.pm @@ -30,6 +30,7 @@ my %gets = ( # Name, Data to send to the CUL, Regexp for the answer ); my %sets = ( + "reopen" => "", "hmPairForSec" => "HomeMatic", "hmPairSerial" => "HomeMatic", "raw" => "", @@ -115,7 +116,8 @@ CUL_Initialize($) "showtime:1,0 model:CUL,CUN sendpool addvaltrigger ". "rfmode:SlowRF,HomeMatic,MAX,WMBus_T,WMBus_S ". "hmId ". - "hmProtocolEvents:0_off,1_dump,2_dumpFull,3_dumpTrigger "; + "hmProtocolEvents:0_off,1_dump,2_dumpFull,3_dumpTrigger " . + $readingFnAttributes; $hash->{ShutdownFn} = "CUL_Shutdown"; @@ -223,6 +225,15 @@ CUL_RemoveHMPair($) delete($hash->{hmPair}); } +##################################### +sub +CUL_Reopen($) +{ + my ($hash) = @_; + DevIo_CloseDev($hash); + DevIo_OpenDev($hash, 1, "CUL_DoInit"); +} + ##################################### sub CUL_Set($@) @@ -240,7 +251,10 @@ CUL_Set($@) return "This command is not valid in the current rfmode" if($sets{$type} && $sets{$type} ne AttrVal($name, "rfmode", "SlowRF")); - if($type eq "hmPairForSec") { #################################### + if($type eq "reopen") { #################################### + CUL_Reopen($hash); + + } elsif($type eq "hmPairForSec") { #################################### return "Usage: set $name hmPairForSec " if(!$arg || $arg !~ m/^\d+$/); $hash->{hmPair} = 1; @@ -271,7 +285,6 @@ CUL_Set($@) CUL_WriteInit($hash); # Will reprogram the CC1101 } elsif($type eq "bWidth") { ###################################### KHz - my ($err, $ob); if(!IsDummy($hash->{NAME})) { CUL_SimpleWrite($hash, "C10"); @@ -392,8 +405,7 @@ CUL_Get($@) } - $hash->{READINGS}{$a[1]}{VAL} = $msg; - $hash->{READINGS}{$a[1]}{TIME} = TimeNow(); + readingsSingleUpdate($hash, $a[1], $msg, 0); return "$a[0] $a[1] => $msg"; } @@ -463,9 +475,7 @@ CUL_DoInit($) } } - $hash->{STATE} = - $hash->{READINGS}{state}{VAL} = "Initialized"; - $hash->{READINGS}{state}{TIME} = TimeNow(); + readingsSingleUpdate($hash, "state", "Initialized", 1); # Reset the counter delete($hash->{XMIT_TIME}); @@ -891,7 +901,7 @@ CUL_Parse($$$$@) $hash->{"${name}_MSGCNT"}++; $hash->{"${name}_TIME"} = - $hash->{READINGS}{state}{TIME} = TimeNow(); # showtime attribute + readingsSingleUpdate($hash, "state", $hash->{READINGS}{state}{VAL}, 0); # showtime attribute $hash->{RAWMSG} = $rmsg; my %addvals = (RAWMSG => $dmsg); if(defined($rssi)) { @@ -1148,6 +1158,8 @@ CUL_prefix($$$) Set
+ +
  • readingFnAttributes

  • @@ -1406,6 +1420,8 @@ CUL_prefix($$$) Set
    +
  • readingFnAttributes