############################################## # $Id$ package main; use strict; use warnings; use Time::HiRes qw(gettimeofday); ##################################### sub at_Initialize($) { my ($hash) = @_; $hash->{DefFn} = "at_Define"; $hash->{UndefFn} = "at_Undef"; $hash->{SetFn} = "at_Set"; $hash->{AttrFn} = "at_Attr"; $hash->{StateFn} = "at_State"; $hash->{AttrList} = "disable:0,1 disabledForIntervals $readingFnAttributes ". "skip_next:0,1 alignTime computeAfterInit"; $hash->{FW_detailFn} = "at_fhemwebFn"; } my %at_stt; my $at_detailFnCalled; sub at_SecondsTillTomorrow($) # 86400, if tomorrow is no DST change { my $t = shift; my $dayHour = int($t/3600); if(!$at_stt{$dayHour}) { my @l1 = localtime($t); my @l2 = localtime($t+86400); $at_stt{$dayHour} = 86400+($l1[8]-$l2[8])*3600; } return $at_stt{$dayHour}; } ##################################### sub at_Define($$) { my ($hash, $def) = @_; my ($name, undef, $tm, $command) = split("[ \t\n]+", $def, 4); if(!$command) { if($hash->{OLDDEF}) { # Called from modify, where command is optional RemoveInternalTimer($hash); (undef, $command) = split("[ \t]+", $hash->{OLDDEF}, 2); $hash->{DEF} = "$tm $command"; } else { return "Usage: define at [timespec or datespec] "; } } return "Wrong timespec, use \"[+][*[{count}]]