HOL device manual switch option
git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@1836 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -13,6 +13,7 @@ HOL_Initialize($$) {
|
|||||||
|
|
||||||
$hash->{SetFn} = "HOL_Set";
|
$hash->{SetFn} = "HOL_Set";
|
||||||
$hash->{DefFn} = "HOL_Define";
|
$hash->{DefFn} = "HOL_Define";
|
||||||
|
$hash->{UndefFn} = "HOL_Undef";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
@@ -24,17 +25,21 @@ HOL_Set {
|
|||||||
my $currentState = $hash->{STATE};
|
my $currentState = $hash->{STATE};
|
||||||
return "state is already $v" if $currentState eq $v;
|
return "state is already $v" if $currentState eq $v;
|
||||||
|
|
||||||
if ($v eq "on" || $v eq "off") {
|
if ($v eq "on" || $v eq "off" || $v eq "switch") {
|
||||||
if($v eq "on") {
|
if($v eq "on") {
|
||||||
$hash->{STATE} = "on";
|
$hash->{STATE} = "on";
|
||||||
HOL_switch($hash->{NAME});
|
HOL_switch($hash);
|
||||||
} elsif ($v eq "off") {
|
} elsif ($v eq "off") {
|
||||||
$hash->{STATE} = "off";
|
$hash->{STATE} = "off";
|
||||||
HOL_turnOffCurrentDevice($hash);
|
HOL_turnOffCurrentDevice($hash);
|
||||||
|
} elsif ($v eq "switch") {
|
||||||
|
my $state = "$hash->{STATE}";
|
||||||
|
return "can only switch if state is on" if ($state ne "on");
|
||||||
|
HOL_switch($hash);
|
||||||
}
|
}
|
||||||
return $v;
|
return $v;
|
||||||
} else {
|
} else {
|
||||||
return "unknown set value, choose one of on off";
|
return "unknown set value, choose one of on off switch";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,8 +61,7 @@ HOL_turnOffCurrentDevice {
|
|||||||
|
|
||||||
sub
|
sub
|
||||||
HOL_switch {
|
HOL_switch {
|
||||||
my ($deviceName) = @_;
|
my ($hash) = @_;
|
||||||
my $hash = $defs{$deviceName};
|
|
||||||
|
|
||||||
HOL_turnOffCurrentDevice($hash);
|
HOL_turnOffCurrentDevice($hash);
|
||||||
|
|
||||||
@@ -95,11 +99,20 @@ HOL_switch {
|
|||||||
$hash->{nextTrigger} = FmtDateTime($nextTrigger);
|
$hash->{nextTrigger} = FmtDateTime($nextTrigger);
|
||||||
|
|
||||||
fhem "set $deviceName on-for-timer $switchTime";
|
fhem "set $deviceName on-for-timer $switchTime";
|
||||||
InternalTimer($nextTrigger, "HOL_switch", $deviceName, 0);
|
InternalTimer($nextTrigger, "HOL_switch", $hash, 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
HOL_Undef($$)
|
||||||
|
{
|
||||||
|
my ($hash, $arg) = @_;
|
||||||
|
|
||||||
|
RemoveInternalTimer($hash);
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
HOL_GetRandomItemInArray {
|
HOL_GetRandomItemInArray {
|
||||||
my (@arr) = @_;
|
my (@arr) = @_;
|
||||||
|
|||||||
Reference in New Issue
Block a user