mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-08 19:32:42 +00:00
AutomowerConnectFamily: enhanced zone statistics
git-svn-id: https://svn.fhem.de/fhem/trunk@27529 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e1cd62dc8f
commit
8219e41d8f
@ -1,5 +1,6 @@
|
||||
# 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: AutomowerConnectFamily: enhanced zone statistics
|
||||
- bugfix: 72_FRITZBOX: XML::Simple entfernt
|
||||
wg diverese Inkompatibilitaeten
|
||||
- change: codemirror updated from 5.22.0 to 5.65.13
|
||||
|
@ -428,12 +428,20 @@ sub getMowerResponse {
|
||||
my @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
||||
my $sumLastDayCnt=0;
|
||||
my $sumCurrentWeekCnt=0;
|
||||
my $sumLastDayArea=0;
|
||||
my $sumCurrentWeekArea=0;
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastDayCnt} = $hash->{helper}{mapZones}{$_}{zoneCnt};
|
||||
$sumLastDayCnt += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekCnt} += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
||||
$sumCurrentWeekCnt += $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
||||
$hash->{helper}{mapZones}{$_}{zoneCnt} = 0;
|
||||
|
||||
$hash->{helper}{mapZones}{$_}{lastDayArea} = $hash->{helper}{mapZones}{$_}{zoneLength};
|
||||
$sumLastDayArea += $hash->{helper}{mapZones}{$_}{lastDayArea};
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekArea} += $hash->{helper}{mapZones}{$_}{lastDayArea};
|
||||
$sumCurrentWeekArea += $hash->{helper}{mapZones}{$_}{currentWeekArea};
|
||||
$hash->{helper}{mapZones}{$_}{zoneLength} = 0;
|
||||
} @zonekeys;
|
||||
|
||||
map {
|
||||
@ -444,6 +452,14 @@ sub getMowerResponse {
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekCnt} / $sumCurrentWeekCnt * 100 );
|
||||
} @zonekeys if( $sumCurrentWeekCnt );
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastDayAreaPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastDayArea} / $sumLastDayArea * 100 );
|
||||
} @zonekeys if( $sumLastDayArea );
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekAreaPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekArea} / $sumCurrentWeekArea * 100 );
|
||||
} @zonekeys if( $sumCurrentWeekArea );
|
||||
|
||||
}
|
||||
# do on days
|
||||
if ( $time[6] == 1 ) {
|
||||
@ -457,16 +473,24 @@ sub getMowerResponse {
|
||||
|
||||
my @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
||||
my $sumLastWeekCnt=0;
|
||||
my $sumLastWeekArea=0;
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekCnt} = $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
||||
$sumLastWeekCnt += $hash->{helper}{mapZones}{$_}{lastWeekCnt};
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekCnt} = 0;
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekArea} = $hash->{helper}{mapZones}{$_}{currentWeekArea};
|
||||
$sumLastWeekArea += $hash->{helper}{mapZones}{$_}{lastWeekArea};
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekArea} = 0;
|
||||
} @zonekeys;
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekCnt} / $sumLastWeekCnt * 100 );
|
||||
} @zonekeys if( $sumLastWeekCnt );
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekAreaPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekArea} / $sumLastWeekArea * 100 );
|
||||
} @zonekeys if( $sumLastWeekArea );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -261,12 +261,20 @@ sub Notify {
|
||||
my @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
||||
my $sumLastDayCnt=0;
|
||||
my $sumCurrentWeekCnt=0;
|
||||
my $sumLastDayArea=0;
|
||||
my $sumCurrentWeekArea=0;
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastDayCnt} = $hash->{helper}{mapZones}{$_}{zoneCnt};
|
||||
$sumLastDayCnt += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekCnt} += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
||||
$sumCurrentWeekCnt += $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
||||
$hash->{helper}{mapZones}{$_}{zoneCnt} = 0;
|
||||
|
||||
$hash->{helper}{mapZones}{$_}{lastDayArea} = $hash->{helper}{mapZones}{$_}{zoneLength};
|
||||
$sumLastDayArea += $hash->{helper}{mapZones}{$_}{lastDayArea};
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekArea} += $hash->{helper}{mapZones}{$_}{lastDayArea};
|
||||
$sumCurrentWeekArea += $hash->{helper}{mapZones}{$_}{currentWeekArea};
|
||||
$hash->{helper}{mapZones}{$_}{zoneLength} = 0;
|
||||
} @zonekeys;
|
||||
|
||||
map {
|
||||
@ -277,6 +285,14 @@ sub Notify {
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekCnt} / $sumCurrentWeekCnt * 100 );
|
||||
} @zonekeys if( $sumCurrentWeekCnt );
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastDayAreaPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastDayArea} / $sumLastDayArea * 100 );
|
||||
} @zonekeys if( $sumLastDayArea );
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekAreaPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekArea} / $sumCurrentWeekArea * 100 );
|
||||
} @zonekeys if( $sumCurrentWeekArea );
|
||||
|
||||
}
|
||||
# do on days
|
||||
if ( $time[6] == 1 ) {
|
||||
@ -290,16 +306,24 @@ sub Notify {
|
||||
|
||||
my @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
||||
my $sumLastWeekCnt=0;
|
||||
my $sumLastWeekArea=0;
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekCnt} = $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
||||
$sumLastWeekCnt += $hash->{helper}{mapZones}{$_}{lastWeekCnt};
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekCnt} = 0;
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekArea} = $hash->{helper}{mapZones}{$_}{currentWeekArea};
|
||||
$sumLastWeekArea += $hash->{helper}{mapZones}{$_}{lastWeekArea};
|
||||
$hash->{helper}{mapZones}{$_}{currentWeekArea} = 0;
|
||||
} @zonekeys;
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekCnt} / $sumLastWeekCnt * 100 );
|
||||
} @zonekeys if( $sumLastWeekCnt );
|
||||
|
||||
map {
|
||||
$hash->{helper}{mapZones}{$_}{lastWeekAreaPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekArea} / $sumLastWeekArea * 100 );
|
||||
} @zonekeys if( $sumLastWeekArea );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ sub AlignArray {
|
||||
|
||||
if ( $act =~ /^(MOWING)$/ && $actold =~ /^(MOWING|LEAVING|PARKED_IN_CS|CHARGING)$/ ) {
|
||||
|
||||
AreaStatistics ( $hash, $tmp, $cnt );
|
||||
AreaStatistics ( $hash, $cnt );
|
||||
|
||||
}
|
||||
|
||||
@ -858,8 +858,8 @@ sub ZoneHandling {
|
||||
|
||||
}
|
||||
|
||||
$hash->{helper}{mapZones}{$zonekeys[$k]}{zoneCnt}++;
|
||||
|
||||
$hash->{helper}{mapZones}{$zonekeys[$k]}{zoneLength} += calcPathLength( $hash, $i, $i + 1 );
|
||||
$hash->{helper}{mapZones}{$zonekeys[$k]}{zoneCnt}++;
|
||||
last;
|
||||
|
||||
} elsif ( $k == @zonekeys-2 ) { # last zone
|
||||
@ -871,6 +871,7 @@ sub ZoneHandling {
|
||||
|
||||
}
|
||||
|
||||
$hash->{helper}{mapZones}{$zonekeys[$k+1]}{zoneLength} += calcPathLength( $hash, $i, $i + 1 );
|
||||
$hash->{helper}{mapZones}{$zonekeys[$k+1]}{zoneCnt}++;
|
||||
|
||||
}
|
||||
@ -882,7 +883,12 @@ 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 if ( $sumDayCnt );
|
||||
$hash->{helper}{newzonedatasets} = $cnt;
|
||||
|
||||
my $sumDayArea=0;
|
||||
map { $sumDayArea += $hash->{helper}{mapZones}{$_}{zoneLength} } @zonekeys;
|
||||
map { $hash->{helper}{mapZones}{$_}{currentDayAreaPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{zoneLength} / $sumDayArea * 100 ) } @zonekeys if ( $sumDayArea );
|
||||
|
||||
$hash->{helper}{newzonedatasets} = $cnt;
|
||||
|
||||
}
|
||||
|
||||
@ -943,23 +949,30 @@ sub HighlightPath {
|
||||
}
|
||||
|
||||
#########################
|
||||
sub AreaStatistics {
|
||||
my ( $hash, $poshash, $i ) = @_;
|
||||
sub calcPathLength {
|
||||
my ( $hash, $istart, $i ) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $activity = 'MOWING';
|
||||
my $k = 0;
|
||||
my @xyarr = @{$hash->{helper}{areapos}};# areapos
|
||||
my $n = scalar @xyarr;
|
||||
my ($sclon, $sclat) = AttrVal($name,'scaleToMeterXY', $hash->{helper}{scaleToMeterLongitude} . ' ' .$hash->{helper}{scaleToMeterLatitude}) =~ /(-?\d+)\s+(-?\d+)/;
|
||||
my $lsum = 0;
|
||||
my $asum = 0;
|
||||
my $vm = 0;
|
||||
|
||||
for ( $k = 0; $k <= $i-1; $k++) {
|
||||
for ( $k = $istart; $k < $i; $k++) {
|
||||
|
||||
$lsum += ( ( ( $xyarr[ $k ]{longitude} - $xyarr[ $k+1 ]{longitude} ) * $sclon ) ** 2 + ( ( $xyarr[ $k ]{latitude} - $xyarr[ $k+1 ]{latitude} ) * $sclat ) ** 2 ) ** 0.5 if ( $xyarr[ $k+1 ]{longitude} && $xyarr[ $k+1 ]{latitude} );
|
||||
|
||||
}
|
||||
return $lsum;
|
||||
}
|
||||
|
||||
#########################
|
||||
sub AreaStatistics {
|
||||
my ( $hash, $i ) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $activity = 'MOWING';
|
||||
my $lsum = calcPathLength( $hash, 0, $i );
|
||||
my $asum = 0;
|
||||
|
||||
$asum = $lsum * AttrVal($name,'mowerCuttingWidth',0.24);
|
||||
$hash->{helper}{$activity}{track} = $lsum;
|
||||
@ -1128,6 +1141,34 @@ sub listStatisticsData {
|
||||
|
||||
}
|
||||
|
||||
for ( @zonekeys ) {
|
||||
|
||||
$cnt++;
|
||||
$ret .= '<tr class="column '.( $cnt % 2 ? 'odd' : 'even' ) . '"><td> $hash->{helper}{mapZones}{' . $_ . '}{<b>currentDayAreaPct</b>}  </td><td> ' . ( $hash->{helper}{mapZones}{$_}{currentDayAreaPct} ? $hash->{helper}{mapZones}{$_}{currentDayAreaPct} : '' ) . ' </td><td> % </td></tr>';
|
||||
|
||||
}
|
||||
|
||||
for ( @zonekeys ) {
|
||||
|
||||
$cnt++;
|
||||
$ret .= '<tr class="column '.( $cnt % 2 ? 'odd' : 'even' ) . '"><td> $hash->{helper}{mapZones}{' . $_ . '}{<b>lastDayAreaPct</b>}  </td><td> ' . ( $hash->{helper}{mapZones}{$_}{lastDayAreaPct} ? $hash->{helper}{mapZones}{$_}{lastDayAreaPct} : '' ) . ' </td><td> % </td></tr>';
|
||||
|
||||
}
|
||||
|
||||
for ( @zonekeys ) {
|
||||
|
||||
$cnt++;
|
||||
$ret .= '<tr class="column '.( $cnt % 2 ? 'odd' : 'even' ) . '"><td> $hash->{helper}{mapZones}{' . $_ . '}{<b>currentWeekAreaPct</b>}  </td><td> ' . ( $hash->{helper}{mapZones}{$_}{currentWeekAreaPct} ? $hash->{helper}{mapZones}{$_}{currentWeekAreaPct} : '' ) . ' </td><td> % </td></tr>';
|
||||
|
||||
}
|
||||
|
||||
for ( @zonekeys ) {
|
||||
|
||||
$cnt++;
|
||||
$ret .= '<tr class="column '.( $cnt % 2 ? 'odd' : 'even' ) . '"><td> $hash->{helper}{mapZones}{' . $_ . '}{<b>lastWeekAreaPct</b>}  </td><td> ' . ( $hash->{helper}{mapZones}{$_}{lastWeekAreaPct} ? $hash->{helper}{mapZones}{$_}{lastWeekAreaPct} : '' ). ' </td><td> % </td></tr>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$ret .= '</tbody></table>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user