fix: api call,rate limit
This commit is contained in:
parent
90a561be10
commit
03b2130625
@ -264,6 +264,8 @@ sub Attr {
|
|||||||
if ( $cmd eq 'set' && $attrVal eq '1' ) {
|
if ( $cmd eq 'set' && $attrVal eq '1' ) {
|
||||||
RemoveInternalTimer( $hash,
|
RemoveInternalTimer( $hash,
|
||||||
"FHEM::GardenaSmartBridge::getDevices" );
|
"FHEM::GardenaSmartBridge::getDevices" );
|
||||||
|
RemoveInternalTimer( $hash,
|
||||||
|
"FHEM::GardenaSmartBridge::getToken" );
|
||||||
readingsSingleUpdate( $hash, 'state', 'inactive', 1 );
|
readingsSingleUpdate( $hash, 'state', 'inactive', 1 );
|
||||||
Log3 $name, 3, "GardenaSmartBridge ($name) - disabled";
|
Log3 $name, 3, "GardenaSmartBridge ($name) - disabled";
|
||||||
}
|
}
|
||||||
@ -691,6 +693,20 @@ sub ErrorHandling {
|
|||||||
"GardenaSmartBridge ($dname) - RequestERROR: check the ???";
|
"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 {
|
else {
|
||||||
|
|
||||||
Log3 $dname, 5,
|
Log3 $dname, 5,
|
||||||
@ -1289,7 +1305,10 @@ sub createHttpValueStrings {
|
|||||||
my ( $hash, $payload, $deviceId, $abilities, $service_id ) = @_;
|
my ( $hash, $payload, $deviceId, $abilities, $service_id ) = @_;
|
||||||
|
|
||||||
my $session_id = $hash->{helper}{session_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 $uri = '';
|
||||||
my $method = 'POST';
|
my $method = 'POST';
|
||||||
$header .= "\r\nAuthorization: Bearer $session_id"
|
$header .= "\r\nAuthorization: Bearer $session_id"
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
UPD 2024-04-15_15:52:28 49971 FHEM/73_GardenaSmartBridge.pm
|
UPD 2024-05-21_10:28:45 50909 FHEM/73_GardenaSmartBridge.pm
|
||||||
UPD 2024-04-15_15:52:28 127762 FHEM/74_GardenaSmartDevice.pm
|
UPD 2024-05-21_09:01:54 127762 FHEM/74_GardenaSmartDevice.pm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user