From ab2e990ffb2a673ededb92b8e4628459cfa352e3 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 23 Jun 2022 11:31:22 +0200 Subject: [PATCH] [alpha] - extendedState - fix next irrigation and irregation left time --- CHANGED | 2 +- FHEM/74_GardenaSmartDevice.pm | 50 +++++++++++++++++++++++++++++++-- controls_GardenaSmartDevice.txt | 4 +-- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/CHANGED b/CHANGED index 8f5ec26..8430654 100644 --- a/CHANGED +++ b/CHANGED @@ -1 +1 @@ - [extendetState] - fix up schedule + scheduling if event != '' diff --git a/FHEM/74_GardenaSmartDevice.pm b/FHEM/74_GardenaSmartDevice.pm index db58885..77fba9e 100644 --- a/FHEM/74_GardenaSmartDevice.pm +++ b/FHEM/74_GardenaSmartDevice.pm @@ -734,6 +734,7 @@ sub WriteReadings { . $propertie->{name} eq 'ic24-valves_master_config' ); if ( ref( $propertie->{value} ) eq "HASH" ) { + my $sub_state = 0; my $sub_value = 0; while ( my ( $r, $v ) = each %{ $propertie->{value} } ) { readingsBulkUpdate( $hash, @@ -742,10 +743,54 @@ sub WriteReadings { . $r, RigReadingsValue( $hash, $v ) ); - Log3 $name, 3, "[DEBUG] - GardenaSmartDevice ($name) Ventil $propertie->{name} $r: $v"; + Log3 $name, 3, "[DEBUG] - GardenaSmartDevice ($name) Ventil $propertie->{name} $r: $v"; } } + + + + # ic24 and more watering duration ? + readingsBulkUpdateIfChanged( + $hash, + $decode_json->{abilities}[$abilities]{name} . '-' + . $propertie->{name} + . '_irrigation_left', + sprintf("%.f" ,(RigReadingsValue( + $hash, + $decode_json->{abilities}[$abilities]{timestamp} + "%Y-%m-%d %H:%M:%S")+($propertie->{value}{duration} + 3 )) - Time::Piece::localtime->new ) + ) + if ( defined( $propertie->{value} ) + && $decode_json->{abilities}[$abilities]{name} eq 'watering' + && $propertie->{value}{duration} > 0 ); + +#2022-06-21T08:56:42.488Z -> 2022-06-21 08:56:48 + + + # $propertie->{value}{duration} + # $propertie->{value}{valve_id} + + + # Time::Piece->strptime( + # RigReadingsValue( $hash, $propertie->{timestamp} ), + # "%Y-%m-%d %H:%M:%S" )->add(seconds => ($propertie->{value}{duration} +3))) + + + + # "%Y-%m-%d %H:%M:%S" )->strftime('%s') + + + # "name": "watering_timer_4", + # "timestamp": "2022-06-21T08:56:42.488Z", + durati^n + 3 + # "unit": "complex", + # "value": { + # "state": "manual", + # "duration": 1497, + # "valve_id": 4 + + + } } @@ -885,7 +930,8 @@ sub setState { && ReadingsVal( $name, "watering-watering_timer_".$_."_duration", 0 ) > 0 && ReadingsVal( $name, "watering-watering_timer_".$_."_duration", 0 ) > $longest_duration ) ); - if ( ReadingsVal($name, 'scheduling-scheduled_watering_next_start_'.$_, '') ne '') { + if ( ReadingsVal($name, 'scheduling-scheduled_watering_next_start_'.$_, '') ne '' + && ReadingsVal($name, 'scheduling-schedules_paused_until_'.$_ , '') ne '2038-01-18T00:00:00.000Z' ) { $nearst_irrigation = ReadingsVal($name, 'scheduling-scheduled_watering_next_start_'.$_, '') if ( Time::Piece->strptime( ReadingsVal($name, 'scheduling-scheduled_watering_next_start_'.$_, ''), "%Y-%m-%d %H:%M") < Time::Piece->strptime( $nearst_irrigation, "%Y-%m-%d %H:%M") diff --git a/controls_GardenaSmartDevice.txt b/controls_GardenaSmartDevice.txt index d7c59a3..7210d20 100644 --- a/controls_GardenaSmartDevice.txt +++ b/controls_GardenaSmartDevice.txt @@ -1,2 +1,2 @@ -UPD 2022-05-28_13:13:38 49520 FHEM/73_GardenaSmartBridge.pm -UPD 2022-06-16_20:08:37 68329 FHEM/74_GardenaSmartDevice.pm +UPD 2022-06-21_08:17:57 49520 FHEM/73_GardenaSmartBridge.pm +UPD 2022-06-23_11:30:43 70219 FHEM/74_GardenaSmartDevice.pm