EGPM2LAN: Get commands fixed

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@12092 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
alexus2033 2016-08-30 10:39:50 +00:00
parent 35e04e140c
commit 916131b08a
2 changed files with 24 additions and 21 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- change: 17_EGPM2LAN: get-commands fixed
- change: 93_DbRep: plausibility checks of database column character length - change: 93_DbRep: plausibility checks of database column character length
- bugfix: 98_Hyperion: final fix for crash bug - bugfix: 98_Hyperion: final fix for crash bug
- bugfix: 74_AMAD: fix usb-ethernet condition in the "Send Data to - bugfix: 74_AMAD: fix usb-ethernet condition in the "Send Data to

View File

@ -44,27 +44,27 @@ sub
EGPM2LAN_Get($@) EGPM2LAN_Get($@)
{ {
my ($hash, @a) = @_; my ($hash, @a) = @_;
my $what; my $getcommand;
return "argument is missing" if(int(@a) != 2); return "argument is missing" if(int(@a) != 2);
$what = $a[1]; $getcommand = $a[1];
if($what =~ /^(state|lastcommand)$/) if($getcommand eq "state")
{ {
if(defined($hash->{READINGS}{$what})) if(defined($hash->{STATE})) {
{ return $hash->{STATE}; }
return $hash->{READINGS}{$what}{VAL}; }
} elsif($getcommand eq "lastcommand")
else {
{ if(defined($hash->{READINGS}{lastcommand}{VAL})) {
return "reading not found: $what"; return $hash->{READINGS}{lastcommand}{VAL}; }
}
} }
else else
{ {
return "Unknown argument $what, choose one of state:noArg lastcommand:noArg".(exists($hash->{READINGS}{output})?" output:noArg":""); return "Unknown argument $getcommand, choose one of state:noArg lastcommand:noArg".(exists($hash->{READINGS}{output})?" output:noArg":"");
} }
return "";
} }
################################### ###################################
@ -78,7 +78,7 @@ EGPM2LAN_Set($@)
my $name = shift @a; my $name = shift @a;
my $setcommand = shift @a; my $setcommand = shift @a;
my $params = join(" ", @a); my $params = join(" ", @a);
my $logLevel = GetLogLevel($name,4); my $logLevel = GetLogLevel($name,4);
Log $logLevel, "EGPM2LAN set $name (". $hash->{IP}. ") $setcommand $params"; Log $logLevel, "EGPM2LAN set $name (". $hash->{IP}. ") $setcommand $params";
@ -163,7 +163,7 @@ sub EGPM2LAN_Login($$) {
Log $logLevel,"EGPM2LAN try to Login @".$hash->{IP}; Log $logLevel,"EGPM2LAN try to Login @".$hash->{IP};
eval{ eval{
GetFileFromURL("http://".$hash->{IP}."/login.html", 5,"pw=" . (defined($hash->{PASSWORD}) ? $hash->{PASSWORD} : ""),0 ,$logLevel); GetFileFromURLQuiet("http://".$hash->{IP}."/login.html", 5,"pw=" . (defined($hash->{PASSWORD}) ? $hash->{PASSWORD} : ""),0 ,$logLevel);
}; };
if ($@){ if ($@){
### catch block ### catch block
@ -215,7 +215,6 @@ sub EGPM2LAN_Statusrequest($$$) {
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $response = GetFileFromURL("http://".$hash->{IP}."/", 5,"" , 0 ,$logLevel); my $response = GetFileFromURL("http://".$hash->{IP}."/", 5,"" , 0 ,$logLevel);
#CustomGetFileFromURL($hash, "http://".$hash->{IP}."/", 10, "", 0, $logLevel);
#Log 1,$response; #Log 1,$response;
if(defined($response) && $response =~ /.,.,.,./) if(defined($response) && $response =~ /.,.,.,./)
{ {
@ -255,8 +254,8 @@ sub EGPM2LAN_Statusrequest($$$) {
} }
else else
{ {
Log 2, "EGPM2LAN: Autocreate disabled in globals section"; Log 2, "EGPM2LAN: Autocreate disabled in globals section";
$attr{$name}{autocreate} = "off"; $attr{$name}{autocreate} = "off";
} }
} }
@ -306,19 +305,19 @@ EGPM2LAN_Define($$)
{ {
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
my $u = "wrong syntax: define <name> EGPM2LAN IP Password"; my $u = "wrong syntax: define <name> EGPM2LAN IP Password";
return $u if(int(@a) < 2); return $u if(int(@a) < 2);
$hash->{IP} = $a[2]; $hash->{IP} = $a[2];
if(int(@a) == 4) if(int(@a) == 4)
{ {
$hash->{PASSWORD} = $a[3]; $hash->{PASSWORD} = $a[3];
} }
else else
{ {
$hash->{PASSWORD} = ""; $hash->{PASSWORD} = "";
} }
my $result = EGPM2LAN_Login($hash, 3); my $result = EGPM2LAN_Login($hash, 3);
if($result == 1) if($result == 1)
{ {
@ -333,6 +332,9 @@ EGPM2LAN_Define($$)
1; 1;
=pod =pod
=item device
=item summary controls a LAN-Socket device from Gembird
=item summary_DE steuert eine LAN-Steckdosenleiste von Gembird
=begin html =begin html
<a name="EGPM2LAN"></a> <a name="EGPM2LAN"></a>