mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
70_DoorPi.pm: Neue Version
git-svn-id: https://svn.fhem.de/fhem/trunk@11627 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3f14747e47
commit
af3c64a724
@ -41,7 +41,7 @@ use vars qw{%attr %defs};
|
|||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
#-- globals on start
|
#-- globals on start
|
||||||
my $version = "1.0beta8";
|
my $version = "1.0beta9";
|
||||||
|
|
||||||
#-- these we may get on request
|
#-- these we may get on request
|
||||||
my %gets = (
|
my %gets = (
|
||||||
@ -123,6 +123,7 @@ sub DoorPi_Define($$) {
|
|||||||
$init_done = 1;
|
$init_done = 1;
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
readingsBulkUpdate($hash,"state","Initialized");
|
readingsBulkUpdate($hash,"state","Initialized");
|
||||||
|
readingsBulkUpdate($hash,"lockstate","Unknown");
|
||||||
readingsBulkUpdate($hash,"door","Unknown");
|
readingsBulkUpdate($hash,"door","Unknown");
|
||||||
readingsEndUpdate($hash,1);
|
readingsEndUpdate($hash,1);
|
||||||
|
|
||||||
@ -302,17 +303,83 @@ sub DoorPi_Set ($@) {
|
|||||||
Log 1,"[DoorPi_Set] Error: attribute target$value does not exist";
|
Log 1,"[DoorPi_Set] Error: attribute target$value does not exist";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#-- door opening - either from FHEM, or just as message from DoorPi
|
|
||||||
|
#-- Door opening - rather complicated
|
||||||
}elsif( ($key eq "$door")||($key eq "door") ){
|
}elsif( ($key eq "$door")||($key eq "door") ){
|
||||||
|
my $lockstate = ReadingsVal($name,"lockstate",undef);
|
||||||
|
|
||||||
|
#-- from FHEM: door opening, forward to DoorPi
|
||||||
if( $value eq "opened" ){
|
if( $value eq "opened" ){
|
||||||
$v=DoorPi_Cmd($hash,"dooropen");
|
if( $lockstate eq "unlocked" ){
|
||||||
Log 1,"[DoorPi_Set] sent dooropen command to DoorPi";
|
$v=DoorPi_Cmd($hash,"dooropen");
|
||||||
if(AttrVal($name, "dooropencmd",undef)){
|
Log 1,"[DoorPi_Set] sent dooropen command to DoorPi";
|
||||||
fhem(AttrVal($name, "dooropencmd",undef));
|
if(AttrVal($name, "dooropencmd",undef)){
|
||||||
|
fhem(AttrVal($name, "dooropencmd",undef));
|
||||||
|
}
|
||||||
|
readingsSingleUpdate($hash,$door,"opened",1);
|
||||||
|
}else{
|
||||||
|
Log 1,"[DoorPi_Set] opening of door not possible, is locked";
|
||||||
}
|
}
|
||||||
readingsSingleUpdate($hash,$door,"opened",1);
|
|
||||||
|
#-- from DoorPi: door has to be unlocked if necessary
|
||||||
|
}elsif( $value eq "unlockandopen" ){
|
||||||
|
#-- need to unlock the door now
|
||||||
|
if( $lockstate eq "locked" ){
|
||||||
|
if( AttrVal($name, "doorunlockcmd",undef) ){
|
||||||
|
fhem(AttrVal($name, "doorunlockcmd",undef));
|
||||||
|
Log 1,"[DoorPi_Set] received unlockandopen command from DoorPi and executed FHEM doorunlock command";
|
||||||
|
readingsSingleUpdate($hash,"lockstate","unlocked",1);
|
||||||
|
readingsSingleUpdate($hash,$door,"unlocked",1);
|
||||||
|
$v=DoorPi_Cmd($hash,"doorunlocked");
|
||||||
|
}else{
|
||||||
|
Log 1,"[DoorPi_Set] received unlockandopen command from DoorPi, but no FHEM doorunlock command";
|
||||||
|
}
|
||||||
|
}elsif( $lockstate eq "unlocked" ){
|
||||||
|
Log 1,"[DoorPi_Set] received unlockandopen command from DoorPi, but is already unlocked";
|
||||||
|
}else{
|
||||||
|
#-- error message
|
||||||
|
Log 1,"[DoorPi_Set] received unlockandopen command from DoorPi, but uncertain lockstate";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#-- Now open the door by DoorPi
|
||||||
|
$v=DoorPi_Cmd($hash,"dooropen");
|
||||||
|
|
||||||
|
#-- from DoorPi: door has to be locked if necessary
|
||||||
|
}elsif( $value eq "softlock" ){
|
||||||
|
#-- need to lock the door now
|
||||||
|
if( $lockstate eq "unlocked" ){
|
||||||
|
if( AttrVal($name, "doorlockcmd",undef) ){
|
||||||
|
fhem(AttrVal($name, "doorlockcmd",undef));
|
||||||
|
Log 1,"[DoorPi_Set] received softlock command from DoorPi and executed FHEM doorlock command";
|
||||||
|
readingsSingleUpdate($hash,"lockstate","locked",1);
|
||||||
|
readingsSingleUpdate($hash,$door,"locked",1);
|
||||||
|
$v=DoorPi_Cmd($hash,"doorlocked");
|
||||||
|
}else{
|
||||||
|
Log 1,"[DoorPi_Set] received softlock command from DoorPi, but no FHEM doorlock command";
|
||||||
|
}
|
||||||
|
}elsif( $lockstate eq "locked" ){
|
||||||
|
Log 1,"[DoorPi_Set] received softlock command from DoorPi, but is already locked";
|
||||||
|
}else{
|
||||||
|
#-- error message
|
||||||
|
Log 1,"[DoorPi_Set] received softlock command from DoorPi, but uncertain lockstate";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#-- from FHEM: unlocking the door
|
||||||
|
}elsif( $value eq "unlocked" ){
|
||||||
|
#-- careful here -
|
||||||
|
# a third parameter indicates that the door is already unlocked
|
||||||
|
# because the command has been issued by the lock itself
|
||||||
|
if( (AttrVal($name, "doorunlockcmd",undef)) && (!$a[0]) ){
|
||||||
|
fhem(AttrVal($name, "doorunlockcmd",undef));
|
||||||
|
Log 1,"[DoorPi_Set] sent doorunlocked command to DoorPi and executed FHEM doorunlock command";
|
||||||
|
}else{
|
||||||
|
Log 1,"[DoorPi_Set] sent doorunlocked command to DoorPi and NOT executed FHEM doorunlock command";
|
||||||
|
}
|
||||||
|
readingsSingleUpdate($hash,"lockstate","unlocked",1);
|
||||||
|
readingsSingleUpdate($hash,$door,"unlocked",1);
|
||||||
|
$v=DoorPi_Cmd($hash,"doorunlocked");
|
||||||
|
#-- from FHEM: locking the door
|
||||||
}elsif( $value eq "locked" ){
|
}elsif( $value eq "locked" ){
|
||||||
$v=DoorPi_Cmd($hash,"doorlocked");
|
|
||||||
#-- careful here -
|
#-- careful here -
|
||||||
# a third parameter indicates that the door is already unlocked
|
# a third parameter indicates that the door is already unlocked
|
||||||
if( (AttrVal($name, "doorlockcmd",undef)) && (!$a[0]) ){
|
if( (AttrVal($name, "doorlockcmd",undef)) && (!$a[0]) ){
|
||||||
@ -321,19 +388,11 @@ sub DoorPi_Set ($@) {
|
|||||||
}else{
|
}else{
|
||||||
Log 1,"[DoorPi_Set] sent doorlocked command to DoorPi and NOT executed extra FHEM doorlock command";
|
Log 1,"[DoorPi_Set] sent doorlocked command to DoorPi and NOT executed extra FHEM doorlock command";
|
||||||
}
|
}
|
||||||
|
readingsSingleUpdate($hash,"lockstate","locked",1);
|
||||||
readingsSingleUpdate($hash,$door,"locked",1);
|
readingsSingleUpdate($hash,$door,"locked",1);
|
||||||
}elsif( $value eq "unlocked" ){
|
$v=DoorPi_Cmd($hash,"doorlocked");
|
||||||
$v=DoorPi_Cmd($hash,"doorunlocked");
|
|
||||||
#-- careful here -
|
|
||||||
# a third parameter indicates that the door is already unlocked
|
|
||||||
if( (AttrVal($name, "doorunlockcmd",undef)) && (!$a[0]) ){
|
|
||||||
fhem(AttrVal($name, "doorunlockcmd",undef));
|
|
||||||
Log 1,"[DoorPi_Set] sent doorunlocked command to DoorPi and executed extra FHEM doorunlock command";
|
|
||||||
}else{
|
|
||||||
Log 1,"[DoorPi_Set] sent doorunlocked command to DoorPi and NOT executed extra FHEM doorunlock command";
|
|
||||||
}
|
|
||||||
readingsSingleUpdate($hash,$door,"unlocked",1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- snapshot
|
#-- snapshot
|
||||||
}elsif( $key eq "$snapshot" ){
|
}elsif( $key eq "$snapshot" ){
|
||||||
$v=DoorPi_Cmd($hash,"snapshot");
|
$v=DoorPi_Cmd($hash,"snapshot");
|
||||||
|
@ -11,10 +11,10 @@ checkstream() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FHEMDP="A.Door.Pi"
|
FHEMDP="A.Door.Pi"
|
||||||
FHEMIP="192.168.0.90"
|
FHEMIP="xxx"
|
||||||
FHEM="http://$FHEMIP:8083/fhem?XHR=1&cmd.$FHEMDP"
|
FHEM="http://$FHEMIP:8083/fhem?XHR=1&cmd.$FHEMDP"
|
||||||
HOME="/home/doorpi"
|
HOME="/home/doorpi"
|
||||||
default_target="XXXX"
|
default_target=""
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|
||||||
@ -29,9 +29,9 @@ case $1 in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
dooropen)
|
doorunlockandopen)
|
||||||
curl "$FHEM=set%20GalaxyTab%20ttsSay%20Ein%20Bewohner%20betritt%20das%20Haus" &
|
curl "$FHEM=set%20GalaxyTab%20ttsSay%20Ein%20Bewohner%20betritt%20das%20Haus" &
|
||||||
curl "$FHEM=set%20$FHEMDP%20door%20opened" &
|
curl "$FHEM=set%20$FHEMDP%20door%20unlockandopen" &
|
||||||
;;
|
;;
|
||||||
|
|
||||||
wrongid)
|
wrongid)
|
||||||
@ -40,7 +40,7 @@ case $1 in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
softlock)
|
softlock)
|
||||||
curl "$FHEM=set%20$FHEMDP%20door%20locked" &
|
curl "$FHEM=set%20$FHEMDP%20door%20softlock" &
|
||||||
;;
|
;;
|
||||||
|
|
||||||
call)
|
call)
|
||||||
|
@ -54,27 +54,6 @@ guests = dashboard
|
|||||||
[DTMF]
|
[DTMF]
|
||||||
"#" = out:door,1,0,3
|
"#" = out:door,1,0,3
|
||||||
|
|
||||||
####################### Events #######################
|
|
||||||
[EVENT_OnStartup]
|
|
||||||
10 = sleep:1
|
|
||||||
20 = os_execute:/home/doorpi/FHEMHelper call init
|
|
||||||
|
|
||||||
[EVENT_BeforeSipPhoneMakeCall]
|
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper call startup
|
|
||||||
20 = take_snapshot
|
|
||||||
|
|
||||||
[EVENT_OnCallStateDisconnect]
|
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper call end
|
|
||||||
|
|
||||||
[EVENT_OnCallStateDismissed]
|
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper call dismissed
|
|
||||||
|
|
||||||
[EVENT_OnCallStateReject]
|
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper call rejected
|
|
||||||
|
|
||||||
[EVENT_OnTimeMinuteEvery5]
|
|
||||||
10=statuswatchdog:/tmp/doorpi.watchdog
|
|
||||||
|
|
||||||
####################### SIP phone #######################
|
####################### SIP phone #######################
|
||||||
[SIP-Phone]
|
[SIP-Phone]
|
||||||
identity = DoorPi
|
identity = DoorPi
|
||||||
@ -82,9 +61,9 @@ local_port = 5060
|
|||||||
firewallpolicy = PolicyNoFirewall
|
firewallpolicy = PolicyNoFirewall
|
||||||
#
|
#
|
||||||
sipphonetyp = linphone
|
sipphonetyp = linphone
|
||||||
sipserver_password = xxxxxx
|
sipserver_password = xxxx
|
||||||
sipserver_realm = cccc
|
sipserver_realm = fritz.box
|
||||||
sipserver_server = ccccc
|
sipserver_server = xxxx
|
||||||
sipserver_username = 620
|
sipserver_username = 620
|
||||||
stun_server =
|
stun_server =
|
||||||
#
|
#
|
||||||
@ -108,6 +87,28 @@ video_device = StaticImage: Static picture
|
|||||||
video_display_enabled = False
|
video_display_enabled = False
|
||||||
video_size = vga
|
video_size = vga
|
||||||
|
|
||||||
|
####################### Events #######################
|
||||||
|
[EVENT_OnStartup]
|
||||||
|
10 = sleep:1
|
||||||
|
20 = os_execute:/home/doorpi/FHEMHelper.sh call init
|
||||||
|
|
||||||
|
[EVENT_BeforeSipPhoneMakeCall]
|
||||||
|
10 = os_execute:/home/doorpi/FHEMHelper.sh call startup
|
||||||
|
20 = take_snapshot
|
||||||
|
#30 = mailto:haus271828@henning-weingarten.de,DoorPi,DoorPi initiating call
|
||||||
|
|
||||||
|
[EVENT_OnCallStateDisconnect]
|
||||||
|
10 = os_execute:/home/doorpi/FHEMHelper.sh call end
|
||||||
|
|
||||||
|
[EVENT_OnCallStateDismissed]
|
||||||
|
10 = os_execute:/home/doorpi/FHEMHelper.sh call dismissed
|
||||||
|
|
||||||
|
[EVENT_OnCallStateReject]
|
||||||
|
10 = os_execute:/home/doorpi/FHEMHelper.sh call rejected
|
||||||
|
|
||||||
|
[EVENT_OnTimeMinuteEvery5]
|
||||||
|
10=statuswatchdog:/tmp/doorpi.watchdog
|
||||||
|
|
||||||
####################### Keyboards ##############################
|
####################### Keyboards ##############################
|
||||||
[keyboards]
|
[keyboards]
|
||||||
webservice = filesystem
|
webservice = filesystem
|
||||||
@ -139,7 +140,7 @@ button2 = sleep:0
|
|||||||
#-- communicate to FHEM that a snapshot has been taken
|
#-- communicate to FHEM that a snapshot has been taken
|
||||||
[EVENT_OnKeyPressed_webservice.snapshot]
|
[EVENT_OnKeyPressed_webservice.snapshot]
|
||||||
10 = take_snapshot
|
10 = take_snapshot
|
||||||
20 = os_execute:/home/doorpi/FHEMHelper call snapshot
|
20 = os_execute:/home/doorpi/FHEMHelper.sh call snapshot
|
||||||
|
|
||||||
#-- start video stream
|
#-- start video stream
|
||||||
[EVENT_OnKeyPressed_webservice.streamon]
|
[EVENT_OnKeyPressed_webservice.streamon]
|
||||||
@ -151,18 +152,18 @@ button2 = sleep:0
|
|||||||
|
|
||||||
#-- obtain the target call number from FHEM
|
#-- obtain the target call number from FHEM
|
||||||
[EVENT_OnKeyPressed_webservice.gettarget]
|
[EVENT_OnKeyPressed_webservice.gettarget]
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper gettarget
|
10 = os_execute:/home/doorpi/FHEMHelper.sh gettarget
|
||||||
|
|
||||||
#-- purge all files older than current PID file
|
#-- purge all files older than current PID file
|
||||||
[EVENT_OnKeyPressed_webservice.purge]
|
[EVENT_OnKeyPressed_webservice.purge]
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper purge
|
10 = os_execute:/home/doorpi/FHEMHelper.sh purge
|
||||||
|
|
||||||
#-- clear all files
|
#-- clear all files
|
||||||
[EVENT_OnKeyPressed_webservice.clear]
|
[EVENT_OnKeyPressed_webservice.clear]
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper clear
|
10 = os_execute:/home/doorpi/FHEMHelper.sh clear
|
||||||
|
|
||||||
[EVENT_OnKeyPressed_webservice.button1]
|
[EVENT_OnKeyPressed_webservice.button1]
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper sabotage
|
10 = os_execute:/home/doorpi/FHEMHelper.sh sabotage
|
||||||
|
|
||||||
[EVENT_OnKeyPressed_webservice.button2]
|
[EVENT_OnKeyPressed_webservice.button2]
|
||||||
10 = file_call_value:/home/doorpi/calltarget
|
10 = file_call_value:/home/doorpi/calltarget
|
||||||
@ -189,30 +190,29 @@ pull_up_down = PUD_UP
|
|||||||
#-- DoorOpen pin from Arduino
|
#-- DoorOpen pin from Arduino
|
||||||
[EVENT_OnKeyPressed_onboardpins.1]
|
[EVENT_OnKeyPressed_onboardpins.1]
|
||||||
10 = out:dashlight,1
|
10 = out:dashlight,1
|
||||||
20 = os_execute:/home/doorpi/FHEMHelper dooropen
|
20 = os_execute:/home/doorpi/FHEMHelper.sh doorunlockandopen
|
||||||
30 = os_execute:aplay -D plughw:1,0 /home/doorpi/sounds/067_willkommen.wav
|
30 = os_execute:aplay -D plughw:1,0 /home/doorpi/sounds/067_willkommen.wav
|
||||||
40 = out:door,1,0,3
|
40 = out:dashlight,0
|
||||||
50 = out:dashlight,0
|
|
||||||
|
|
||||||
#-- WrongID pin from Arduino
|
#-- WrongID pin from Arduino
|
||||||
[EVENT_OnKeyPressed_onboardpins.4]
|
[EVENT_OnKeyPressed_onboardpins.4]
|
||||||
10 = out:dashlight,1
|
10 = out:dashlight,1
|
||||||
20 = os_execute:/home/doorpi/FHEMHelper wrongid
|
20 = os_execute:/home/doorpi/FHEMHelper.sh wrongid
|
||||||
30 = take_snapshot
|
30 = take_snapshot
|
||||||
40 = out:dashlight,0
|
40 = out:dashlight,0
|
||||||
|
|
||||||
#-- LockState pin from Arduino - FHEM will transform softlock into hardlock
|
#-- LockState pin from Arduino - FHEM will transform softlock into hardlock
|
||||||
[EVENT_OnKeyPressed_onboardpins.5]
|
[EVENT_OnKeyPressed_onboardpins.5]
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper softlock
|
10 = os_execute:/home/doorpi/FHEMHelper.sh softlock
|
||||||
|
|
||||||
#-- Movement detection
|
#-- Movement detection
|
||||||
[EVENT_OnKeyPressed_onboardpins.6]
|
[EVENT_OnKeyPressed_onboardpins.6]
|
||||||
10 = out:dashlight,1,0,60
|
10 = out:dashlight,1,0,60
|
||||||
20 = os_execute:/home/doorpi/FHEMHelper movement
|
20 = os_execute:/home/doorpi/FHEMHelper.sh movement
|
||||||
|
|
||||||
#-- Sabotage detection
|
#-- Sabotage detection
|
||||||
[EVENT_OnKeyPressed_onboardpins.7]
|
[EVENT_OnKeyPressed_onboardpins.7]
|
||||||
10 = os_execute:/home/doorpi/FHEMHelper sabotage
|
10 = os_execute:/home/doorpi/FHEMHelper.sh sabotage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user