From f9661f645269e27687984531a1819007848ac026 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 15 Apr 2024 09:32:51 +0200 Subject: [PATCH 1/3] fix: patch code scheduling by hhhdg --- FHEM/74_GardenaSmartDevice.pm | 42 ++++++++++++++++++++++++--------- controls_GardenaSmartDevice.txt | 4 ++-- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/FHEM/74_GardenaSmartDevice.pm b/FHEM/74_GardenaSmartDevice.pm index d80d4f2..f0d185f 100644 --- a/FHEM/74_GardenaSmartDevice.pm +++ b/FHEM/74_GardenaSmartDevice.pm @@ -754,6 +754,8 @@ sub WriteReadings { . $propertie->{name} ne 'ic24-valves_connected' && $decode_json->{abilities}[$abilities]{name} . '-' . $propertie->{name} ne 'ic24-valves_master_config' + && ($decode_json->{abilities}[$abilities]{name} . '-' + . $propertie->{name}) !~ /scheduling-timeslot_state_\d/ && ref( $propertie->{value} ) ne "HASH" ); readingsBulkUpdateIfChanged( @@ -850,7 +852,28 @@ sub WriteReadings { } } } - + # decode timeslot_state_N arrays code by hhhdg + if ( defined( $propertie->{value} ) + && $decode_json->{abilities}[$abilities]{name} . '-' + . $propertie->{name} =~ /scheduling-timeslot_state_\d/ + && ref( $propertie->{value} ) eq "ARRAY" ) { + while ( my ( $r, $v ) = each @{ $propertie->{value} } ) { + if ( ref($v) eq "HASH" ) { + my $entry = $r+1; + while ( my ( $i_r, $i_v ) = each %{$v} ) { + readingsBulkUpdateIfChanged( + $hash, + $decode_json->{abilities}[$abilities]{name} + . '-' + . $propertie->{name} . '_' + . $entry . '_' + . $i_r, + RigReadingsValue( $hash, $i_v ) + ); + } + } + } + } # fi defined # ic24 and other watering devices calc irrigation left in sec readingsBulkUpdateIfChanged( $hash, @@ -907,15 +930,15 @@ sub WriteReadings { foreach my $dev_schedules ( sort keys %{ $hash->{READINGS} } ) { my $dev_reading = ReadingsVal( $name, $dev_schedules, "error" ); push @ist, $dev_reading - if $dev_schedules =~ /schedule.*\d_id/; # push reading _id + if $dev_schedules =~ /schedule.*\d+_id/; # push reading _id push @ist, $1 if $dev_schedules =~ - /schedule.*_(\d)_id/; # push readigs d from x_id + /schedule.*_(\d+)_id/; # push readigs d from x_id Log3 $name, 5, "[DEBUG] $name - Schedule - Key ist : $dev_schedules "; Log3 $name, 5, "[DEBUG] $name - Schedule - ID FOUND $dev_reading" - if $dev_schedules =~ /schedule.*_\d_id/; # cloud hat SOLL + if $dev_schedules =~ /schedule.*_\d+_id/; # cloud hat SOLL } #Log3 $name, 5, "[DEBUG] Cloud:".Dumper(@soll) . "- Internal:". Dumper(@ist); @@ -951,15 +974,12 @@ sub WriteReadings { && scalar(@soll) != scalar( @ist / 2 ) ) { while ( my $old_schedule_id = shift(@ist) ) { - if ( length($old_schedule_id) == 1 ) { - foreach ( keys %{ $hash->{READINGS} } ) { - delete $hash->{READINGS}->{$_} - if ( $_ =~ - /scheduling-schedules_event_$old_schedule_id.*/ ); - } + foreach ( keys %{ $hash->{READINGS} } ) { + delete $hash->{READINGS}->{$_} + if ( $_ =~ /scheduling-schedules_event_${old_schedule_id}_.*/ ); } # fi Log3 $name, 5, -"[DEBUG] - $name : deletereading scheduling-schedules_event_$old_schedule_id.*" +"[DEBUG] - $name : deletereading scheduling-schedules_event_${old_schedule_id}_.*" if length($old_schedule_id) == 1; } } diff --git a/controls_GardenaSmartDevice.txt b/controls_GardenaSmartDevice.txt index a453629..33fb221 100644 --- a/controls_GardenaSmartDevice.txt +++ b/controls_GardenaSmartDevice.txt @@ -1,2 +1,2 @@ -UPD 2024-03-18_10:15:10 48866 FHEM/73_GardenaSmartBridge.pm -UPD 2024-03-17_20:57:32 126450 FHEM/74_GardenaSmartDevice.pm \ No newline at end of file +UPD 2024-04-15_09:21:58 49572 FHEM/73_GardenaSmartBridge.pm +UPD 2024-04-15_09:32:30 127663 FHEM/74_GardenaSmartDevice.pm -- 2.45.2 From 03ad7e3fba1c8ce88ac34535f0652b93e5e7679f Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 15 Apr 2024 09:38:16 +0200 Subject: [PATCH 2/3] fix: version push --- CHANGELOG.md | 114 +++++++++++++++++++++++++++++++- FHEM/74_GardenaSmartDevice.pm | 2 +- controls_GardenaSmartDevice.txt | 2 +- 3 files changed, 114 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb5100c..a3f54ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,114 @@ -### test: smartdevice variable wintermode initializied Bridge consolidiert wifi/ethernet (HEAD -> patch_mucki) +### fix: patch code scheduling by hhhdg (HEAD -> patch_valve_hhhdg) +>Mon, 15 Apr 2024 09:32:51 +0200 + +>Author: Sebastian (em@ail.tld) + +>Commiter: Sebastian (em@ail.tld) + + + + +### controls_GardenaSmartDevice.txt aktualisiert +>Thu, 28 Mar 2024 06:05:59 +0100 + +>Author: Marko Oldenburg (marko@noreply@cooltux.net) + +>Commiter: Marko Oldenburg (marko@noreply@cooltux.net) + + + + +### controls_GardenaSmartDevice.txt aktualisiert +>Thu, 28 Mar 2024 05:59:55 +0100 + +>Author: Marko Oldenburg (marko@noreply@cooltux.net) + +>Commiter: Marko Oldenburg (marko@noreply@cooltux.net) + + + + +### fix: put to post (origin/patch_newstart_command, patch_newstart_command) +>Mon, 18 Mar 2024 10:15:25 +0100 + +>Author: Sebastian (em@ail.tld) + +>Commiter: Sebastian (em@ail.tld) + + + + +### test: new api start cmd +>Sun, 17 Mar 2024 20:58:13 +0100 + +>Author: Sebastian (em@ail.tld) + +>Commiter: Sebastian (em@ail.tld) + + + + +### test: catch null value (origin/patch_mucki_gwoffline, patch_mucki_gwoffline) +>Fri, 23 Feb 2024 22:52:25 +0100 + +>Author: Sebastian (em@ail.tld) + +>Commiter: Sebastian (em@ail.tld) + + + + +### fix: fix +>Wed, 21 Feb 2024 22:00:02 +0100 + +>Author: Sebastian (em@ail.tld) + +>Commiter: Sebastian (em@ail.tld) + + + + +### fix: push version +>Wed, 21 Feb 2024 21:58:05 +0100 + +>Author: Sebastian (em@ail.tld) + +>Commiter: Sebastian (em@ail.tld) + + + + +### test: fix error spam +>Wed, 21 Feb 2024 21:56:14 +0100 + +>Author: Sebastian (em@ail.tld) + +>Commiter: Sebastian (em@ail.tld) + + + + +### fix: closes #90 +>Tue, 28 Nov 2023 08:52:33 +0100 + +>Author: Marko Oldenburg (fhemdevelopment@cooltux.net) + +>Commiter: Marko Oldenburg (fhemdevelopment@cooltux.net) + + + + +### fix: missing tree (origin/patch_mucki, patch_mucki) +>Sun, 12 Nov 2023 19:47:49 +0100 + +>Author: Sebastian (em@ail.tld) + +>Commiter: Sebastian (em@ail.tld) + + + + +### test: smartdevice variable wintermode initializied Bridge consolidiert wifi/ethernet >Sun, 5 Nov 2023 21:52:24 +0100 >Author: Sebastian (em@ail.tld) @@ -8,7 +118,7 @@ -### test: fix initial variables (origin/patch_mucki) +### test: fix initial variables >Wed, 1 Nov 2023 21:04:39 +0100 >Author: Sebastian (em@ail.tld) diff --git a/FHEM/74_GardenaSmartDevice.pm b/FHEM/74_GardenaSmartDevice.pm index f0d185f..097c11f 100644 --- a/FHEM/74_GardenaSmartDevice.pm +++ b/FHEM/74_GardenaSmartDevice.pm @@ -2704,7 +2704,7 @@ sub SetPredefinedStartPoints { ], "release_status": "stable", "license": "GPL_2", - "version": "v2.6.2", + "version": "v2.6.3", "author": [ "Marko Oldenburg " ], diff --git a/controls_GardenaSmartDevice.txt b/controls_GardenaSmartDevice.txt index 33fb221..271e21a 100644 --- a/controls_GardenaSmartDevice.txt +++ b/controls_GardenaSmartDevice.txt @@ -1,2 +1,2 @@ UPD 2024-04-15_09:21:58 49572 FHEM/73_GardenaSmartBridge.pm -UPD 2024-04-15_09:32:30 127663 FHEM/74_GardenaSmartDevice.pm +UPD 2024-04-15_09:37:55 127663 FHEM/74_GardenaSmartDevice.pm -- 2.45.2 From 8b66df8407c8f536e0f60431259d3c7201a6eb86 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Mon, 15 Apr 2024 15:45:33 +0200 Subject: [PATCH 3/3] docs: change copyright year Ticket: no --- FHEM/73_GardenaSmartBridge.pm | 93 +++++++++++++++++++-------------- FHEM/74_GardenaSmartDevice.pm | 44 +++++++++------- controls_GardenaSmartDevice.txt | 4 +- 3 files changed, 81 insertions(+), 60 deletions(-) diff --git a/FHEM/73_GardenaSmartBridge.pm b/FHEM/73_GardenaSmartBridge.pm index 9e6bde2..524578e 100644 --- a/FHEM/73_GardenaSmartBridge.pm +++ b/FHEM/73_GardenaSmartBridge.pm @@ -2,7 +2,7 @@ # # Developed with VSCodium and richterger perl plugin. # -# (c) 2017-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) +# (c) 2017-2024 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to comitters: @@ -75,9 +75,9 @@ eval { use IO::Socket::SSL; 1 } # try to use JSON::MaybeXS wrapper # for chance of better performance + open code eval { - require JSON::MaybeXS; - import JSON::MaybeXS qw( decode_json encode_json ); - 1; + require JSON::MaybeXS; + import JSON::MaybeXS qw( decode_json encode_json ); + 1; } or do { # try to use JSON wrapper @@ -629,31 +629,32 @@ sub ErrorHandling { if ($decode_json) { if ( ref( $decode_json->{errors} ) eq "ARRAY" && exists( $decode_json->{errors} ) ) - # replace defined with exists - # && defined( $decode_json->{errors} ) ) + + # replace defined with exists + # && defined( $decode_json->{errors} ) ) { # $decode_json->{errors} -> ARRAY # $decode_json->{errors}[0] -> HASH - if (exists ($decode_json->{errors}[0]{error}) ) { - readingsBulkUpdate( - $dhash, - "state", - $decode_json->{errors}[0]{error} . ' ' - . $decode_json->{errors}[0]{attribute}, - 1 - ); - readingsBulkUpdate( - $dhash, - "lastRequestState", - $decode_json->{errors}[0]{error} . ' ' - . $decode_json->{errors}[0]{attribute}, - 1 - ); - Log3 $dname, 5, - "GardenaSmartBridge ($dname) - RequestERROR: " - . $decode_json->{errors}[0]{error} . " " - . $decode_json->{errors}[0]{attribute}; - } # fi exists error + if ( exists( $decode_json->{errors}[0]{error} ) ) { + readingsBulkUpdate( + $dhash, + "state", + $decode_json->{errors}[0]{error} . ' ' + . $decode_json->{errors}[0]{attribute}, + 1 + ); + readingsBulkUpdate( + $dhash, + "lastRequestState", + $decode_json->{errors}[0]{error} . ' ' + . $decode_json->{errors}[0]{attribute}, + 1 + ); + Log3 $dname, 5, + "GardenaSmartBridge ($dname) - RequestERROR: " + . $decode_json->{errors}[0]{error} . " " + . $decode_json->{errors}[0]{attribute}; + } # fi exists error } } else { @@ -1059,12 +1060,18 @@ sub WriteReadings { if ( ref($v) eq 'ARRAY' ); #$v = encode_utf8($v); - $v = ' ' if (!defined $v); - Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 1 ".$decode_json->{abilities}[0]{properties}[$properties]{name} if ( $decode_json->{abilities}[0]{properties}[$properties] + $v = ' ' if ( !defined $v ); + Log3 $name, 4, + "Gardena DEBUG DEBUG DEBUG stage 1 " + . $decode_json->{abilities}[0]{properties}[$properties] + {name} + if ( $decode_json->{abilities}[0]{properties}[$properties] {name} !~ /ethernet_status|wifi_status/ ); - Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 2".$t if ( $decode_json->{abilities}[0]{properties}[$properties] + Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 2" . $t + if ( $decode_json->{abilities}[0]{properties}[$properties] {name} !~ /ethernet_status|wifi_status/ ); - Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 3".$v if ( $decode_json->{abilities}[0]{properties}[$properties] + Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 3" . $v + if ( $decode_json->{abilities}[0]{properties}[$properties] {name} !~ /ethernet_status|wifi_status/ ); readingsBulkUpdateIfChanged( @@ -1084,16 +1091,22 @@ sub WriteReadings { ) && ref($v) eq 'HASH' ) - { - if ($v->{is_connected} ) { - readingsBulkUpdateIfChanged( $hash, - $decode_json->{abilities}[0]{properties}[$properties]{name}.'-ip', $v->{ip} ) - if ( ref( $v->{ip} ) ne 'HASH' ); - readingsBulkUpdateIfChanged( $hash, - $decode_json->{abilities}[0]{properties}[$properties]{name}.'-isconnected', $v->{is_connected} ) - if ( $v->{is_connected} ); + { + if ( $v->{is_connected} ) { + readingsBulkUpdateIfChanged( + $hash, + $decode_json->{abilities}[0]{properties} + [$properties]{name} . '-ip', + $v->{ip} + ) if ( ref( $v->{ip} ) ne 'HASH' ); + readingsBulkUpdateIfChanged( + $hash, + $decode_json->{abilities}[0]{properties} + [$properties]{name} . '-isconnected', + $v->{is_connected} + ) if ( $v->{is_connected} ); } - } # fi ethernet and wifi + } # fi ethernet and wifi } $properties--; @@ -1326,7 +1339,7 @@ sub createHttpValueStrings { && $abilities eq 'mower' ) { my $valve_id; - + $uri .= '/devices/' . $deviceId diff --git a/FHEM/74_GardenaSmartDevice.pm b/FHEM/74_GardenaSmartDevice.pm index 097c11f..60d0f5c 100644 --- a/FHEM/74_GardenaSmartDevice.pm +++ b/FHEM/74_GardenaSmartDevice.pm @@ -2,7 +2,7 @@ # # Developed with VSCodium and richterger perl plugin. # -# (c) 2017-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) +# (c) 2017-2024 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to comitters: @@ -324,7 +324,8 @@ sub Set { elsif ( lc $cmd eq 'parkuntilnexttimer' ) { $payload = '"name":"park_until_next_timer"'; if ( $mainboard_version > 10.30 ) { - $payload = '"mowerTimer":0,"startingPointDistance":null,"areaId":null'; + $payload = + '"mowerTimer":0,"startingPointDistance":null,"areaId":null'; $abilities = 'mower'; } } @@ -339,12 +340,14 @@ sub Set { } } elsif ( lc $cmd eq 'startoverridetimer' ) { + # $payload = '"name":"start_override_timer","parameters":{"duration":' - # . $aArg->[0] * 60 . '}'; + # . $aArg->[0] * 60 . '}'; # if ( $mainboard_version > 10.30 ) { - $payload = '"startingPointDistance":null,"areaId":null, "mowerTimer": ' - . $aArg->[0] * 60; - $abilities = 'mower'; + $payload = '"startingPointDistance":null,"areaId":null, "mowerTimer": ' + . $aArg->[0] * 60; + $abilities = 'mower'; + # } removed code < 10.30 api changes March 2024 } @@ -735,7 +738,8 @@ sub WriteReadings { . RigReadingsValue( $hash, $propertie->{value} ) # cast all data to string with "" ) - if ( exists( $propertie->{value} ) + if ( + exists( $propertie->{value} ) && $decode_json->{abilities}[$abilities]{name} . '-' . $propertie->{name} ne 'radio-quality' && $decode_json->{abilities}[$abilities]{name} . '-' @@ -754,9 +758,10 @@ sub WriteReadings { . $propertie->{name} ne 'ic24-valves_connected' && $decode_json->{abilities}[$abilities]{name} . '-' . $propertie->{name} ne 'ic24-valves_master_config' - && ($decode_json->{abilities}[$abilities]{name} . '-' - . $propertie->{name}) !~ /scheduling-timeslot_state_\d/ - && ref( $propertie->{value} ) ne "HASH" ); + && ( $decode_json->{abilities}[$abilities]{name} . '-' + . $propertie->{name} ) !~ /scheduling-timeslot_state_\d/ + && ref( $propertie->{value} ) ne "HASH" + ); readingsBulkUpdateIfChanged( $hash, @@ -852,14 +857,16 @@ sub WriteReadings { } } } + # decode timeslot_state_N arrays code by hhhdg if ( defined( $propertie->{value} ) && $decode_json->{abilities}[$abilities]{name} . '-' - . $propertie->{name} =~ /scheduling-timeslot_state_\d/ - && ref( $propertie->{value} ) eq "ARRAY" ) { + . $propertie->{name} =~ /scheduling-timeslot_state_\d/ + && ref( $propertie->{value} ) eq "ARRAY" ) + { while ( my ( $r, $v ) = each @{ $propertie->{value} } ) { if ( ref($v) eq "HASH" ) { - my $entry = $r+1; + my $entry = $r + 1; while ( my ( $i_r, $i_v ) = each %{$v} ) { readingsBulkUpdateIfChanged( $hash, @@ -873,8 +880,8 @@ sub WriteReadings { } } } - } # fi defined - # ic24 and other watering devices calc irrigation left in sec + } # fi defined + # ic24 and other watering devices calc irrigation left in sec readingsBulkUpdateIfChanged( $hash, $decode_json->{abilities}[$abilities]{name} . '-' @@ -974,9 +981,10 @@ sub WriteReadings { && scalar(@soll) != scalar( @ist / 2 ) ) { while ( my $old_schedule_id = shift(@ist) ) { - foreach ( keys %{ $hash->{READINGS} } ) { - delete $hash->{READINGS}->{$_} - if ( $_ =~ /scheduling-schedules_event_${old_schedule_id}_.*/ ); + foreach ( keys %{ $hash->{READINGS} } ) { + delete $hash->{READINGS}->{$_} + if ( $_ =~ + /scheduling-schedules_event_${old_schedule_id}_.*/ ); } # fi Log3 $name, 5, "[DEBUG] - $name : deletereading scheduling-schedules_event_${old_schedule_id}_.*" diff --git a/controls_GardenaSmartDevice.txt b/controls_GardenaSmartDevice.txt index 271e21a..0c90e22 100644 --- a/controls_GardenaSmartDevice.txt +++ b/controls_GardenaSmartDevice.txt @@ -1,2 +1,2 @@ -UPD 2024-04-15_09:21:58 49572 FHEM/73_GardenaSmartBridge.pm -UPD 2024-04-15_09:37:55 127663 FHEM/74_GardenaSmartDevice.pm +UPD 2024-04-15_15:44:03 49971 FHEM/73_GardenaSmartBridge.pm +UPD 2024-04-15_15:43:50 127762 FHEM/74_GardenaSmartDevice.pm -- 2.45.2