2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 11:26:55 +00:00

STATE can now be used in any way you want

git-svn-id: https://svn.fhem.de/fhem/trunk@6319 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
dietmar63 2014-07-25 22:14:36 +00:00
parent 7d1ac5e2a5
commit fa32471616

View File

@ -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);
}
}