mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
DoorPi.pm: 1.0beta6
git-svn-id: https://svn.fhem.de/fhem/trunk@11386 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
118409a5b2
commit
e254979ab2
@ -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 <i>dooropencmd</i> attribute.
|
||||
<br>If the Attributes doorlockcmd and doorunlockcmd are specified, these commands may be used to lock and unlock the door<br>
|
||||
Instead of <i>door</i>, one must use the value of the doorbutton attribute.</li>
|
||||
<li><a name="doorpi_target">
|
||||
<code>set <DoorPi-Device> target 0|1|2|3 </code></a><br />
|
||||
Set the call target number for DoorPi to the corresponding attribute value (see below)</li>
|
||||
<li><a name="doorpi_dashlight">
|
||||
<code>set <DoorPi-Device> dashlight on|off </code></a><br />
|
||||
Set the dashlight (illuminating the door station) on or off.
|
||||
@ -944,6 +993,9 @@ sub DoorPi_makeTable($$$$){
|
||||
</ul>
|
||||
<h4>Attributes</h4>
|
||||
<ul>
|
||||
<li><a name="doorpi_target2"><code>attr <DoorPi-Device> target[0|1|2|3]
|
||||
<string></code></a>
|
||||
<br />Call target numbers for different redirections, presence of target0 is mandatory</li>
|
||||
<li><a name="doorpi_doorbutton"><code>attr <DoorPi-Device> doorbutton
|
||||
<string></code></a>
|
||||
<br />DoorPi name for door action (default: door)</li>
|
||||
@ -977,6 +1029,7 @@ sub DoorPi_makeTable($$$$){
|
||||
<li><a name="doorpi_iconaudio"><code>attr <DoorPi-Device> iconaudio
|
||||
<string></code></a>
|
||||
<br />Icon to be used in overview instead of a verbal link to the audio recording</li>
|
||||
|
||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
|
||||
</ul>
|
||||
<h4>Necessary ingredients of the DoorPi configuration</h4>
|
||||
@ -1006,22 +1059,18 @@ base_path_input = <dome directory>
|
||||
base_path_output = <some directory>
|
||||
|
||||
[<virtualkeyboardname>_InputPins]
|
||||
door = <some doorpi action>
|
||||
lighton = <some doorpi action>
|
||||
lightonfortimer = <some doorpi action>
|
||||
lightoff = <some doorpi action>
|
||||
dashlighton = <some doorpi action>
|
||||
dashlightoff = <some doorpi action>
|
||||
purge = <some doorpi action>
|
||||
clear = <some doorpi action>
|
||||
door = <doorpi action opeing the door>
|
||||
lighton = <doorpi action to switch on scene light>
|
||||
lightonfortimer = <doorpi action to switch on scene light for some time>
|
||||
lightoff = <doorpi action to switch off scene light>
|
||||
dashlighton = <doorpi action to switch on dashlight>
|
||||
dashlightoff = <doorpi action to switch off dashlight>
|
||||
gettarget = <doorpi action to acquire call target number>
|
||||
purge = <doorpi action to purge old files>
|
||||
clear = <doorpi action>
|
||||
... (optional buttons)
|
||||
button1 = <some doorpi action>
|
||||
... (further button definitions)
|
||||
</pre>
|
||||
=end html
|
||||
=cut
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=cut
|
@ -51,13 +51,17 @@ guests = dashboard
|
||||
[AdminNumbers]
|
||||
**621 = active
|
||||
|
||||
[DTMF]
|
||||
"#" = out:door,1,0,3
|
||||
|
||||
####################### Events #######################
|
||||
[EVENT_OnStartup]
|
||||
10 = sleep:1
|
||||
|
||||
[EVENT_BeforeSipPhoneMakeCall]
|
||||
10 = url_call:http://192.168.0.90:8083/fhem?XHR=1&cmd.A.Haus.T=set A.Haus.T call start
|
||||
20 = take_snapshot
|
||||
30 = mailto:xxx@yyyy,DoorPi,DoorPi initiating call
|
||||
30 = mailto:xxxxxxxx@yyyyyyyyyy,DoorPi,DoorPi initiating call
|
||||
|
||||
[EVENT_OnCallStateDisconnect]
|
||||
10 = url_call:http://192.168.0.90:8083/fhem?XHR=1&cmd.A.Haus.T=set A.Haus.T call end
|
||||
@ -71,20 +75,21 @@ guests = dashboard
|
||||
[EVENT_OnTimeMinuteEvery5]
|
||||
10=statuswatchdog:/tmp/doorpi.watchdog
|
||||
|
||||
####################### SIP phone #######################
|
||||
[SIP-Phone]
|
||||
identity = DoorPi
|
||||
local_port = 5060
|
||||
firewallpolicy = PolicyNoFirewall
|
||||
#
|
||||
sipphonetyp = linphone
|
||||
sipserver_password = XXXX
|
||||
sipserver_password = xxxxxxxxxxxxxxxxx
|
||||
sipserver_realm = fritz.box
|
||||
sipserver_server = 192.168.0.254
|
||||
sipserver_username = 620
|
||||
stun_server =
|
||||
#
|
||||
max_call_time = 120
|
||||
call_timeout = 15
|
||||
max_call_time = 300
|
||||
call_timeout = 60
|
||||
ua.max_calls = 2
|
||||
#
|
||||
capture_device = ALSA: USB PnP Sound Device
|
||||
@ -107,6 +112,7 @@ video_size = vga
|
||||
onboardpins = piface
|
||||
webservice = filesystem
|
||||
|
||||
####################### Virtual keyboard #######################
|
||||
[webservice_keyboard]
|
||||
base_path_input = /home/doorpi/keyboard/inputs/
|
||||
base_path_output = /home/doorpi/keyboard/outputs/
|
||||
@ -118,11 +124,16 @@ lightonfortimer = out:light,1,0,60
|
||||
lightoff = out:light,0
|
||||
dashlighton = out:dashlight,1
|
||||
dashlightoff = out:dashlight,0
|
||||
gettarget = sleep:0
|
||||
purge = sleep:0
|
||||
clear = sleep:0
|
||||
button1 = sleep:0
|
||||
button2 = sleep:0
|
||||
|
||||
#-- obtain the target call number from FHEM
|
||||
[EVENT_OnKeyPressed_webservice.gettarget]
|
||||
10 = os_execute:echo '{ReadingsVal("A.Haus.T","call_target",722622)}' | socat -t50 - TCP:192.168.0.90:7072 > /home/doorpi/calltarget
|
||||
|
||||
#-- purge all files older than current PID file
|
||||
[EVENT_OnKeyPressed_webservice.purge]
|
||||
10 = os_execute:find /home/doorpi/records/ -type f ! -newer var/run/doorpi.pid -delete
|
||||
@ -132,11 +143,13 @@ button2 = sleep:0
|
||||
10 = os_execute:/home/doorpi/purge.sh clear > /home/doorpi/yyy
|
||||
|
||||
[EVENT_OnKeyPressed_webservice.button1]
|
||||
10 = call:xxxxx
|
||||
10 = call:722622
|
||||
|
||||
[EVENT_OnKeyPressed_webservice.button2]
|
||||
10 = os_execute:echo '{ReadingsVal("A.Haus.T","call_number",xxxxx)}' | socat -t50 - TCP:192.168.0.90:7072 > /home/doorpi/callnumber
|
||||
10 = file_call_value:/home/doorpi/calltarget
|
||||
|
||||
|
||||
####################### Real keyboard #######################
|
||||
[onboardpins_keyboard]
|
||||
pull_up_down = PUD_UP
|
||||
|
||||
@ -147,13 +160,11 @@ pull_up_down = PUD_UP
|
||||
3 = blinking_led
|
||||
|
||||
[onboardpins_InputPins]
|
||||
0 = call:xxxxx
|
||||
0 = call:722622
|
||||
1 = call:**621
|
||||
2 = file_call_value:/home/doorpi/callnumber
|
||||
2 = file_call_value:/home/doorpi/calltarget
|
||||
3 = take_snapshot
|
||||
#--OK pin from Arduino
|
||||
6 = sleep:0
|
||||
#-- NOK pin from Arduino
|
||||
7 = sleep:0
|
||||
|
||||
#-- OK pin from Arduino
|
||||
@ -169,6 +180,4 @@ pull_up_down = PUD_UP
|
||||
20 = url_call:http://192.168.0.90:8085/fhem?XHR=1&cmd.GalaxyTab=set GalaxyTab ttsSay Unerlaubter Zutrittsversuch
|
||||
30 = url_call:http://192.168.0.90:8085/fhem?XHR=1&cmd.A.Haus.T=set A.Haus.T door wrong_id
|
||||
|
||||
[DTMF]
|
||||
"#" = out:door,1,0,3
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user