fix bug Can't use string as a HASH ref

error with newest firmware
Can't use string ("updating synchrometer") as a HASH ref while "strict refs"

[Ticket: no]
This commit is contained in:
Marko Oldenburg 2022-02-28 14:50:57 +01:00
parent d9a7ac4853
commit d604ef1baf
2 changed files with 31 additions and 27 deletions

View File

@ -1,2 +1,2 @@
UPD 2022-01-29_04:24:06 6874 FHEM/46_TeslaPowerwall2AC.pm
UPD 2022-02-19_20:54:38 28171 lib/FHEM/Devices/Tesla/Powerwall.pm
UPD 2022-02-28_14:49:01 28406 lib/FHEM/Devices/Tesla/Powerwall.pm

View File

@ -521,7 +521,7 @@ sub ErrorHandling {
}
## Fehler für neuen Token
## {"code":401,"error":"User session not found from HEZwKy9lY17-gLagEdpyzk3IsJgUvrE1jTP_SBDTyDQ2PPU--A8kF_p2tRmBQRLVKYzR11ijhO0j6kOXFzmxcw==","message":"Invalid bearer token"}
## {"code":401,"error":"User session not found from HEZwKy9lY17-gLagEdpyzk3IsJgUvrE1XFzmxcw==","message":"Invalid bearer token"}
if ( $data =~ m#{"code":(\d+),"error":"(.+)","message":"(.+)"}\z#xms ) {
@ -712,6 +712,7 @@ sub ReadingsProcessing_Powerwalls {
my $r1 = $_;
my $hRef;
for my $hRef ( @{ $decode_json->{$_} } ) {
if ( ref($hRef) eq 'HASH' ) {
for ( keys %{$hRef} ) {
$r1 =~ s/s$//xg;
$readings{qq(${r1}_${i}_${_})} = $hRef->{$_}
@ -723,7 +724,8 @@ sub ReadingsProcessing_Powerwalls {
my $r2 = $_;
my $r3 = $hRef->{$_};
for ( keys %{$r3} ) {
$readings{qq(${r1}_${i}_${r2}_${_})} = $r3->{$_}
$readings{qq(${r1}_${i}_${r2}_${_})} =
$r3->{$_}
if ( ref( $r3->{$_} ) ne 'ARRAY'
&& defined( $r3->{$_} ) );
@ -736,7 +738,8 @@ sub ReadingsProcessing_Powerwalls {
$readings{
qq(${r1}_${i}_${r2}_${r4}_${ii}_${_})
} = $hRef->{$_}
if ( ref( $hRef->{$_} ) ne 'HASH'
if (
ref( $hRef->{$_} ) ne 'HASH'
&& defined( $hRef->{$_} ) );
}
@ -746,6 +749,7 @@ qq(${r1}_${i}_${r2}_${r4}_${ii}_${_})
}
}
}
}
$i++;
}