2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00

70_ZoneMinder:added attribute loginInterval and setter for login

git-svn-id: https://svn.fhem.de/fhem/trunk@17594 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
delmar 2018-10-22 16:40:45 +00:00
parent 7b25f64de2
commit 3e89054103

View File

@ -53,7 +53,7 @@ sub ZoneMinder_Initialize {
$hash->{WriteFn} = "ZoneMinder_Write";
$hash->{ReadyFn} = "ZoneMinder_Ready";
$hash->{AttrList} = "interval publicAddress webConsoleContext " . $readingFnAttributes;
$hash->{AttrList} = "loginInterval publicAddress webConsoleContext " . $readingFnAttributes;
$hash->{MatchList} = { "1:ZM_Monitor" => "^.*" };
Log3 '', 3, "ZoneMinder - Initialize done ...";
@ -182,6 +182,7 @@ sub ZoneMinder_API_Login_Callback {
my $name = $hash->{NAME};
$hash->{APILoginStatus} = $param->{code};
Log3 $name, 3, "ZoneMinder ($name) - login status: $hash->{APILoginStatus}";
if($err ne "") {
Log3 $name, 0, "error while requesting ".$param->{url}." - $err";
@ -205,7 +206,9 @@ sub ZoneMinder_API_Login_Callback {
}
}
InternalTimer(gettimeofday() + 3600, "ZoneMinder_API_Login", $hash);
RemoveInternalTimer($hash, "ZoneMinder_API_Login");
my $interval = AttrVal($name, 'loginInterval', 3600);
InternalTimer(gettimeofday() + $interval, "ZoneMinder_API_Login", $hash);
return undef;
}
@ -624,11 +627,16 @@ sub ZoneMinder_Get {
}
sub ZoneMinder_Set {
my ( $hash, $param ) = @_;
my ( $hash, $name, $opt, $args ) = @_;
if ("login" eq $opt) {
Log3 $name, 1, "ZoneMinder ($name) - Manually triggered Login";
ZoneMinder_API_Login($hash);
return undef;
}
my $name = $hash->{NAME};
# Log3 $name, 3, "ZoneMinder ($name) - Set done ...";
return undef;
return "Unknown argument $opt, choose one of login";
}
sub ZoneMinder_Ready {