mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 10:46:03 +00:00
98_RandomTimer: some cleanup
git-svn-id: https://svn.fhem.de/fhem/trunk@25370 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
15255fbf1d
commit
80b45e3c36
@ -126,7 +126,7 @@ sub Define {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my ( $e, $h, $m, $s, $f ) = GetTimeSpec($stspec);
|
my ( $e, $h, $m, $s, $f ) = GetTimeSpec($stspec);
|
||||||
return $e if ($e);
|
return $e if $e;
|
||||||
|
|
||||||
return "invalid timeToSwitch <$timeToSwitch>, use 9999"
|
return "invalid timeToSwitch <$timeToSwitch>, use 9999"
|
||||||
if ( !( $timeToSwitch =~ m{^[0-9]{2,4}$}ixms ) );
|
if ( !( $timeToSwitch =~ m{^[0-9]{2,4}$}ixms ) );
|
||||||
@ -158,8 +158,7 @@ sub Define {
|
|||||||
$hash->{helper}{offReading} = q{state};
|
$hash->{helper}{offReading} = q{state};
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsSingleUpdate( $hash, 'TimeToSwitch', $hash->{helper}{TIMETOSWITCH},
|
readingsSingleUpdate( $hash, 'TimeToSwitch', $hash->{helper}{TIMETOSWITCH}, 1 );
|
||||||
1 );
|
|
||||||
|
|
||||||
RemoveInternalTimer($hash,\&RT_SetTimer);
|
RemoveInternalTimer($hash,\&RT_SetTimer);
|
||||||
InternalTimer(time,\&RT_SetTimer,$hash);
|
InternalTimer(time,\&RT_SetTimer,$hash);
|
||||||
@ -167,12 +166,8 @@ sub Define {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub Undef {
|
sub Undef {
|
||||||
|
my $hash = shift // return;
|
||||||
my $hash = shift;
|
|
||||||
my $arg = shift // return;
|
|
||||||
|
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
|
|
||||||
delete $modules{RandomTimer}{defptr}{ $hash->{NAME} };
|
delete $modules{RandomTimer}{defptr}{ $hash->{NAME} };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -204,7 +199,7 @@ sub Attr {
|
|||||||
return $err if $err;
|
return $err if $err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,8 +266,7 @@ sub device_switch {
|
|||||||
Log3( $hash, 4, "[$hash->{NAME}] command: $command" );
|
Log3( $hash, 4, "[$hash->{NAME}] command: $command" );
|
||||||
|
|
||||||
my $ret = AnalyzeCommandChain( $hash, $command );
|
my $ret = AnalyzeCommandChain( $hash, $command );
|
||||||
Log3( $hash, 3, "[$hash->{NAME}] ERROR: $ret SENDING $command" )
|
Log3( $hash, 3, "[$hash->{NAME}] ERROR: $ret SENDING $command" ) if $ret;
|
||||||
if ($ret);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -319,20 +313,16 @@ sub disableDown {
|
|||||||
my $hash = shift // return;
|
my $hash = shift // return;
|
||||||
my $disableCondCmd = AttrVal( $hash->{NAME}, "disableCondCmd", 0 );
|
my $disableCondCmd = AttrVal( $hash->{NAME}, "disableCondCmd", 0 );
|
||||||
|
|
||||||
if ( $disableCondCmd ne 'none' ) {
|
return Log3( $hash, 4, "[$hash->{NAME}] no action requested on $hash->{DEVICE}" )
|
||||||
Log3( $hash, 4,
|
if $disableCondCmd eq 'none';
|
||||||
"[$hash->{NAME}] setting requested disableCondCmd on $hash->{DEVICE}: " );
|
|
||||||
$hash->{COMMAND} =
|
Log3( $hash, 4,
|
||||||
AttrVal( $hash->{NAME}, 'disableCondCmd', 0 ) eq 'onCmd'
|
"[$hash->{NAME}] setting requested disableCondCmd on $hash->{DEVICE}: " );
|
||||||
? 'on'
|
$hash->{COMMAND} =
|
||||||
: 'off';
|
AttrVal( $hash->{NAME}, 'disableCondCmd', 0 ) eq 'onCmd'
|
||||||
device_switch($hash);
|
? 'on'
|
||||||
}
|
: 'off';
|
||||||
else {
|
return device_switch($hash);
|
||||||
Log3( $hash, 4,
|
|
||||||
"[$hash->{NAME}] no action requested on $hash->{DEVICE}" );
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub down {
|
sub down {
|
||||||
@ -341,8 +331,7 @@ sub down {
|
|||||||
"[$hash->{NAME}] setting requested keepDeviceAlive on $hash->{DEVICE}" );
|
"[$hash->{NAME}] setting requested keepDeviceAlive on $hash->{DEVICE}" );
|
||||||
$hash->{COMMAND} =
|
$hash->{COMMAND} =
|
||||||
AttrVal( $hash->{NAME}, 'keepDeviceAlive', 0 ) ? 'on' : 'off';
|
AttrVal( $hash->{NAME}, 'keepDeviceAlive', 0 ) ? 'on' : 'off';
|
||||||
device_switch($hash);
|
return device_switch($hash);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub RT_Exec {
|
sub RT_Exec {
|
||||||
@ -465,11 +454,8 @@ sub isAktive {
|
|||||||
sub isDisabled {
|
sub isDisabled {
|
||||||
my $hash = shift // return;
|
my $hash = shift // return;
|
||||||
|
|
||||||
my $disable = IsDisabled( $hash->{NAME} );
|
return if IsDisabled( $hash->{NAME} );
|
||||||
return $disable if $disable;
|
my $disableCond = AttrVal( $hash->{NAME}, 'disableCond', undef) // return 0;
|
||||||
|
|
||||||
my $disableCond = AttrVal( $hash->{NAME}, "disableCond", "nf" );
|
|
||||||
return 0 if $disableCond eq 'nf';
|
|
||||||
|
|
||||||
return AnalyzePerlCommand( $hash, $disableCond );
|
return AnalyzePerlCommand( $hash, $disableCond );
|
||||||
}
|
}
|
||||||
@ -483,9 +469,9 @@ sub schaltZeitenErmitteln {
|
|||||||
|
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
|
|
||||||
readingsBulkUpdate( $hash, "StartTime",
|
readingsBulkUpdate( $hash, 'StartTime',
|
||||||
FmtDateTime( $hash->{helper}{startTime} ) );
|
FmtDateTime( $hash->{helper}{startTime} ) );
|
||||||
readingsBulkUpdate( $hash, "StopTime",
|
readingsBulkUpdate( $hash, 'StopTime',
|
||||||
FmtDateTime( $hash->{helper}{stopTime} ) );
|
FmtDateTime( $hash->{helper}{stopTime} ) );
|
||||||
readingsEndUpdate( $hash, defined( $hash->{LOCAL} ? 0 : 1 ) );
|
readingsEndUpdate( $hash, defined( $hash->{LOCAL} ? 0 : 1 ) );
|
||||||
return;
|
return;
|
||||||
@ -496,7 +482,7 @@ sub setActive {
|
|||||||
my $value = shift // return;
|
my $value = shift // return;
|
||||||
$hash->{helper}{active} = $value;
|
$hash->{helper}{active} = $value;
|
||||||
my $trigger = ( isDisabled($hash) ) ? 0 : 1;
|
my $trigger = ( isDisabled($hash) ) ? 0 : 1;
|
||||||
readingsSingleUpdate( $hash, "active", $value, $trigger );
|
readingsSingleUpdate( $hash, 'active', $value, $trigger );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,8 +647,8 @@ sub zeitBerechnen {
|
|||||||
$jetzt_arr[2] = $hour;
|
$jetzt_arr[2] = $hour;
|
||||||
$jetzt_arr[1] = $min;
|
$jetzt_arr[1] = $min;
|
||||||
$jetzt_arr[0] = $sec;
|
$jetzt_arr[0] = $sec;
|
||||||
my $next = timelocal_nocheck(@jetzt_arr);
|
my $nxt = timelocal_nocheck(@jetzt_arr);
|
||||||
return $next;
|
return $nxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user