2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +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:
Ellert 2023-06-23 22:06:55 +00:00
parent b5bbe5c029
commit 3110fac750
3 changed files with 14 additions and 13 deletions

View File

@ -378,11 +378,11 @@ __END__
<li><a id='AutomowerConnect-attr-addPollingMinInterval'>addPollingMinInterval</a><br>
<code>attr &lt;name&gt; addPollingMinInterval &lt;interval in seconds&gt;</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>
<code>attr &lt;name&gt; addPositionPolling &lt;[1|<b>0</b>]&gt;</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>
@ -745,7 +745,7 @@ __END__
<li><a id='AutomowerConnect-attr-addPositionPolling'>addPositionPolling</a><br>
<code>attr &lt;name&gt; addPositionPolling &lt;[1|<b>0</b>]&gt;</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>

View File

@ -297,7 +297,6 @@ my $mapZonesTpl = '{
$hash->{Host} = 'ws.openapi.husqvarna.dev';
$hash->{Port} = '443/v1';
AddExtension( $name, \&GetMap, "$type/$name/map" );
AddExtension( $name, \&GetJson, "$type/$name/json" );
@ -1138,7 +1137,7 @@ sub CMDResponse {
my $hash = $param->{hash};
my $name = $hash->{NAME};
my $type = $hash->{TYPE};
my $statuscode = $param->{code};
my $statuscode = $param->{code} // '';
my $iam = "$type $name CMDResponse:";
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" ) {
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;
Log3 $name, 4, "$iam $cmd $attrName $attrVal";
@ -1420,7 +1419,7 @@ sub Attr {
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;
Log3 $name, 4, "$iam $cmd $attrName $attrVal";
@ -1599,7 +1598,7 @@ sub Attr {
sub AlignArray {
my ($hash) = @_;
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 $actold = $hash->{helper}{mowerold}{attributes}{mower}{activity};
my $cnt = @{ $hash->{helper}{mower}{attributes}{positions} };
@ -1611,7 +1610,7 @@ sub AlignArray {
my $deltaTime = $hash->{helper}{positionsTime} - $hash->{helper}{statusTime};
# 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;
@ -2482,7 +2481,7 @@ sub wsKeepAlive {
my ($hash) = @_;
RemoveInternalTimer( $hash, \&wsKeepAlive);
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 ( $@ ) {
Log3( $name, 2, "$iam - JSON error while request: $@");
Log3( $name, 1, "$iam - JSON error while request: $@\n\nbuffer content: >$buf<\n");
} else {
@ -2566,13 +2565,14 @@ sub wsRead {
$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}{storesum} += $hash->{helper}{storediff} if ( $additional_polling );
my $act = $result->{attributes}{mower}{activity};
if ( !$additional_polling ) {
isErrorThanPrepare( $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;
# RemoveInternalTimer( $hash, \&getMowerWs );

View File

@ -275,7 +275,8 @@ function AutomowerConnectTor ( x0, y0, x1, y1 ) {
function AutomowerConnectUpdateJson ( path ) {
$.getJSON( path, function( data, textStatus ) {
log( 'AutomowerConnectUpdateJson ( '+path+' ): status '+textStatus );
AutomowerConnectUpdateDetail ( data.name, data.type, data.detailfnfirst, data.picx, data.picy, data.scalx, data.errdesc, data.posxy, data.poserrxy );
if ( textStatus == 'success')
AutomowerConnectUpdateDetail ( data.name, data.type, data.detailfnfirst, data.picx, data.picy, data.scalx, data.errdesc, data.posxy, data.poserrxy );
});