patch_login_autodisable_api #108

Merged
marko merged 7 commits from patch_login_autodisable_api into dev 2024-05-22 17:10:37 +00:00
3 changed files with 99 additions and 31 deletions

View File

@ -1,4 +1,35 @@
### fix: patch code scheduling by hhhdg (HEAD -> patch_valve_hhhdg)
### fix: api call,rate limit (HEAD -> patch_login_autodisable_api)
>Tue, 21 May 2024 10:29:07 +0200
>Author: Sebastian (em@ail.tld)
>Commiter: Sebastian (em@ail.tld)
### docs: change copyright year
>Mon, 15 Apr 2024 15:45:33 +0200
>Author: Marko Oldenburg (fhemdevelopment@cooltux.net)
>Commiter: Marko Oldenburg (fhemdevelopment@cooltux.net)
Ticket: no
### fix: version push (origin/patch_valve_hhhdg, patch_valve_hhhdg)
>Mon, 15 Apr 2024 09:38:16 +0200
>Author: Sebastian (em@ail.tld)
>Commiter: Sebastian (em@ail.tld)
### fix: patch code scheduling by hhhdg
>Mon, 15 Apr 2024 09:32:51 +0200
>Author: Sebastian (em@ail.tld)
@ -8,6 +39,16 @@
### docs: new CHANGELOG
>Thu, 28 Mar 2024 12:41:42 +0100
>Author: Marko Oldenburg (fhemdevelopment@cooltux.net)
>Commiter: Marko Oldenburg (fhemdevelopment@cooltux.net)
### controls_GardenaSmartDevice.txt aktualisiert
>Thu, 28 Mar 2024 06:05:59 +0100
@ -188,7 +229,7 @@
### feat: changelog
### feat: changelog (origin/patch_setExtention, patch_setExtention)
>Thu, 2 Mar 2023 11:58:58 +0100
>Author: Sebastian (em@ail.tld)
@ -218,7 +259,7 @@
### docs: add changelog file (tag: v2.6.0, origin/patch-changeVersion, patch-changeVersion)
### docs: add changelog file (tag: v2.6.0, origin/patch-changeVersion)
>Tue, 10 Jan 2023 09:51:23 +0100
>Author: Marko Oldenburg (fhemdevelopment@cooltux.net)
@ -250,7 +291,7 @@ hooks for commit test and create changelog
### [translaten] - add commandref translation
### [translaten] - add commandref translation (origin/patch-fix_commandref_spell, patch-fix_commandref_spell)
>Sun, 18 Sep 2022 08:52:43 +0200
>Author: Sebastian (em@ail.tld)
@ -270,7 +311,7 @@ hooks for commit test and create changelog
### [enhancement] - commandref
### [enhancement] - commandref (origin/patch-wc_rest_valve_and_additinal_commandref, patch-wc_rest_valve_and_additinal_commandref)
>Tue, 6 Sep 2022 12:32:40 +0200
>Author: Sebastian (em@ail.tld)
@ -320,7 +361,7 @@ hooks for commit test and create changelog
### [fix] - upper/lower case
### [fix] - upper/lower case (origin/patch-offline_status_startup_undefined, patch-offline_status_startup_undefined)
>Thu, 11 Aug 2022 14:25:19 +0200
>Author: Sebastian (em@ail.tld)
@ -610,7 +651,7 @@ hooks for commit test and create changelog
### readd lost setter webinterface
### readd lost setter webinterface (origin/patch-dev_merge_failed_electronic_pressure_pump, patch-dev_merge_failed_electronic_pressure_pump)
>Wed, 13 Jul 2022 20:56:47 +0200
>Author: Sebastian (em@ail.tld)
@ -631,7 +672,7 @@ hooks for commit test and create changelog
### „FHEM/74_GardenaSmartDevice.pm“ ändern
### „FHEM/74_GardenaSmartDevice.pm“ ändern (origin/patch_electronic_pressure_pump_water_pump_name_mistake)
>Tue, 12 Jul 2022 20:09:33 +0200
>Author: Sebastian Schwaz (sebastianschwarz@noreply@cooltux.net)
@ -851,7 +892,7 @@ hooks for commit test and create changelog
### [fix] - setter procedure
### [fix] - setter procedure (origin/patch_pressure_pump_setlist, patch_pressure_pump_setlist)
>Wed, 29 Jun 2022 20:32:00 +0200
>Author: Sebastian (em@ail.tld)
@ -1001,7 +1042,7 @@ hooks for commit test and create changelog
### patch lono. eventuell recrusive readings einbauen. waterpump rechtschreibfehler mit fixed
### patch lono. eventuell recrusive readings einbauen. waterpump rechtschreibfehler mit fixed (origin/patch_lona, patch_lona)
>Sat, 25 Jun 2022 12:58:59 +0200
>Author: Sebastian (em@ail.tld)
@ -1381,7 +1422,7 @@ hooks for commit test and create changelog
### lona
### lona (origin/patch_waterpump, patch_waterpump)
>Tue, 17 May 2022 20:53:37 +0200
>Author: Sebastian (em@ail.tld)
@ -1771,7 +1812,7 @@ hooks for commit test and create changelog
### round minutes in irregation
### round minutes in irregation (origin/patch_water_control)
>Tue, 12 Apr 2022 08:40:40 +0200
>Author: Sebastian (em@ail.tld)
@ -1911,7 +1952,7 @@ hooks for commit test and create changelog
### fix state
### fix state (origin/patch_add_sensor2)
>Tue, 5 Apr 2022 09:23:34 +0200
>Author: Sebastian (em@ail.tld)
@ -1941,7 +1982,7 @@ hooks for commit test and create changelog
### fix ic24
### fix ic24 (origin/patch_ic24_schedule)
>Tue, 29 Mar 2022 16:35:58 +0200
>Author: Sebastian (em@ail.tld)

