From 930e42835b47a0e3c1a8da3c41b771f1daba1b8b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 23 Jun 2022 12:55:03 +0200 Subject: [PATCH] [alpha] excentedState - fix wc state, add irrigation duration --- CHANGED | 2 +- FHEM/74_GardenaSmartDevice.pm | 54 +++------------------------------ controls_GardenaSmartDevice.txt | 2 +- 3 files changed, 6 insertions(+), 52 deletions(-) diff --git a/CHANGED b/CHANGED index 6b83971..a2d7c19 100644 --- a/CHANGED +++ b/CHANGED @@ -1 +1 @@ - debugg + [alpha] - extendetState - irrigation stuff diff --git a/FHEM/74_GardenaSmartDevice.pm b/FHEM/74_GardenaSmartDevice.pm index 7ae31ab..7aa4854 100644 --- a/FHEM/74_GardenaSmartDevice.pm +++ b/FHEM/74_GardenaSmartDevice.pm @@ -747,65 +747,19 @@ sub WriteReadings { Log3 $name, 3, "[DEBUG] - GardenaSmartDevice ($name) Ventil $propertie->{name} $r: $v"; } } - - - - # ic24 and more watering duration ? + # ic24 and other watering devices calc irrigation left in sec readingsBulkUpdateIfChanged( $hash, $decode_json->{abilities}[$abilities]{name} . '-' . $propertie->{name} . '_irrigation_left', - sprintf("%.f" , (Time::Piece::localtime->strptime( RigReadingsValue($hash, $propertie->{timestamp}), "%Y-%m-%d %H:%M:%S") - + ($propertie->{value}{duration} + 3 ) - Time::Piece::localtime->new) / 60 ) + + ($propertie->{value}{duration} + 3 ) - Time::Piece::localtime->new) ) if ( defined( $propertie->{value} ) && $decode_json->{abilities}[$abilities]{name} eq 'watering' && $propertie->{value}{duration} > 0 ); - - # if ( defined( $propertie->{value} ) - # && $decode_json->{abilities}[$abilities]{name} eq 'watering' - # && $propertie->{value}{duration} > 0 ){ - # Log3 $name, 2, "[DDebug] " . Time::Piece::localtime->strptime( - # RigReadingsValue($hash, $propertie->{timestamp}), "%Y-%m-%d %H:%M:%S"); - # my $dt = Time::Piece::localtime->strptime( RigReadingsValue($hash, $propertie->{timestamp}), "%Y-%m-%d %H:%M:%S"); - # Log3 $name, 2, "[DEBUG] $dt"; - # my $ndt = Time::Piece::localtime->new; - # Log3 $name, 2, "[cDEBUG] $ndt"; - # Log3 $name, 2, "[aDEBUG] " . ($propertie->{value}{duration} + 3 ); - # Log3 $name, 2, "[sDEBUG] " . sprintf("%.f" , - # Time::Piece::localtime->strptime( - # RigReadingsValue($hash, $propertie->{timestamp}), "%Y-%m-%d %H:%M:%S") - # + ($propertie->{value}{duration} + 3 ) - Time::Piece::localtime->new ); - # } -#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 - - - } } @@ -1058,12 +1012,12 @@ sub setState { ? ( ReadingsVal($name, 'scheduling-schedules_paused_until', '' ) eq '' ) # leer ( zeitplan aktiv ... ) - ? sprintf( (RigReadingsValue($hash, 'will be irrigated %.f minutes remaining.').' '.RigReadingsValue($hash, 'next watering: %s')), (ReadingsVal( $name, 'watering-watering_timer_1_duration', 0 )/60), RigReadingsValue($hash, ReadingsVal($name, 'scheduling-scheduled_watering_next_start', '')) ) + ? sprintf( (RigReadingsValue($hash, 'will be irrigated %.f minutes remaining.').' '.RigReadingsValue($hash, 'next watering: %s')), (ReadingsVal( $name, 'watering-watering_timer_1_irrigation_left', 0 )/60), RigReadingsValue($hash, ReadingsVal($name, 'scheduling-scheduled_watering_next_start', '')) ) # zeitplan pausiert : ( ReadingsVal($name, 'scheduling-schedules_paused_until', '') eq '2038-01-18T00:00:00.000Z') # pause bis dauerhaft - ? sprintf( (RigReadingsValue($hash, 'will be irrigated %.f minutes remaining.').' '.RigReadingsValue($hash , 'schedule permanently paused')), (ReadingsVal( $name, 'watering-watering_timer_1_duration', 0 )/60) ) + ? sprintf( (RigReadingsValue($hash, 'will be irrigated %.f minutes remaining.').' '.RigReadingsValue($hash , 'schedule permanently paused')), (ReadingsVal( $name, 'watering-watering_timer_1_irrigation_left', 0 )/60) ) # naechter termin : sprintf( RigReadingsValue($hash , 'paused until %s'), RigReadingsValue($hash, ReadingsVal($name, 'scheduling-schedules_paused_until', '')) ) # zu diff --git a/controls_GardenaSmartDevice.txt b/controls_GardenaSmartDevice.txt index 75ef282..7f280c2 100644 --- a/controls_GardenaSmartDevice.txt +++ b/controls_GardenaSmartDevice.txt @@ -1,2 +1,2 @@ UPD 2022-06-21_08:17:57 49520 FHEM/73_GardenaSmartBridge.pm -UPD 2022-06-23_12:44:35 71419 FHEM/74_GardenaSmartDevice.pm +UPD 2022-06-23_12:54:46 69289 FHEM/74_GardenaSmartDevice.pm