From 8acadea5bfc06048bc83a2a438de656bf3b447d2 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Mon, 25 Mar 2019 21:55:01 +0100 Subject: [PATCH] add power plugin support --- 73_GardenaSmartBridge.pm | 17 +++++++++++++++++ 74_GardenaSmartDevice.pm | 17 ++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/73_GardenaSmartBridge.pm b/73_GardenaSmartBridge.pm index 104cf6d..da3c847 100644 --- a/73_GardenaSmartBridge.pm +++ b/73_GardenaSmartBridge.pm @@ -383,6 +383,8 @@ sub Write($@) { Log3 $name, 4, "GardenaSmartBridge ($name) - Send with URL: $hash->{URL}$uri, HEADER: secret!, DATA: secret!, METHOD: $method"; +# Log3 $name, 3, +# "GardenaSmartBridge ($name) - Send with URL: $hash->{URL}$uri, HEADER: $header, DATA: $payload, METHOD: $method"; } sub ErrorHandling($$$) { @@ -979,6 +981,21 @@ sub createHttpValueStrings($@) { . '/properties/watering_timer_' . $valve_id; + } + elsif ( defined($abilities) + and defined($payload) + and $abilities eq 'power' ) + { + my $valve_id; + $method = 'PUT'; + + $uri .= + '/devices/' + . $deviceId + . '/abilities/' + . $abilities + . '/properties/power_timer'; + } else { $uri .= diff --git a/74_GardenaSmartDevice.pm b/74_GardenaSmartDevice.pm index cbc0d5f..32c764e 100644 --- a/74_GardenaSmartDevice.pm +++ b/74_GardenaSmartDevice.pm @@ -238,7 +238,7 @@ sub Set($@) { SetPredefinedStartPoints( $hash, @args ); return $err if ( defined($err) ); - ### watering_computer + ### watering_computer } elsif ( lc $cmd eq 'manualoverride' ) { @@ -251,20 +251,15 @@ sub Set($@) { $payload = '"name":"cancel_override"'; - ### Watering ic24 + } elsif ( lc $cmd eq 'on' or lc $cmd eq 'off' or lc $cmd eq 'on-for-timer' ) { - my $duration = join( " ", @args ); - if ( lc $cmd eq 'on-for-timer' ) { - $payload = '"name":"power_timer","parameters":{"duration":' - . $duration . '}'; - } - else { $payload = '"name":"power_timer","parameters":{"duration":' - . lc $cmd . '}'; - } + my $val = ( defined($args[0]) ? join( " ", @args ) : lc $cmd ); + $payload = + '"properties":{"value":"' . $val . '"}'; } - + ### Watering ic24 elsif ( $cmd =~ /manualDurationValve/ ) { my $valve_id;