From f4e8a7248ba0e19f0445f2b70b4e44c5b9744efc Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 10 Jul 2012 06:18:47 +0000 Subject: [PATCH] secSince2000 fixes git-svn-id: https://svn.fhem.de/fhem/trunk@1710 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_HMLAN.pm | 15 ++++++++++++++- fhem/FHEM/10_CUL_HM.pm | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/00_HMLAN.pm b/fhem/FHEM/00_HMLAN.pm index 1cc776bbc..68f9b8e7a 100755 --- a/fhem/FHEM/00_HMLAN.pm +++ b/fhem/FHEM/00_HMLAN.pm @@ -11,6 +11,7 @@ sub HMLAN_Read($); sub HMLAN_Write($$$); sub HMLAN_ReadAnswer($$$); sub HMLAN_uptime($); +sub HMLAN_secSince2000(); sub HMLAN_SimpleWrite(@); @@ -352,7 +353,7 @@ HMLAN_DoInit($) my $id = AttrVal($name, "hmId", undef); my $key = AttrVal($name, "hmKey", ""); # 36(!) hex digits - my $s2000 = sprintf("%02X", secSince2000()); + my $s2000 = sprintf("%02X", HMLAN_secSince2000()); HMLAN_SimpleWrite($hash, "A$id") if($id); HMLAN_SimpleWrite($hash, "C"); @@ -376,4 +377,16 @@ HMLAN_KeepAlive($) InternalTimer(gettimeofday()+25, "HMLAN_KeepAlive", $hash, 1); } +sub +HMLAN_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 -= 7200; # HM Special + $t += fhemTzOffset($t); + return $t; +} + 1; diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 9d3b5aa9b..2a12fbfa8 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -18,6 +18,7 @@ sub CUL_HM_Set($@); sub CUL_HM_DumpProtocol($$@); sub CUL_HM_convTemp($); sub CUL_HM_pushConfig($$$$$$$$); +sub CUL_HM_secSince2000(); my %culHmDevProps=( "01" => { st => "AlarmControl", cl => "controller" }, # by peterp @@ -489,7 +490,7 @@ CUL_HM_Parse($$) if($id eq $dst) { if($cmd eq "A03F") { # Timestamp request - my $s2000 = sprintf("%02X", secSince2000()); + my $s2000 = sprintf("%02X", CUL_HM_secSince2000()); CUL_HM_SendCmd($shash, "++803F$id${src}0204$s2000",1,0); push @event, "time-request"; @@ -1898,4 +1899,17 @@ CUL_HM_maticFn($$$$$) return $sndcmd; } +sub +CUL_HM_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 -= 7200; # HM Special + $t += fhemTzOffset($t); + return $t; +} + + 1;