From fcef72d497ce0b6866d136f09749fde89c4672b3 Mon Sep 17 00:00:00 2001 From: pahenning <> Date: Wed, 21 Jan 2015 18:20:43 +0000 Subject: [PATCH] Alarm.pm: Neue Version git-svn-id: https://svn.fhem.de/fhem/trunk@7651 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/95_Alarm.pm | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/fhem/FHEM/95_Alarm.pm b/fhem/FHEM/95_Alarm.pm index 4fc6d966c..50d37ff5c 100644 --- a/fhem/FHEM/95_Alarm.pm +++ b/fhem/FHEM/95_Alarm.pm @@ -40,7 +40,7 @@ my $alarmname = "Alarms"; # link text my $alarmhiddenroom = "AlarmRoom"; # hidden room my $alarmpublicroom = "Alarm"; # public room my $alarmno = 8; -my $alarmversion = "2.1"; +my $alarmversion = "2.3"; ######################################################################################### # @@ -166,28 +166,30 @@ sub Alarm_CreateEntry($) { sub Alarm_Set($@) { my ( $hash, $name, $cmd, @args ) = @_; - if ( ($cmd eq "cancel") || ($cmd eq "armed") || ($cmd eq "disarmed") ) { + if ( $cmd =~ /^(cancel|arm|disarm)(ed)?$/ ) { return "[Alarm] Invalid argument to set $cmd, must be numeric" if ( $args[0] !~ /\d+/ ); return "[Alarm] Invalid argument to set $cmd, must be 0 < arg < $alarmno" if ( ($args[0] >= $alarmno)||($args[0]<0) ); - if( $cmd eq "cancel" ){ + if( $cmd =~ /^cancel(ed)?$/ ){ Alarm_Exec($name,$args[0],"web","button","cancel"); - }elsif ( $cmd eq "arm" ) { + }elsif ( $cmd =~ /^arm(ed)?$/ ) { Alarm_Arm($name,$args[0],"web","button","arm"); - }else{ + }elsif ( $cmd =~ /^disarm(ed)?$/ ){ Alarm_Arm($name,$args[0],"web","button","disarm"); + }else{ + return "[Alarm] Invalid argument set $cmd"; } return; - } elsif ( $cmd eq "lock" ) { + } elsif ( $cmd =~ /^lock(ed)?$/ ) { readingsSingleUpdate( $hash, "lockstate", "locked", 0 ); return; - } elsif ( $cmd eq "unlock" ) { + } elsif ( $cmd =~ /^unlock(ed)?$/ ) { readingsSingleUpdate( $hash, "lockstate", "unlocked", 0 ); return; } else { my $str = join(",",(0..($alarmno-1))); - return "[Alarm] Unknown argument " . $cmd . ", choose one of cancel:$str arm:$str disarm:$str lock:noArg unlock:noArg"; + return "[Alarm] Unknown argument " . $cmd . ", choose one of canceled:$str armed:$str disarmed:$str locked:noArg unlocked:noArg"; } } @@ -661,7 +663,7 @@ sub Alarm_Html($) $ret .= sprintf("",AttrVal($name, "cancelact","")); $ret .= ""; $ret .= "LevelTime [hh:mm]Message Part II". - "Arm/Cancel\n"; + "Armed/Cancel\n"; for( my $k=0;$k<$alarmno;$k++ ){ $row++; my $sval = AttrVal($name, "level".$k."start", 0); @@ -765,19 +767,19 @@ sub Alarm_Html($)

Set