mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
98_RandomTimer: should solve the problem with the disable attribute: https://forum.fhem.de/index.php/topic,14010.msg621068.html#msg621068
git-svn-id: https://svn.fhem.de/fhem/trunk@14040 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
34609ad49e
commit
039a0c33e5
@ -108,6 +108,8 @@ sub RandomTimer_Define($$)
|
|||||||
$hash->{helper}{S_REL} = $srel;
|
$hash->{helper}{S_REL} = $srel;
|
||||||
$hash->{COMMAND} = Value($hash->{DEVICE});
|
$hash->{COMMAND} = Value($hash->{DEVICE});
|
||||||
|
|
||||||
|
#$attr{$name}{verbose} = 4;
|
||||||
|
|
||||||
readingsSingleUpdate ($hash, "TimeToSwitch", $hash->{helper}{TIMETOSWITCH}, 1);
|
readingsSingleUpdate ($hash, "TimeToSwitch", $hash->{helper}{TIMETOSWITCH}, 1);
|
||||||
|
|
||||||
myRemoveInternalTimer("SetTimer", $hash);
|
myRemoveInternalTimer("SetTimer", $hash);
|
||||||
@ -151,12 +153,17 @@ sub RandomTimer_SetTimer($) {
|
|||||||
# attr Test verbose 5 ;
|
# attr Test verbose 5 ;
|
||||||
# define ds at +00:00:30 attr Test disable 1 ;
|
# define ds at +00:00:30 attr Test disable 1 ;
|
||||||
#
|
#
|
||||||
|
# delete RT_Test; define RT_Test RandomTimer *22:00:00 Brunnen 23:00:00 300
|
||||||
|
# set RT_Test disable 0
|
||||||
|
# delete RT_Test
|
||||||
sub RandomTimer_Exec($) {
|
sub RandomTimer_Exec($) {
|
||||||
my ($myHash) = @_;
|
my ($myHash) = @_;
|
||||||
|
|
||||||
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
my $hash = myGetHashIndirekt($myHash, (caller(0))[3]);
|
||||||
return if (!defined($hash));
|
return if (!defined($hash));
|
||||||
|
|
||||||
|
my $now = time();
|
||||||
|
|
||||||
# Wenn aktiv aber disabled, dann timer abschalten, Meldung ausgeben.
|
# Wenn aktiv aber disabled, dann timer abschalten, Meldung ausgeben.
|
||||||
my $active = RandomTimer_isAktive($hash);
|
my $active = RandomTimer_isAktive($hash);
|
||||||
my $disabled = RandomTimer_isDisabled($hash);
|
my $disabled = RandomTimer_isDisabled($hash);
|
||||||
@ -201,15 +208,19 @@ sub RandomTimer_Exec($) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$disabled) {
|
if (!$disabled) {
|
||||||
Log3 $hash, 3, "[".$hash->{NAME}."]"." starting RandomTimer on $hash->{DEVICE}: "
|
if ($now>$hash->{helper}{startTime} && $now<$hash->{helper}{stopTime}) {
|
||||||
. strftime("%H:%M:%S(%d)",localtime($hash->{helper}{startTime})) . " - "
|
Log3 $hash, 3, "[".$hash->{NAME}."]"." starting RandomTimer on $hash->{DEVICE}: "
|
||||||
. strftime("%H:%M:%S(%d)",localtime($hash->{helper}{stopTime}));
|
. strftime("%H:%M:%S(%d)",localtime($hash->{helper}{startTime})) . " - "
|
||||||
RandomTimer_setActive($hash,1);
|
. strftime("%H:%M:%S(%d)",localtime($hash->{helper}{stopTime}));
|
||||||
|
RandomTimer_setActive($hash,1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomTimer_setState($hash);
|
RandomTimer_setState($hash);
|
||||||
RandomTimer_device_toggle($hash) if (!$disabled);
|
if ($now>$hash->{helper}{startTime} && $now<$hash->{helper}{stopTime}) {
|
||||||
|
RandomTimer_device_toggle($hash) if (!$disabled);
|
||||||
|
}
|
||||||
|
|
||||||
my $nextSwitch = time() + RandomTimer_getSecsToNextAbschaltTest($hash);
|
my $nextSwitch = time() + RandomTimer_getSecsToNextAbschaltTest($hash);
|
||||||
myRemoveInternalTimer("Exec", $hash);
|
myRemoveInternalTimer("Exec", $hash);
|
||||||
@ -575,6 +586,17 @@ sub RandomTimer_Wakeup() { # {RandomTimer_Wakeup()}
|
|||||||
</pre>
|
</pre>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
the decision to switch on or off depends on the state of the device and is evaluated by the funktion Value(<device>). Value() must
|
||||||
|
evaluate one of the values "on" or "off". The behavior of devices that do not evaluate one of those values can be corrected by defining a statFormat:
|
||||||
|
<pre>
|
||||||
|
attr stateFormat EDIPlug_01 {(ReadingsVal("EDIPlug_01","state","nF") =~ m/(ON|on)/i) ? "on" : "off" }
|
||||||
|
</pre>
|
||||||
|
if a devices Value() funktion does not evalute to on or off(like WLAN-Steckdose von Edimax) you get the message:
|
||||||
|
<pre>
|
||||||
|
[EDIPlug] result of function Value(EDIPlug_01) must be 'on' or 'off'
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
<li><a name="switchmode">switchmode</a><br>
|
<li><a name="switchmode">switchmode</a><br>
|
||||||
Setting the switchmode you can influence the behavior of switching on/off.
|
Setting the switchmode you can influence the behavior of switching on/off.
|
||||||
The parameter has the Format 999/999 and the default ist 800/200. The values are in "per mill".
|
The parameter has the Format 999/999 and the default ist 800/200. The values are in "per mill".
|
||||||
|
Loading…
Reference in New Issue
Block a user