mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 10:46:03 +00:00
git-svn-id: https://svn.fhem.de/fhem/trunk@6569 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
81ec865f98
commit
bbffa1d25a
@ -40,7 +40,7 @@ my $alarmname = "Alarms"; # link text
|
|||||||
my $alarmhiddenroom = "AlarmRoom"; # hidden room
|
my $alarmhiddenroom = "AlarmRoom"; # hidden room
|
||||||
my $alarmpublicroom = "Alarm"; # public room
|
my $alarmpublicroom = "Alarm"; # public room
|
||||||
my $alarmno = 8;
|
my $alarmno = 8;
|
||||||
my $alarmversion = "1.3";
|
my $alarmversion = "1.4";
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
#
|
#
|
||||||
@ -274,13 +274,15 @@ sub Alarm_Exec($$$$$){
|
|||||||
|
|
||||||
my ($name,$level,$dev,$evt,$act) = @_;
|
my ($name,$level,$dev,$evt,$act) = @_;
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
my $aclvl = $hash->{READINGS}{"level"}{VAL};
|
my $aclvl = $hash->{READINGS}{'level'.$level}{VAL};
|
||||||
my $msg = '';
|
my $msg = '';
|
||||||
my $cmd;
|
my $cmd;
|
||||||
my $mga;
|
my $mga;
|
||||||
my $dly;
|
my $dly;
|
||||||
my @sta;
|
my @sta;
|
||||||
|
|
||||||
|
#Log3 $hash,1,"[Alarm $level] Exec called with dev $dev evt $evt act $act]";
|
||||||
|
|
||||||
#-- raising the alarm
|
#-- raising the alarm
|
||||||
if( $act eq "on" ){
|
if( $act eq "on" ){
|
||||||
my $xec = AttrVal($name, "level".$level."xec", 0);
|
my $xec = AttrVal($name, "level".$level."xec", 0);
|
||||||
@ -327,26 +329,26 @@ sub Alarm_Exec($$$$$){
|
|||||||
}elsif( $act eq "off" ){
|
}elsif( $act eq "off" ){
|
||||||
#-- only if this level is active
|
#-- only if this level is active
|
||||||
if( $hash->{READINGS}{"level".$level}{VAL} ne "off"){
|
if( $hash->{READINGS}{"level".$level}{VAL} ne "off"){
|
||||||
#-- deleting all running ats
|
#-- deleting all running ats
|
||||||
$dly = sprintf("alarm%1ddly",$level);
|
$dly = sprintf("alarm%1ddly",$level);
|
||||||
foreach my $d (sort keys %intAt ) {
|
foreach my $d (sort keys %intAt ) {
|
||||||
next if( $intAt{$d}{FN} ne "at_Exec" );
|
next if( $intAt{$d}{FN} ne "at_Exec" );
|
||||||
$mga = $intAt{$d}{ARG}{NAME};
|
$mga = $intAt{$d}{ARG}{NAME};
|
||||||
next if( $mga !~ /$dly\d/);
|
next if( $mga !~ /$dly\d/);
|
||||||
#Log3 $hash,1,"[Alarm] Killing delayed action $name";
|
#Log3 $hash,1,"[Alarm] Killing delayed action $name";
|
||||||
CommandDelete(undef,"$mga");
|
CommandDelete(undef,"$mga");
|
||||||
}
|
}
|
||||||
#-- calling actors
|
#-- calling actors
|
||||||
$cmd = AttrVal($name, "level".$level."offact", 0);
|
$cmd = AttrVal($name, "level".$level."offact", 0);
|
||||||
fhem($cmd);
|
fhem($cmd);
|
||||||
#-- readings
|
#-- readings
|
||||||
readingsSingleUpdate( $hash, "level".$level,"off",0 );
|
readingsSingleUpdate( $hash, "level".$level,"off",0 );
|
||||||
$mga = " Level $level canceled";
|
$mga = " Level $level canceled";
|
||||||
readingsSingleUpdate( $hash, "short", $mga, 0);
|
readingsSingleUpdate( $hash, "short", "", 0);
|
||||||
$mga = Alarm_getstate($hash)." ".$mga;
|
$mga = Alarm_getstate($hash)." ".$mga;
|
||||||
readingsSingleUpdate( $hash, "state", $mga, 0 );
|
readingsSingleUpdate( $hash, "state", $mga, 0 );
|
||||||
$msg = "[Alarm $level] canceled from device $dev";
|
$msg = "[Alarm $level] canceled from device $dev";
|
||||||
Log3 $hash,3,$msg;
|
Log3 $hash,3,$msg;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Log3 $hash,3,"[Alarm $level] Exec called with act=$act";
|
Log3 $hash,3,"[Alarm $level] Exec called with act=$act";
|
||||||
@ -440,8 +442,9 @@ sub Alarm_CreateNotifiers($){
|
|||||||
fhem('delete alarm'.$level.'.unsh.N' )
|
fhem('delete alarm'.$level.'.unsh.N' )
|
||||||
if( defined $defs{'alarm'.$level.'.unsh.N'});
|
if( defined $defs{'alarm'.$level.'.unsh.N'});
|
||||||
|
|
||||||
my @st = split(':',AttrVal($name, "level".$level."start", 0));
|
|
||||||
my @et = split(':',AttrVal($name, "level".$level."end", 0));
|
my @st = split(':',(AttrVal($name, "level".$level."start", 0) ne '')?AttrVal($name, "level".$level."start", 0):'0:00');
|
||||||
|
my @et = split(':',(AttrVal($name, "level".$level."end", 0) ne '')?AttrVal($name, "level".$level."end", 0):'23:59');
|
||||||
|
|
||||||
if( (int(@st)!=2) || ($st[0] > 23) || ($st[0] < 0) || ($st[1] > 59) || ($st[1] < 0) ){
|
if( (int(@st)!=2) || ($st[0] > 23) || ($st[0] < 0) || ($st[1] > 59) || ($st[1] < 0) ){
|
||||||
Log3 $hash,1,"[Alarm $level] Cannot be executed due to wrong time spec ".AttrVal($name, "level".$level."start", 0)." for level".$level."start";
|
Log3 $hash,1,"[Alarm $level] Cannot be executed due to wrong time spec ".AttrVal($name, "level".$level."start", 0)." for level".$level."start";
|
||||||
@ -469,7 +472,7 @@ sub Alarm_CreateNotifiers($){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( $cmd eq '' ){
|
if( $cmd eq '' ){
|
||||||
Log3 $hash,1,"[Alarm $level] Creation of cancel notifier not possible";
|
Log3 $hash,1,"[Alarm $level] No \"Cancel\" device defined, level will be ignored";
|
||||||
} else {
|
} else {
|
||||||
$cmd = substr($cmd,0,length($cmd)-1);
|
$cmd = substr($cmd,0,length($cmd)-1);
|
||||||
$cmd = 'alarm'.$level.'.off.N notify '.$cmd;
|
$cmd = 'alarm'.$level.'.off.N notify '.$cmd;
|
||||||
@ -507,7 +510,7 @@ sub Alarm_CreateNotifiers($){
|
|||||||
}
|
}
|
||||||
#-- raise notifier
|
#-- raise notifier
|
||||||
if( $cmd eq '' ){
|
if( $cmd eq '' ){
|
||||||
Log3 $hash,1,"[Alarm $level] Creation of raise notifier not possible";
|
Log3 $hash,1,"[Alarm $level] No \"Raise\" device defined";
|
||||||
} else {
|
} else {
|
||||||
$cmd = substr($cmd,0,length($cmd)-1);
|
$cmd = substr($cmd,0,length($cmd)-1);
|
||||||
$cmd = 'alarm'.$level.'.on.N notify '.$cmd;
|
$cmd = 'alarm'.$level.'.on.N notify '.$cmd;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user