change condition to find out Invalid bearer token
{"code":401,"error":"User session not found from HEZmxcw==","message":"Invalid bearer token"} [Ticket: no]
This commit is contained in:
parent
3a91b450c7
commit
d9a7ac4853
@ -1,2 +1,2 @@
|
|||||||
UPD 2022-01-29_04:24:06 6874 FHEM/46_TeslaPowerwall2AC.pm
|
UPD 2022-01-29_04:24:06 6874 FHEM/46_TeslaPowerwall2AC.pm
|
||||||
UPD 2022-02-17_08:35:26 28294 lib/FHEM/Devices/Tesla/Powerwall.pm
|
UPD 2022-02-19_20:54:38 28171 lib/FHEM/Devices/Tesla/Powerwall.pm
|
||||||
|
@ -161,12 +161,11 @@ sub Define {
|
|||||||
my $name = $aArg->[0];
|
my $name = $aArg->[0];
|
||||||
my $host = $aArg->[2];
|
my $host = $aArg->[2];
|
||||||
|
|
||||||
$hash->{HOST} = $host;
|
$hash->{HOST} = $host;
|
||||||
$hash->{INTERVAL} = 300;
|
$hash->{INTERVAL} = 300;
|
||||||
$hash->{VERSION} = version->parse($VERSION)->normal;
|
$hash->{VERSION} = version->parse($VERSION)->normal;
|
||||||
$hash->{NOTIFYDEV} = qq(global,$name);
|
$hash->{NOTIFYDEV} = qq(global,$name);
|
||||||
$hash->{actionQueue} = [];
|
$hash->{actionQueue} = [];
|
||||||
$hash->{helper}->{loginerr} = 0;
|
|
||||||
|
|
||||||
::CommandAttr( undef, $name . q{ room Tesla} )
|
::CommandAttr( undef, $name . q{ room Tesla} )
|
||||||
if ( ::AttrVal( $name, 'room', 'none' ) eq 'none' );
|
if ( ::AttrVal( $name, 'room', 'none' ) eq 'none' );
|
||||||
@ -305,8 +304,6 @@ sub Get {
|
|||||||
|
|
||||||
return 'Unknown argument ' . $cmd . ', choose one of ' . $list;
|
return 'Unknown argument ' . $cmd . ', choose one of ' . $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash->{helper}->{loginerr} = 0 if $cmd eq 'login';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'There are still path commands in the action queue'
|
return 'There are still path commands in the action queue'
|
||||||
@ -524,33 +521,29 @@ sub ErrorHandling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
## Fehler für neuen Token
|
## Fehler für neuen Token
|
||||||
## {"code":401,"error":"bad credentials","message":"Login Error"}
|
## {"code":401,"error":"User session not found from HEZwKy9lY17-gLagEdpyzk3IsJgUvrE1jTP_SBDTyDQ2PPU--A8kF_p2tRmBQRLVKYzR11ijhO0j6kOXFzmxcw==","message":"Invalid bearer token"}
|
||||||
|
|
||||||
if ( $data =~ m#{"code":(\d+),"error":"(.+)","message":"(.+)"}$#xms ) {
|
if ( $data =~ m#{"code":(\d+),"error":"(.+)","message":"(.+)"}\z#xms ) {
|
||||||
|
|
||||||
if ( $1 == 401
|
if ( $1 == 401
|
||||||
&& $2 eq 'bad credentials'
|
&& $2 =~ m#\AUser\ssession\snot\sfound\sfrom\s.*#xms
|
||||||
&& $3 eq 'Login Error'
|
&& $3 eq 'Invalid bearer token' )
|
||||||
&& $hash->{helper}->{loginerr} == 0 )
|
|
||||||
{
|
{
|
||||||
$hash->{helper}->{loginerr} = 1;
|
|
||||||
$hash->{actionQueue} = [];
|
$hash->{actionQueue} = [];
|
||||||
delete $hash->{TOKEN};
|
delete $hash->{TOKEN};
|
||||||
unshift @{ $hash->{actionQueue} }, 'login';
|
unshift @{ $hash->{actionQueue} }, 'login';
|
||||||
|
|
||||||
::Log3 $name, 1,
|
::Log3 $name, 1,
|
||||||
"TeslaPowerwall2AC ($name) - Login Error. Empty action queue";
|
"TeslaPowerwall2AC ($name) - Invalid bearer token. Empty action queue";
|
||||||
::Log3 $name, 1,
|
::Log3 $name, 1,
|
||||||
"TeslaPowerwall2AC ($name) - Login Error. run relogin";
|
"TeslaPowerwall2AC ($name) - Invalid bearer token. run relogin";
|
||||||
::Log3 $name, 1,
|
::Log3 $name, 1,
|
||||||
"TeslaPowerwall2AC ($name) - Login Error. New action queue "
|
"TeslaPowerwall2AC ($name) - Invalid bearer token. New action queue "
|
||||||
. join ',', @{ $hash->{actionQueue} };
|
. join ',', @{ $hash->{actionQueue} };
|
||||||
|
|
||||||
return Write($hash);
|
return Write($hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash->{helper}->{loginerr} = 0;
|
|
||||||
|
|
||||||
::readingsBeginUpdate($hash);
|
::readingsBeginUpdate($hash);
|
||||||
|
|
||||||
::readingsBulkUpdate( $hash, 'state', $1, 1 );
|
::readingsBulkUpdate( $hash, 'state', $1, 1 );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user