View File

@ -205,6 +205,7 @@ sub Define {
my $hash = shift // return;
my $aArg = shift // return;
return $@ unless ( FHEM::Meta::SetInternals($hash) );
use version 0.60; our $VERSION = FHEM::Meta::Get( $hash, 'version' );
@ -221,8 +222,9 @@ sub Define {
$hash->{URL} =
AttrVal( $name, 'gardenaBaseURL', 'https://smart.gardena.com' ) . '/v1';
$hash->{VERSION} = version->parse($VERSION)->normal;
$hash->{INTERVAL} = 60;
$hash->{INTERVAL} = 180;
$hash->{NOTIFYDEV} = "global,$name";
$hash->{helper}{gettoken_count} = 0;
CommandAttr( undef, $name . ' room GardenaSmart' )
if ( AttrVal( $name, 'room', 'none' ) eq 'none' );
@ -264,6 +266,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";
}
@ -290,14 +294,14 @@ sub Attr {
if ( $attrVal == 0 );
RemoveInternalTimer( $hash,
"FHEM::GardenaSmartBridge::getDevices" );
$hash->{INTERVAL} = $attrVal;
$hash->{INTERVAL} = $attrVal if $attrVal >= 180;
Log3 $name, 3,
"GardenaSmartBridge ($name) - set interval: $attrVal";
}
elsif ( $cmd eq 'del' ) {
RemoveInternalTimer( $hash,
"FHEM::GardenaSmartBridge::getDevices" );
$hash->{INTERVAL} = 60;
$hash->{INTERVAL} = 180;
Log3 $name, 3,
"GardenaSmartBridge ($name) - delete User interval and set default: 60";
}
@ -691,6 +695,16 @@ sub ErrorHandling {
"GardenaSmartBridge ($dname) - RequestERROR: check the ???";
}
elsif ( $decode_json->{errors}[0]{code} eq "ratelimit.exceeded" ) {
Log3 $name, 5,
"GardenaSmartBridge ($name) - RequestERROR: error ratelimit.exceeded";
readingsBulkUpdate( $hash, "lastRequestState", "too many requests", 1 );
readingsBulkUpdate( $hash, "state", "inactive", 1 );
# remove all timer and disable bridge
RemoveInternalTimer( $hash );
return; # post request max.
}
else {
Log3 $dname, 5,
@ -700,8 +714,18 @@ sub ErrorHandling {
if ( !defined( $hash->{helper}{session_id} ) ) {
readingsSingleUpdate( $hash, 'token', 'none', 1 );
InternalTimer( gettimeofday() + 5,
"FHEM::GardenaSmartBridge::getToken", $hash );
Log3 $name, 3,
"GardenaSmartBridge ($name) - getToken limit: "
. $hash->{helper}{gettoken_count} ;
if ($hash->{helper}{gettoken_count} < 6) {
$hash->{helper}{gettoken_count}++;
InternalTimer( gettimeofday() + 5,
"FHEM::GardenaSmartBridge::getToken", $hash )
} else {
RemoveInternalTimer ($hash);
$hash->{helper}{gettoken_count} = 0;
}
}
readingsEndUpdate( $dhash, 1 );
@ -1176,21 +1200,21 @@ sub getToken {
Write(
$hash,
'"data": {"type":"token", "attributes":{"username": "'
'"data":{"type":"token","attributes":{"username":"'
. AttrVal( $name, 'gardenaAccountEmail', 'none' )
. '","password": "'
. '","password":"'
. ReadPassword( $hash, $name )
. '", "client_id":"smartgarden-jwt-client"}}',
. '","client_id":"smartgarden-jwt-client"}}',
undef,
undef
);
Log3 $name, 4,
'"data": {"type":"token", "attributes":{"username": "'
'"data": {"type":"token", "attributes":{"username":"'
. AttrVal( $name, 'gardenaAccountEmail', 'none' )
. '","password": "'
. '","password":"'
. ReadPassword( $hash, $name )
. '", "client_id":"smartgarden-jwt-client"}}';
. '","client_id":"smartgarden-jwt-client"}}';
Log3 $name, 3,
"GardenaSmartBridge ($name) - send credentials to fetch Token and locationId";
@ -1289,7 +1313,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";
$header .= "\r\nuser-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
#my $header = "Content-Type: application/json; origin: https://smart.gardena.com";
my $uri = '';
my $method = 'POST';
$header .= "\r\nAuthorization: Bearer $session_id"
@ -1496,7 +1523,7 @@ sub DeletePassword {
<ul>
<li>debugJSON - </li>
<li>disable - Disables the Bridge</li>
<li>interval - Interval in seconds (Default=60)</li>
<li>interval - Interval in seconds (Default=180)</li>
<li>gardenaAccountEmail - Email Adresse which was used in the GardenaAPP</li>
</ul>
</ul>
@ -1557,7 +1584,7 @@ sub DeletePassword {
<ul>
<li>debugJSON - JSON Fehlermeldungen</li>
<li>disable - Schaltet die Datenübertragung der Bridge ab</li>
<li>interval - Abfrageinterval in Sekunden (default: 60)</li>
<li>interval - Abfrageinterval in Sekunden (default: 180)</li>
<li>gardenaAccountEmail - Email Adresse, die auch in der GardenaApp verwendet wurde</li>
</ul>
</ul>
@ -1581,7 +1608,7 @@ sub DeletePassword {
],
"release_status": "stable",
"license": "GPL_2",
"version": "v2.6.2",
"version": "v2.6.3",
"author": [
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
],

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-22_18:46:22 51262 FHEM/73_GardenaSmartBridge.pm
UPD 2024-05-21_09:01:54 127762 FHEM/74_GardenaSmartDevice.pm