diff --git a/CHANGED b/CHANGED index be95ac140..d6e5a094d 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 74_GardenaSmartDevice: fix uninitialized value in concatenation - feature: 98_backup: split modul code in to two files. add code for error handling - bugfix: lib/FHEM/Core/Authentication/Passwords.pm: diff --git a/FHEM/73_GardenaSmartBridge.pm b/FHEM/73_GardenaSmartBridge.pm index 7517fd680..79ab0d99f 100644 --- a/FHEM/73_GardenaSmartBridge.pm +++ b/FHEM/73_GardenaSmartBridge.pm @@ -2,7 +2,7 @@ # # Developed with Kate # -# (c) 2017-2019 Copyright: Marko Oldenburg (leongaultier at gmail dot com) +# (c) 2017-2011 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to comitters: @@ -156,8 +156,11 @@ BEGIN { readingsBeginUpdate readingsEndUpdate Log3 + devspec2array + asyncOutput CommandAttr AttrVal + InternalVal ReadingsVal CommandDefMod modules @@ -404,18 +407,17 @@ sub Get { // return qq{"get $name" needs at least one argument}; if ( lc $cmd eq 'debug_devices_list' ) { - $hash->{helper}{debug_device_list} = 'get'; - #Log3 $name, 2, Dumper($hash->{helper}); - #Write($hash, undef, undef, undef, undef); - - return 'coming soon'; + my $device = shift @$aArg; + $hash->{helper}{debug_device} = $device; + Write($hash, undef, undef, undef, undef); + return undef; } else { - my $list = ""; - $list .= " debug_devices_list:noArg" - if ( AttrVal( $name, "debugJSON", "none") ne "none" ); - - return "Unknown argument $cmd,choose one of $list"; - + my $list = ""; + $list .= " debug_devices_list:" + .join( ',', @{ $hash->{helper}{deviceList} }) + if ( AttrVal( $name, "debugJSON", "none") ne "none" + && exists($hash->{helper}{deviceList}) ); + return "Unknown argument $cmd,choose one of $list"; } } @@ -487,6 +489,7 @@ sub Write { method => $method, header => $header, doTrigger => 1, + cl => $hash->{CL}, callback => \&ErrorHandling } ); @@ -514,7 +517,7 @@ sub ErrorHandling { if ( defined( $param->{'device_id'} ) ); my $dname = $dhash->{NAME}; - + Log3 $name, 4, "GardenaSmartBridge ($name) - Request: $data"; my $decode_json = eval { decode_json($data) }; @@ -709,7 +712,31 @@ sub ErrorHandling { return; } - + if (defined($hash->{helper}{debug_device})){ + Log3 $name, 5, "GardenaSmartBridge DEBUG Device"; + my @device_spec = ("name", "id", "category"); + my $devJson=$decode_json->{devices}; + my $output = '.:{ DEBUG OUTPUT for '.$devJson->{name}.' }:. \n'; + for my $spec (@device_spec) { + $output .= "$spec : $devJson->{$spec} \n"; + } + #settings + $output .= '\n=== Settings \n'; + my $i = 0; + for my $dev_settings ( @ { $devJson->{settings} } ) { + $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; + } readingsSingleUpdate( $hash, 'state', 'Connected', 1 ) if ( defined( $hash->{helper}{locations_id} ) ); ResponseProcessing( $hash, $data ) @@ -773,19 +800,6 @@ sub ResponseProcessing { return; } - elsif ( exists($hash->{helper}{debug_device_list}) ) { - Log3 $name, 4, "Debug Devices List"; - my $msg; - $msg = "test krams"; - - my @buffer = split( '"devices":\[', $json ); - my ( $json, $tail ) = ParseJSON( $hash, $buffer[1] ); - - $decode_json = eval { decode_json($json) }; - - delete $hash->{helper}{debug_device_list}; - return $msg; - } elsif (defined( $decode_json->{devices} ) && ref( $decode_json->{devices} ) eq 'ARRAY' && scalar( @{ $decode_json->{devices} } ) > 0 ) @@ -960,6 +974,12 @@ sub getDevices { if ( not IsDisabled($name) ) { + delete $hash->{helper}{deviceList}; + my @list; + @list = devspec2array('TYPE=GardenaSmartDevice'); + for my $gardenaDev (@list){ + push( @{ $hash->{helper}{deviceList} }, $gardenaDev ); + } Write( $hash, undef, undef, undef ); Log3 $name, 4, "GardenaSmartBridge ($name) - fetch device list and device states"; @@ -1195,6 +1215,7 @@ sub createHttpValueStrings { && defined( $hash->{helper}{locations_id} ) ); } + $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} ) ) { diff --git a/FHEM/74_GardenaSmartDevice.pm b/FHEM/74_GardenaSmartDevice.pm index bdd4e004c..c3195e497 100644 --- a/FHEM/74_GardenaSmartDevice.pm +++ b/FHEM/74_GardenaSmartDevice.pm @@ -2,7 +2,7 @@ # # Developed with Kate # -# (c) 2017-2019 Copyright: Marko Oldenburg (leongaultier at gmail dot com) +# (c) 2017-2021 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to comitters: @@ -604,9 +604,10 @@ sub WriteReadings { #Log3 $name, 1, " - KEIN ARRAY" if ( ref( $decode_json->{settings}[$settings]{value} ) ne "ARRAY"); #Log3 $name, 1, " - IST ARRAY" if ( ref( $decode_json->{settings}[$settings]{value} ) eq "ARRAY"); - if ( $decode_json->{settings}[$settings]{name} eq 'schedules_paused_until' - || $decode_json->{settings}[$settings]{name} eq 'eco_mode' - ) + if ( exists($decode_json->{settings}[$settings]{name}) + && ( $decode_json->{settings}[$settings]{name} eq 'schedules_paused_until' + || $decode_json->{settings}[$settings]{name} eq 'eco_mode' ) + ) { if ( $hash->{helper}{$decode_json->{settings}[$settings]{name}.'_id'} ne $decode_json->{settings}[$settings]{id} ) @@ -615,6 +616,7 @@ sub WriteReadings { $decode_json->{settings}[$settings]{id}; } } + if ( ref( $decode_json->{settings}[$settings]{value} ) eq "ARRAY" && $decode_json->{settings}[$settings]{name} eq 'starting_points' ) { @@ -687,7 +689,7 @@ sub WriteReadings { readingsEndUpdate( $hash, 1 ); - Log3 $name, 4, "GardenaSmartDevice ($name) - readings was written}"; + Log3 $name, 4, "GardenaSmartDevice ($name) - readings was written"; return; } @@ -1255,7 +1257,7 @@ sub SetPredefinedStartPoints { ], "release_status": "stable", "license": "GPL_2", - "version": "v2.2.2", + "version": "v2.2.3", "author": [ "Marko Oldenburg " ],