refactored set methods

This commit is contained in:
Matthias Sandmann 2022-03-16 21:27:34 +01:00
parent cf5b76fcfb
commit 5ffb942374

View File

@ -11,6 +11,7 @@ use JSON;
my %EaseeWallbox_gets = ( my %EaseeWallbox_gets = (
update => "noArg", update => "noArg",
health => "noArg", health => "noArg",
baseData => "noArg",
chargers => "noArg", chargers => "noArg",
sites => "noArg", sites => "noArg",
profile => "noArg", profile => "noArg",
@ -281,43 +282,24 @@ sub EaseeWallbox_Get($@) {
my $cmd = $args[0]; my $cmd = $args[0];
my $arg = $args[1]; my $arg = $args[1];
if ( $opt eq "chargers" ) { if ($opt eq 'baseData') {
EaseeWallbox_GetChargers($hash);
return EaseeWallbox_GetChargers($hash); EaseeWallbox_GetChargerConfig($hash);
EaseeWallbox_GetChargerSite($hash);
} EaseeWallbox_RefreshData($hash);
elsif ( $opt eq "profile" ) {
return EaseeWallbox_RefreshData($hash);
}
elsif ( $opt eq "config" ) {
return EaseeWallbox_GetChargerConfig($hash);
}
elsif ( $opt eq "sites" ) {
return EaseeWallbox_GetChargerSite($hash);
}
elsif ( $opt eq "update" ) {
} elsif ( $opt eq "update" ) {
Log3 $name, 3, "EaseeWallbox_Get $name: Updating all data"; Log3 $name, 3, "EaseeWallbox_Get $name: Updating all data";
$hash->{LOCAL} = 1; $hash->{LOCAL} = 1;
EaseeWallbox_RequestChargerState($hash); EaseeWallbox_RequestChargerState($hash);
EaseeWallbox_RequestCurrentSession($hash); EaseeWallbox_RequestCurrentSession($hash);
delete $hash->{LOCAL}; delete $hash->{LOCAL};
return undef; return undef;
} else {
} return EaseeWallbox_GetChargers($hash) if $opt eq "chargers";
else { return EaseeWallbox_RefreshData($hash) if $opt eq "profile";
return EaseeWallbox_GetChargerConfig($hash) if $opt eq "config";
my @cList = keys %EaseeWallbox_gets; return EaseeWallbox_GetChargerSite($hash) if $opt eq "sites";
return "Unknown v2 argument $opt, choose one of "
. join( " ", @cList );
} }
} }