diff --git a/fhem/FHEM/17_EGPM2LAN.pm b/fhem/FHEM/17_EGPM2LAN.pm
index 60642b3bc..6d9202b46 100644
--- a/fhem/FHEM/17_EGPM2LAN.pm
+++ b/fhem/FHEM/17_EGPM2LAN.pm
@@ -1,5 +1,5 @@
##############################################
-# $Id: EGPM2LAN.pm 2891 2013-07-15 19:12:50Z alexus $
+# $Id: EGPM2LAN.pm 2013-12-08 10:11:20Z alexus $
#
# based / modified Version 98_EGPMS2LAN from ericl
#
@@ -33,11 +33,40 @@ EGPM2LAN_Initialize($)
{
my ($hash) = @_;
$hash->{Clients} = ":EGPM:";
+ $hash->{GetFn} = "EGPM2LAN_Get";
$hash->{SetFn} = "EGPM2LAN_Set";
$hash->{DefFn} = "EGPM2LAN_Define";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 stateDisplay:sockNumber,sockName autocreate:on,off";
}
+###################################
+sub
+EGPM2LAN_Get($@)
+{
+ my ($hash, @a) = @_;
+ my $what;
+
+ return "argument is missing" if(int(@a) != 2);
+
+ $what = $a[1];
+
+ if($what =~ /^(state|lastcommand)$/)
+ {
+ if(defined($hash->{READINGS}{$what}))
+ {
+ return $hash->{READINGS}{$what}{VAL};
+ }
+ else
+ {
+ return "reading not found: $what";
+ }
+ }
+ else
+ {
+ return "Unknown argument $what, choose one of state:noArg lastcommand:noArg".(exists($hash->{READINGS}{output})?" output:noArg":"");
+ }
+}
+
###################################
sub
EGPM2LAN_Set($@)
@@ -45,7 +74,7 @@ EGPM2LAN_Set($@)
my ($hash, @a) = @_;
return "no set value specified" if(int(@a) < 2);
- return "Unknown argument $a[1], choose one of on:1,2,3,4,all off:1,2,3,4,all toggle:1,2,3,4 clearreadings statusrequest" if($a[1] eq "?");
+ return "Unknown argument $a[1], choose one of on:1,2,3,4,all off:1,2,3,4,all toggle:1,2,3,4 clearreadings:noArg statusrequest:noArg" if($a[1] eq "?");
my $name = shift @a;
my $setcommand = shift @a;
@@ -184,7 +213,7 @@ sub EGPM2LAN_Statusrequest($$) {
my ($hash, $logLevel) = @_;
my $name = $hash->{NAME};
- my $response = CustomGetFileFromURL($hash, "http://".$hash->{IP}."/", 10, undef, 0, $logLevel);
+ my $response = CustomGetFileFromURL($hash, "http://".$hash->{IP}."/", 10, "", 0, $logLevel);
#Log 1,$response;
if(defined($response) && $response =~ /.,.,.,./)
{
@@ -198,6 +227,7 @@ sub EGPM2LAN_Statusrequest($$) {
my $newstatestring;
my @socketlist = EGPM2LAN_GetDeviceInfo($hash,$response);
readingsBeginUpdate($hash);
+
foreach my $powerstate (@powerstates)
{
$index++;
@@ -231,8 +261,11 @@ sub EGPM2LAN_Statusrequest($$) {
#Write state 2 related Socket-Object
if (defined($defptr))
{
- Log $logLevel, "Update State of ".$defptr->{NAME};
- readingsSingleUpdate($defptr, "state", ($powerstates[$index-1] ? "on" : "off") ,0);
+ if (ReadingsVal($defptr->{NAME},"state","") ne ($powerstates[$index-1] ? "on" : "off"))
+ { #check for chages and update -> trigger event
+ Log $logLevel, "Update State of ".$defptr->{NAME};
+ readingsSingleUpdate($defptr, "state", ($powerstates[$index-1] ? "on" : "off") ,1);
+ }
$defptr->{DEVICENAME} = $hash->{DEVICENAME};
$defptr->{SOCKETNAME} = $socketlist[$index-1];
}
@@ -262,7 +295,8 @@ sub EGPM2LAN_Statusrequest($$) {
sub EGPM2LAN_Logoff($$) {
my ($hash, $logLevel) = @_;
- CustomGetFileFromURL($hash, "http://".$hash->{IP}."/login.html", 10, undef, 0, $logLevel);
+ #$quiet, $url, $timeout, $data, $noshutdown, $loglevel
+ CustomGetFileFromURL($hash, "http://".$hash->{IP}."/login.html", 10, "", 0, $logLevel);
return 1;
}
@@ -312,7 +346,8 @@ EGPM2LAN_Define($$)
Creates a Gembird ® Energenie EG-PM2-LAN device to switch up to 4 sockets over the network.
If you have more than one device, it is helpful to connect and set names for your sockets over the web-interface first.
- The name settings will be adopted to FHEM and helps you to identify the sockets. Please make sure that you´re logged off from the Energenie web-interface otherwise you can´t control it with FHEM at the same time.
+ The name settings will be adopted to FHEM and helps you to identify the sockets. Please make sure that you´re logged off from the Energenie web-interface otherwise you can´t control it with FHEM at the same time.
+ EG-PMS2-LAN with surge protector feature was not tested until now.
Set
@@ -347,6 +382,7 @@ EGPM2LAN_Define($$)
+
Example:
@@ -356,4 +392,62 @@ EGPM2LAN_Define($$)
=end html
-=cut
\ No newline at end of file
+=begin html_DE
+
+
+EGPM2LAN
+
+
+
+ Define
+
+ define <name> EGPM2LAN <IP-Address> [<Password>]
+
+ Das Modul erstellt eine Verbindung zu einer Gembird ® Energenie EG-PM2-LAN Steckdosenleiste.
+ Falls mehrere Steckdosenleisten über das Netzwerk gesteuert werden, ist es ratsam, diese zuerst über die Web-Oberfläche zu konfigurieren und die einzelnen Steckdosen zu benennen. Die Namen werden dann automatisch in die
+ Oberfläche von FHEM übernommen. Bitte darauf achten, die Weboberfläche mit Logoff wieder zu verlassen, da der Zugriff sonst blockiert wird.
+
+
+ Set
+
+ set <name> <[on|off|toggle]> <socketnr.>
+ Schaltet die gewählte Steckdose ein oder aus.
+
+ set <name> <[on|off]> <all>
+ Schaltet alle Steckdosen gleichzeitig ein oder aus.
+
+ set <name> <staterequest>
+ Aktualisiert die Statusinformation der Steckdosenleiste.
+ Wenn das globale Attribut autocreate aktiviert ist, wird für jede Steckdose ein EGPM-Eintrag erstellt.
+
+ set <name> <clearreadings>
+ Löscht alle ungültigen Einträge im Abschnitt <readings>.
+
+
+
+ Get
+
+
+ Attribute
+
+ - stateDisplay
+ Default: socketNumer wechselt zwischen socketNumer and socketName für jeden Statuseintrag. Verwende set statusrequest, um die Anzeige zu aktualisieren.
+ - autocreate
+ Default: on EGPM-Einträge werden automatisch mit dem set-command erstellt.
+ - loglevel
+ - readingFnAttributes
+
+
+
+
+
+ Beispiel:
+
+ define sleiste EGPM2LAN 10.192.192.20 SecretGarden
+ set sleiste on 1
+
+
+=end html_DE
+
+=cut
+
diff --git a/fhem/FHEM/70_EGPM.pm b/fhem/FHEM/70_EGPM.pm
index d9f1d45f0..220ba56ea 100644
--- a/fhem/FHEM/70_EGPM.pm
+++ b/fhem/FHEM/70_EGPM.pm
@@ -1,5 +1,5 @@
##############################################
-# $Id: EGPM.pm 2892 2013-07-11 12:47:57Z alexus $
+# $Id: EGPM2LAN.pm 2013-12-08 10:11:20Z alexus $
#
# (c) 2013 Copyright: Alex Storny (moselking at arcor dot de)
# All rights reserved
@@ -33,6 +33,7 @@ EGPM_Initialize($)
my ($hash) = @_;
$hash->{SetFn} = "EGPM_Set";
+ $hash->{GetFn} = "EGPM_Get";
$hash->{DefFn} = "EGPM_Define";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6". $readingFnAttributes;
$hash->{UndefFn} = "EGPM_Undef";
@@ -48,11 +49,11 @@ EGPM_Set($@)
my $loglevel = GetLogLevel($name,4);
return "no set value specified" if(int(@a) < 1);
- return "Unknown argument ?, choose one of off on toggle" if($a[0] eq "?");
+ return "Unknown argument ?, choose one of off:noArg on:noArg toggle:noArg" if($a[0] eq "?");
if(not Value($parent))
{
- my $u = "$parent not found. Please define EGPM2LAN device.";
+ my $u = "$parent device not found. Please define EGPM2LAN device.";
Log $loglevel, $u;
return $u;
}
@@ -60,10 +61,37 @@ EGPM_Set($@)
my $v = join(" ", @a);
Log $loglevel, "EGPM set $name $v";
CommandSet(undef,$hash->{IODEV}." $v ".$hash->{SOCKETNR});
-
return undef;
}
+###################################
+sub
+EGPM_Get($@)
+{
+ my ($hash, @a) = @_;
+ my $what;
+
+ return "argument is missing" if(int(@a) != 2);
+
+ $what = $a[1];
+
+ if($what =~ /^(state)$/)
+ {
+ if(defined($hash->{READINGS}{$what}))
+ {
+ return $hash->{READINGS}{$what}{VAL};
+ }
+ else
+ {
+ return "reading not found: $what";
+ }
+ }
+ else
+ {
+ return "Unknown argument $what, choose one of state:noArg".(exists($hash->{READINGS}{output})?" output:noArg":"");
+ }
+}
+
#####################################
sub
EGPM_Define($$)
@@ -117,30 +145,29 @@ EGPM_Undef($$)
EGPM Socket
- Define a Socket from EGPM2LAN Module. If the global Module AUTOCREATE is enabled,
- this device will be created automatically. For manual Setup, pls. see the description of EGPM2LAN.
+ Defines a Socket from EGPM2LAN Module. If the global Module AUTOCREATE is enabled,
+ this device will be created automatically. For manual Setup, pls. see the description of EGPM2LAN.
Define
define <name> EGPM <device> <socket-nr>
-
-
- Example:
-
- define socket_lamp EGPM mainswitch 1
- set socket_lamp on
-
+
Set
-
- set <name> <value>
- Set any value.
-
+
+ set <name> <[on|off|toggle]>
+ Switches the socket on or of.
+
+ Example:
+
+ define lamp1 EGPM mainswitch 1
+ set lamp1 on
+
@@ -153,8 +180,64 @@ EGPM_Undef($$)
readingFnAttributes
+
+ Generated events
+
+ - EGPM <name> <[on|off]>
+
=end html
-=cut
+=begin html_DE
+
+
+EGPM Steckdose
+
+
+ Definiert eine einzelne Netzwerk-Steckdose vom EGPM2LAN. Diese Definition wird beim Einrichten eines EGPM2LAN automatisch erstellt,
+ wenn das globale FHEM-Attribut AUTOCREATE aktiviert wurde. Für weitere Informationen, siehe Beschreibung von EGPM2LAN.
+
+
+
+ Define
+
+ define <name> EGPM <device> <socket-nr>
+
+
+
+
+
+ Set
+
+ set <name> <[on|off|toggle]>
+ Schaltet die Steckdose ein oder aus.
+
+ Beispiel:
+
+ define lampe1 EGPM steckdose 1
+ set lampe1 on
+
+
+
+
+ Get
+
+
+
+ Attributes
+
+
+
+
+ Generated events
+
+ - EGPM <name> <[on|off]>
+
+
+=end html_DE
+
+=cut
\ No newline at end of file