2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

74_AutomowerConnect: prevent division by zero, delay ws init, force new access token when set client_secret

git-svn-id: https://svn.fhem.de/fhem/trunk@27628 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Ellert 2023-05-29 22:49:13 +00:00
parent 84d39b9eda
commit 976bcfb874
2 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,7 @@
# 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.
- bugfix: 74_AutomowerConnect: prevent division by zero, delay ws init
force new access token when set client_secret
- change: 74_AutomowerConnect: Common.pm, automowerconnect.js - change: 74_AutomowerConnect: Common.pm, automowerconnect.js
implemented error stack and getter to show implemented error stack and getter to show
show daily collisions, not calculate statistics solved show daily collisions, not calculate statistics solved

View File

@ -394,8 +394,10 @@ sub getMowerResponse {
# schedule new access token # schedule new access token
RemoveInternalTimer( $hash, \&APIAuth ); RemoveInternalTimer( $hash, \&APIAuth );
InternalTimer( ReadingsVal($name, '.expires', 600)-37, \&APIAuth, $hash, 0 ); InternalTimer( ReadingsVal($name, '.expires', 600)-37, \&APIAuth, $hash, 0 );
# Websocket initialisieren, schedule ping, reopen # Websocket initialisieren, schedule ping, reopen
wsReopen( $hash ); RemoveInternalTimer( $hash, \&wsReopen );
InternalTimer( gettimeofday() + 1.5, \&wsReopen, $hash, 0 );
return undef; return undef;
@ -614,6 +616,13 @@ sub Set {
my ($passResp, $passErr) = $hash->{helper}->{passObj}->setStorePassword($name, $setVal); my ($passResp, $passErr) = $hash->{helper}->{passObj}->setStorePassword($name, $setVal);
Log3 $name, 1, "$iam error: $passErr" if ($passErr); Log3 $name, 1, "$iam error: $passErr" if ($passErr);
return "$iam $passErr" if( $passErr ); return "$iam $passErr" if( $passErr );
readingsBeginUpdate($hash);
readingsBulkUpdateIfChanged( $hash, '.access_token', '', 0 );
readingsBulkUpdateIfChanged( $hash, 'device_state', 'initialized');
readingsBulkUpdateIfChanged( $hash, 'mower_commandStatus', 'cleared');
readingsEndUpdate($hash, 1);
RemoveInternalTimer($hash, \&APIAuth); RemoveInternalTimer($hash, \&APIAuth);
APIAuth($hash); APIAuth($hash);
return undef; return undef;
@ -774,6 +783,12 @@ sub Attr {
if( $cmd eq "set" ) { if( $cmd eq "set" ) {
return "$iam $attrName has a wrong format use linewise pairs <floating point longitude><one space character><floating point latitude>" unless( $attrVal =~ /(-?\d*\.?\d+)\s(-?\d*\.?\d+)(\R|\s)(-?\d*\.?\d+)\s(-?\d*\.?\d+)/ ); return "$iam $attrName has a wrong format use linewise pairs <floating point longitude><one space character><floating point latitude>" unless( $attrVal =~ /(-?\d*\.?\d+)\s(-?\d*\.?\d+)(\R|\s)(-?\d*\.?\d+)\s(-?\d*\.?\d+)/ );
my ( $lo1, $la1, $lo2, $la2 ) = ( $1, $2, $4, $5 );
return "$iam $attrName illegal value 0 for the difference of longitudes." unless ( $lo1 - $lo2 );
return "$iam $attrName illegal value 0 for the difference of latitudes." unless ( $la1 - $la2 );
Log3 $name, 3, "$iam $cmd $attrName $attrVal"; Log3 $name, 3, "$iam $cmd $attrName $attrVal";
} elsif( $cmd eq "del" ) { } elsif( $cmd eq "del" ) {