mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 10:46:03 +00:00
95_Alarm.pm: Bugfix
70_DoorPi.pm: Neue Version git-svn-id: https://svn.fhem.de/fhem/trunk@12733 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c924c62a62
commit
5f7e4ea62f
@ -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.81";
|
my $alarmversion = "2.82";
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
#
|
#
|
||||||
@ -156,15 +156,15 @@ sub Alarm_CreateEntry($) {
|
|||||||
}
|
}
|
||||||
#-- recover state from stored readings
|
#-- recover state from stored readings
|
||||||
for( my $level=0;$level<$alarmno;$level++ ){
|
for( my $level=0;$level<$alarmno;$level++ ){
|
||||||
my $val = $hash->{READINGS}{"level".$level}{VAL};
|
my $val = ReadingsVal($name,"level".$level,"");
|
||||||
if( $val eq "disarmed" ){#
|
if( $val eq "disarmed" ){#
|
||||||
CommandAttr (undef,$name.' level'.$level.'xec disarmed');
|
CommandAttr (undef,$name.' level'.$level.'xec disarmed');
|
||||||
}elsif( $val eq "armed" ){
|
}elsif( $val eq "armed" ){
|
||||||
CommandAttr (undef,$name.' level'.$level.'xec armed');
|
CommandAttr (undef,$name.' level'.$level.'xec armed');
|
||||||
}else{
|
}else{
|
||||||
Log3 $hash,1,"[Alarm $level] has undefined save data, disarming";
|
Log3 $hash,1,"[Alarm $level] has undefined save data $val, disarming";
|
||||||
CommandAttr (undef,$name.' level'.$level.'xec disarmed');
|
CommandAttr (undef,$name.' level'.$level.'xec disarmed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $mga = Alarm_getstate($hash)." Keine Störung";
|
my $mga = Alarm_getstate($hash)." Keine Störung";
|
||||||
readingsSingleUpdate( $hash, "state", $mga, 1 );
|
readingsSingleUpdate( $hash, "state", $mga, 1 );
|
||||||
|
@ -41,7 +41,7 @@ use vars qw{%attr %defs};
|
|||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
#-- globals on start
|
#-- globals on start
|
||||||
my $version = "1.6";
|
my $version = "1.8";
|
||||||
|
|
||||||
#-- these we may get on request
|
#-- these we may get on request
|
||||||
my %gets = (
|
my %gets = (
|
||||||
@ -74,7 +74,7 @@ sub DoorPi_Initialize ($) {
|
|||||||
|
|
||||||
$hash->{AttrList}= "verbose ".
|
$hash->{AttrList}= "verbose ".
|
||||||
"language:de,en ringcmd ".
|
"language:de,en ringcmd ".
|
||||||
"doorbutton dooropencmd doorlockcmd doorunlockcmd ".
|
"doorbutton dooropencmd doorlockcmd doorunlockcmd dooropendly ".
|
||||||
"lightbutton lightoncmd lighttimercmd lightoffcmd ".
|
"lightbutton lightoncmd lighttimercmd lightoffcmd ".
|
||||||
"snapshotbutton streambutton ".
|
"snapshotbutton streambutton ".
|
||||||
"dashlightbutton iconpic iconaudio ".
|
"dashlightbutton iconpic iconaudio ".
|
||||||
@ -221,9 +221,15 @@ sub DoorPi_Get ($@) {
|
|||||||
|
|
||||||
sub DoorPi_Set ($@) {
|
sub DoorPi_Set ($@) {
|
||||||
my ($hash, @a) = @_;
|
my ($hash, @a) = @_;
|
||||||
#-- only hash as parameter when acting as timer callback
|
#-- if only hash as parameter, this is acting as timer callback
|
||||||
if( !@a ){
|
if( !@a ){
|
||||||
@a=($hash->{NAME},"light","off");
|
Log 1,"[DoorPi_Set] delayed action started with ".$hash->{DELAYED};
|
||||||
|
if( $hash->{DELAYED} eq "light"){
|
||||||
|
@a=($hash->{NAME},"light","off");
|
||||||
|
}elsif( $hash->{DELAYED} eq "door_time"){
|
||||||
|
@a=($hash->{NAME},"door","opened");
|
||||||
|
}
|
||||||
|
$hash->{DELAYED} = "";
|
||||||
}
|
}
|
||||||
my $name = shift @a;
|
my $name = shift @a;
|
||||||
|
|
||||||
@ -231,7 +237,7 @@ sub DoorPi_Set ($@) {
|
|||||||
|
|
||||||
#-- commands
|
#-- commands
|
||||||
my $door = AttrVal($name, "doorbutton", "door");
|
my $door = AttrVal($name, "doorbutton", "door");
|
||||||
my $doorsubs = "open";
|
my $doorsubs = "opened";
|
||||||
$doorsubs .= ",locked"
|
$doorsubs .= ",locked"
|
||||||
if(AttrVal($name, "doorlockcmd",undef));
|
if(AttrVal($name, "doorlockcmd",undef));
|
||||||
$doorsubs .= ",unlocked"
|
$doorsubs .= ",unlocked"
|
||||||
@ -339,6 +345,10 @@ sub DoorPi_Set ($@) {
|
|||||||
#-- from FHEM: door opening, forward to DoorPi
|
#-- from FHEM: door opening, forward to DoorPi
|
||||||
if( $value eq "opened" ){
|
if( $value eq "opened" ){
|
||||||
if( $lockstate eq "unlocked" ){
|
if( $lockstate eq "unlocked" ){
|
||||||
|
if( $hash->{DELAYED} eq "door_event"){
|
||||||
|
fhem("delete dooropendelay");
|
||||||
|
$hash->{DELAYED} = "";
|
||||||
|
}
|
||||||
$v=DoorPi_Cmd($hash,"dooropen");
|
$v=DoorPi_Cmd($hash,"dooropen");
|
||||||
Log 1,"[DoorPi_Set] sent dooropen command to DoorPi";
|
Log 1,"[DoorPi_Set] sent dooropen command to DoorPi";
|
||||||
if(AttrVal($name, "dooropencmd",undef)){
|
if(AttrVal($name, "dooropencmd",undef)){
|
||||||
@ -346,35 +356,49 @@ sub DoorPi_Set ($@) {
|
|||||||
}
|
}
|
||||||
readingsSingleUpdate($hash,$door,"opened",1);
|
readingsSingleUpdate($hash,$door,"opened",1);
|
||||||
}else{
|
}else{
|
||||||
Log 1,"[DoorPi_Set] opening of door not possible, is locked";
|
Log3 $name, 1,"[DoorPi_Set] opening of door not possible, is locked";
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- from DoorPi: door has to be unlocked if necessary
|
#-- from DoorPi: door has to be unlocked if necessary
|
||||||
}elsif( $value eq "unlockandopen" ){
|
}elsif( $value eq "unlockandopen" ){
|
||||||
#-- need to unlock the door now
|
|
||||||
|
#-- unlocking the door now, delayed opening
|
||||||
if( $lockstate eq "locked" ){
|
if( $lockstate eq "locked" ){
|
||||||
if( AttrVal($name, "doorunlockcmd",undef) ){
|
if( AttrVal($name, "doorunlockcmd",undef) ){
|
||||||
fhem(AttrVal($name, "doorunlockcmd",undef));
|
fhem(AttrVal($name, "doorunlockcmd",undef));
|
||||||
Log 1,"[DoorPi_Set] received unlockandopen command from DoorPi and executed FHEM doorunlock command";
|
Log3 $name,5,"[DoorPi_Set] received unlockandopen command from DoorPi and executed FHEM doorunlock command";
|
||||||
readingsSingleUpdate($hash,"lockstate","unlocked",1);
|
readingsSingleUpdate($hash,"lockstate","unlocked",1);
|
||||||
readingsSingleUpdate($hash,$door,"unlocked",1);
|
readingsSingleUpdate($hash,$door,"unlocked",1);
|
||||||
$v=DoorPi_Cmd($hash,"doorunlocked");
|
$v=DoorPi_Cmd($hash,"doorunlocked");
|
||||||
|
my $dly=AttrVal($name, "dooropendly",5);
|
||||||
|
#-- delay by fixed number of seconds
|
||||||
|
if( $dly =~ /\d+/ ){
|
||||||
|
$hash->{DELAYED} = "door_time";
|
||||||
|
InternalTimer(gettimeofday() + $dly, "DoorPi_Set", $hash,1);
|
||||||
|
#-- delay by event
|
||||||
|
}else{
|
||||||
|
$hash->{DELAYED} = "door_event";
|
||||||
|
fhem(" define dooropendelay notify $dly set $name $door opened");
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
Log 1,"[DoorPi_Set] received unlockandopen command from DoorPi, but no FHEM doorunlock command";
|
Log3 $name,5,"[DoorPi_Set] received unlockandopen command from DoorPi, but no FHEM doorunlock command";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-- no unlocking necessary, immediate door opening
|
||||||
}elsif( $lockstate eq "unlocked" ){
|
}elsif( $lockstate eq "unlocked" ){
|
||||||
Log 1,"[DoorPi_Set] received unlockandopen command from DoorPi, but is already unlocked";
|
Log3 $name,5,"[DoorPi_Set] received unlockandopen command from DoorPi, but is already unlocked";
|
||||||
|
$v=DoorPi_Cmd($hash,"dooropen");
|
||||||
|
|
||||||
|
#-- error message
|
||||||
}else{
|
}else{
|
||||||
#-- error message
|
Log3 $name, 1,"[DoorPi_Set] received unlockandopen command from DoorPi, but uncertain lockstate";
|
||||||
Log 1,"[DoorPi_Set] received unlockandopen command from DoorPi, but uncertain lockstate";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#-- Now open the door by DoorPi
|
|
||||||
$v=DoorPi_Cmd($hash,"dooropen");
|
|
||||||
|
|
||||||
#-- from DoorPi: door has to be locked if necessary
|
#-- from DoorPi: door has to be locked if necessary
|
||||||
}elsif( $value eq "softlock" ){
|
}elsif( $value eq "softlock" ){
|
||||||
#-- need to lock the door now
|
|
||||||
|
#-- locking the door now
|
||||||
if( $lockstate eq "unlocked" ){
|
if( $lockstate eq "unlocked" ){
|
||||||
if( AttrVal($name, "doorlockcmd",undef) ){
|
if( AttrVal($name, "doorlockcmd",undef) ){
|
||||||
fhem(AttrVal($name, "doorlockcmd",undef));
|
fhem(AttrVal($name, "doorlockcmd",undef));
|
||||||
@ -458,6 +482,7 @@ sub DoorPi_Set ($@) {
|
|||||||
}
|
}
|
||||||
readingsSingleUpdate($hash,$light,"on",1);
|
readingsSingleUpdate($hash,$light,"on",1);
|
||||||
#-- Intiate turning off light
|
#-- Intiate turning off light
|
||||||
|
$hash->{DELAYED} = "light";
|
||||||
InternalTimer(gettimeofday() + 60, "DoorPi_Set", $hash,1);
|
InternalTimer(gettimeofday() + 60, "DoorPi_Set", $hash,1);
|
||||||
}
|
}
|
||||||
#-- dashboard lighting
|
#-- dashboard lighting
|
||||||
@ -1375,6 +1400,7 @@ sub DoorPi_list($;$){
|
|||||||
<br /> Returns the version number of the FHEM DoorPi module</li>
|
<br /> Returns the version number of the FHEM DoorPi module</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h4>Attributes</h4>
|
<h4>Attributes</h4>
|
||||||
|
<h5>Basic DoorPi actions</h5>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a name="doorpi_target2"><code>attr <DoorPi-Device> target[0|1|2|3]
|
<li><a name="doorpi_target2"><code>attr <DoorPi-Device> target[0|1|2|3]
|
||||||
<string></code></a>
|
<string></code></a>
|
||||||
@ -1388,12 +1414,28 @@ sub DoorPi_list($;$){
|
|||||||
<li><a name="doorpi_dooropencmd"><code>attr <DoorPi-Device> dooropencmd
|
<li><a name="doorpi_dooropencmd"><code>attr <DoorPi-Device> dooropencmd
|
||||||
<string></code></a>
|
<string></code></a>
|
||||||
<br />FHEM command additionally executed for door opening action (no default)</li>
|
<br />FHEM command additionally executed for door opening action (no default)</li>
|
||||||
|
</ul>
|
||||||
|
<h5>Basic FHEM actions</h5>
|
||||||
|
Door locking and unlocking is executed by FHEM only. After an unlocking action, the following
|
||||||
|
opening action will be delayed either by a fixed number of seconds or by waiting for an event.
|
||||||
|
<ul>
|
||||||
<li><a name="doorpi_doorlockcmd"><code>attr <DoorPi-Device> doorlockcmd
|
<li><a name="doorpi_doorlockcmd"><code>attr <DoorPi-Device> doorlockcmd
|
||||||
<string></code></a>
|
<string></code></a>
|
||||||
<br />FHEM command for door locking action (no default)</li>
|
<br />FHEM command for door locking action (no default)</li>
|
||||||
|
<li><a name="doorpi_doorunlockcmd"><code>attr <DoorPi-Device> doorunlockcmd
|
||||||
|
<string></code></a>
|
||||||
<li><a name="doorpi_doorunlockcmd"><code>attr <DoorPi-Device> doorunlockcmd
|
<li><a name="doorpi_doorunlockcmd"><code>attr <DoorPi-Device> doorunlockcmd
|
||||||
<string></code></a>
|
<string></code></a>
|
||||||
<br />FHEM command for door unlocking action (no default)</li>
|
<br />FHEM command for door unlocking action (no default)</li>
|
||||||
|
<li><a name="doorpi_dooropendly"><code>attr <DoorPi-Device> dooropendly
|
||||||
|
<number>|<string></code></a>
|
||||||
|
<br />If number, delay of opening action after unlocking is given by <number> seconds;
|
||||||
|
otherwise the string will be interpreted as a regular expression for an event that
|
||||||
|
has to be registered befor sending the door opening command from FHEM to DoorPi after an
|
||||||
|
unlocking action.
|
||||||
|
<h5>Advanced DoorPi actions</h5>
|
||||||
|
These actions will only be possible if they are defined in the virtual DoorPi keyboard
|
||||||
|
<ul>
|
||||||
<li><a name="doorpi_snapshotbutton"><code>attr <DoorPi-Device> snapshotbutton
|
<li><a name="doorpi_snapshotbutton"><code>attr <DoorPi-Device> snapshotbutton
|
||||||
<string></code></a>
|
<string></code></a>
|
||||||
<br />DoorPi name for snapshot action (default: snapshot)</li>
|
<br />DoorPi name for snapshot action (default: snapshot)</li>
|
||||||
@ -1412,6 +1454,10 @@ sub DoorPi_list($;$){
|
|||||||
<li><a name="doorpi_dashlightbutton"><code>attr <DoorPi-Device> dashlightbutton
|
<li><a name="doorpi_dashlightbutton"><code>attr <DoorPi-Device> dashlightbutton
|
||||||
<string></code></a>
|
<string></code></a>
|
||||||
<br />DoorPi name for dashlight action (default: dashlight)</li>
|
<br />DoorPi name for dashlight action (default: dashlight)</li>
|
||||||
|
</ul>
|
||||||
|
<h5>Visual attributes</h5>
|
||||||
|
These actions will only be possible if they are defined in the virtual DoorPi keyboard
|
||||||
|
<ul>
|
||||||
<li><a name="doorpi_iconpic"><code>attr <DoorPi-Device> iconpic
|
<li><a name="doorpi_iconpic"><code>attr <DoorPi-Device> iconpic
|
||||||
<string></code></a>
|
<string></code></a>
|
||||||
<br />Icon to be used in overview instead of a (slow !) miniature picture</li>
|
<br />Icon to be used in overview instead of a (slow !) miniature picture</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user