2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

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
This commit is contained in:
rudolfkoenig 2012-04-04 10:54:55 +00:00
parent cd6d0f0c7a
commit cb8e092ae8
3 changed files with 29 additions and 13 deletions

View File

@ -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");

View File

@ -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,8 +483,18 @@ CUL_HM_Parse($$)
push @event, "desired-temp:" .sprintf("%0.1f", hex($1)/2);
}
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
if($id eq $dst && $cmd ne "8002");
}
}
} elsif($model eq "HM-CC-VD") { ###################
@ -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})) {

View File

@ -2970,4 +2970,17 @@ 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;