mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-25 03:39:21 +00:00
PIONEERAVR: new attribute: checkConnection
git-svn-id: https://svn.fhem.de/fhem/trunk@6198 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1bb5d56267
commit
0dafa3e87c
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: PIONEERAVR: new attribute: checkConnection
|
||||||
- change: do no parse empty lines in 57_Calendar.pm
|
- change: do no parse empty lines in 57_Calendar.pm
|
||||||
- bugfix: 10_SOMFY.pm: save enc-key and rolling-code as reading instead of attribute
|
- bugfix: 10_SOMFY.pm: save enc-key and rolling-code as reading instead of attribute
|
||||||
to prevent loss of control after FHEM restart.
|
to prevent loss of control after FHEM restart.
|
||||||
|
@ -118,7 +118,7 @@ PIONEERAVR_Initialize($) {
|
|||||||
$hash->{GetFn} = "PIONEERAVR_Get";
|
$hash->{GetFn} = "PIONEERAVR_Get";
|
||||||
$hash->{SetFn} = "PIONEERAVR_Set";
|
$hash->{SetFn} = "PIONEERAVR_Set";
|
||||||
$hash->{AttrFn} = "PIONEERAVR_Attr";
|
$hash->{AttrFn} = "PIONEERAVR_Attr";
|
||||||
$hash->{AttrList}= "logTraffic:0,1,2,3,4,5 ".
|
$hash->{AttrList}= "logTraffic:0,1,2,3,4,5 checkConnection:enable,disable ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
|
|
||||||
# remotecontrol
|
# remotecontrol
|
||||||
@ -1339,11 +1339,14 @@ sub PIONEERAVR_Read($)
|
|||||||
# We delete the current "inactivity timer" and set a new timer
|
# We delete the current "inactivity timer" and set a new timer
|
||||||
# to check if connection to the Pioneer AV receiver is still working in 120s
|
# to check if connection to the Pioneer AV receiver is still working in 120s
|
||||||
|
|
||||||
my $in120s = gettimeofday()+120;
|
if (AttrVal($name, "checkConnection", "enable") eq "enable" ) {
|
||||||
$hash->{helper}{nextConnectionCheck} = $in120s;
|
my $in120s = gettimeofday()+120;
|
||||||
RemoveInternalTimer($hash);
|
$hash->{helper}{nextConnectionCheck} = $in120s;
|
||||||
InternalTimer($in120s, "PIONEERAVR_checkConnection", $hash, 0);
|
RemoveInternalTimer($hash);
|
||||||
Log3 $hash,5,"PIONEERAVR $name: Connection is up --- Check again in 120s --> Internal timer (120s) set";
|
InternalTimer($in120s, "PIONEERAVR_checkConnection", $hash, 0);
|
||||||
|
Log3 $hash,5,"PIONEERAVR $name: Connection is up --- Check again in 120s --> Internal timer (120s) set";
|
||||||
|
}
|
||||||
|
|
||||||
readingsEndUpdate($hash, 1);
|
readingsEndUpdate($hash, 1);
|
||||||
$hash->{PARTIAL} = $buf;
|
$hash->{PARTIAL} = $buf;
|
||||||
}
|
}
|
||||||
@ -1385,7 +1388,7 @@ sub PIONEERAVR_Reopen($) {
|
|||||||
my $ret = DevIo_OpenDev($hash, 1, undef);
|
my $ret = DevIo_OpenDev($hash, 1, undef);
|
||||||
if ($hash->{STATE} eq "opened") {
|
if ($hash->{STATE} eq "opened") {
|
||||||
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_Reopen() -> now opened";
|
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_Reopen() -> now opened";
|
||||||
readingsSingleUpdate($hash , "connectionState" , "opened" , 1 );
|
#readingsSingleUpdate($hash , "connectionState" , "opened" , 1 );
|
||||||
PIONEERAVR_statusUpdate($hash);
|
PIONEERAVR_statusUpdate($hash);
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -1395,15 +1398,19 @@ sub PIONEERAVR_Reopen($) {
|
|||||||
# connection check 3s after writing
|
# connection check 3s after writing
|
||||||
sub PIONEERAVR_Write($$) {
|
sub PIONEERAVR_Write($$) {
|
||||||
my ($hash, $msg) = @_;
|
my ($hash, $msg) = @_;
|
||||||
|
my $name= $hash->{NAME};
|
||||||
$msg= $msg."\r\n";
|
$msg= $msg."\r\n";
|
||||||
my $logMsg = "SimpleWrite " . dq($msg);
|
my $logMsg = "SimpleWrite " . dq($msg);
|
||||||
PIONEERAVR_Log($hash, undef, $logMsg);
|
PIONEERAVR_Log($hash, undef, $logMsg);
|
||||||
DevIo_SimpleWrite($hash, $msg, 0);
|
DevIo_SimpleWrite($hash, $msg, 0);
|
||||||
my $now3 = gettimeofday()+3;
|
|
||||||
if ($hash->{helper}{nextConnectionCheck} > $now3) {
|
if (AttrVal($name, "checkConnection", "enable") eq "enable" ) {
|
||||||
$hash->{helper}{nextConnectionCheck} = $now3;
|
my $now3 = gettimeofday()+3;
|
||||||
RemoveInternalTimer($hash);
|
if ($hash->{helper}{nextConnectionCheck} > $now3) {
|
||||||
InternalTimer($now3, "PIONEERAVR_checkConnection", $hash, 0);
|
$hash->{helper}{nextConnectionCheck} = $now3;
|
||||||
|
RemoveInternalTimer($hash);
|
||||||
|
InternalTimer($now3, "PIONEERAVR_checkConnection", $hash, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1438,23 +1445,17 @@ sub PIONEERAVR_checkConnection ($) {
|
|||||||
# not connected!
|
# not connected!
|
||||||
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- reopen()";
|
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- reopen()";
|
||||||
PIONEERAVR_Reopen($hash);
|
PIONEERAVR_Reopen($hash);
|
||||||
}
|
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- state after PIONEERAVR_Reopen(): ".$hash->{STATE}." state: $state ConnState: ".dq($connState);
|
||||||
#restore state $hash->{STATE}
|
} else {
|
||||||
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- state after PIONEERAVR_Reopen(): ".$hash->{STATE}." state: $state ConnState: ".dq($connState);
|
# we got a reply -> connection is good -> restore state
|
||||||
if (($hash->{STATE} eq "opened" || $hash->{STATE} eq "connected" ) && ($state eq "on" || $state eq "off")){
|
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- state: ".$hash->{STATE}." restored to: $state";
|
||||||
#readingsSingleUpdate($hash, "state", $state,1 );
|
|
||||||
$hash->{STATE} = $state;
|
$hash->{STATE} = $state;
|
||||||
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- state: $state restored to: ".$hash->{STATE};
|
}
|
||||||
} elsif ($hash->{STATE} eq "disconnected") {
|
if (AttrVal($name, "checkConnection", "enable") eq "enable" ) {
|
||||||
Log3 $name, 3, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- state (discon): ".$hash->{STATE};
|
$hash->{helper}{nextConnectionCheck} = gettimeofday()+120;
|
||||||
readingsBeginUpdate($hash);
|
InternalTimer($hash->{helper}{nextConnectionCheck}, "PIONEERAVR_checkConnection", $hash, 0);
|
||||||
readingsBulkUpdate($hash, "connectionState","disconnected",1 );
|
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection(): set internaltimer(120s)";
|
||||||
#readingsBulkUpdate($hash, "state", $hash->{STATE},1 );
|
|
||||||
readingsEndUpdate($hash, 1);
|
|
||||||
}
|
}
|
||||||
#RemoveInternalTimer($hash);
|
|
||||||
$hash->{helper}{nextConnectionCheck} = gettimeofday()+120;
|
|
||||||
InternalTimer($hash->{helper}{nextConnectionCheck}, "PIONEERAVR_checkConnection", $hash, 0);
|
|
||||||
}
|
}
|
||||||
#########################################################
|
#########################################################
|
||||||
sub PIONEERAVR_statusUpdate($) {
|
sub PIONEERAVR_statusUpdate($) {
|
||||||
@ -1644,6 +1645,7 @@ RC_layout_PioneerAVR() {
|
|||||||
<b>Attributes</b>
|
<b>Attributes</b>
|
||||||
<br><br>
|
<br><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>checkConnection <enable|disable>><br>Enables/disbales the check if the data connection to the Pioneer AV reciver is open.(Default: enable)</li>
|
||||||
<li>logTraffic <loglevel><br>Enables logging of sent and received datagrams with the given loglevel.
|
<li>logTraffic <loglevel><br>Enables logging of sent and received datagrams with the given loglevel.
|
||||||
Control characters in the logged datagrams are escaped, i.e. a double backslash is shown for a single backslash,
|
Control characters in the logged datagrams are escaped, i.e. a double backslash is shown for a single backslash,
|
||||||
\n is shown for a line feed character, etc.</li>
|
\n is shown for a line feed character, etc.</li>
|
||||||
@ -1784,6 +1786,8 @@ RC_layout_PioneerAVR() {
|
|||||||
<b>Attribute</b>
|
<b>Attribute</b>
|
||||||
<br><br>
|
<br><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>checkConnection <enable|disable>><br>Ein-/Ausscahlten der regelmäßigen Überprüfung, ob die Datenverbindung
|
||||||
|
zum Pioneer AV Receiver funktionert. Ist das Attribut nicht gesetzt, oder "enable" so wird regelmäßig die Verbindung überprüft.</li>
|
||||||
<li>logTraffic <loglevel><br>Ermöglicht das loggen der Datenommunikation vom/zum Pioneer AV Receiver.
|
<li>logTraffic <loglevel><br>Ermöglicht das loggen der Datenommunikation vom/zum Pioneer AV Receiver.
|
||||||
Steuerzeichen werden angezeigtz.B. ein doppelter Ruckwärts-Schrägstrich wird als einfacher Rückwärts-Schrägstrich angezeigt,
|
Steuerzeichen werden angezeigtz.B. ein doppelter Ruckwärts-Schrägstrich wird als einfacher Rückwärts-Schrägstrich angezeigt,
|
||||||
\n wird für das Steuerzeichen "line feed" angezeigt, etc.</li>
|
\n wird für das Steuerzeichen "line feed" angezeigt, etc.</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user