From cb8e092ae8d9c0ca61937d5a0c5f8b01ad848642 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Wed, 4 Apr 2012 10:54:55 +0000 Subject: [PATCH] Added HM-CC-TC time-reply, moved secSince2000 from HMLAN to fhem.pl git-svn-id: https://svn.fhem.de/fhem/trunk@1407 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_HMLAN.pm | 10 +--------- fhem/FHEM/10_CUL_HM.pm | 19 +++++++++++++++---- fhem/fhem.pl | 13 +++++++++++++ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/fhem/FHEM/00_HMLAN.pm b/fhem/FHEM/00_HMLAN.pm index 8d22ea61b..1cc776bbc 100755 --- a/fhem/FHEM/00_HMLAN.pm +++ b/fhem/FHEM/00_HMLAN.pm @@ -352,15 +352,7 @@ HMLAN_DoInit($) my $id = AttrVal($name, "hmId", undef); my $key = AttrVal($name, "hmKey", ""); # 36(!) hex digits - #my $s2000 = sprintf("%02X", time()-946681200); # sec since 2000 - - # Calculate the local time in seconds from 2000. - my $t = time(); - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($t); - $t -= 946684800; # seconds between 01.01.2000, 00:00 and THE EPOCH (1970) - $t -= 1*3600; # Timezone offset from UTC * 3600 (MEZ=1). FIXME/HARDCODED - $t += 3600 if $isdst; - my $s2000 = sprintf("%02X", $t); + my $s2000 = sprintf("%02X", secSince2000()); HMLAN_SimpleWrite($hash, "A$id") if($id); HMLAN_SimpleWrite($hash, "C"); diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index d77ccca47..e82a81534 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -225,7 +225,6 @@ CUL_HM_Parse($$) # Generate an UNKNOWN event for pairing requests, ignore everything else if($lcm =~ m/1A8.00/) { my $sname = "CUL_HM_$src"; - # prefer subType over model to make autocreate easier # model names are quite cryptic anyway my $model = substr($p, 2, 4); @@ -428,6 +427,7 @@ CUL_HM_Parse($$) } push @event, $msg if($msg); } + # 0402000000000501090000 } elsif($cmd eq "A410" && $p =~ m/^0402000000000(.)(..)(..)/) { my ($plist, $o1, $v1) = @@ -483,10 +483,20 @@ CUL_HM_Parse($$) push @event, "desired-temp:" .sprintf("%0.1f", hex($1)/2); } - CUL_HM_SendCmd($shash, "++8002$id${src}00",1,0) # Send Ack - if($id eq $dst && $cmd ne "8002"); - + if($id eq $dst) { + if($cmd eq "A03F") { # Timestamp request + my $s2000 = sprintf("%02X", secSince2000()); + CUL_HM_SendCmd($shash, "++803F$id${src}0204$s2000",1,0); + push @event, "time-request"; + + } elsif($cmd ne "8002" && $cmd ne "A03F") { + CUL_HM_SendCmd($shash, "++8002$id${src}00",1,0) # Send Ack + + } + } + + } elsif($model eq "HM-CC-VD") { ################### # CMD:8202 SRC:13F251 DST:15B50D 010100002A # status ACK to controlling HM-CC-TC @@ -1436,6 +1446,7 @@ CUL_HM_Pair(@) if(($stn eq "switch" || $stn eq "threeStateSensor") && $devInfo =~ m,(..)(..)(..), ) { my ($b1, $b2, $b3) = (hex($1)&0xf, hex($2), $3); + for(my $i = $b2+1; $i<=$b1; $i++) { my $nSrc = sprintf("%s%02X", $src, $i); if(!defined($modules{CUL_HM}{defptr}{$nSrc})) { diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 2b3d366bb..9eb5c1e7b 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -2969,5 +2969,18 @@ readingsUpdate($$$) { return $rv; } + +################## +sub +secSince2000() +{ + # Calculate the local time in seconds from 2000. + my $t = time(); + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($t); + $t -= 946684800; # seconds between 01.01.2000, 00:00 and THE EPOCH (1970) + $t -= 1*3600; # Timezone offset from UTC * 3600 (MEZ=1). FIXME/HARDCODED + $t += 3600 if $isdst; + return $t; +} 1;