From 6e5f2d98b39e5f16f7ccb1bc9d8d48983184ab55 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 28 May 2021 20:25:44 +0200 Subject: [PATCH] buttonconfing + cmdref --- FHEM/73_GardenaSmartBridge.pm | 26 +++++++++++++++++- FHEM/74_GardenaSmartDevice.pm | 48 +++++++++++++++++++++++++++++++-- controls_GardenaSmartDevice.txt | 4 +-- 3 files changed, 73 insertions(+), 5 deletions(-) diff --git a/FHEM/73_GardenaSmartBridge.pm b/FHEM/73_GardenaSmartBridge.pm index 12363aa..2302bd2 100644 --- a/FHEM/73_GardenaSmartBridge.pm +++ b/FHEM/73_GardenaSmartBridge.pm @@ -731,6 +731,18 @@ sub ErrorHandling { $output .= "value: $dev_settings->{value} \n"; } } + $output .= '\n=== Abilities \n'; + my $i = 0; + for my $dev_settings ( @ { $devJson->{abilities} } ) { + $output .= "[".$i++."]id: $dev_settings->{id} \n"; + $output .= "name: $dev_settings->{name} "; + if (ref ($dev_settings->{value}) eq 'ARRAY' + || ref ($dev_settings->{value}) eq 'HASH'){ + $output .= 'N/A \n'; + } else { + $output .= "value: $dev_settings->{value} \n"; + } + } $hash->{helper}{debug_device_output} = $output; asyncOutput($param->{cl}, $hash->{helper}{debug_device_output}); return; @@ -1215,7 +1227,6 @@ sub createHttpValueStrings { $uri = '/devices/'.InternalVal($hash->{helper}{debug_device}, 'DEVICEID', 0 ) if ( exists ($hash->{helper}{debug_device})); $uri = '/auth/token' if ( !defined( $hash->{helper}{session_id} ) ); - if ( defined( $hash->{helper}{locations_id} ) ) { if ( defined($abilities) && $abilities =~ /.*_settings/ ) { @@ -1279,6 +1290,19 @@ sub createHttpValueStrings { . $abilities . '/properties/manual_watering_timer'; + } + elsif (defined($abilities) + && defined($payload) + && $abilities eq 'watering_button_config' ) + { + $method = 'PUT'; + + $uri .= + '/devices/' + . $deviceId + . '/abilities/watering' + . '/properties/button_config_time'; + } elsif (defined($abilities) && defined($payload) diff --git a/FHEM/74_GardenaSmartDevice.pm b/FHEM/74_GardenaSmartDevice.pm index 23d3c06..8b34629 100644 --- a/FHEM/74_GardenaSmartDevice.pm +++ b/FHEM/74_GardenaSmartDevice.pm @@ -361,6 +361,18 @@ sub Set { . $aArg->[0] * 60 . ',"valve_id":1}}'; } + elsif ( lc $cmd eq 'manualbuttontime'){ + $service_id = $hash->{helper}{button_config_time_id}; + $payload= + '"properties":{"name":"button_config_time",' + .'"value":' + . $aArg->[0] * 60 + . ',"timestamp":"2021-05-26T19:06:23.680Z"' + . ',"at_bound":null,"unit":"seconds","ability":"' + . $service_id + .'"}'; + $abilities = 'watering_button_config'; + } elsif ( $cmd =~ m{\AcancelOverride}xms ) { my $valve_id = 1; @@ -464,7 +476,7 @@ sub Set { 'parkUntilFurtherNotice:noArg parkUntilNextTimer:noArg startResumeSchedule:noArg startOverrideTimer:slider,0,1,240 startpoint' if ( AttrVal( $name, 'model', 'unknown' ) eq 'mower' ); - $list .= 'manualOverride:slider,1,1,59 cancelOverride:noArg resumeSchedule:noArg stopSchedule' + $list .= 'manualOverride:slider,1,1,59 cancelOverride:noArg resumeSchedule:noArg stopSchedule manualButtonTime:slider,0,2,100' if ( AttrVal( $name, 'model', 'unknown' ) eq 'watering_computer' ); $list .= @@ -559,6 +571,27 @@ sub WriteReadings { for my $propertie ( @{ $decode_json->{abilities}[$abilities]{properties} } ) { + if ( exists($decode_json->{abilities}[$abilities]{name}) + && ( + $decode_json->{abilities}[$abilities]{name} eq 'watering' ) + ) { + if ( $propertie->{name} eq 'button_config_time' ) + { + if ( $hash->{helper}{$propertie->{name}.'_id'} ne + $decode_json->{abilities}[$abilities]{id} ) + { + $hash->{helper}{$propertie->{name}.'_id'} = + $decode_json->{abilities}[$abilities]{id}; + } + readingsBulkUpdateIfChanged( + $hash, + 'manualButtonTime', + (RigReadingsValue( $hash, $propertie->{value} / 60) ) + ); + next; + } + } + readingsBulkUpdateIfChanged( $hash, $decode_json->{abilities}[$abilities]{name} . '-' @@ -1137,6 +1170,7 @@ sub SetPredefinedStartPoints { set - +

irrigation control

  • resumeScheduleValve - start schedule irrigation on valve n
  • stopScheduleValve - stop schedule irrigation on valve n (Default: 2040-12-31T22:00:00.000Z) | optional params hours (now + hours)
  • closeAllValves - close all valves
  • +

    water control

    +
  • manualButtonTime - set manual time for button press (in minutes) 0 disable button
  • +
  • stopSchedule - stop schedule
  • +
  • resumeSchedule - resume schedule
  • @@ -1285,6 +1323,7 @@ sub SetPredefinedStartPoints { set +

    irrigation control

  • resumeScheduleValve - Startet Bew&aauml;sserung am Ventil n nach Zeitplan
  • stopScheduleValve - Setzt Bew&aauml;sserung am Ventil n aus (Default: 2040-12-31T22:00:00.000Z) | Optionaler Parameter Stunden (Jetzt + Stunden)
  • closeAllValves - Stopt Bew&aauml;sserung an allen Ventilen
  • +

    water control

    +
  • manualButtonTime - setzt die Dauer für den manuellen Knopf (in Minuten) 0 Schaltet den Knopf aus
  • +
  • stopSchedule - Halte Zeitplan an
  • +
  • resumeSchedule - Weiterführung des Zeitplans
  • diff --git a/controls_GardenaSmartDevice.txt b/controls_GardenaSmartDevice.txt index 63aa76e..ac6150d 100644 --- a/controls_GardenaSmartDevice.txt +++ b/controls_GardenaSmartDevice.txt @@ -1,2 +1,2 @@ -UPD 2021-05-26_20:23:34 46135 FHEM/73_GardenaSmartBridge.pm -UPD 2021-05-26_20:36:16 52284 FHEM/74_GardenaSmartDevice.pm +UPD 2021-05-28_19:58:57 46928 FHEM/73_GardenaSmartBridge.pm +UPD 2021-05-28_20:23:31 54307 FHEM/74_GardenaSmartDevice.pm