50_HP1000.pm: add Activity timer

git-svn-id: https://svn.fhem.de/fhem/trunk@12325 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
loredo
2016-10-11 11:55:05 +00:00
parent 9ea2ac07d0
commit 524c2ee955

View File

@@ -98,6 +98,9 @@ sub HP1000_Define($$) {
# create global unique device definition
$modules{HP1000}{defptr} = $hash;
RemoveInternalTimer($hash);
InternalTimer( gettimeofday() + 120, "HP1000_SetAliveState", $hash );
return undef;
}
@@ -111,6 +114,8 @@ sub HP1000_Undefine($$) {
# release global unique device definition
delete $modules{HP1000}{defptr};
RemoveInternalTimer($hash);
return undef;
}
@@ -120,6 +125,26 @@ sub HP1000_Undefine($$) {
#
############################################################################################################
#####################################
sub HP1000_SetAliveState($;$) {
my ( $hash, $alive ) = @_;
my $name = $hash->{NAME};
Log3 $name, 5, "HP1000 $name: called function HP1000_SetAliveState()";
RemoveInternalTimer($hash);
my $activity = "dead";
$activity = "alive" if ($alive);
readingsBeginUpdate($hash);
readingsBulkUpdateIfChanged( $hash, "Activity", $activity );
readingsEndUpdate( $hash, 1 );
InternalTimer( gettimeofday() + 120, "HP1000_SetAliveState", $hash );
return;
}
###################################
sub HP1000_CGI() {
@@ -171,6 +196,8 @@ sub HP1000_CGI() {
$hash = $defs{$name};
HP1000_SetAliveState( $hash, 1 );
$hash->{SWVERSION} = $webArgs->{softwaretype};
$hash->{INTERVAL} = (
$hash->{SYSTEMTIME_UTC}