mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
AutomowerConnectFamily: change calculation mode for zone statistics, prevent possible division by zero
git-svn-id: https://svn.fhem.de/fhem/trunk@27488 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fcc88c1a26
commit
83fc1c5d14
@ -369,7 +369,7 @@ sub getMowerResponse {
|
||||
if ( AttrVal($name, 'mapZones', 0) && $hash->{helper}{currentZone} && $hash->{helper}{mapZones}{$hash->{helper}{currentZone}}{curZoneCnt} ) {
|
||||
my $curZon = $hash->{helper}{currentZone};
|
||||
my $curZonCnt = $hash->{helper}{mapZones}{$curZon}{curZoneCnt};
|
||||
readingsBulkUpdateIfChanged($hash, $pref.'_currentZone', $curZon . '(' . $curZonCnt . '/' . $hash->{helper}{newdatasets} . ')' );
|
||||
readingsBulkUpdateIfChanged($hash, $pref.'_currentZone', $curZon . '(' . $curZonCnt . '/' . $hash->{helper}{newzonedatasets} . ')' );
|
||||
}
|
||||
|
||||
my $tstamp = $hash->{helper}{mower}{attributes}{$pref}{errorCodeTimestamp};
|
||||
@ -438,8 +438,11 @@ sub getMowerResponse {
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastDayCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastDayCnt} / $sumLastDayCnt * 100 );
|
||||
} @zonekeys if( $sumLastDayCnt );
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekCnt} / $sumCurrentWeekCnt * 100 );
|
||||
} @zonekeys;
|
||||
} @zonekeys if( $sumCurrentWeekCnt );
|
||||
|
||||
}
|
||||
# do on days
|
||||
@ -462,7 +465,7 @@ sub getMowerResponse {
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekCnt} / $sumLastWeekCnt * 100 );
|
||||
} @zonekeys;
|
||||
} @zonekeys if( $sumLastWeekCnt );
|
||||
|
||||
}
|
||||
|
||||
@ -1161,7 +1164,7 @@ __END__
|
||||
<li>batteryPercent - battery state of charge in percent</li>
|
||||
<li>mower_activity - current activity "UNKNOWN" | "NOT_APPLICABLE" | "MOWING" | "GOING_HOME" | "CHARGING" | "LEAVING" | "PARKED_IN_CS" | "STOPPED_IN_GARDEN"</li>
|
||||
<li>mower_commandStatus - Status of the last sent command cleared each status update</li>
|
||||
<li>mower_currentZone - Zone name with activity MOWING in the last interval and number of way points in parenthesis.</li>
|
||||
<li>mower_currentZone - Zone name with activity MOWING in the last status time stamp interval and number of way points in parenthesis.</li>
|
||||
<li>mower_errorCode - last error code</li>
|
||||
<li>mower_errorCodeTimestamp - last error code time stamp</li>
|
||||
<li>mower_errorDescription - error description</li>
|
||||
@ -1469,7 +1472,7 @@ __END__
|
||||
<li><a id='AutomowerConnect-attr-mowerActivityToHighLight'>mowerActivityToHighLight</a><br>
|
||||
<code>attr <name> mowerActivityToHighLight <perl condition to determine a path section></code><br>
|
||||
Eine Perl Bedingung, die Aktivitäten verknüpft, um einen Pfadabschnitt festzulegen, der hervorgehoben wird.<br>
|
||||
Die Aktivität im aktuellen Interval steht über die Perlvariable $act und die Aktivität im letzten Intervall über $actold zur Verfügung.<br>
|
||||
Die Aktivität im aktuellen Intervall steht über die Perlvariable $act und die Aktivität im letzten Intervall über $actold zur Verfügung.<br>
|
||||
Die Farbe, Strichstärke und Muster können über das Attribut <i>mapDesignAttributes</i> unter otherActivityPath... eingestellt werden.<br>
|
||||
Beispiel: Pfad beim Verlassen der Ladestation hervorheben.<br>
|
||||
<code>attr <name> mowerActivityToHighLight $act =~ /MOWING|LEAVING/ && $actold =~ /LEAVING|PARKED_IN_CS|CHARGING/</code><br>
|
||||
@ -1496,7 +1499,7 @@ __END__
|
||||
<li>batteryPercent - Batterieladung in Prozent</li>
|
||||
<li>mower_activity - aktuelle Aktivität "UNKNOWN" | "NOT_APPLICABLE" | "MOWING" | "GOING_HOME" | "CHARGING" | "LEAVING" | "PARKED_IN_CS" | "STOPPED_IN_GARDEN"</li>
|
||||
<li>mower_commandStatus - Status des letzten uebermittelten Kommandos wird duch Statusupdate zurückgesetzt.</li>
|
||||
<li>mower_currentZone - Name der Zone im aktuell abgefragten Intervall, in der der Mäher gemäht hat und Anzahl der Wegpunkte in der Zone in Klammern.</li>
|
||||
<li>mower_currentZone - Name der Zone im aktuell abgefragten Intervall der Statuszeitstempel , in der der Mäher gemäht hat und Anzahl der Wegpunkte in der Zone in Klammern.</li>
|
||||
<li>mower_errorCode - last error code</li>
|
||||
<li>mower_errorCodeTimestamp - last error code time stamp</li>
|
||||
<li>mower_errorDescription - error description</li>
|
||||
|
@ -200,7 +200,7 @@ sub Notify {
|
||||
if ( AttrVal($name, 'mapZones', 0) && $hash->{helper}{currentZone} && $hash->{helper}{mapZones}{$hash->{helper}{currentZone}}{curZoneCnt} ) {
|
||||
my $curZon = $hash->{helper}{currentZone};
|
||||
my $curZonCnt = $hash->{helper}{mapZones}{$curZon}{curZoneCnt};
|
||||
readingsBulkUpdateIfChanged($hash, $pref.'_currentZone', $curZon . '(' . $curZonCnt . '/' . $hash->{helper}{newdatasets} . ')' );
|
||||
readingsBulkUpdateIfChanged($hash, $pref.'_currentZone', $curZon . '(' . $curZonCnt . '/' . $hash->{helper}{newzonedatasets} . ')' );
|
||||
}
|
||||
|
||||
my $tstamp = $hash->{helper}{mower}{attributes}{$pref}{errorCodeTimestamp};
|
||||
@ -271,8 +271,11 @@ sub Notify {
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastDayCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastDayCnt} / $sumLastDayCnt * 100 );
|
||||
} @zonekeys if( $sumLastDayCnt );
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekCnt} / $sumCurrentWeekCnt * 100 );
|
||||
} @zonekeys;
|
||||
} @zonekeys if( $sumCurrentWeekCnt );
|
||||
|
||||
}
|
||||
# do on days
|
||||
@ -295,7 +298,7 @@ sub Notify {
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekCnt} / $sumLastWeekCnt * 100 );
|
||||
} @zonekeys;
|
||||
} @zonekeys if( $sumLastWeekCnt );
|
||||
|
||||
}
|
||||
|
||||
@ -914,7 +917,7 @@ __END__
|
||||
<li>batteryPercent - battery state of charge in percent</li>
|
||||
<li>mower_activity - current activity "UNKNOWN" | "NOT_APPLICABLE" | "MOWING" | "GOING_HOME" | "CHARGING" | "LEAVING" | "PARKED_IN_CS" | "STOPPED_IN_GARDEN"</li>
|
||||
<li>mower_commandStatus - Status of the last sent command cleared each status update</li>
|
||||
<li>mower_currentZone - Zone name with activity MOWING in the last interval and number of way points in parenthesis.</li>
|
||||
<li>mower_currentZone - Zone name with activity MOWING in the last status time stamp interval and number of way points in parenthesis.</li>
|
||||
<li>mower_errorCode - last error code</li>
|
||||
<li>mower_errorCodeTimestamp - last error code time stamp</li>
|
||||
<li>mower_errorDescription - error description</li>
|
||||
@ -1219,7 +1222,7 @@ __END__
|
||||
<li>batteryPercent - Batterieladung in Prozent</li>
|
||||
<li>mower_activity - aktuelle Aktivität "UNKNOWN" | "NOT_APPLICABLE" | "MOWING" | "GOING_HOME" | "CHARGING" | "LEAVING" | "PARKED_IN_CS" | "STOPPED_IN_GARDEN"</li>
|
||||
<li>mower_commandStatus - Status des letzten uebermittelten Kommandos wird duch Statusupdate zurückgesetzt.</li>
|
||||
<li>mower_currentZone - Name der Zone im aktuell abgefragten Intervall, in der der Mäher gemäht hat und Anzahl der Wegpunkte in der Zone in Klammern.</li>
|
||||
<li>mower_currentZone - Name der Zone im aktuell abgefragten Intervall der Statuszeitstempel, in der der Mäher gemäht hat und Anzahl der Wegpunkte in der Zone in Klammern.</li>
|
||||
<li>mower_errorCode - last error code</li>
|
||||
<li>mower_errorCodeTimestamp - last error code time stamp</li>
|
||||
<li>mower_errorDescription - error description</li>
|
||||
|
@ -185,6 +185,7 @@ my $mapZonesTpl = '{
|
||||
mapZonesTpl => $mapZonesTpl,
|
||||
posMinMax => "-180 90\n180 -90",
|
||||
newdatasets => 0,
|
||||
newzonedatasets => 0,
|
||||
MAP_PATH => '',
|
||||
MAP_MIME => '',
|
||||
MAP_CACHE => '',
|
||||
@ -727,7 +728,8 @@ sub AlignArray {
|
||||
|
||||
}
|
||||
|
||||
if ( AttrVal($name, 'mapZones', 0) && $act =~ /^(MOWING)$/ && $actold =~ /^(MOWING|LEAVING|PARKED_IN_CS|CHARGING)$/ ) {
|
||||
if ( AttrVal($name, 'mapZones', 0) && $act =~ /^(MOWING)$/ && $actold =~ /^(MOWING|LEAVING|PARKED_IN_CS|CHARGING)$/
|
||||
|| $act =~ /^(GOING_HOME|PARKED_IN_CS|CHARGING)$/ && $actold =~ /^(MOWING)$/ ) {
|
||||
|
||||
$tmp = dclone( \@ar );
|
||||
ZoneHandling ( $hash, $tmp, $cnt );
|
||||
@ -849,7 +851,7 @@ sub ZoneHandling {
|
||||
|
||||
if ( eval ("$hash->{helper}{mapZones}{$zonekeys[$k]}{condition}") ) {
|
||||
|
||||
if ( $hash->{helper}{mapZones}{$zonekeys[$k]}{curZoneCnt} == $i) { # find current zone and count consecutive way points
|
||||
if ( $hash->{helper}{mapZones}{$zonekeys[$k]}{curZoneCnt} == $i) { # find current zone and count consecutive way points
|
||||
|
||||
$hash->{helper}{mapZones}{$zonekeys[$k]}{curZoneCnt}++;
|
||||
$hash->{helper}{currentZone} = $zonekeys[$k];
|
||||
@ -873,14 +875,15 @@ sub ZoneHandling {
|
||||
|
||||
}
|
||||
|
||||
my $sumDayCnt=0;
|
||||
map { $sumDayCnt += $hash->{helper}{mapZones}{$_}{zoneCnt} } @zonekeys;
|
||||
map { $hash->{helper}{mapZones}{$_}{currentDayCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{zoneCnt} / $sumDayCnt * 100 ) } @zonekeys;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
my $sumDayCnt=0;
|
||||
map { $sumDayCnt += $hash->{helper}{mapZones}{$_}{zoneCnt} } @zonekeys;
|
||||
map { $hash->{helper}{mapZones}{$_}{currentDayCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{zoneCnt} / $sumDayCnt * 100 ) } @zonekeys if ( $sumDayCnt );
|
||||
$hash->{helper}{newzonedatasets} = $cnt;
|
||||
|
||||
}
|
||||
|
||||
#########################
|
||||
|
Loading…
Reference in New Issue
Block a user