Compare commits
66 Commits
aea73bb010
...
testing
Author | SHA1 | Date | |
---|---|---|---|
8972880d78 | |||
c75f865589 | |||
9412aac176 | |||
ae437a09f2 | |||
640a7544d7 | |||
f38236f721 | |||
517f033ccc | |||
03b2130625 | |||
90a561be10 | |||
69d7681a28 | |||
5e60969fc4 | |||
2d756e4aaa | |||
80147631d6 | |||
8b66df8407 | |||
fc3740fe9b | |||
03ad7e3fba | |||
dfea4716d3 | |||
f9661f6452 | |||
b41e583a9e | |||
5138e6b3b0 | |||
89bc35b1bd | |||
03e79bc782 | |||
74635dfd0a | |||
443ecd7776 | |||
bbb4be939c | |||
72daa71daf | |||
68f66c8430 | |||
579f632990 | |||
790d5206b6 | |||
2c94924e97 | |||
918f4dc6a3 | |||
f14d34c1b4 | |||
274cb067cf | |||
897a3c7aef | |||
232f82eafe | |||
9c49aa49b9 | |||
24db680413 | |||
df1830a670 | |||
de58578a2d | |||
e15a70ff0b | |||
98b093bcba | |||
82907c73a3 | |||
13de67f570 | |||
7385959b38 | |||
7dfa0b2dda | |||
abb325b448 | |||
d7d5e4f843 | |||
c0dec3d3fb | |||
3e540471d5 | |||
608719ba2f | |||
472fe88ac0 | |||
682dea8bd1 | |||
fb3a690993 | |||
2cae1812d8 | |||
2111939863 | |||
c9a3cc9e1d | |||
b399fcd524 | |||
89bbb4bb10 | |||
801a1a468f | |||
eddcb708ba | |||
c7073b24b4 | |||
fe97f0b203 | |||
eebe13bb7b | |||
a6174d9982 | |||
4cb9f2e50b | |||
ebb342d83f |
4243
CHANGELOG.md
Normal file
4243
CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Developed with VSCodium and richterger perl plugin.
|
||||
#
|
||||
# (c) 2017-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
|
||||
# (c) 2017-2024 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
|
||||
# All rights reserved
|
||||
#
|
||||
# Special thanks goes to comitters:
|
||||
@ -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";
|
||||
}
|
||||
@ -437,11 +441,13 @@ sub Set {
|
||||
|
||||
DeletePassword($hash);
|
||||
}
|
||||
elsif ( lc $cmd eq 'debughelper') {
|
||||
elsif ( lc $cmd eq 'debughelper' ) {
|
||||
return "usage: $cmd" if ( scalar( @{$aArg} ) != 2 );
|
||||
my $new_helper = $aArg->[0];
|
||||
my $new_helper_value = $aArg->[1];
|
||||
Log3( $name, 5, "[DEBUG] - GardenaSmartBridge ($name) - override helper $new_helper with $new_helper_value");
|
||||
Log3( $name, 5,
|
||||
"[DEBUG] - GardenaSmartBridge ($name) - override helper $new_helper with $new_helper_value"
|
||||
);
|
||||
$hash->{helper}{$new_helper} = $new_helper_value;
|
||||
}
|
||||
else {
|
||||
@ -488,8 +494,8 @@ sub Write {
|
||||
"GardenaSmartBridge ($name) - Send with URL: $hash->{URL}$uri, HEADER: secret!, DATA: secret!, METHOD: $method"
|
||||
);
|
||||
|
||||
# Log3($name, 3,
|
||||
# "GardenaSmartBridge ($name) - Send with URL: $hash->{URL}$uri, HEADER: $header, DATA: $payload, METHOD: $method");
|
||||
# Log3($name, 3,
|
||||
# "GardenaSmartBridge ($name) - Send with URL: $hash->{URL}$uri, HEADER: $header, DATA: $payload, METHOD: $method");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -611,8 +617,7 @@ sub ErrorHandling {
|
||||
}
|
||||
|
||||
if (
|
||||
$data =~ /Error/
|
||||
&& $data !~ /lastLonaErrorCode/
|
||||
$data =~ /Error/ && $data !~ /lastLonaErrorCode/
|
||||
|| ( defined($decode_json)
|
||||
&& ref($decode_json) eq 'HASH'
|
||||
&& defined( $decode_json->{errors} ) )
|
||||
@ -627,8 +632,14 @@ sub ErrorHandling {
|
||||
if ( $param->{code} == 400 ) {
|
||||
if ($decode_json) {
|
||||
if ( ref( $decode_json->{errors} ) eq "ARRAY"
|
||||
&& defined( $decode_json->{errors} ) )
|
||||
&& exists( $decode_json->{errors} ) )
|
||||
|
||||
# replace defined with exists
|
||||
# && defined( $decode_json->{errors} ) )
|
||||
{
|
||||
# $decode_json->{errors} -> ARRAY
|
||||
# $decode_json->{errors}[0] -> HASH
|
||||
if ( exists( $decode_json->{errors}[0]{error} ) ) {
|
||||
readingsBulkUpdate(
|
||||
$dhash,
|
||||
"state",
|
||||
@ -647,6 +658,7 @@ sub ErrorHandling {
|
||||
"GardenaSmartBridge ($dname) - RequestERROR: "
|
||||
. $decode_json->{errors}[0]{error} . " "
|
||||
. $decode_json->{errors}[0]{attribute};
|
||||
} # fi exists error
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -683,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,
|
||||
@ -692,8 +714,18 @@ sub ErrorHandling {
|
||||
|
||||
if ( !defined( $hash->{helper}{session_id} ) ) {
|
||||
readingsSingleUpdate( $hash, 'token', 'none', 1 );
|
||||
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 );
|
||||
"FHEM::GardenaSmartBridge::getToken", $hash )
|
||||
} else {
|
||||
RemoveInternalTimer ($hash);
|
||||
$hash->{helper}{gettoken_count} = 0;
|
||||
}
|
||||
}
|
||||
readingsEndUpdate( $dhash, 1 );
|
||||
|
||||
@ -1052,6 +1084,20 @@ sub WriteReadings {
|
||||
if ( ref($v) eq 'ARRAY' );
|
||||
|
||||
#$v = encode_utf8($v);
|
||||
$v = ' ' if ( !defined $v );
|
||||
Log3 $name, 4,
|
||||
"Gardena DEBUG DEBUG DEBUG stage 1 "
|
||||
. $decode_json->{abilities}[0]{properties}[$properties]
|
||||
{name}
|
||||
if ( $decode_json->{abilities}[0]{properties}[$properties]
|
||||
{name} !~ /ethernet_status|wifi_status/ );
|
||||
Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 2" . $t
|
||||
if ( $decode_json->{abilities}[0]{properties}[$properties]
|
||||
{name} !~ /ethernet_status|wifi_status/ );
|
||||
Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 3" . $v
|
||||
if ( $decode_json->{abilities}[0]{properties}[$properties]
|
||||
{name} !~ /ethernet_status|wifi_status/ );
|
||||
|
||||
readingsBulkUpdateIfChanged(
|
||||
$hash,
|
||||
$decode_json->{abilities}[0]{properties}[$properties]
|
||||
@ -1070,35 +1116,21 @@ sub WriteReadings {
|
||||
&& ref($v) eq 'HASH'
|
||||
)
|
||||
{
|
||||
if ( $decode_json->{abilities}[0]{properties}
|
||||
[$properties]{name} eq 'ethernet_status' )
|
||||
{
|
||||
readingsBulkUpdateIfChanged( $hash,
|
||||
'ethernet_status-mac', $v->{mac} );
|
||||
readingsBulkUpdateIfChanged( $hash,
|
||||
'ethernet_status-ip', $v->{ip} )
|
||||
if ( ref( $v->{ip} ) ne 'HASH' );
|
||||
readingsBulkUpdateIfChanged( $hash,
|
||||
'ethernet_status-isconnected',
|
||||
$v->{isConnected} );
|
||||
}
|
||||
elsif ( $decode_json->{abilities}[0]{properties}
|
||||
[$properties]{name} eq 'wifi_status' )
|
||||
{
|
||||
readingsBulkUpdateIfChanged( $hash,
|
||||
'wifi_status-ssid', $v->{ssid} )
|
||||
if ( ref( $v->{ssid} ) ne 'HASH' );
|
||||
readingsBulkUpdateIfChanged( $hash,
|
||||
'wifi_status-mac', $v->{mac} );
|
||||
readingsBulkUpdateIfChanged( $hash,
|
||||
'wifi_status-ip', $v->{ip} )
|
||||
if ( ref( $v->{ip} ) ne 'HASH' );
|
||||
readingsBulkUpdateIfChanged( $hash,
|
||||
'wifi_status-isconnected', $v->{isConnected} );
|
||||
readingsBulkUpdateIfChanged( $hash,
|
||||
'wifi_status-signal', $v->{signal} );
|
||||
}
|
||||
if ( $v->{is_connected} ) {
|
||||
readingsBulkUpdateIfChanged(
|
||||
$hash,
|
||||
$decode_json->{abilities}[0]{properties}
|
||||
[$properties]{name} . '-ip',
|
||||
$v->{ip}
|
||||
) if ( ref( $v->{ip} ) ne 'HASH' );
|
||||
readingsBulkUpdateIfChanged(
|
||||
$hash,
|
||||
$decode_json->{abilities}[0]{properties}
|
||||
[$properties]{name} . '-isconnected',
|
||||
$v->{is_connected}
|
||||
) if ( $v->{is_connected} );
|
||||
}
|
||||
} # fi ethernet and wifi
|
||||
}
|
||||
$properties--;
|
||||
|
||||
@ -1168,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";
|
||||
|
||||
@ -1281,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"
|
||||
@ -1328,17 +1363,16 @@ sub createHttpValueStrings {
|
||||
} # park until next schedules or override
|
||||
elsif (defined($abilities)
|
||||
&& defined($payload)
|
||||
&& $abilities eq 'mower_timer' )
|
||||
&& $abilities eq 'mower' )
|
||||
{
|
||||
my $valve_id;
|
||||
$method = 'PUT';
|
||||
|
||||
$uri .=
|
||||
'/devices/'
|
||||
. $deviceId
|
||||
. '/abilities/'
|
||||
. $abilities
|
||||
. '/properties/mower_timer';
|
||||
. '/commands/manual_start';
|
||||
|
||||
}
|
||||
elsif (defined($abilities)
|
||||
@ -1489,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>
|
||||
@ -1550,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>
|
||||
@ -1574,7 +1608,7 @@ sub DeletePassword {
|
||||
],
|
||||
"release_status": "stable",
|
||||
"license": "GPL_2",
|
||||
"version": "v2.5.2",
|
||||
"version": "v2.6.3",
|
||||
"author": [
|
||||
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
|
||||
],
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,2 @@
|
||||
UPD 2022-07-21_19:43:48 49634 FHEM/73_GardenaSmartBridge.pm
|
||||
UPD 2022-09-06_12:31:38 123049 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
|
||||
|
36
hooks/commit-msg
Executable file
36
hooks/commit-msg
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message.
|
||||
# Called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero
|
||||
# status after issuing an appropriate message if it wants to stop the
|
||||
# commit. The hook is allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "commit-msg".
|
||||
|
||||
# Uncomment the below to add a Signed-off-by line to the message.
|
||||
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
||||
# hook is more suited to it.
|
||||
#
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||
|
||||
# This example catches duplicate Signed-off-by lines.
|
||||
|
||||
commit_msg=$(cat "${1:?Missing commit message file}")
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ! echo "$commit_msg" | grep -Eq "^(build|chore|ci|docs|feat|feat!|fix|perf|refactor|revert|style|test)(\(.+\))?: .*$" ; then
|
||||
|
||||
echo "Invalid commit message"
|
||||
|
||||
exit 1
|
||||
|
||||
fi
|
||||
|
||||
echo "Commit message is valid!"
|
18
hooks/post-commit
Executable file
18
hooks/post-commit
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
# destination of the final changelog file
|
||||
OUTPUT_FILE=CHANGELOG.md
|
||||
|
||||
# generate the changelog
|
||||
git --no-pager log --no-merges --format="### %s%d%n>%aD%n%n>Author: %aN (%aE)%n%n>Commiter: %cN (%cE)%n%n%b%n%N%n" > $OUTPUT_FILE
|
||||
|
||||
# prevent recursion!
|
||||
# since a 'commit --amend' will trigger the post-commit script again
|
||||
# we have to check if the changelog file has changed or not
|
||||
res=$(git status --porcelain | grep -c ".\$OUTPUT_FILE$")
|
||||
if [ "$res" -gt 0 ]; then
|
||||
git add $OUTPUT_FILE
|
||||
git commit --amend
|
||||
echo "Populated Changelog in $OUTPUT_FILE"
|
||||
fi
|
Reference in New Issue
Block a user