mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 20:06:18 +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.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: AutomowerConnectFamily: enhanced zone statistics
|
||||||
- bugfix: 72_FRITZBOX: XML::Simple entfernt
|
- bugfix: 72_FRITZBOX: XML::Simple entfernt
|
||||||
wg diverese Inkompatibilitaeten
|
wg diverese Inkompatibilitaeten
|
||||||
- change: codemirror updated from 5.22.0 to 5.65.13
|
- 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 @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
||||||
my $sumLastDayCnt=0;
|
my $sumLastDayCnt=0;
|
||||||
my $sumCurrentWeekCnt=0;
|
my $sumCurrentWeekCnt=0;
|
||||||
|
my $sumLastDayArea=0;
|
||||||
|
my $sumCurrentWeekArea=0;
|
||||||
map {
|
map {
|
||||||
$hash->{helper}{mapZones}{$_}{lastDayCnt} = $hash->{helper}{mapZones}{$_}{zoneCnt};
|
$hash->{helper}{mapZones}{$_}{lastDayCnt} = $hash->{helper}{mapZones}{$_}{zoneCnt};
|
||||||
$sumLastDayCnt += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
$sumLastDayCnt += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
||||||
$hash->{helper}{mapZones}{$_}{currentWeekCnt} += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
$hash->{helper}{mapZones}{$_}{currentWeekCnt} += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
||||||
$sumCurrentWeekCnt += $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
$sumCurrentWeekCnt += $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
||||||
$hash->{helper}{mapZones}{$_}{zoneCnt} = 0;
|
$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;
|
} @zonekeys;
|
||||||
|
|
||||||
map {
|
map {
|
||||||
@ -444,6 +452,14 @@ sub getMowerResponse {
|
|||||||
$hash->{helper}{mapZones}{$_}{currentWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekCnt} / $sumCurrentWeekCnt * 100 );
|
$hash->{helper}{mapZones}{$_}{currentWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekCnt} / $sumCurrentWeekCnt * 100 );
|
||||||
} @zonekeys if( $sumCurrentWeekCnt );
|
} @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
|
# do on days
|
||||||
if ( $time[6] == 1 ) {
|
if ( $time[6] == 1 ) {
|
||||||
@ -457,16 +473,24 @@ sub getMowerResponse {
|
|||||||
|
|
||||||
my @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
my @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
||||||
my $sumLastWeekCnt=0;
|
my $sumLastWeekCnt=0;
|
||||||
|
my $sumLastWeekArea=0;
|
||||||
map {
|
map {
|
||||||
$hash->{helper}{mapZones}{$_}{lastWeekCnt} = $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
$hash->{helper}{mapZones}{$_}{lastWeekCnt} = $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
||||||
$sumLastWeekCnt += $hash->{helper}{mapZones}{$_}{lastWeekCnt};
|
$sumLastWeekCnt += $hash->{helper}{mapZones}{$_}{lastWeekCnt};
|
||||||
$hash->{helper}{mapZones}{$_}{currentWeekCnt} = 0;
|
$hash->{helper}{mapZones}{$_}{currentWeekCnt} = 0;
|
||||||
|
$hash->{helper}{mapZones}{$_}{lastWeekArea} = $hash->{helper}{mapZones}{$_}{currentWeekArea};
|
||||||
|
$sumLastWeekArea += $hash->{helper}{mapZones}{$_}{lastWeekArea};
|
||||||
|
$hash->{helper}{mapZones}{$_}{currentWeekArea} = 0;
|
||||||
} @zonekeys;
|
} @zonekeys;
|
||||||
|
|
||||||
map {
|
map {
|
||||||
$hash->{helper}{mapZones}{$_}{lastWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekCnt} / $sumLastWeekCnt * 100 );
|
$hash->{helper}{mapZones}{$_}{lastWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekCnt} / $sumLastWeekCnt * 100 );
|
||||||
} @zonekeys if( $sumLastWeekCnt );
|
} @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 @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
||||||
my $sumLastDayCnt=0;
|
my $sumLastDayCnt=0;
|
||||||
my $sumCurrentWeekCnt=0;
|
my $sumCurrentWeekCnt=0;
|
||||||
|
my $sumLastDayArea=0;
|
||||||
|
my $sumCurrentWeekArea=0;
|
||||||
map {
|
map {
|
||||||
$hash->{helper}{mapZones}{$_}{lastDayCnt} = $hash->{helper}{mapZones}{$_}{zoneCnt};
|
$hash->{helper}{mapZones}{$_}{lastDayCnt} = $hash->{helper}{mapZones}{$_}{zoneCnt};
|
||||||
$sumLastDayCnt += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
$sumLastDayCnt += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
||||||
$hash->{helper}{mapZones}{$_}{currentWeekCnt} += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
$hash->{helper}{mapZones}{$_}{currentWeekCnt} += $hash->{helper}{mapZones}{$_}{lastDayCnt};
|
||||||
$sumCurrentWeekCnt += $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
$sumCurrentWeekCnt += $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
||||||
$hash->{helper}{mapZones}{$_}{zoneCnt} = 0;
|
$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;
|
} @zonekeys;
|
||||||
|
|
||||||
map {
|
map {
|
||||||
@ -277,6 +285,14 @@ sub Notify {
|
|||||||
$hash->{helper}{mapZones}{$_}{currentWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekCnt} / $sumCurrentWeekCnt * 100 );
|
$hash->{helper}{mapZones}{$_}{currentWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{currentWeekCnt} / $sumCurrentWeekCnt * 100 );
|
||||||
} @zonekeys if( $sumCurrentWeekCnt );
|
} @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
|
# do on days
|
||||||
if ( $time[6] == 1 ) {
|
if ( $time[6] == 1 ) {
|
||||||
@ -290,16 +306,24 @@ sub Notify {
|
|||||||
|
|
||||||
my @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
my @zonekeys = sort (keys %{$hash->{helper}{mapZones}});
|
||||||
my $sumLastWeekCnt=0;
|
my $sumLastWeekCnt=0;
|
||||||
|
my $sumLastWeekArea=0;
|
||||||
map {
|
map {
|
||||||
$hash->{helper}{mapZones}{$_}{lastWeekCnt} = $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
$hash->{helper}{mapZones}{$_}{lastWeekCnt} = $hash->{helper}{mapZones}{$_}{currentWeekCnt};
|
||||||
$sumLastWeekCnt += $hash->{helper}{mapZones}{$_}{lastWeekCnt};
|
$sumLastWeekCnt += $hash->{helper}{mapZones}{$_}{lastWeekCnt};
|
||||||
$hash->{helper}{mapZones}{$_}{currentWeekCnt} = 0;
|
$hash->{helper}{mapZones}{$_}{currentWeekCnt} = 0;
|
||||||
|
$hash->{helper}{mapZones}{$_}{lastWeekArea} = $hash->{helper}{mapZones}{$_}{currentWeekArea};
|
||||||
|
$sumLastWeekArea += $hash->{helper}{mapZones}{$_}{lastWeekArea};
|
||||||
|
$hash->{helper}{mapZones}{$_}{currentWeekArea} = 0;
|
||||||
} @zonekeys;
|
} @zonekeys;
|
||||||
|
|
||||||
map {
|
map {
|
||||||
$hash->{helper}{mapZones}{$_}{lastWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekCnt} / $sumLastWeekCnt * 100 );
|
$hash->{helper}{mapZones}{$_}{lastWeekCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{lastWeekCnt} / $sumLastWeekCnt * 100 );
|
||||||
} @zonekeys if( $sumLastWeekCnt );
|
} @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)$/ ) {
|
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;
|
last;
|
||||||
|
|
||||||
} elsif ( $k == @zonekeys-2 ) { # last zone
|
} 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}++;
|
$hash->{helper}{mapZones}{$zonekeys[$k+1]}{zoneCnt}++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -882,6 +883,11 @@ sub ZoneHandling {
|
|||||||
my $sumDayCnt=0;
|
my $sumDayCnt=0;
|
||||||
map { $sumDayCnt += $hash->{helper}{mapZones}{$_}{zoneCnt} } @zonekeys;
|
map { $sumDayCnt += $hash->{helper}{mapZones}{$_}{zoneCnt} } @zonekeys;
|
||||||
map { $hash->{helper}{mapZones}{$_}{currentDayCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{zoneCnt} / $sumDayCnt * 100 ) } @zonekeys if ( $sumDayCnt );
|
map { $hash->{helper}{mapZones}{$_}{currentDayCntPct} = sprintf( "%.0f", $hash->{helper}{mapZones}{$_}{zoneCnt} / $sumDayCnt * 100 ) } @zonekeys if ( $sumDayCnt );
|
||||||
|
|
||||||
|
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;
|
$hash->{helper}{newzonedatasets} = $cnt;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -943,23 +949,30 @@ sub HighlightPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
sub AreaStatistics {
|
sub calcPathLength {
|
||||||
my ( $hash, $poshash, $i ) = @_;
|
my ( $hash, $istart, $i ) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $activity = 'MOWING';
|
|
||||||
my $k = 0;
|
my $k = 0;
|
||||||
my @xyarr = @{$hash->{helper}{areapos}};# areapos
|
my @xyarr = @{$hash->{helper}{areapos}};# areapos
|
||||||
my $n = scalar @xyarr;
|
my $n = scalar @xyarr;
|
||||||
my ($sclon, $sclat) = AttrVal($name,'scaleToMeterXY', $hash->{helper}{scaleToMeterLongitude} . ' ' .$hash->{helper}{scaleToMeterLatitude}) =~ /(-?\d+)\s+(-?\d+)/;
|
my ($sclon, $sclat) = AttrVal($name,'scaleToMeterXY', $hash->{helper}{scaleToMeterLongitude} . ' ' .$hash->{helper}{scaleToMeterLatitude}) =~ /(-?\d+)\s+(-?\d+)/;
|
||||||
my $lsum = 0;
|
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} );
|
$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);
|
$asum = $lsum * AttrVal($name,'mowerCuttingWidth',0.24);
|
||||||
$hash->{helper}{$activity}{track} = $lsum;
|
$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>';
|
$ret .= '</tbody></table>';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user