diff --git a/fhem/contrib/DoorPi/70_DoorPi.pm b/fhem/contrib/DoorPi/70_DoorPi.pm
index 42aabeb65..35cdf792a 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.0beta5";
+my $version = "1.0beta6";
#-- these we may get on request
my %gets = (
@@ -48,6 +48,9 @@ my %gets = (
"version:noArg" => "V"
);
+#-- capabilities of doorpi instance for light and target
+my ($lon,$loff,$lonft,$don,$doff,$gtt) = (0,0,0,0,0,0);
+
########################################################################################
#
# DoorPi_Initialize
@@ -72,6 +75,7 @@ sub DoorPi_Initialize ($) {
"doorbutton dooropencmd doorlockcmd doorunlockcmd ".
"lightbutton lightoncmd lighttimercmd lightoffcmd ".
"dashlightbutton iconpic iconaudio ".
+ "target0 target1 target2 target3 ".
$readingFnAttributes;
$hash->{FW_detailFn} = "DoorPi_makeTable";
@@ -120,6 +124,7 @@ sub DoorPi_Define($$) {
DoorPi_GetConfig($hash);
DoorPi_GetHistory($hash);
$init_done = $oid;
+
return undef;
}
@@ -173,15 +178,14 @@ sub DoorPi_Get ($@) {
my ($hash, @a) = @_;
#-- check syntax
- return "[DoorPi] DoorPi_Get needs exactly one parameter" if(@a != 2);
+ return "[DoorPi_Get] needs exactly one parameter" if(@a != 2);
my $name = $hash->{NAME};
my $v;
#-- get version
if( $a[1] eq "version") {
return "$name.version => $version";
- }
-
+ }
#-- current configuration
if($a[1] eq "config") {
$v = DoorPi_GetConfig($hash);
@@ -189,7 +193,10 @@ sub DoorPi_Get ($@) {
}elsif($a[1] eq "history") {
$v = DoorPi_GetHistory($hash);
} else {
- return "DoorPi_Get with unknown argument $a[1], choose one of " . join(" ", sort keys %gets);
+ my $newkeys = join(" ", sort keys %gets);
+ $newkeys =~ s/:noArg//g
+ if( $a[1] ne "?");
+ return "[DoorPi_Get] with unknown argument $a[1], choose one of ".$newkeys;
}
if(defined($v)) {
@@ -220,6 +227,13 @@ sub DoorPi_Set ($@) {
$doorsubs .= ",unlock"
if(AttrVal($name, "doorunlockcmd",undef));
+ my @tsubs = ();
+ for( my $i=0;$i<4;$i++ ){
+ push(@tsubs,$i)
+ if(AttrVal($name, "target$i",undef));
+ }
+ my $tsubs2 = join(',',@tsubs);
+
my $light = AttrVal($name, "lightbutton", "light");
my $dashlight = AttrVal($name, "dashlightbutton", "dashlight");
@@ -227,11 +241,12 @@ sub DoorPi_Set ($@) {
if ($a[0] eq "?"){
$newkeys = join(" ",@{ $hash->{HELPER}->{CMDS} });
#Log 1,"=====> newkeys before subs $newkeys";
- $newkeys =~ s/$door/$door:$doorsubs/; # FHEMWEB sugar
- $newkeys =~ s/\s$light/ $light:on,on-for-timer,off/; # FHEMWEB sugar
- $newkeys =~ s/$dashlight/$dashlight:on,off/; # FHEMWEB sugar
- $newkeys =~ s/button(\d\d?)/button$1:noArg/g; # FHEMWEB sugar
- $newkeys =~ s/purge/purge:noArg/; # FHEMWEB sugar
+ $newkeys =~ s/$door/$door:$doorsubs/; # FHEMWEB sugar
+ $newkeys =~ s/\s$light/ $light:on,on-for-timer,off/; # FHEMWEB sugar
+ $newkeys =~ s/$dashlight/$dashlight:on,off/; # FHEMWEB sugar
+ $newkeys =~ s/button(\d\d?)/button$1:noArg/g; # FHEMWEB sugar
+ $newkeys =~ s/purge/purge:noArg/; # FHEMWEB sugar
+ $newkeys =~ s/target/target:$tsubs2/; # FHEMWEB sugar
#Log 1,"=====> newkeys after subs $newkeys";
return $newkeys;
}
@@ -256,6 +271,20 @@ sub DoorPi_Set ($@) {
readingsSingleUpdate($hash,"call","dismissed",1);
DoorPi_GetHistory($hash);
}
+ #-- call targetd
+ }elsif( $key eq "target" ){
+ if( $value =~ /[0123]/ ){
+ if(AttrVal($name, "target$value",undef)){
+ readingsSingleUpdate($hash,"call_target",AttrVal($name, "target$value",undef),1);
+ DoorPi_Cmd($hash,"gettarget");
+ }else{
+ Log 1,"[DoorPi_Set] Error: target$value attribute not set";
+ return;
+ }
+ }else{
+ Log 1,"[DoorPi_Set] Error: attribute target$value does not exist";
+ return;
+ }
#-- door opening - either from FHEM, or just as message from DoorPi
}elsif( ($key eq "$door")||($key eq "door") ){
if( $value eq "open" ){
@@ -316,7 +345,7 @@ sub DoorPi_Set ($@) {
Log GetLogLevel($name,2), "[DoorPi_Set] $key error $v";
return "$key => Error $v";
}
- return "$key => ok";
+ return undef;
}
#######################################################################################
@@ -380,15 +409,20 @@ sub DoorPi_GetConfig {
my $light = AttrVal($name, "lightbutton", "light");
my $dashlight = AttrVal($name, "dashlightbutton", "dashlight");
- my ($lon,$loff,$lonft,$don,$doff) = (0,0,0,0,0);
+
+ #-- initialize command list
@{$hash->{HELPER}->{CMDS}} = ();
foreach my $key (sort(keys $fscmds)) {
+
+ #-- check for dashboard lighting buttons
if($key =~ /$dashlight(on)/){
push(@{ $hash->{HELPER}->{CMDS}},"$dashlight");
$don = 1;
}elsif($key =~ /$dashlight(off)/){
$doff = 1;
+
+ #-- check for scene lighting buttons
}elsif($key =~ /$light(on)fortimer/){
$lonft = 1;
}elsif($key =~ /$light(on)/){
@@ -396,20 +430,32 @@ sub DoorPi_GetConfig {
$lon = 1;
}elsif($key =~ /$light(off)/){
$loff = 1;
+
+ #-- use target instead of gettarget
+ }elsif($key =~ /gettarget/){
+ if( !AttrVal($name,"target0",undef) && !AttrVal($name,"target1",undef) &&
+ !AttrVal($name,"target2",undef) && !AttrVal($name,"target3",undef) ){
+ Log 1,"[DoorPi_GetConfig] Warning: No attribute named \"target[0|1|2|3]\" defined";
+ } else {
+ push(@{ $hash->{HELPER}->{CMDS}},"target");
+ $gtt = 1;
+ }
+ #-- one of the possible other commands
}else{
push(@{ $hash->{HELPER}->{CMDS}},$key)
}
}
- Log 1,"[DoorPi_GetConfig] Warning: No InputPin named \"".$light."on\" defined"
+ Log 1,"[DoorPi_GetConfig] Warning: No DoorPi InputPin named \"".$light."on\" defined"
if( $lon==0 );
- Log 1,"[DoorPi_GetConfig] Warning: No InputPin named \"".$light."off\" defined"
+ Log 1,"[DoorPi_GetConfig] Warning: No DoorPi InputPin named \"".$light."off\" defined"
if( $loff==0 );
- Log 1,"[DoorPi_GetConfig] Warning: No InputPin named \"".$light."onfortimer\" defined"
+ Log 1,"[DoorPi_GetConfig] Warning: No DoorPi InputPin named \"".$light."onfortimer\" defined"
if( $lonft==0 );
- Log 1,"[DoorPi_GetConfig] Warning: No InputPin named \"".$dashlight."on\" defined"
+ Log 1,"[DoorPi_GetConfig] Warning: No DoorPi InputPin named \"".$dashlight."on\" defined"
if( $don==0 );
- Log 1,"[DoorPi_GetConfig] Warning: No InputPin named \"".$dashlight."off\" defined"
+ Log 1,"[DoorPi_GetConfig] Warning: No DoorPi InputPin named \"".$dashlight."off\" defined"
if( $doff==0 );
+
}else{
Log 1,"[DoorPi_GetConfig] Warning: No keyboard \"filesystem\" defined";
};
@@ -636,8 +682,8 @@ sub DoorPi_GetHistory {
#--put into READINGS
readingsBeginUpdate($hash);
- readingsBulkUpdate($hash,"number_calls",int(@{ $hash->{DATA}}));
- readingsBulkUpdate($hash,"history","ok");
+ readingsBulkUpdate($hash,"call_listed",int(@{ $hash->{DATA}}));
+ readingsBulkUpdate($hash,"call_history","ok");
readingsBulkUpdate($hash,$dashlight,$dashlightstate);
readingsBulkUpdate($hash,$light,$lightstate);
readingsEndUpdate($hash,1);
@@ -910,6 +956,9 @@ sub DoorPi_makeTable($$$$){
specified in the dooropencmd attribute.
If the Attributes doorlockcmd and doorunlockcmd are specified, these commands may be used to lock and unlock the door
Instead of door, one must use the value of the doorbutton attribute.
+
set <DoorPi-Device> target 0|1|2|3 set <DoorPi-Device> dashlight on|off attr <DoorPi-Device> target[0|1|2|3]
+ <string>
+ attr <DoorPi-Device> doorbutton
<string>
attr <DoorPi-Device> iconaudio
<string>