2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

Alarm.pm: Neue Version

git-svn-id: https://svn.fhem.de/fhem/trunk@7651 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
pahenning 2015-01-21 18:20:43 +00:00
parent 350a949839
commit fcef72d497

View File

@ -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 = "2.1"; my $alarmversion = "2.3";
######################################################################################### #########################################################################################
# #
@ -166,28 +166,30 @@ sub Alarm_CreateEntry($) {
sub Alarm_Set($@) { sub Alarm_Set($@) {
my ( $hash, $name, $cmd, @args ) = @_; 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" return "[Alarm] Invalid argument to set $cmd, must be numeric"
if ( $args[0] !~ /\d+/ ); if ( $args[0] !~ /\d+/ );
return "[Alarm] Invalid argument to set $cmd, must be 0 < arg < $alarmno" return "[Alarm] Invalid argument to set $cmd, must be 0 < arg < $alarmno"
if ( ($args[0] >= $alarmno)||($args[0]<0) ); if ( ($args[0] >= $alarmno)||($args[0]<0) );
if( $cmd eq "cancel" ){ if( $cmd =~ /^cancel(ed)?$/ ){
Alarm_Exec($name,$args[0],"web","button","cancel"); Alarm_Exec($name,$args[0],"web","button","cancel");
}elsif ( $cmd eq "arm" ) { }elsif ( $cmd =~ /^arm(ed)?$/ ) {
Alarm_Arm($name,$args[0],"web","button","arm"); Alarm_Arm($name,$args[0],"web","button","arm");
}else{ }elsif ( $cmd =~ /^disarm(ed)?$/ ){
Alarm_Arm($name,$args[0],"web","button","disarm"); Alarm_Arm($name,$args[0],"web","button","disarm");
}else{
return "[Alarm] Invalid argument set $cmd";
} }
return; return;
} elsif ( $cmd eq "lock" ) { } elsif ( $cmd =~ /^lock(ed)?$/ ) {
readingsSingleUpdate( $hash, "lockstate", "locked", 0 ); readingsSingleUpdate( $hash, "lockstate", "locked", 0 );
return; return;
} elsif ( $cmd eq "unlock" ) { } elsif ( $cmd =~ /^unlock(ed)?$/ ) {
readingsSingleUpdate( $hash, "lockstate", "unlocked", 0 ); readingsSingleUpdate( $hash, "lockstate", "unlocked", 0 );
return; return;
} else { } else {
my $str = join(",",(0..($alarmno-1))); 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("<input type=\"text\" id=\"cancelaction\" size=\"50\" maxlength=\"512\" value=\"%s\"/>",AttrVal($name, "cancelact","")); $ret .= sprintf("<input type=\"text\" id=\"cancelaction\" size=\"50\" maxlength=\"512\" value=\"%s\"/>",AttrVal($name, "cancelact",""));
$ret .= "</td></tr></table></td></tr>"; $ret .= "</td></tr></table></td></tr>";
$ret .= "<tr class=\"odd\"><td class=\"col1\">Level</td><td class=\"col2\">Time [hh:mm]</td><td class=\"col3\">Message Part II</td>". $ret .= "<tr class=\"odd\"><td class=\"col1\">Level</td><td class=\"col2\">Time [hh:mm]</td><td class=\"col3\">Message Part II</td>".
"<td class=\"col4\">Arm/Cancel</td></tr>\n"; "<td class=\"col4\">Armed/Cancel</td></tr>\n";
for( my $k=0;$k<$alarmno;$k++ ){ for( my $k=0;$k<$alarmno;$k++ ){
$row++; $row++;
my $sval = AttrVal($name, "level".$k."start", 0); my $sval = AttrVal($name, "level".$k."start", 0);
@ -765,19 +767,19 @@ sub Alarm_Html($)
<h4>Set</h4> <h4>Set</h4>
<ul> <ul>
<li><a name="alarm_cancel"> <li><a name="alarm_cancel">
<code>set &lt;name&gt; cancel &lt;level&gt;</code> <code>set &lt;name&gt; canceled &lt;level&gt;</code>
</a> </a>
<br/>cancels an alarm of level &lt;level&gt;, where &lt;level&gt; = 1..7 <br/>cancels an alarm of level &lt;level&gt;, where &lt;level&gt; = 1..7
</li> </li>
<li><a name="alarm_arm"> <li><a name="alarm_arm">
<code>set &lt;name&gt; arm &lt;level&gt;</code><br/> <code>set &lt;name&gt; armed &lt;level&gt;</code><br/>
<code>set &lt;name&gt; disarm &lt;level&gt;</code> <code>set &lt;name&gt; disarmed &lt;level&gt;</code>
</a> </a>
<br/>sets the alarm of level &lt;level&gt; to armed (i.e., active) or disarmed (i.e., inactive), where &lt;level&gt; = 1..7 <br/>sets the alarm of level &lt;level&gt; to armed (i.e., active) or disarmed (i.e., inactive), where &lt;level&gt; = 1..7
</li> </li>
<li><a name="alarm_lock"> <li><a name="alarm_lock">
<code>set &lt;name&gt; lock</code><br/> <code>set &lt;name&gt; locked</code><br/>
<code>set &lt;name&gt; unlock</code> <code>set &lt;name&gt; unlocked</code>
</a> </a>
<br/>sets the lockstate of the alarm module to <i>locked</i> (i.e., alarm setups may not be changed) <br/>sets the lockstate of the alarm module to <i>locked</i> (i.e., alarm setups may not be changed)
resp. <i>unlocked</i> (i.e., alarm setups may be changed>)</li> resp. <i>unlocked</i> (i.e., alarm setups may be changed>)</li>