From ade33c4b3f83f7f058f221d56fd3366c626f10c0 Mon Sep 17 00:00:00 2001
From: Ellert <>
Date: Sat, 15 Apr 2023 17:08:41 +0000
Subject: [PATCH] AutomowerConnect(Device): add attribute to determine the days
of a week when the way point stack will be reset
git-svn-id: https://svn.fhem.de/fhem/trunk@27448 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 2 +
fhem/FHEM/74_AutomowerConnect.pm | 29 ++++++++++++-
fhem/FHEM/75_AutomowerConnectDevice.pm | 59 +++++++++++++++++++-------
3 files changed, 73 insertions(+), 17 deletions(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index 039316aee..35317fa57 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,7 @@
# 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.
+ - feature: 7x_AutomowerConnect(Device): add attribute to determine
+ the days of a week when the way point stack will be reset
- bugfix: AutomowerConnectFamily:minor fixes and changes in cref
- bugfix: 72_FRITZBOX: kleinere Korrekturen
- bugfix: 72_FRITZBOX: TR-064 Problem (topic=133142.0)
diff --git a/fhem/FHEM/74_AutomowerConnect.pm b/fhem/FHEM/74_AutomowerConnect.pm
index f3762222d..197019de7 100644
--- a/fhem/FHEM/74_AutomowerConnect.pm
+++ b/fhem/FHEM/74_AutomowerConnect.pm
@@ -119,6 +119,7 @@ sub Initialize() {
"mowerSchedule:textField-long " .
"mowingAreaLimits:textField-long " .
"propertyLimits:textField-long " .
+ "weekdaysToResetWayPoints " .
"numberOfWayPointsToDisplay " .
$readingFnAttributes;
@@ -421,11 +422,16 @@ sub getMowerResponse {
$hash->{helper}{statistics}{currentWeekTrack} = 0;
$hash->{helper}{statistics}{currentWeekArea} = 0;
- #clear position arrays
+ }
+
+ #clear position arrays
+ if ( AttrVal( $name, 'weekdaysToResetWayPoints', 1 ) =~ $time[6] ) {
+
$hash->{helper}{areapos} = [];
$hash->{helper}{otherpos} = [];
}
+
}
readingsSingleUpdate($hash, 'state', 'connected', 1 );
@@ -589,6 +595,19 @@ sub Attr {
}
##########
+ } elsif( $attrName eq "weekdaysToResetWayPoints" ) {
+
+ if( $cmd eq "set" ) {
+
+ return "$iam $attrName is invalid enter a combination of weekday numbers <0123456>" unless( $attrVal =~ /0|1|2|3|4|5|6/ );
+ Log3 $name, 3, "$iam $cmd $attrName $attrVal";
+
+ } elsif( $cmd eq "del" ) {
+
+ Log3 $name, 3, "$iam $cmd $attrName and set default to 1";
+
+ }
+ ##########
} elsif ( $attrName eq 'numberOfWayPointsToDisplay' ) {
my $icurr = @{$hash->{helper}{areapos}};
@@ -966,6 +985,10 @@ __END__
While in activity MOWING every 30 s a geo data set is generated.
While in activity PARKED_IN_CS/CHARGING every 42 min a geo data set is generated.
+
weekdaysToResetWayPoints
+ attr <name> weekdaysToResetWayPoints <any combination of weekday numbers from 0123456>
+ A combination of weekday numbers when the way point stack will be reset, default 1.
+
scaleToMeterXY
attr <name> scaleToMeterXY <scale factor longitude><seperator><scale factor latitude>
The scale factor depends from the Location on earth, so it has to be calculated for short ranges only. <seperator> is one space character.
@@ -1246,6 +1269,10 @@ __END__
Legt die Anzahl der gespeicherten und und anzuzeigenden Wegpunkte fest, default 5000
Während der Aktivität MOWING wird ca. alle 30 s und während PARKED_IN_CS/CHARGING wird alle 42 min ein Geodatensatz erzeugt.
+ weekdaysToResetWayPoints
+ attr <name> weekdaysToResetWayPoints <any combination of weekday numbers from 0123456>
+ Eine Kombination von Wochentagnummern an denen der Wegpunktspeicher gelöscht wird, default 1.
+
scaleToMeterXY
attr <name> scaleToMeterXY <scale factor longitude><seperator><scale factor latitude>
Der Skalierfaktor hängt vom Standort ab und muss daher für kurze Strecken berechnet werden. <seperator> ist 1 Leerzeichen.
diff --git a/fhem/FHEM/75_AutomowerConnectDevice.pm b/fhem/FHEM/75_AutomowerConnectDevice.pm
index 7497d2e9e..ff026f878 100644
--- a/fhem/FHEM/75_AutomowerConnectDevice.pm
+++ b/fhem/FHEM/75_AutomowerConnectDevice.pm
@@ -114,6 +114,7 @@ sub Initialize() {
"mowingAreaLimits:textField-long " .
"propertyLimits:textField-long " .
"numberOfWayPointsToDisplay " .
+ "weekdaysToResetWayPoints " .
$readingFnAttributes;
return undef;
@@ -240,25 +241,30 @@ sub Notify {
# do at midnight
if ( $secs <= $interval ) {
- $hash->{helper}{statistics}{lastDayTrack} = $hash->{helper}{statistics}{currentDayTrack};
- $hash->{helper}{statistics}{lastDayArea} = $hash->{helper}{statistics}{currentDayArea};
- $hash->{helper}{statistics}{currentWeekTrack} += $hash->{helper}{statistics}{currentDayTrack};
- $hash->{helper}{statistics}{currentWeekArea} += $hash->{helper}{statistics}{currentDayArea};
- $hash->{helper}{statistics}{currentDayTrack} = 0;
- $hash->{helper}{statistics}{currentDayArea} = 0;
- # do on mondays
- if ( $time[6] == 1 ) {
+ $hash->{helper}{statistics}{lastDayTrack} = $hash->{helper}{statistics}{currentDayTrack};
+ $hash->{helper}{statistics}{lastDayArea} = $hash->{helper}{statistics}{currentDayArea};
+ $hash->{helper}{statistics}{currentWeekTrack} += $hash->{helper}{statistics}{currentDayTrack};
+ $hash->{helper}{statistics}{currentWeekArea} += $hash->{helper}{statistics}{currentDayArea};
+ $hash->{helper}{statistics}{currentDayTrack} = 0;
+ $hash->{helper}{statistics}{currentDayArea} = 0;
+ # do on mondays
+ if ( $time[6] == 1 ) {
- $hash->{helper}{statistics}{lastWeekTrack} = $hash->{helper}{statistics}{currentWeekTrack};
- $hash->{helper}{statistics}{lastWeekArea} = $hash->{helper}{statistics}{currentWeekArea};
- $hash->{helper}{statistics}{currentWeekTrack} = 0;
- $hash->{helper}{statistics}{currentWeekArea} = 0;
-
- #clear position arrays
- $hash->{helper}{areapos} = [];
- $hash->{helper}{otherpos} = [];
+ $hash->{helper}{statistics}{lastWeekTrack} = $hash->{helper}{statistics}{currentWeekTrack};
+ $hash->{helper}{statistics}{lastWeekArea} = $hash->{helper}{statistics}{currentWeekArea};
+ $hash->{helper}{statistics}{currentWeekTrack} = 0;
+ $hash->{helper}{statistics}{currentWeekArea} = 0;
}
+
+ #clear position arrays
+ if ( AttrVal( $name, 'weekdaysToResetWayPoints', 1 ) =~ $time[6] ) {
+
+ $hash->{helper}{areapos} = [];
+ $hash->{helper}{otherpos} = [];
+
+ }
+
}
readingsSingleUpdate($hash, 'state', 'connected',1);
@@ -390,6 +396,19 @@ sub Attr {
}
##########
+ } elsif( $attrName eq "weekdaysToResetWayPoints" ) {
+
+ if( $cmd eq "set" ) {
+
+ return "$iam $attrName is invalid enter a combination of weekday numbers <0123456>" unless( $attrVal =~ /0|1|2|3|4|5|6/ );
+ Log3 $name, 3, "$iam $cmd $attrName $attrVal";
+
+ } elsif( $cmd eq "del" ) {
+
+ Log3 $name, 3, "$iam $cmd $attrName and set default to 1";
+
+ }
+ ##########
} elsif ( $attrName eq 'numberOfWayPointsToDisplay' ) {
my $icurr = @{$hash->{helper}{areapos}};
@@ -719,6 +738,14 @@ __END__
While in activity MOWING every 30 s a geo data set is generated.
While in activity PARKED_IN_CS/CHARGING every 42 min a geo data set is generated.
+ weekdaysToResetWayPoints
+ attr <name> weekdaysToResetWayPoints <any combination of weekday numbers from 0123456>
+ A combination of weekday numbers when the way point stack will be reset, default 1.
+
+ weekdaysToResetWayPoints
+ attr <name> weekdaysToResetWayPoints <any combination of weekday numbers from 0123456>
+ Eine Kombination von Wochentagnummern an denen der Wegpunktspeicher gelöscht wird, default 1.
+
scaleToMeterXY
attr <name> scaleToMeterXY <scale factor longitude><seperator><scale factor latitude>
The scale factor depends from the Location on earth, so it has to be calculated for short ranges only. <seperator> is one space character.