readings number of powerwalls, values pro powerwalls

This commit is contained in:
Marko Oldenburg 2018-01-20 06:38:17 +01:00
parent 385f5085d6
commit 3db2e709fe

View File

@ -66,7 +66,7 @@ use HttpUtils;
eval "use JSON;1" or $missingModul .= "JSON "; eval "use JSON;1" or $missingModul .= "JSON ";
my $version = "0.2.3"; my $version = "0.2.4";
@ -231,6 +231,7 @@ sub TeslaPowerwall2AC_Notify($$) {
TeslaPowerwall2AC_Timer_GetData($hash) if( grep /^INITIALIZED$/,@{$events} TeslaPowerwall2AC_Timer_GetData($hash) if( grep /^INITIALIZED$/,@{$events}
or grep /^DELETEATTR.$name.disable$/,@{$events} or grep /^DELETEATTR.$name.disable$/,@{$events}
or grep /^DELETEATTR.$name.interval$/,@{$events}
or (grep /^DEFINED.$name$/,@{$events} and $init_done) ); or (grep /^DEFINED.$name$/,@{$events} and $init_done) );
return; return;
} }
@ -489,16 +490,21 @@ sub TeslaPowerwall2AC_ReadingsProcessing_Powerwalls($$) {
if( ref($decode_json->{powerwalls}) eq "ARRAY" and scalar(@{$decode_json->{powerwalls}}) > 0 ) { if( ref($decode_json->{powerwalls}) eq "ARRAY" and scalar(@{$decode_json->{powerwalls}}) > 0 ) {
my $i = 0;
foreach my $powerwall (@{$decode_json->{powerwalls}}) { foreach my $powerwall (@{$decode_json->{powerwalls}}) {
if( ref($powerwall) eq "HASH" ) { if( ref($powerwall) eq "HASH" ) {
while( my ($r,$v) = each %{$powerwall} ) { while( my ($r,$v) = each %{$powerwall} ) {
$readings{$r} = $v; $readings{'wall'.$i.'_'.$r} = $v;
} }
$i++;
} }
} }
$readings{'numberOfWalls'} = $i;
} else { } else {
$readings{'error'} = 'aggregates response is not a Array'; $readings{'error'} = 'aggregates response is not a Array';
} }