mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
60_Watches.pm: contrib 0.27.0
git-svn-id: https://svn.fhem.de/fhem/trunk@22586 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
178b54d4d8
commit
40b3233677
@ -126,6 +126,7 @@ my %hset = ( #
|
|||||||
countdownwatch => {set => "alarmSet alarmDel:noArg reset:noArg resume:noArg start:noArg stop:noArg countDownInit" },
|
countdownwatch => {set => "alarmSet alarmDel:noArg reset:noArg resume:noArg start:noArg stop:noArg countDownInit" },
|
||||||
watch => {set => "alarmSet alarmDel:noArg" },
|
watch => {set => "alarmSet alarmDel:noArg" },
|
||||||
text => {set => "displayTextSet displayTextDel:noArg textTicker:on,off" },
|
text => {set => "displayTextSet displayTextDel:noArg textTicker:on,off" },
|
||||||
|
time => {fn => "_setTime" },
|
||||||
);
|
);
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@ -217,7 +218,6 @@ sub Set { ## no critic 'compl
|
|||||||
my $prop = $a[2];
|
my $prop = $a[2];
|
||||||
my $prop1 = $a[3];
|
my $prop1 = $a[3];
|
||||||
my $prop2 = $a[4];
|
my $prop2 = $a[4];
|
||||||
my $prop3 = $a[5];
|
|
||||||
|
|
||||||
return if(IsDisabled($name));
|
return if(IsDisabled($name));
|
||||||
|
|
||||||
@ -310,8 +310,43 @@ sub Set { ## no critic 'compl
|
|||||||
delReadings ($name);
|
delReadings ($name);
|
||||||
readingsSingleUpdate($hash, "state", "initialized", 1);
|
readingsSingleUpdate($hash, "state", "initialized", 1);
|
||||||
|
|
||||||
} elsif ($opt eq "time") {
|
}
|
||||||
return qq{The value for "$opt" is invalid. Use parameter "hh mm ss" like "19 45 13".} if($prop>23 || $prop1>59 || $prop2>59);
|
|
||||||
|
my $params = {
|
||||||
|
hash => $hash,
|
||||||
|
name => $name,
|
||||||
|
opt => $opt,
|
||||||
|
prop => $prop,
|
||||||
|
prop1 => $prop1,
|
||||||
|
prop2 => $prop2,
|
||||||
|
aref => \@a,
|
||||||
|
};
|
||||||
|
|
||||||
|
no strict "refs"; ## no critic 'NoStrict'
|
||||||
|
if($hset{$opt}) {
|
||||||
|
my $ret = "";
|
||||||
|
$ret = &{$hset{$opt}{fn}} ($params) if(defined &{$hset{$opt}{fn}});
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
use strict "refs";
|
||||||
|
|
||||||
|
return "$setlist";
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# Setter time
|
||||||
|
################################################################
|
||||||
|
sub _setTime { ## no critic "not used"
|
||||||
|
my $paref = shift;
|
||||||
|
my $hash = $paref->{hash};
|
||||||
|
my $opt = $paref->{opt};
|
||||||
|
my $prop = sprintf("%0d", $paref->{prop} // 0);
|
||||||
|
my $prop1 = sprintf("%0d", $paref->{prop1} // 0);
|
||||||
|
my $prop2 = sprintf("%0d", $paref->{prop2} // 0);
|
||||||
|
|
||||||
|
my $msg = qq{The value for "$opt" is invalid. Use parameter "hh mm ss" like "19 45 13"};
|
||||||
|
|
||||||
|
return $msg if($prop>23 || $prop1>59 || $prop2>59);
|
||||||
|
|
||||||
readingsBeginUpdate ($hash);
|
readingsBeginUpdate ($hash);
|
||||||
readingsBulkUpdate ($hash, "hour", $prop);
|
readingsBulkUpdate ($hash, "hour", $prop);
|
||||||
@ -319,10 +354,6 @@ sub Set { ## no critic 'compl
|
|||||||
readingsBulkUpdate ($hash, "second", $prop2);
|
readingsBulkUpdate ($hash, "second", $prop2);
|
||||||
readingsEndUpdate ($hash, 1);
|
readingsEndUpdate ($hash, 1);
|
||||||
|
|
||||||
} else {
|
|
||||||
return "$setlist";
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user