STATE can now be used in any way you want
git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@6319 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -36,6 +36,7 @@ sub WOL_Initialize($) {
|
||||
################################################################################
|
||||
sub WOL_Set($@) {
|
||||
my ($hash, @a) = @_;
|
||||
|
||||
return "no set value specified" if(int(@a) < 2);
|
||||
return "Unknown argument $a[1], choose one of on off refresh" if($a[1] eq "?");
|
||||
|
||||
@@ -68,7 +69,7 @@ sub WOL_Set($@) {
|
||||
RemoveInternalTimer($hash);
|
||||
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "WOL_UpdateReadings", $hash, 0);
|
||||
|
||||
if ($hash->{STATE} eq "on") {
|
||||
if (AttrVal($name, "state", "") eq "on") {
|
||||
WOL_GetUpdate($hash);
|
||||
}
|
||||
return undef;
|
||||
@@ -132,7 +133,8 @@ sub WOL_UpdateReadings($) {
|
||||
$hash->{INTERVAL} = AttrVal($hash->{NAME}, "interval", 900);
|
||||
|
||||
my $ip = $hash->{IP};
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
readingsBeginUpdate ($hash);
|
||||
|
||||
if (`ping -c 1 -w 2 $ip` =~ m/100%/) {
|
||||
@@ -148,11 +150,12 @@ sub WOL_UpdateReadings($) {
|
||||
sub WOL_GetUpdate($) {
|
||||
my ($hash) = @_;
|
||||
|
||||
if ($hash->{STATE} eq "on") {
|
||||
my $name = $hash->{NAME};
|
||||
if (AttrVal($name, "state", "") eq "on") {
|
||||
wake($hash);
|
||||
}
|
||||
|
||||
if ($hash->{REPEAT} > 0 && $hash->{STATE} eq "on" ) {
|
||||
if ($hash->{REPEAT} > 0 && AttrVal($name, "state", "") eq "on" ) {
|
||||
InternalTimer(gettimeofday()+$hash->{REPEAT}, "WOL_GetUpdate", $hash, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user