70_BRAVIA.pm: fix registration renewal

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@24219 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
vuffiraa 2021-04-11 14:29:19 +00:00
parent 8ef88dabc0
commit a146daa349
3 changed files with 50 additions and 3 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix: 70_BRAVIA: fix registration renewal
- change: 49_IPCAM: imageWithCallback wrapped in internalTimer with 0 delay
- bugfix: 47_OBIS: Reintegrate buggy DZG meters support
- change: 49_IPCAM: introduced attribute httpTimeout

View File

@ -2214,8 +2214,10 @@ sub CheckRegistration {
my ( $hash, $service, $cmd, $param, @successor ) = @_;
my $name = $hash->{NAME};
if (ReadingsVal($name, "authCookie", "") ne "" and
ReadingsTimestamp($name, "authCookie", "") =~ m/^(\d{4})-(\d{2})-(\d{2}) ([0-2]\d):([0-5]\d):([0-5]\d)$/xms) {
my $authCookie = ReadingsVal($name, "authCookie", "");
my $authCookieTS = ReadingsTimestamp($name, "authCookie", "");
if ($authCookie ne "" and
$authCookieTS =~ m/^(\d{4})-(\d{2})-(\d{2})\ ([0-2]\d):([0-5]\d):([0-5]\d)$/xms) {
my $time = fhemTimeLocal($6, $5, $4, $3, $2 - 1, $1 - 1900);
# max age defaults to 14 days
@ -2235,12 +2237,16 @@ sub CheckRegistration {
$msg .= " $i: ";
$msg .= join(",", map { defined($_) ? $_ : '' } @succ_item);
}
Log3($name, 4, "BOTVAC created".$msg);
Log3($name, 4, "BRAVIA $name: created".$msg);
SendCommand( $hash, "register", "renew", undef, @successor );
return 1;
} else {
Log3($name, 5, "BRAVIA $name: registration valid until $authCookieTS");
}
} else {
Log3($name, 4, "BRAVIA $name: authCookie not valid '$authCookie $authCookieTS'");
}
return;
}

View File

@ -0,0 +1,40 @@
################################################
# test Set
################################################
package FHEM::BRAVIA;
use strict;
use warnings;
use Test::More;
# used to import of FHEM functions from fhem.pl
use GPUtils qw(:all);
BEGIN {
GP_Import(
qw(
fhem
FhemTestUtils_gotLog
FhemTestUtils_resetLogs
)
);
}
# execute checkRegistration
{
CheckRegistration($::defs{tv});
}
is(FhemTestUtils_gotLog("BRAVIA tv: authCookie not valid ' '"), 1, "Registration missing");
FhemTestUtils_resetLogs();
fhem('setreading tv authCookie test');
{
CheckRegistration($::defs{tv});
}
is(FhemTestUtils_gotLog("BRAVIA tv: authCookie not valid '.*'"), 0, "Registration valid");
is(FhemTestUtils_gotLog("BRAVIA tv: registration valid until .*"), 1, "Registration period");
done_testing;
exit(0);
1;