mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
74_AutomowerConnect: Common.pm, automowerconnect.js, fix path color for LEAVING in polling mode
git-svn-id: https://svn.fhem.de/fhem/trunk@27701 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b5bbe5c029
commit
3110fac750
@ -378,11 +378,11 @@ __END__
|
|||||||
|
|
||||||
<li><a id='AutomowerConnect-attr-addPollingMinInterval'>addPollingMinInterval</a><br>
|
<li><a id='AutomowerConnect-attr-addPollingMinInterval'>addPollingMinInterval</a><br>
|
||||||
<code>attr <name> addPollingMinInterval <interval in seconds></code><br>
|
<code>attr <name> addPollingMinInterval <interval in seconds></code><br>
|
||||||
Set minimum intervall for additional polling, default 0 (no polling). Gets periodically statistics data from mower. Make sure to be within API limits.</li>
|
Set minimum intervall for additional polling, default 0 (no polling). Gets periodically statistics data from mower. Make sure to be within API limits (10000 calls per month).</li>
|
||||||
|
|
||||||
<li><a id='AutomowerConnect-attr-addPositionPolling'>addPositionPolling</a><br>
|
<li><a id='AutomowerConnect-attr-addPositionPolling'>addPositionPolling</a><br>
|
||||||
<code>attr <name> addPositionPolling <[1|<b>0</b>]></code><br>
|
<code>attr <name> addPositionPolling <[1|<b>0</b>]></code><br>
|
||||||
Set position polling, default 0 (no position polling). Gets periodically position data from mower, instead from websocket. Must not be set without setting attribute addPollingMinInterval.</li>
|
Set position polling, default 0 (no position polling). Gets periodically position data from mower, instead from websocket. It has no effect without setting attribute addPollingMinInterval.</li>
|
||||||
|
|
||||||
<li><a href="disable">disable</a></li>
|
<li><a href="disable">disable</a></li>
|
||||||
|
|
||||||
@ -745,7 +745,7 @@ __END__
|
|||||||
|
|
||||||
<li><a id='AutomowerConnect-attr-addPositionPolling'>addPositionPolling</a><br>
|
<li><a id='AutomowerConnect-attr-addPositionPolling'>addPositionPolling</a><br>
|
||||||
<code>attr <name> addPositionPolling <[1|<b>0</b>]></code><br>
|
<code>attr <name> addPositionPolling <[1|<b>0</b>]></code><br>
|
||||||
Setzt das Positionspolling, default 0 (kein Positionpolling). Liest periodisch Positiondaten des Mähers, an Stelle der über Websocket gelieferten Daten. Darf nur im Zusammenhang mit dem Attribut addPollingMinInterval verwendet werden.</li>
|
Setzt das Positionspolling, default 0 (kein Positionpolling). Liest periodisch Positiondaten des Mähers, an Stelle der über Websocket gelieferten Daten. Das Attribut ist nur wirksam, wenn durch das Attribut addPollingMinInterval das Polling eingeschaltet ist.</li>
|
||||||
|
|
||||||
<li><a href="disable">disable</a></li>
|
<li><a href="disable">disable</a></li>
|
||||||
|
|
||||||
|
@ -297,7 +297,6 @@ my $mapZonesTpl = '{
|
|||||||
$hash->{Host} = 'ws.openapi.husqvarna.dev';
|
$hash->{Host} = 'ws.openapi.husqvarna.dev';
|
||||||
$hash->{Port} = '443/v1';
|
$hash->{Port} = '443/v1';
|
||||||
|
|
||||||
|
|
||||||
AddExtension( $name, \&GetMap, "$type/$name/map" );
|
AddExtension( $name, \&GetMap, "$type/$name/map" );
|
||||||
AddExtension( $name, \&GetJson, "$type/$name/json" );
|
AddExtension( $name, \&GetJson, "$type/$name/json" );
|
||||||
|
|
||||||
@ -1138,7 +1137,7 @@ sub CMDResponse {
|
|||||||
my $hash = $param->{hash};
|
my $hash = $param->{hash};
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $type = $hash->{TYPE};
|
my $type = $hash->{TYPE};
|
||||||
my $statuscode = $param->{code};
|
my $statuscode = $param->{code} // '';
|
||||||
my $iam = "$type $name CMDResponse:";
|
my $iam = "$type $name CMDResponse:";
|
||||||
|
|
||||||
Log3 $name, 1, "$iam response time ". sprintf( "%.2f", ( gettimeofday() - $param->{t_begin} ) ) . ' s' if ( $param->{timeout} == 60 );
|
Log3 $name, 1, "$iam response time ". sprintf( "%.2f", ( gettimeofday() - $param->{t_begin} ) ) . ' s' if ( $param->{timeout} == 60 );
|
||||||
@ -1404,7 +1403,7 @@ sub Attr {
|
|||||||
|
|
||||||
if( $cmd eq "set" ) {
|
if( $cmd eq "set" ) {
|
||||||
|
|
||||||
return "$iam $attrVal is invalid, allowed time in seconds as integer 0, 29 and higher." unless( $attrVal =~ /^\d+$/ && ( $attrVal == 0 || $attrVal > 28 ) );
|
return "$iam $attrVal is invalid, allowed time in seconds >= 0." unless( $attrVal >= 0 ) );
|
||||||
$hash->{helper}{additional_polling} = $attrVal;
|
$hash->{helper}{additional_polling} = $attrVal;
|
||||||
Log3 $name, 4, "$iam $cmd $attrName $attrVal";
|
Log3 $name, 4, "$iam $cmd $attrName $attrVal";
|
||||||
|
|
||||||
@ -1420,7 +1419,7 @@ sub Attr {
|
|||||||
|
|
||||||
if( $cmd eq "set" ) {
|
if( $cmd eq "set" ) {
|
||||||
|
|
||||||
return "$iam $attrVal is invalid, allowed time in seconds as integer 0, 29 and higher." unless( $attrVal == 0 || $attrVal == 1 );
|
return "$iam $attrVal is invalid, allowed value 0 or 1." unless( $attrVal == 0 || $attrVal == 1 );
|
||||||
$hash->{helper}{use_position_polling} = $attrVal;
|
$hash->{helper}{use_position_polling} = $attrVal;
|
||||||
Log3 $name, 4, "$iam $cmd $attrName $attrVal";
|
Log3 $name, 4, "$iam $cmd $attrName $attrVal";
|
||||||
|
|
||||||
@ -1599,7 +1598,7 @@ sub Attr {
|
|||||||
sub AlignArray {
|
sub AlignArray {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $use_position_polling = AttrVal( $name, 'addPositionPolling', 0 );
|
my $use_position_polling = $hash->{helper}{use_position_polling};
|
||||||
my $act = $hash->{helper}{mower}{attributes}{mower}{activity};
|
my $act = $hash->{helper}{mower}{attributes}{mower}{activity};
|
||||||
my $actold = $hash->{helper}{mowerold}{attributes}{mower}{activity};
|
my $actold = $hash->{helper}{mowerold}{attributes}{mower}{activity};
|
||||||
my $cnt = @{ $hash->{helper}{mower}{attributes}{positions} };
|
my $cnt = @{ $hash->{helper}{mower}{attributes}{positions} };
|
||||||
@ -1611,7 +1610,7 @@ sub AlignArray {
|
|||||||
my $deltaTime = $hash->{helper}{positionsTime} - $hash->{helper}{statusTime};
|
my $deltaTime = $hash->{helper}{positionsTime} - $hash->{helper}{statusTime};
|
||||||
|
|
||||||
# if encounter positions shortly after status event old activity is assigned to positions
|
# if encounter positions shortly after status event old activity is assigned to positions
|
||||||
if ( $cnt > 1 && $deltaTime > 0 && $deltaTime < 0.29 ) {
|
if ( $cnt > 1 && $deltaTime > 0 && $deltaTime < 0.29 && !$use_position_polling) {
|
||||||
|
|
||||||
map { $_->{act} = $hash->{helper}{$actold}{short} } @ar;
|
map { $_->{act} = $hash->{helper}{$actold}{short} } @ar;
|
||||||
|
|
||||||
@ -2482,7 +2481,7 @@ sub wsKeepAlive {
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
RemoveInternalTimer( $hash, \&wsKeepAlive);
|
RemoveInternalTimer( $hash, \&wsKeepAlive);
|
||||||
DevIo_Ping($hash);
|
DevIo_Ping($hash);
|
||||||
InternalTimer(gettimeofday() + 60, \&wsKeepAlive, $hash, 0);
|
InternalTimer(gettimeofday() + $hash->{helper}{interval_ping}, \&wsKeepAlive, $hash, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2538,7 +2537,7 @@ sub wsRead {
|
|||||||
|
|
||||||
if ( $@ ) {
|
if ( $@ ) {
|
||||||
|
|
||||||
Log3( $name, 2, "$iam - JSON error while request: $@");
|
Log3( $name, 1, "$iam - JSON error while request: $@\n\nbuffer content: >$buf<\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -2566,13 +2565,14 @@ sub wsRead {
|
|||||||
$hash->{helper}{mower}{attributes}{planner} = dclone( $result->{attributes}{planner} );
|
$hash->{helper}{mower}{attributes}{planner} = dclone( $result->{attributes}{planner} );
|
||||||
$hash->{helper}{storediff} = $hash->{helper}{mower}{attributes}{metadata}{statusTimestamp} - $hash->{helper}{mowerold}{attributes}{metadata}{statusTimestamp};
|
$hash->{helper}{storediff} = $hash->{helper}{mower}{attributes}{metadata}{statusTimestamp} - $hash->{helper}{mowerold}{attributes}{metadata}{statusTimestamp};
|
||||||
$hash->{helper}{storesum} += $hash->{helper}{storediff} if ( $additional_polling );
|
$hash->{helper}{storesum} += $hash->{helper}{storediff} if ( $additional_polling );
|
||||||
|
my $act = $result->{attributes}{mower}{activity};
|
||||||
|
|
||||||
if ( !$additional_polling ) {
|
if ( !$additional_polling ) {
|
||||||
|
|
||||||
isErrorThanPrepare( $hash );
|
isErrorThanPrepare( $hash );
|
||||||
resetLastErrorIfCorrected( $hash );
|
resetLastErrorIfCorrected( $hash );
|
||||||
|
|
||||||
} elsif ( $additional_polling < $hash->{helper}{storesum} && !$hash->{helper}{midnightCycle} ) {
|
} elsif ( ( $additional_polling < $hash->{helper}{storesum} || $additional_polling && $act eq 'LEAVING' ) && !$hash->{helper}{midnightCycle} ) {
|
||||||
|
|
||||||
$hash->{helper}{storesum} = 0;
|
$hash->{helper}{storesum} = 0;
|
||||||
# RemoveInternalTimer( $hash, \&getMowerWs );
|
# RemoveInternalTimer( $hash, \&getMowerWs );
|
||||||
|
@ -275,6 +275,7 @@ function AutomowerConnectTor ( x0, y0, x1, y1 ) {
|
|||||||
function AutomowerConnectUpdateJson ( path ) {
|
function AutomowerConnectUpdateJson ( path ) {
|
||||||
$.getJSON( path, function( data, textStatus ) {
|
$.getJSON( path, function( data, textStatus ) {
|
||||||
log( 'AutomowerConnectUpdateJson ( '+path+' ): status '+textStatus );
|
log( 'AutomowerConnectUpdateJson ( '+path+' ): status '+textStatus );
|
||||||
|
if ( textStatus == 'success')
|
||||||
AutomowerConnectUpdateDetail ( data.name, data.type, data.detailfnfirst, data.picx, data.picy, data.scalx, data.errdesc, data.posxy, data.poserrxy );
|
AutomowerConnectUpdateDetail ( data.name, data.type, data.detailfnfirst, data.picx, data.picy, data.scalx, data.errdesc, data.posxy, data.poserrxy );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user