mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
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:
parent
101a53f8bd
commit
84e8f67fdb
@ -1,9 +1,9 @@
|
||||
##############################################
|
||||
# $Id: EGPM2LAN.pm 2013-12-08 10:11:20Z alexus $
|
||||
# $Id$
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# This script free software; you can redistribute it and/or modify
|
||||
@ -97,11 +97,11 @@ EGPM2LAN_Set($@)
|
||||
{ #switch single Socket
|
||||
EGPM2LAN_Switch($hash, $setcommand, $params, $logLevel);
|
||||
}
|
||||
EGPM2LAN_Statusrequest($hash, $logLevel);
|
||||
EGPM2LAN_Statusrequest($hash, $logLevel, 1);
|
||||
}
|
||||
elsif($setcommand eq "toggle")
|
||||
{
|
||||
my $currentstate = EGPM2LAN_Statusrequest($hash, $logLevel);
|
||||
my $currentstate = EGPM2LAN_Statusrequest($hash, $logLevel, 1);
|
||||
if(defined($currentstate))
|
||||
{
|
||||
my @powerstates = split(",", $currentstate);
|
||||
@ -111,12 +111,12 @@ EGPM2LAN_Set($@)
|
||||
$newcommand="on";
|
||||
}
|
||||
EGPM2LAN_Switch($hash, $newcommand, $params, $logLevel);
|
||||
EGPM2LAN_Statusrequest($hash, $logLevel);
|
||||
EGPM2LAN_Statusrequest($hash, $logLevel, 0);
|
||||
}
|
||||
}
|
||||
elsif($setcommand eq "statusrequest")
|
||||
{
|
||||
EGPM2LAN_Statusrequest($hash, $logLevel);
|
||||
EGPM2LAN_Statusrequest($hash, $logLevel, 1);
|
||||
}
|
||||
elsif($setcommand eq "clearreadings")
|
||||
{
|
||||
@ -209,8 +209,8 @@ sub EGPM2LAN_GetDeviceInfo($$) {
|
||||
}
|
||||
|
||||
################################
|
||||
sub EGPM2LAN_Statusrequest($$) {
|
||||
my ($hash, $logLevel) = @_;
|
||||
sub EGPM2LAN_Statusrequest($$$) {
|
||||
my ($hash, $logLevel, $autoCr) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
my $response = CustomGetFileFromURL($hash, "http://".$hash->{IP}."/", 10, "", 0, $logLevel);
|
||||
@ -244,7 +244,7 @@ sub EGPM2LAN_Statusrequest($$) {
|
||||
#Create Socket-Object if not available
|
||||
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")
|
||||
{
|
||||
@ -295,7 +295,7 @@ sub EGPM2LAN_Statusrequest($$) {
|
||||
sub EGPM2LAN_Logoff($$) {
|
||||
my ($hash, $logLevel) = @_;
|
||||
|
||||
#$quiet, $url, $timeout, $data, $noshutdown, $loglevel
|
||||
#$quiet, $url, $timeout, $data, $noshutdown, $loglevel
|
||||
CustomGetFileFromURL($hash, "http://".$hash->{IP}."/login.html", 10, "", 0, $logLevel);
|
||||
return 1;
|
||||
}
|
||||
@ -321,10 +321,9 @@ EGPM2LAN_Define($$)
|
||||
my $result = EGPM2LAN_Login($hash, 3);
|
||||
if($result == 1)
|
||||
{
|
||||
#delayed auto-create
|
||||
#InternalTimer(gettimeofday()+ 3, "EGPM2LAN_Statusrequest", $hash, 4);
|
||||
EGPM2LAN_Logoff($hash, 4);
|
||||
$hash->{STATE} = "initialized";
|
||||
EGPM2LAN_Statusrequest($hash, 4, 0);
|
||||
EGPM2LAN_Logoff($hash, 4);
|
||||
}
|
||||
|
||||
return undef;
|
||||
@ -346,7 +345,7 @@ EGPM2LAN_Define($$)
|
||||
<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.
|
||||
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>
|
||||
</ul><br>
|
||||
<a name="EGPM2LANset"></a>
|
||||
@ -403,7 +402,7 @@ EGPM2LAN_Define($$)
|
||||
<ul>
|
||||
<code>define <name> EGPM2LAN <IP-Address> [<Password>]</code><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
|
||||
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>
|
||||
|
@ -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
|
||||
#
|
||||
# This script free software; you can redistribute it and/or modify
|
||||
@ -26,6 +26,7 @@ package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use SetExtensions;
|
||||
|
||||
sub
|
||||
EGPM_Initialize($)
|
||||
@ -35,7 +36,7 @@ EGPM_Initialize($)
|
||||
$hash->{SetFn} = "EGPM_Set";
|
||||
$hash->{GetFn} = "EGPM_Get";
|
||||
$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";
|
||||
}
|
||||
|
||||
@ -47,9 +48,10 @@ EGPM_Set($@)
|
||||
my $name = shift @a;
|
||||
my $parent = $hash->{IODEV};
|
||||
my $loglevel = GetLogLevel($name,4);
|
||||
my $cmdList = "off:noArg on:noArg toggle:noArg";
|
||||
|
||||
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))
|
||||
{
|
||||
@ -58,12 +60,19 @@ EGPM_Set($@)
|
||||
return $u;
|
||||
}
|
||||
|
||||
my $v = join(" ", @a);
|
||||
Log $loglevel, "EGPM set $name $v";
|
||||
CommandSet(undef,$hash->{IODEV}." $v ".$hash->{SOCKETNR});
|
||||
return undef;
|
||||
if($a[0] =~ /^(on|off|toggle)$/)
|
||||
{
|
||||
my $v = join(" ", @a);
|
||||
Log $loglevel, "EGPM set $name $v";
|
||||
CommandSet(undef,$hash->{IODEV}." $v ".$hash->{SOCKETNR});
|
||||
return undef;
|
||||
} else {
|
||||
Log $loglevel, "EGPM set $name $a[0]";
|
||||
return SetExtensions($hash,$cmdList,$name,@a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
###################################
|
||||
sub
|
||||
EGPM_Get($@)
|
||||
@ -110,14 +119,24 @@ EGPM_Define($$)
|
||||
$hash->{IODEV} = $parent;
|
||||
$hash->{SOCKETNR} = $socket;
|
||||
$hash->{NAME} = $name;
|
||||
|
||||
|
||||
$modules{EGPM}{defptr}{$parent.$socket} = $hash;
|
||||
|
||||
if (defined($attr{$parent}{room}))
|
||||
{
|
||||
$attr{$name}{room} = $attr{$parent}{room};
|
||||
}
|
||||
$hash->{STATE} = "initialized";
|
||||
|
||||
my $currentstate = ReadingsVal($parent, "state", "?");
|
||||
if ($currentstate eq "?")
|
||||
{
|
||||
$hash->{STATE} = "initialized";
|
||||
}
|
||||
else
|
||||
{
|
||||
my @powerstates = split(":", $currentstate);
|
||||
$hash->{STATE} = trim(substr $powerstates[$socket], 1, 3);
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
@ -159,9 +178,11 @@ EGPM_Undef($$)
|
||||
|
||||
<a name="EGPMset"></a>
|
||||
<b>Set</b>
|
||||
<code>
|
||||
<ul>set <name> <[on|off|toggle]></code><br>
|
||||
<ul><code>set <name> <[on|off|toggle]></code><br>
|
||||
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>
|
||||
Example:
|
||||
<ul>
|
||||
@ -194,9 +215,8 @@ EGPM_Undef($$)
|
||||
<a name="EGPM"></a>
|
||||
<h3>EGPM Steckdose</h3>
|
||||
<ul>
|
||||
|
||||
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 <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>
|
||||
|
||||
<a name="EGPMdefine"></a>
|
||||
@ -209,9 +229,11 @@ EGPM_Undef($$)
|
||||
|
||||
<a name="EGPMset"></a>
|
||||
<b>Set</b>
|
||||
<code>
|
||||
<ul>set <name> <[on|off|toggle]></code><br>
|
||||
<ul><code>set <name> <[on|off|toggle]></code><br>
|
||||
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>
|
||||
Beispiel:
|
||||
<ul>
|
||||
@ -240,4 +262,4 @@ EGPM_Undef($$)
|
||||
</ul>
|
||||
=end html_DE
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
Loading…
x
Reference in New Issue
Block a user