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: =end html -=cut \ No newline at end of file +=begin html_DE + + +

EGPM2LAN

+ +=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


+ + Generated events + =end html -=cut +=begin html_DE + + +

EGPM Steckdose

+ +=end html_DE + +=cut \ No newline at end of file