code cleaning
This commit is contained in:
@ -62,15 +62,13 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
use Data::Dumper; #debugging
|
|
||||||
|
|
||||||
eval "use Encode qw(encode encode_utf8 decode_utf8);1" or $missingModul .= "Encode ";
|
eval "use Encode qw(encode encode_utf8 decode_utf8);1" or $missingModul .= "Encode ";
|
||||||
eval "use JSON;1" or $missingModul .= "JSON ";
|
eval "use JSON;1" or $missingModul .= "JSON ";
|
||||||
eval "use IO::Socket::SSL;1" or $missingModul .= "IO::Socket::SSL ";
|
eval "use IO::Socket::SSL;1" or $missingModul .= "IO::Socket::SSL ";
|
||||||
###todo Hier fehlt noch Modulabfrage für ssl
|
|
||||||
|
|
||||||
|
|
||||||
my $version = "0.2.2";
|
my $version = "0.2.4";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -318,58 +316,21 @@ sub GardenaSmartBridge_ErrorHandling($$$) {
|
|||||||
|
|
||||||
my $hash = $param->{hash};
|
my $hash = $param->{hash};
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
my $dhash = $hash;
|
||||||
|
|
||||||
|
$dhash = $modules{GardenaSmartDevice}{defptr}{$param->{'device_id'}}
|
||||||
|
unless( not defined( $param->{'device_id'}) );
|
||||||
|
|
||||||
my $dhash;
|
|
||||||
if( defined( $param->{'device_id'}) ) {
|
|
||||||
$dhash = $modules{GardenaSmartDevice}{defptr}{$param->{'device_id'}};
|
|
||||||
} else {
|
|
||||||
$dhash = $hash;
|
|
||||||
}
|
|
||||||
my $dname = $dhash->{NAME};
|
my $dname = $dhash->{NAME};
|
||||||
|
|
||||||
|
|
||||||
###todo Das gesamte Errorhandling muss hier noch rein
|
#if( defined( $param->{'device_id'}) ) {
|
||||||
|
# $dhash = $modules{GardenaSmartDevice}{defptr}{$param->{'device_id'}};
|
||||||
#Log3 $name, 1, "GardenaSmartBridge ($name) - Header:\n".Dumper($param->{header});
|
#} else {
|
||||||
#Log3 $name, 1, "GardenaSmartBridge ($name) - CODE:\n".Dumper($param->{code});
|
# $dhash = $hash;
|
||||||
#Log3 $name, 1, "GardenaSmartBridge ($name) - Error:\n".Dumper($err);
|
#}
|
||||||
#Log3 $name, 1, "GardenaSmartBridge ($name) - Data:\n".Dumper($data);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Ein Fehler der Behandelt werden muss
|
|
||||||
# Data:
|
|
||||||
# '<html>
|
|
||||||
# <head>
|
|
||||||
# <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
# <title>Error 400 Bad Request</title>
|
|
||||||
# </head>
|
|
||||||
# <body><h2>HTTP ERROR 400</h2>
|
|
||||||
# <p>Problem accessing /sg-1/devices/2ad0d816-8bc3-4f0a-8c52-8b0dc8d7b2ec/abilities/watering_computer/command. Reason:
|
|
||||||
# <pre> Bad Request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>
|
|
||||||
#
|
|
||||||
# </body>
|
|
||||||
# </html>
|
|
||||||
# ';
|
|
||||||
|
|
||||||
# '<html>
|
|
||||||
# <head>
|
|
||||||
# <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
# <title>Error 503 Service Unavailable</title>
|
|
||||||
# </head>
|
|
||||||
# <body><h2>HTTP ERROR 503</h2>
|
|
||||||
# <p>Problem accessing /sg-1/devices/2ad0d816-8bc3-4f0a-8c52-8b0dc8d7b2ec/abilities/outlet/command. Reason:
|
|
||||||
# <pre> Service Unavailable</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>
|
|
||||||
#
|
|
||||||
# </body>
|
|
||||||
# </html>
|
|
||||||
# ';
|
|
||||||
|
|
||||||
|
|
||||||
# 2017.08.10 11:17:20 1: GardenaSmartBridge (myGardena) - Data:
|
|
||||||
# $VAR1 = '{"errors":[{"attribute":"password","error":"invalid"}]}';
|
|
||||||
|
|
||||||
|
#my $dname = $dhash->{NAME};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,13 +62,10 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use Time::Local;
|
use Time::Local;
|
||||||
|
|
||||||
use Data::Dumper; #debugging
|
|
||||||
|
|
||||||
# eval "use Encode qw(encode encode_utf8 decode_utf8);1" or $missingModul .= "Encode "; wird nicht benötigt
|
|
||||||
eval "use JSON;1" or $missingModul .= "JSON ";
|
eval "use JSON;1" or $missingModul .= "JSON ";
|
||||||
|
|
||||||
|
|
||||||
my $version = "0.2.3";
|
my $version = "0.2.4";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -314,7 +311,6 @@ sub GardenaSmartDevice_Parse($$) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
Log3 $name, 3, "GardenaSmartDevice ($name) - autocreate new device " . makeDeviceName($decode_json->{name}) . " with deviceId $decode_json->{id}, model $decode_json->{category} and IODev IODev=$name";
|
Log3 $name, 3, "GardenaSmartDevice ($name) - autocreate new device " . makeDeviceName($decode_json->{name}) . " with deviceId $decode_json->{id}, model $decode_json->{category} and IODev IODev=$name";
|
||||||
#return "UNDEFINED " . join('',split("[ \t]+",$decode_json->{name})) . " GardenaSmartDevice $decode_json->{id} $decode_json->{category} IODev=$name";
|
|
||||||
return "UNDEFINED " . makeDeviceName($decode_json->{name}) . " GardenaSmartDevice $decode_json->{id} $decode_json->{category} IODev=$name";
|
return "UNDEFINED " . makeDeviceName($decode_json->{name}) . " GardenaSmartDevice $decode_json->{id} $decode_json->{category} IODev=$name";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user