From 3db2e709feab4c4ae09974a87328e1e0314dff2d Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Sat, 20 Jan 2018 06:38:17 +0100 Subject: [PATCH] readings number of powerwalls, values pro powerwalls --- 46_TeslaPowerwall2AC.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/46_TeslaPowerwall2AC.pm b/46_TeslaPowerwall2AC.pm index 843063d..51d87de 100644 --- a/46_TeslaPowerwall2AC.pm +++ b/46_TeslaPowerwall2AC.pm @@ -66,7 +66,7 @@ use HttpUtils; 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} or grep /^DELETEATTR.$name.disable$/,@{$events} + or grep /^DELETEATTR.$name.interval$/,@{$events} or (grep /^DEFINED.$name$/,@{$events} and $init_done) ); return; } @@ -489,15 +490,20 @@ sub TeslaPowerwall2AC_ReadingsProcessing_Powerwalls($$) { if( ref($decode_json->{powerwalls}) eq "ARRAY" and scalar(@{$decode_json->{powerwalls}}) > 0 ) { - + my $i = 0; + foreach my $powerwall (@{$decode_json->{powerwalls}}) { if( ref($powerwall) eq "HASH" ) { while( my ($r,$v) = each %{$powerwall} ) { - $readings{$r} = $v; + $readings{'wall'.$i.'_'.$r} = $v; } + + $i++; } } + + $readings{'numberOfWalls'} = $i; } else { $readings{'error'} = 'aggregates response is not a Array';