|
|
|
|
@@ -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 = "<table>";
|
|
|
|
|
|
|
|
|
|
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 = '<a href="http://'.$hash->{TCPIP}.'/'.$record.'">'.$rs.'</a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( $snapshot ne ""){
|
|
|
|
|
$state = '<a href="http://'.$hash->{TCPIP}.'/'.$snapshot.'"><img src="http://'.$hash->{TCPIP}.'/'.$snapshot.'" width="40" height="30"></a>';
|
|
|
|
|
$state = '<a href="http://'.$hash->{TCPIP}.'/'.$snapshot.'">';
|
|
|
|
|
$state .= ($iconpic) ? $iconpic : '<img src="http://'.$hash->{TCPIP}.'/'.$snapshot.'" width="40" height="30"></a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ret .= '<tr align="center" class="doorpicalllist '.($index % 2 == 1 ? "odd" : "even").'">';
|
|
|
|
|
@@ -867,7 +891,7 @@ sub DoorPi_makeTable($$$$){
|
|
|
|
|
<a name="DoorPi_Define"></a>
|
|
|
|
|
<h4>Define</h4>
|
|
|
|
|
<p>
|
|
|
|
|
<code>define <name> DoorPi <IP address></code>
|
|
|
|
|
<code>define <DoorPi-Device> DoorPi <IP address></code>
|
|
|
|
|
<br /><br /> Define a DoorpiPi instance.<br /><br />
|
|
|
|
|
</p>
|
|
|
|
|
<ul>
|
|
|
|
|
@@ -881,27 +905,27 @@ sub DoorPi_makeTable($$$$){
|
|
|
|
|
<h4>Set</h4>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><a name="doorpi_door">
|
|
|
|
|
<code>set <name> door open[|locked|unlocked] </code></a><br />
|
|
|
|
|
<code>set <DoorPi-Device> door open[|locked|unlocked] </code></a><br />
|
|
|
|
|
Activate the door opener in DoorPi, accompanied by an optional FHEM command
|
|
|
|
|
specified in the <i>dooropencmd</i> attribute.
|
|
|
|
|
<br><b>If the Attributes doorlockcmd and doorunlockcmd are specified, these commands may be used to lock and unlock the door</b><br>
|
|
|
|
|
<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_dashlight">
|
|
|
|
|
<code>set <name> dashlight on|off </code></a><br />
|
|
|
|
|
<code>set <DoorPi-Device> dashlight on|off </code></a><br />
|
|
|
|
|
Set the dashlight (illuminating the door station) on or off.
|
|
|
|
|
Instead of <i>dashlight</i>, one must use the value of the dashlightbutton attribute</li>
|
|
|
|
|
<li><a name="doorpi_light">
|
|
|
|
|
<code>set <name> light on|on-for-timer|off </code></a><br />
|
|
|
|
|
<code>set <DoorPi-Device> light on|on-for-timer|off </code></a><br />
|
|
|
|
|
Set the scene light (illuminating the visitor) on, on for a minute or off.
|
|
|
|
|
Instead of <i>light</i>, one must use the value of the lightbutton attribute</li>
|
|
|
|
|
<li><a name="doorpi_button">
|
|
|
|
|
<code>set <name> <i>buttonDD</i> </code></a><br />
|
|
|
|
|
Activate one of the virtual buttons specified in DoorPi.
|
|
|
|
|
<code>set <DoorPi-Device> <i>buttonDD</i> </code></a><br />
|
|
|
|
|
Activate one of the virtual buttons specified in DoorPi.
|
|
|
|
|
<li><a name="doorpi_purge">
|
|
|
|
|
<code>set <name> purge </code></a><br />
|
|
|
|
|
<code>set <DoorPi-Device> purge </code></a><br />
|
|
|
|
|
Clean all recordings and snapshots which are older than the current process </li>
|
|
|
|
|
<li><a name="doorpi_clear">
|
|
|
|
|
<code>set <name> clear </code></a><br />
|
|
|
|
|
<code>set <DoorPi-Device> clear </code></a><br />
|
|
|
|
|
Clear all recordings and snapshots </li>
|
|
|
|
|
</ul>
|
|
|
|
|
<br />
|
|
|
|
|
@@ -909,50 +933,91 @@ sub DoorPi_makeTable($$$$){
|
|
|
|
|
<h4>Get</h4>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><a name="doorpi_config">
|
|
|
|
|
<code>get <name> config</code></a>
|
|
|
|
|
<code>get <DoorPi-Device> config</code></a>
|
|
|
|
|
<br /> Returns the current configuration of DoorPi </li>
|
|
|
|
|
<li><a name="doorpi_history">
|
|
|
|
|
<code>get <name> history</code></a>
|
|
|
|
|
<code>get <DoorPi-Device> history</code></a>
|
|
|
|
|
<br /> Returns the current call history of DoorPi </li>
|
|
|
|
|
<li><a name="doorpi_version">
|
|
|
|
|
<code>get <name> version</code></a>
|
|
|
|
|
<code>get <DoorPi-Device> version</code></a>
|
|
|
|
|
<br /> Returns the version number of the FHEM DoorPi module</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<h4>Attributes</h4>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><a name="doorpi_doorbutton"><code>attr <name> doorbutton
|
|
|
|
|
<li><a name="doorpi_doorbutton"><code>attr <DoorPi-Device> doorbutton
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />DoorPi name for door action (default: door)</li>
|
|
|
|
|
<li><a name="doorpi_dooropencmd"><code>attr <name> dooropencmd
|
|
|
|
|
<li><a name="doorpi_dooropencmd"><code>attr <DoorPi-Device> dooropencmd
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />FHEM command additionally executed for door opening action (no default)</li>
|
|
|
|
|
<li><a name="doorpi_doorlockcmd"><code>attr <name> doorlockcmd
|
|
|
|
|
<li><a name="doorpi_doorlockcmd"><code>attr <DoorPi-Device> doorlockcmd
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />FHEM command for door locking action (no default)</li>
|
|
|
|
|
<li><a name="doorpi_doorunlockcmd"><code>attr <name> doorunlockcmd
|
|
|
|
|
<li><a name="doorpi_doorunlockcmd"><code>attr <DoorPi-Device> doorunlockcmd
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />FHEM command for door unlocking action (no default)</li>
|
|
|
|
|
<li><a name="doorpi_lightbutton"><code>attr <name> lightbutton
|
|
|
|
|
<li><a name="doorpi_lightbutton"><code>attr <DoorPi-Device> lightbutton
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />DoorPi name for light action (default: light)</li>
|
|
|
|
|
<li><a name="doorpi_dashlightbutton"><code>attr <name> dashlightbutton
|
|
|
|
|
<li><a name="doorpi_lightoncmd"><code>attr <DoorPi-Device> lightoncmd
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />FHEM command additionally executed for "light on" action (no default)</li>
|
|
|
|
|
<li><a name="doorpi_lightoffcmd"><code>attr <DoorPi-Device> lightoffcmd
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />FHEM command additionally executed for "light off" action (no default)</li>
|
|
|
|
|
<li><a name="doorpi_lighttimercmd"><code>attr <DoorPi-Device> lighttimercmd
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />FHEM command additionally executed for "light off" action (no default)</li>
|
|
|
|
|
<li><a name="doorpi_dashlightbutton"><code>attr <DoorPi-Device> dashlightbutton
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />DoorPi name for dashlight action (default: dashlight)</li>
|
|
|
|
|
<li><a name="doorpi_iconpic"><code>attr <DoorPi-Device> iconpic
|
|
|
|
|
<string></code></a>
|
|
|
|
|
<br />Icon to be used in overview instead of a (slow !) miniature picture</li>
|
|
|
|
|
<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 parts of the DoorPi configuration</h4>
|
|
|
|
|
The following Events need to be defined for DoorPi:
|
|
|
|
|
<ul>
|
|
|
|
|
<li>[EVENT_BeforeSipPhoneMakeCall]<br>
|
|
|
|
|
10 = url_call:<URL of FHEM>/fhem?XHR=1&cmd.<Device name for DoorPi>=set <Device name for DoorPi> call start</li>
|
|
|
|
|
<li>[EVENT_OnCallStateDisconnect]<br>
|
|
|
|
|
10 = url_call:<URL of FHEM>/fhem?XHR=1&cmd.<Device name for DoorPi>=set <Device name for DoorPi> call end</li>
|
|
|
|
|
<li>[EVENT_OnCallStateDismissed]<br>
|
|
|
|
|
10 = url_call:<URL of FHEM>/fhem?XHR=1&cmd.<Device name for DoorPi>=set <Device name for DoorPi> call dismissed</li>
|
|
|
|
|
<li>[EVENT_OnCallStateReject]<br>
|
|
|
|
|
10 = url_call:<URL of FHEM>/fhem?XHR=1&cmd.<Device name for DoorPi>=set <Device name for DoorPi> call rejected</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<h4>Necessary ingredients of the DoorPi configuration</h4>
|
|
|
|
|
The following Events need to be defined for DoorPi in order to communicate with FHEM:
|
|
|
|
|
<pre>
|
|
|
|
|
[EVENT_BeforeSipPhoneMakeCall]
|
|
|
|
|
10 = url_call:<URL of FHEM>/fhem?XHR=1&cmd.<DoorPi-Device>=set <DoorPi-Device> call start
|
|
|
|
|
20 = take_snapshot
|
|
|
|
|
|
|
|
|
|
[EVENT_OnCallStateDisconnect]
|
|
|
|
|
10 = url_call:<URL of FHEM>/fhem?XHR=1&cmd.<DoorPi-Device>=set <DoorPi-Device> call end
|
|
|
|
|
|
|
|
|
|
[EVENT_OnCallStateDismissed]
|
|
|
|
|
10 = url_call:<URL of FHEM>/fhem?XHR=1&cmd.<DoorPi-Device>=set <DoorPi-Device> call dismissed
|
|
|
|
|
|
|
|
|
|
[EVENT_OnCallStateReject]
|
|
|
|
|
10 = url_call:<URL of FHEM>/fhem?XHR=1&cmd.<DoorPi-Device>=set <DoorPi-Device> call rejected
|
|
|
|
|
</pre>
|
|
|
|
|
DoorPi <b>must</b> have a virtual (= filesystem) keyboard
|
|
|
|
|
<pre>
|
|
|
|
|
[keyboards]
|
|
|
|
|
...
|
|
|
|
|
<virtualkeyboardname> = filesystem
|
|
|
|
|
|
|
|
|
|
[<virtualkeyboardname>_keyboard]
|
|
|
|
|
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>
|
|
|
|
|
... (optional buttons)
|
|
|
|
|
button1 = <some doorpi action>
|
|
|
|
|
... (further button definitions)
|
|
|
|
|
</pre>
|
|
|
|
|
=end html
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
|