diff --git a/controls_TeslaPowerwall2AC.txt b/controls_TeslaPowerwall2AC.txt index f046fb9..6893e6f 100644 --- a/controls_TeslaPowerwall2AC.txt +++ b/controls_TeslaPowerwall2AC.txt @@ -1,2 +1,2 @@ -UPD 2022-01-07_07:25:06 6874 FHEM/46_TeslaPowerwall2AC.pm -UPD 2022-01-07_08:33:19 27498 lib/FHEM/Devices/Tesla/Powerwall.pm +UPD 2022-01-09_15:44:54 6874 FHEM/46_TeslaPowerwall2AC.pm +UPD 2022-01-09_15:59:59 27461 lib/FHEM/Devices/Tesla/Powerwall.pm diff --git a/lib/FHEM/Devices/Tesla/Powerwall.pm b/lib/FHEM/Devices/Tesla/Powerwall.pm index 067527a..14b3d86 100644 --- a/lib/FHEM/Devices/Tesla/Powerwall.pm +++ b/lib/FHEM/Devices/Tesla/Powerwall.pm @@ -56,6 +56,7 @@ package FHEM::Devices::Tesla::Powerwall; use strict; use warnings; +use experimental qw( switch ); use HttpUtils; use GPUtils qw(GP_Import); @@ -285,52 +286,27 @@ sub Get { my $cmd = shift @$aArg // return qq(get $name needs at least one argument); my $arg; - if ( $cmd eq 'statusSOE' ) { + $cmd = lc($cmd); - $arg = lc($cmd); - - } - elsif ( $cmd eq 'aggregates' ) { - - $arg = lc($cmd); - - } - elsif ( $cmd eq 'siteinfo' ) { - - $arg = lc($cmd); - - } - elsif ( $cmd eq 'powerwalls' ) { - - $arg = lc($cmd); - - } - elsif ( $cmd eq 'sitemaster' ) { - - $arg = lc($cmd); - - } - elsif ( $cmd eq 'registration' ) { - - $arg = lc($cmd); - - } - elsif ( $cmd eq 'status' ) { - - $arg = lc($cmd); - - } - else { - - my $list = ''; - $list .= + given ($cmd) { + when ('statussoe') { $arg = $cmd; } + when ('aggregates') { $arg = $cmd; } + when ('siteinfo') { $arg = $cmd; } + when ('powerwalls') { $arg = $cmd; } + when ('sitemaster') { $arg = $cmd; } + when ('registration') { $arg = $cmd; } + when ('status') { $arg = $cmd; } + default { + my $list = ''; + $list .= 'statusSOE:noArg aggregates:noArg siteinfo:noArg sitemaster:noArg powerwalls:noArg registration:noArg status:noArg' - if ( ::AttrVal( $name, 'emailaddr', 'none' ) ne 'none' - && exists( $hash->{helper}->{passObj} ) - && defined( $hash->{helper}->{passObj}->getReadPassword($name) ) - && defined( $hash->{TOKEN} ) ); + if ( ::AttrVal( $name, 'emailaddr', 'none' ) ne 'none' + && exists( $hash->{helper}->{passObj} ) + && defined( $hash->{helper}->{passObj}->getReadPassword($name) ) + && defined( $hash->{TOKEN} ) ); - return 'Unknown argument ' . $cmd . ', choose one of ' . $list; + return 'Unknown argument ' . $cmd . ', choose one of ' . $list; + } } return 'There are still path commands in the action queue'