Status-Check after Restart/Definition and SetExtensions added.
git-svn-id: https://svn.fhem.de/fhem/trunk@5344 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
##############################################
|
##############################################
|
||||||
# $Id: EGPM2LAN.pm 2013-12-08 10:11:20Z alexus $
|
# $Id$
|
||||||
#
|
#
|
||||||
# based / modified Version 98_EGPMS2LAN from ericl
|
# based / modified Version 98_EGPMS2LAN from ericl
|
||||||
#
|
#
|
||||||
# (c) 2013 Copyright: Alex Storny (moselking at arcor dot de)
|
# (c) 2013, 2014 Copyright: Alex Storny (moselking at arcor dot de)
|
||||||
# All rights reserved
|
# All rights reserved
|
||||||
#
|
#
|
||||||
# This script free software; you can redistribute it and/or modify
|
# This script free software; you can redistribute it and/or modify
|
||||||
@@ -97,11 +97,11 @@ EGPM2LAN_Set($@)
|
|||||||
{ #switch single Socket
|
{ #switch single Socket
|
||||||
EGPM2LAN_Switch($hash, $setcommand, $params, $logLevel);
|
EGPM2LAN_Switch($hash, $setcommand, $params, $logLevel);
|
||||||
}
|
}
|
||||||
EGPM2LAN_Statusrequest($hash, $logLevel);
|
EGPM2LAN_Statusrequest($hash, $logLevel, 1);
|
||||||
}
|
}
|
||||||
elsif($setcommand eq "toggle")
|
elsif($setcommand eq "toggle")
|
||||||
{
|
{
|
||||||
my $currentstate = EGPM2LAN_Statusrequest($hash, $logLevel);
|
my $currentstate = EGPM2LAN_Statusrequest($hash, $logLevel, 1);
|
||||||
if(defined($currentstate))
|
if(defined($currentstate))
|
||||||
{
|
{
|
||||||
my @powerstates = split(",", $currentstate);
|
my @powerstates = split(",", $currentstate);
|
||||||
@@ -111,12 +111,12 @@ EGPM2LAN_Set($@)
|
|||||||
$newcommand="on";
|
$newcommand="on";
|
||||||
}
|
}
|
||||||
EGPM2LAN_Switch($hash, $newcommand, $params, $logLevel);
|
EGPM2LAN_Switch($hash, $newcommand, $params, $logLevel);
|
||||||
EGPM2LAN_Statusrequest($hash, $logLevel);
|
EGPM2LAN_Statusrequest($hash, $logLevel, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif($setcommand eq "statusrequest")
|
elsif($setcommand eq "statusrequest")
|
||||||
{
|
{
|
||||||
EGPM2LAN_Statusrequest($hash, $logLevel);
|
EGPM2LAN_Statusrequest($hash, $logLevel, 1);
|
||||||
}
|
}
|
||||||
elsif($setcommand eq "clearreadings")
|
elsif($setcommand eq "clearreadings")
|
||||||
{
|
{
|
||||||
@@ -209,8 +209,8 @@ sub EGPM2LAN_GetDeviceInfo($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
################################
|
################################
|
||||||
sub EGPM2LAN_Statusrequest($$) {
|
sub EGPM2LAN_Statusrequest($$$) {
|
||||||
my ($hash, $logLevel) = @_;
|
my ($hash, $logLevel, $autoCr) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
my $response = CustomGetFileFromURL($hash, "http://".$hash->{IP}."/", 10, "", 0, $logLevel);
|
my $response = CustomGetFileFromURL($hash, "http://".$hash->{IP}."/", 10, "", 0, $logLevel);
|
||||||
@@ -244,7 +244,7 @@ sub EGPM2LAN_Statusrequest($$) {
|
|||||||
#Create Socket-Object if not available
|
#Create Socket-Object if not available
|
||||||
my $defptr = $modules{EGPM}{defptr}{$name.$index};
|
my $defptr = $modules{EGPM}{defptr}{$name.$index};
|
||||||
|
|
||||||
if(AttrVal($name, "autocreate", "on") eq "on" && not defined($defptr))
|
if($autoCr && AttrVal($name, "autocreate", "on") eq "on" && not defined($defptr))
|
||||||
{
|
{
|
||||||
if(Value("autocreate") eq "active")
|
if(Value("autocreate") eq "active")
|
||||||
{
|
{
|
||||||
@@ -321,10 +321,9 @@ EGPM2LAN_Define($$)
|
|||||||
my $result = EGPM2LAN_Login($hash, 3);
|
my $result = EGPM2LAN_Login($hash, 3);
|
||||||
if($result == 1)
|
if($result == 1)
|
||||||
{
|
{
|
||||||
#delayed auto-create
|
|
||||||
#InternalTimer(gettimeofday()+ 3, "EGPM2LAN_Statusrequest", $hash, 4);
|
|
||||||
EGPM2LAN_Logoff($hash, 4);
|
|
||||||
$hash->{STATE} = "initialized";
|
$hash->{STATE} = "initialized";
|
||||||
|
EGPM2LAN_Statusrequest($hash, 4, 0);
|
||||||
|
EGPM2LAN_Logoff($hash, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@@ -346,7 +345,7 @@ EGPM2LAN_Define($$)
|
|||||||
<br>
|
<br>
|
||||||
Creates a Gembird ® <a href="http://energenie.com/item.aspx?id=7557" >Energenie EG-PM2-LAN</a> device to switch up to 4 sockets over the network.
|
Creates a Gembird ® <a href="http://energenie.com/item.aspx?id=7557" >Energenie EG-PM2-LAN</a> 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.
|
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.<br>
|
||||||
<b>EG-PMS2-LAN with surge protector feature was not tested until now.</b>
|
<b>EG-PMS2-LAN with surge protector feature was not tested until now.</b>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
<a name="EGPM2LANset"></a>
|
<a name="EGPM2LANset"></a>
|
||||||
@@ -403,7 +402,7 @@ EGPM2LAN_Define($$)
|
|||||||
<ul>
|
<ul>
|
||||||
<code>define <name> EGPM2LAN <IP-Address> [<Password>]</code><br>
|
<code>define <name> EGPM2LAN <IP-Address> [<Password>]</code><br>
|
||||||
<br>
|
<br>
|
||||||
Das Modul erstellt eine Verbindung zu einer Gembird ® <a href="http://energenie.com/item.aspx?id=7557" >Energenie EG-PM2-LAN</a> Steckdosenleiste.
|
Das Modul erstellt eine Verbindung zu einer Gembird ® <a href="http://energenie.com/item.aspx?id=7557" >Energenie EG-PM2-LAN</a> Steckdosenleiste und steuert 4 angeschlossene Geräte..
|
||||||
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
|
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 <i>Logoff</i> wieder zu verlassen, da der Zugriff sonst blockiert wird.
|
Oberfläche von FHEM übernommen. Bitte darauf achten, die Weboberfläche mit <i>Logoff</i> wieder zu verlassen, da der Zugriff sonst blockiert wird.
|
||||||
</ul><br>
|
</ul><br>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
##############################################
|
##############################################
|
||||||
# $Id: EGPM2LAN.pm 2013-12-08 10:11:20Z alexus $
|
# $Id$
|
||||||
#
|
#
|
||||||
# (c) 2013 Copyright: Alex Storny (moselking at arcor dot de)
|
# (c) 2013, 2014 Copyright: Alex Storny (moselking at arcor dot de)
|
||||||
# All rights reserved
|
# All rights reserved
|
||||||
#
|
#
|
||||||
# This script free software; you can redistribute it and/or modify
|
# This script free software; you can redistribute it and/or modify
|
||||||
@@ -26,6 +26,7 @@ package main;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use SetExtensions;
|
||||||
|
|
||||||
sub
|
sub
|
||||||
EGPM_Initialize($)
|
EGPM_Initialize($)
|
||||||
@@ -35,7 +36,7 @@ EGPM_Initialize($)
|
|||||||
$hash->{SetFn} = "EGPM_Set";
|
$hash->{SetFn} = "EGPM_Set";
|
||||||
$hash->{GetFn} = "EGPM_Get";
|
$hash->{GetFn} = "EGPM_Get";
|
||||||
$hash->{DefFn} = "EGPM_Define";
|
$hash->{DefFn} = "EGPM_Define";
|
||||||
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6". $readingFnAttributes;
|
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 $readingFnAttributes ";
|
||||||
$hash->{UndefFn} = "EGPM_Undef";
|
$hash->{UndefFn} = "EGPM_Undef";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,9 +48,10 @@ EGPM_Set($@)
|
|||||||
my $name = shift @a;
|
my $name = shift @a;
|
||||||
my $parent = $hash->{IODEV};
|
my $parent = $hash->{IODEV};
|
||||||
my $loglevel = GetLogLevel($name,4);
|
my $loglevel = GetLogLevel($name,4);
|
||||||
|
my $cmdList = "off:noArg on:noArg toggle:noArg";
|
||||||
|
|
||||||
return "no set value specified" if(int(@a) < 1);
|
return "no set value specified" if(int(@a) < 1);
|
||||||
return "Unknown argument ?, choose one of off:noArg on:noArg toggle:noArg" if($a[0] eq "?");
|
return SetExtensions($hash,$cmdList,$name,@a) if($a[0] eq "?");
|
||||||
|
|
||||||
if(not Value($parent))
|
if(not Value($parent))
|
||||||
{
|
{
|
||||||
@@ -58,12 +60,19 @@ EGPM_Set($@)
|
|||||||
return $u;
|
return $u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($a[0] =~ /^(on|off|toggle)$/)
|
||||||
|
{
|
||||||
my $v = join(" ", @a);
|
my $v = join(" ", @a);
|
||||||
Log $loglevel, "EGPM set $name $v";
|
Log $loglevel, "EGPM set $name $v";
|
||||||
CommandSet(undef,$hash->{IODEV}." $v ".$hash->{SOCKETNR});
|
CommandSet(undef,$hash->{IODEV}." $v ".$hash->{SOCKETNR});
|
||||||
return undef;
|
return undef;
|
||||||
|
} else {
|
||||||
|
Log $loglevel, "EGPM set $name $a[0]";
|
||||||
|
return SetExtensions($hash,$cmdList,$name,@a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
sub
|
sub
|
||||||
EGPM_Get($@)
|
EGPM_Get($@)
|
||||||
@@ -117,7 +126,17 @@ EGPM_Define($$)
|
|||||||
{
|
{
|
||||||
$attr{$name}{room} = $attr{$parent}{room};
|
$attr{$name}{room} = $attr{$parent}{room};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $currentstate = ReadingsVal($parent, "state", "?");
|
||||||
|
if ($currentstate eq "?")
|
||||||
|
{
|
||||||
$hash->{STATE} = "initialized";
|
$hash->{STATE} = "initialized";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
my @powerstates = split(":", $currentstate);
|
||||||
|
$hash->{STATE} = trim(substr $powerstates[$socket], 1, 3);
|
||||||
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@@ -159,9 +178,11 @@ EGPM_Undef($$)
|
|||||||
|
|
||||||
<a name="EGPMset"></a>
|
<a name="EGPMset"></a>
|
||||||
<b>Set</b>
|
<b>Set</b>
|
||||||
<code>
|
<ul><code>set <name> <[on|off|toggle]></code><br>
|
||||||
<ul>set <name> <[on|off|toggle]></code><br>
|
|
||||||
Switches the socket on or of.
|
Switches the socket on or of.
|
||||||
|
</ul>
|
||||||
|
<ul><code>set <name> <[on-for-timer|off-for-timer|on-till|off-till|blink|intervals]></code><br>
|
||||||
|
Switches the socket for a specified time+duration or n-times. For Details see <a href="#setExtensions">set extensions</a>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
Example:
|
Example:
|
||||||
<ul>
|
<ul>
|
||||||
@@ -194,9 +215,8 @@ EGPM_Undef($$)
|
|||||||
<a name="EGPM"></a>
|
<a name="EGPM"></a>
|
||||||
<h3>EGPM Steckdose</h3>
|
<h3>EGPM Steckdose</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
Definiert eine einzelne Netzwerk-Steckdose vom EGPM2LAN. Diese Definition wird beim Einrichten eines EGPM2LAN automatisch erstellt,
|
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<EFBFBD>r weitere Informationen, siehe Beschreibung von <a href="#EGPM2LAN">EGPM2LAN</a>.
|
wenn das globale FHEM-Attribut AUTOCREATE aktiviert wurde. Für weitere Informationen, siehe Beschreibung von <a href="#EGPM2LAN">EGPM2LAN</a>.
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<a name="EGPMdefine"></a>
|
<a name="EGPMdefine"></a>
|
||||||
@@ -209,9 +229,11 @@ EGPM_Undef($$)
|
|||||||
|
|
||||||
<a name="EGPMset"></a>
|
<a name="EGPMset"></a>
|
||||||
<b>Set</b>
|
<b>Set</b>
|
||||||
<code>
|
<ul><code>set <name> <[on|off|toggle]></code><br>
|
||||||
<ul>set <name> <[on|off|toggle]></code><br>
|
|
||||||
Schaltet die Steckdose ein oder aus.
|
Schaltet die Steckdose ein oder aus.
|
||||||
|
</ul>
|
||||||
|
<ul><code>set <name> <[on-for-timer|off-for-timer|on-till|off-till|blink|intervals]></code><br>
|
||||||
|
Schaltet die Steckdose fü einen bestimmten Zeitraum oder mehrfach hintereinander. Weitere Infos hierzu unter <a href="#setExtensions">set extensions</a>.
|
||||||
</ul><br>
|
</ul><br>
|
||||||
Beispiel:
|
Beispiel:
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user