From a5ae65d17bae5077e3f30ba98d5c8e6e86e80843 Mon Sep 17 00:00:00 2001 From: pahenning <> Date: Tue, 3 May 2016 18:56:58 +0000 Subject: [PATCH] DoorPi.pm: Bugfix git-svn-id: https://svn.fhem.de/fhem/trunk@11382 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DoorPi/70_DoorPi.pm | 157 ++++++++++++++++++++-------- fhem/contrib/DoorPi/doorpi.ini.safe | 42 +++++--- fhem/contrib/DoorPi/getparams.sh | 7 -- fhem/contrib/DoorPi/iButton_NOK.sh | 5 - fhem/contrib/DoorPi/iButton_OK.sh | 6 -- fhem/contrib/DoorPi/purge.sh | 19 ---- 6 files changed, 137 insertions(+), 99 deletions(-) delete mode 100755 fhem/contrib/DoorPi/getparams.sh delete mode 100755 fhem/contrib/DoorPi/iButton_NOK.sh delete mode 100755 fhem/contrib/DoorPi/iButton_OK.sh delete mode 100755 fhem/contrib/DoorPi/purge.sh diff --git a/fhem/contrib/DoorPi/70_DoorPi.pm b/fhem/contrib/DoorPi/70_DoorPi.pm index a5920c800..a67ac585a 100644 --- a/fhem/contrib/DoorPi/70_DoorPi.pm +++ b/fhem/contrib/DoorPi/70_DoorPi.pm @@ -39,7 +39,7 @@ use vars qw{%attr %defs}; sub Log($$); #-- globals on start -my $version = "1.0beta3"; +my $version = "1.0beta4"; #-- these we may get on request my %gets = ( @@ -71,7 +71,7 @@ sub DoorPi_Initialize ($) { "language:de,en ". "doorbutton dooropencmd doorlockcmd doorunlockcmd ". "lightbutton lightoncmd lighttimercmd lightoffcmd ". - "dashlightbutton ". + "dashlightbutton iconpic iconaudio ". $readingFnAttributes; $hash->{FW_detailFn} = "DoorPi_makeTable"; @@ -115,6 +115,7 @@ sub DoorPi_Define($$) { my $oid = $init_done; $init_done = 1; readingsSingleUpdate($hash,"state","Initialized",1); + readingsSingleUpdate($hash,"door","Unknown",1); DoorPi_GetConfig($hash); DoorPi_GetHistory($hash); @@ -154,16 +155,10 @@ sub DoorPi_Attr(@) { if ( $do eq "set") { ARGUMENT_HANDLER: { - $key eq "interval" and do { - $hash->{interval} = $value; - if ($main::init_done) { - # WHAT ? + # TODO } - last; - }; - } } - return $ret; + return } ######################################################################################## @@ -245,12 +240,12 @@ sub DoorPi_Set ($@) { $value = shift @a; return "[DoorPi_Set] With unknown argument $key, choose one of " . join(" ", @{$hash->{HELPER}->{CMDS}}) - if ( !grep( /$key/, @{$hash->{HELPER}->{CMDS}} ) && !($key eq "call") ); + if ( !grep( /$key/, @{$hash->{HELPER}->{CMDS}} ) && ($key ne "call") && ($key n "door") ); #-- hidden command to be used by DoorPi for adding a new call if( $key eq "call" ){ if( $value eq "start" ){ - readingsSingleUpdate($hash,"call","started",1); + readingsSingleUpdate($hash,"call","started",1);e }elsif( $value eq "end" ){ readingsSingleUpdate($hash,"call","ended",1); DoorPi_GetHistory($hash); @@ -261,13 +256,19 @@ sub DoorPi_Set ($@) { readingsSingleUpdate($hash,"call","dismissed",1); DoorPi_GetHistory($hash); } - #-- door opening - }elsif( $key eq "$door" ){ + #-- door opening - either from FHEM, or just as message from DoorPi + }elsif( ($key eq "$door")||($key eq "door" ){ if( $value eq "open" ){ $v=DoorPi_Cmd($hash,"door"); if(AttrVal($name, "dooropencmd",undef)){ fhem(AttrVal($name, "dooropencmd",undef)); } + readingsSingleUpdate($hash,$door,"opened",1); + }elsif( $value eq "opened" ){ + if(AttrVal($name, "dooropencmd",undef)){ + fhem(AttrVal($name, "dooropencmd",undef)); + } + readingsSingleUpdate($hash,$door,"opened",1); } #-- scene lighting }elsif( $key eq "$light" ){ @@ -275,9 +276,23 @@ sub DoorPi_Set ($@) { if( $value eq "on" ){ $v=DoorPi_Cmd($hash,"lighton"); readingsSingleUpdate($hash,$light,"on",1); + if(AttrVal($name, "lightoncmd",undef)){ + fhem(AttrVal($name, "lightoncmd",undef)); + } + readingsSingleUpdate($hash,$light,"on",1); }elsif( $value eq "off" ){ $v=DoorPi_Cmd($hash,"lightoff"); + if(AttrVal($name, "lightoffcmd",undef)){ + fhem(AttrVal($name, "lightoffcmd",undef)); + } readingsSingleUpdate($hash,$light,"off",1); + }elsif( $value eq "on-for-timer" ){ + $v=DoorPi_Cmd($hash,"lightonfortimer"); + if(AttrVal($name, "lighttimercmd",undef)){ + fhem(AttrVal($name, "lighttimercmd",undef)); + } + readingsSingleUpdate($hash,$light,"on-for-timer",1); + #-- TODO: reset after time } #-- dashboard lighting }elsif( $key eq "$dashlight" ){ @@ -760,6 +775,13 @@ sub DoorPi_makeTable($$$$){ setlocale(LC_ALL, "en_US.utf8"); } + my $iconpic = AttrVal($hash->{NAME}, "iconpic", undef); + $iconpic = FW_makeImage($iconpic) + if($iconpic); + my $iconaudio = AttrVal($hash->{NAME}, "iconaudio", undef); + $iconaudio = FW_makeImage($iconaudio) + if($iconaudio); + my $ret = ""; if(AttrVal($name, "no-heading", "0") eq "0" and defined($FW_ME) and defined($FW_subdir)) @@ -819,11 +841,13 @@ sub DoorPi_makeTable($$$$){ if( $record ne ""){ my $rs = $record; $rs =~ s/.*$wwwpath\///; + $rs = ($iconaudio) ? $iconaudio : $rs; $record = ''.$rs.''; } if( $snapshot ne ""){ - $state = ''; + $state = ''; + $state .= ($iconpic) ? $iconpic : ''; } $ret .= ''; @@ -867,7 +891,7 @@ sub DoorPi_makeTable($$$$){

Define

- define <name> DoorPi <IP address> + define <DoorPi-Device> DoorPi <IP address>

Define a DoorpiPi instance.