change code for set powerwalls stop or run

This commit is contained in:
Marko Oldenburg 2019-10-09 10:24:29 +02:00
parent 8384d8d57c
commit 9366939b23

View File

@ -177,9 +177,6 @@ my %paths = (
'siteinfo' => 'site_info', 'siteinfo' => 'site_info',
'sitename' => 'site_info/site_name', 'sitename' => 'site_info/site_name',
'sitemaster' => 'sitemaster', 'sitemaster' => 'sitemaster',
# 'powerwallsstop' => 'sitemaster/stop',
# 'powerwallsrun' => 'sitemaster/run',
'powerwalls' => 'powerwalls', 'powerwalls' => 'powerwalls',
'registration' => 'customer/registration', 'registration' => 'customer/registration',
'status' => 'status', 'status' => 'status',
@ -187,6 +184,11 @@ my %paths = (
'gridstatus' => 'system_status/grid_status', 'gridstatus' => 'system_status/grid_status',
); );
my %cmdPaths = (
'powerwallsstop' => 'sitemaster/stop',
'powerwallsrun' => 'sitemaster/run',
);
sub Initialize($) { sub Initialize($) {
my ($hash) = @_; my ($hash) = @_;
@ -236,6 +238,7 @@ sub Undef($$) {
my ( $hash, $arg ) = @_; my ( $hash, $arg ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
RemoveInternalTimer($hash);
Log3 $name, 3, "TeslaPowerwall2AC ($name) - Device $name deleted"; Log3 $name, 3, "TeslaPowerwall2AC ($name) - Device $name deleted";
return undef; return undef;
@ -383,9 +386,7 @@ sub Set($@) {
my $arg; my $arg;
if ( $cmd eq 'powerwalls' ) { if ( $cmd eq 'powerwalls' ) {
$arg = lc( $cmd . $args[0] ); $arg = lc( $cmd . $args[0] );
} }
else { else {
@ -406,6 +407,9 @@ sub Timer_GetData($) {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
RemoveInternalTimer($hash);
if ( defined( $hash->{actionQueue} ) if ( defined( $hash->{actionQueue} )
and scalar( @{ $hash->{actionQueue} } ) == 0 ) and scalar( @{ $hash->{actionQueue} } ) == 0 )
{ {
@ -792,7 +796,14 @@ sub CreateUri($$) {
my $header; my $header;
my $data; my $data;
$uri = $host . '/api/' . $paths{$path}; if ( $path eq 'powerwallsstop'
or $path eq 'powerwallsruns' )
{
$uri = $host . '/api/' . $cmdPaths{$path};
}
else {
$uri = $host . '/api/' . $paths{$path};
}
if ( $path eq 'sitemasterrun' ) { if ( $path eq 'sitemasterrun' ) {
$header = 'Authorization: Bearer' . $hash->{TOKEN}; $header = 'Authorization: Bearer' . $hash->{TOKEN};
@ -901,7 +912,7 @@ sub CreateUri($$) {
], ],
"release_status": "under develop", "release_status": "under develop",
"license": "GPL_2", "license": "GPL_2",
"version": "v0.7.2", "version": "v0.7.3",
"author": [ "author": [
"Marko Oldenburg <leongaultier@gmail.com>" "Marko Oldenburg <leongaultier@gmail.com>"
], ],