fix: api call,rate limit

This commit is contained in:
Sebastian 2024-05-21 10:29:07 +02:00
parent 90a561be10
commit 03b2130625
2 changed files with 28 additions and 9 deletions

View File

@ -264,6 +264,8 @@ sub Attr {
if ( $cmd eq 'set' && $attrVal eq '1' ) {
RemoveInternalTimer( $hash,
"FHEM::GardenaSmartBridge::getDevices" );
RemoveInternalTimer( $hash,
"FHEM::GardenaSmartBridge::getToken" );
readingsSingleUpdate( $hash, 'state', 'inactive', 1 );
Log3 $name, 3, "GardenaSmartBridge ($name) - disabled";
}
@ -691,6 +693,20 @@ sub ErrorHandling {
"GardenaSmartBridge ($dname) - RequestERROR: check the ???";
}
elsif ( $decode_json->{errors}[0]{code} eq "ratelimit.exceeded" ) {
Log3 $dname, 5,
"GardenaSmartBridge ($dname) - RequestERROR: error ratelimit.exceeded";
readingsBulkUpdate( $dhash, "lastRequestState", "too many requests", 1 );
readingsBulkUpdate( $dhash, "state", "inactive", 1 );
# remove all timer and disable bridge
readingsBulkUpdate( $dhash, "disable", "1", 1 );
# AttrVal( $name, 'disable', '1');
RemoveInternalTimer( $dhash, "FHEM::GardenaSmartBridge::getDevices" );
RemoveInternalTimer( $dhash, "FHEM::GardenaSmartBridge::getToken" );
return; # post request max.
}
else {
Log3 $dname, 5,
@ -1289,7 +1305,10 @@ sub createHttpValueStrings {
my ( $hash, $payload, $deviceId, $abilities, $service_id ) = @_;
my $session_id = $hash->{helper}{session_id};
my $header = "Content-Type: application/json";
my $header = 'Content-Type: application/json';
$header .= "\r\norigin: https://smart.gardena.com";
#my $header = "Content-Type: application/json; origin: https://smart.gardena.com";
my $uri = '';
my $method = 'POST';
$header .= "\r\nAuthorization: Bearer $session_id"

View File

@ -1,2 +1,2 @@
UPD 2024-04-15_15:52:28 49971 FHEM/73_GardenaSmartBridge.pm
UPD 2024-04-15_15:52:28 127762 FHEM/74_GardenaSmartDevice.pm
UPD 2024-05-21_10:28:45 50909 FHEM/73_GardenaSmartBridge.pm
UPD 2024-05-21_09:01:54 127762 FHEM/74_GardenaSmartDevice.pm