mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
89_VCONTROL.pm: reconnect for usb and lan adapter optimized
git-svn-id: https://svn.fhem.de/fhem/trunk@7525 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ed3c7d1f5c
commit
0c43ee1450
@ -72,6 +72,9 @@ my %DayHash;
|
|||||||
my @mode = ("WW","RED","NORM","H+WW","H+WW FS","ABSCHALT");
|
my @mode = ("WW","RED","NORM","H+WW","H+WW FS","ABSCHALT");
|
||||||
my $temp_mode=0;
|
my $temp_mode=0;
|
||||||
|
|
||||||
|
#define LAN Hardware (1) or USB device (0)
|
||||||
|
my $LAN_HW = 0;
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
sub VCONTROL_1ByteUParse($$);
|
sub VCONTROL_1ByteUParse($$);
|
||||||
sub VCONTROL_1ByteSParse($$);
|
sub VCONTROL_1ByteSParse($$);
|
||||||
@ -116,7 +119,7 @@ VCONTROL_Initialize($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# define <name> VIESSMANN <port> <commad_config> [<interval>]
|
# define <name> VIESSMANN <port> <command_config> [<interval>]
|
||||||
|
|
||||||
sub
|
sub
|
||||||
VCONTROL_Define($$)
|
VCONTROL_Define($$)
|
||||||
@ -137,6 +140,10 @@ VCONTROL_Define($$)
|
|||||||
delete $hash->{USBDev};
|
delete $hash->{USBDev};
|
||||||
delete $hash->{FD};
|
delete $hash->{FD};
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
###LAN Hardware found
|
||||||
|
$LAN_HW = 1;
|
||||||
|
}
|
||||||
DevIo_CloseDev($hash);
|
DevIo_CloseDev($hash);
|
||||||
|
|
||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
@ -175,6 +182,7 @@ VCONTROL_Define($$)
|
|||||||
#Opening USB Device
|
#Opening USB Device
|
||||||
Log3($name, 3, "VCONTROL opening VCONTROL device $dev");
|
Log3($name, 3, "VCONTROL opening VCONTROL device $dev");
|
||||||
|
|
||||||
|
my $ret = undef;
|
||||||
###USB
|
###USB
|
||||||
if (index($a[2], ':') == -1) {
|
if (index($a[2], ':') == -1) {
|
||||||
|
|
||||||
@ -208,17 +216,16 @@ VCONTROL_Define($$)
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DevIo_OpenDev($hash, 0, undef);
|
$ret = DevIo_OpenDev($hash, 0, "VCONTROL_DoInit");
|
||||||
VCONTROL_DoInit($hash, undef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#set Internal Timer on Polling Interval
|
#set Internal Timer on Polling Interval
|
||||||
my $timer = gettimeofday()+1;
|
my $timer = gettimeofday()+1;
|
||||||
Log3($name, 5, "VCONTROL set InternalTimer +1 to $timer");
|
Log3($name, 5, "VCONTROL set InternalTimer +1 to $timer");
|
||||||
|
|
||||||
InternalTimer(gettimeofday()+1, "VCONTROL_Poll", $hash, 0);
|
InternalTimer(gettimeofday()+1, "VCONTROL_Poll", $hash, 0);
|
||||||
return undef;
|
return $ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +323,7 @@ VCONTROL_Clear($)
|
|||||||
sub
|
sub
|
||||||
VCONTROL_DoInit($$)
|
VCONTROL_DoInit($$)
|
||||||
{
|
{
|
||||||
#Initialisation -> Send one 0x04 so the heating started to send 0x05 Synchonity-Bytes
|
#Initialisation -> Send one 0x04 so the heating started to send 0x05 Synchronity-Bytes
|
||||||
my ($hash,$po) = @_;
|
my ($hash,$po) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $init = pack('H*', "04");
|
my $init = pack('H*', "04");
|
||||||
@ -347,7 +354,6 @@ VCONTROL_DoInit($$)
|
|||||||
sub
|
sub
|
||||||
VCONTROL_Read($)
|
VCONTROL_Read($)
|
||||||
{
|
{
|
||||||
|
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
Log3 $name, 5,"VCONTROL_READ";
|
Log3 $name, 5,"VCONTROL_READ";
|
||||||
@ -357,13 +363,14 @@ VCONTROL_Read($)
|
|||||||
#Read on Device
|
#Read on Device
|
||||||
my $mybuf = DevIo_SimpleRead($hash);
|
my $mybuf = DevIo_SimpleRead($hash);
|
||||||
|
|
||||||
|
if ($LAN_HW == 0) {
|
||||||
#USB device is disconnected try to connect again
|
#USB device is disconnected try to connect again
|
||||||
if(!defined($mybuf) || length($mybuf) == 0) {
|
if(!defined($mybuf) || length($mybuf) == 0) {
|
||||||
my $dev = $hash->{DeviceName};
|
my $dev = $hash->{DeviceName};
|
||||||
Log3 $name, 3,"VCONTROL: USB device $dev disconnected, waiting to reappear";
|
Log3 $name, 3,"VCONTROL: USB device $dev disconnected, waiting to reappear";
|
||||||
$hash->{USBDev}->close();
|
$hash->{USBDev}->close();
|
||||||
DoTrigger($name, "DISCONNECTED");
|
DoTrigger($name, "DISCONNECTED");
|
||||||
|
DevIo_Disconnected($hash);
|
||||||
delete($hash->{USBDev});
|
delete($hash->{USBDev});
|
||||||
delete($selectlist{"$name.$dev"});
|
delete($selectlist{"$name.$dev"});
|
||||||
$readyfnlist{"$name.$dev"} = $hash; # Start polling
|
$readyfnlist{"$name.$dev"} = $hash; # Start polling
|
||||||
@ -374,6 +381,16 @@ VCONTROL_Read($)
|
|||||||
sleep(5);
|
sleep(5);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!defined($mybuf) || length($mybuf) == 0) {
|
||||||
|
my $dev = $hash->{DeviceName};
|
||||||
|
Log3 $name, 3,"VCONTROL: LAN device $dev disconnected, waiting to reappear";
|
||||||
|
DevIo_Disconnected($hash);
|
||||||
|
$hash->{STATE} = "disconnected";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#msg read on device
|
#msg read on device
|
||||||
my $hexline = unpack('H*', $mybuf);
|
my $hexline = unpack('H*', $mybuf);
|
||||||
@ -697,12 +714,15 @@ VCONTROL_Ready($)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$hash->{PARTIAL} = "";
|
$hash->{PARTIAL} = "";
|
||||||
DevIo_OpenDev($hash, 1, undef);
|
return DevIo_OpenDev($hash, 1, "VCONTROL_DoInit")
|
||||||
return undef if(!exists($hash->{FD}));
|
if($hash->{STATE} eq "disconnected");
|
||||||
return undef if(!defined($_[0]->{TCPDev}));
|
# This is relevant for windows/USB only
|
||||||
VCONTROL_DoInit($hash, undef);
|
my $po = $hash->{USBDev};
|
||||||
DoTrigger($name, "CONNECTED");
|
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags);
|
||||||
return undef;
|
if($po) {
|
||||||
|
($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags) = $po->status;
|
||||||
|
}
|
||||||
|
return ($InBytes && $InBytes>0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1174,14 +1194,14 @@ sub VCONTROL_TimerConv($$){
|
|||||||
<a name="VCONTROL"></a>
|
<a name="VCONTROL"></a>
|
||||||
<h3>VCONTROL</h3>
|
<h3>VCONTROL</h3>
|
||||||
<ul>
|
<ul>
|
||||||
VCONTROL is the fhem-Modul to control and read information from a VIESSMANN heating via Optolink-adapter.<br><br>
|
VCONTROL is a fhem-Modul to control and read information from a VIESSMANN heating via Optolink-adapter.<br><br>
|
||||||
|
|
||||||
An Optolink-Adapter is necessary (USB or LAN), you will find information here:<br>
|
An Optolink-Adapter is necessary (USB or LAN), you will find information here:<br>
|
||||||
<a href="http://http://openv.wikispaces.com/">http://openv.wikispaces.com/</a><br><br>
|
<a href="http://openv.wikispaces.com/">http://openv.wikispaces.com/</a><br><br>
|
||||||
|
|
||||||
Additionaly you need to know Memory-Adresses for the div. heating types (e.g. V200KW1, VScotHO1, VPlusHO1 ....),<br>
|
Additionaly you need to know Memory-Adresses for the div. heating types (e.g. V200KW1, VScotHO1, VPlusHO1 ....),<br>
|
||||||
that will be read by the module to get the measurements or to set the actual state.<br>
|
that will be read by the module to get the measurements or to set the actual state.<br>
|
||||||
Additional information you will fin in the forum <a href="http://http://openv.wikispaces.com/">http://openv.wikispaces.com/</a> and on the following wiki page <a href="http://http://openv.wikispaces.com/">http://openv.wikispaces.com/</a><br><br><br>
|
Additional information you will find in the forum <a href="http://forum.fhem.de/index.php/topic,20280.0.html">http://forum.fhem.de/index.php/topic,20280.0.html</a> und auf der wiki Seite <a href="http://www.fhemwiki.de/wiki/Vitotronic_200_%28Viessmann_Heizungssteuerung%29">http://www.fhemwiki.de/wiki/Vitotronic_200_%28Viessmann_Heizungssteuerung%29</a><br><br><br>
|
||||||
|
|
||||||
<a name="VCONTROLdefine"><b>Define</b></a>
|
<a name="VCONTROLdefine"><b>Define</b></a>
|
||||||
<ul>
|
<ul>
|
||||||
@ -1222,13 +1242,13 @@ sub VCONTROL_TimerConv($$){
|
|||||||
get <name> CONFIG<br><br>
|
get <name> CONFIG<br><br>
|
||||||
reload the module specific configfile<br><br>
|
reload the module specific configfile<br><br>
|
||||||
|
|
||||||
More commands will be configured in the configuartion file.
|
More commands will be configured in the configuration file.
|
||||||
</ul>
|
</ul>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<a name="VCONTROLparameter"><b>configfile</b></a>
|
<a name="VCONTROLparameter"><b>configfile</b></a>
|
||||||
<ul>
|
<ul>
|
||||||
You will find Examples for the configuration file for the heating types V200KW1, VScotHO1, VPlusHO1 on the wiki page <a href="http://http://openv.wikispaces.com/">http://openv.wikispaces.com/</a>.<br><br>
|
You will find example configuration files for the heating types V200KW1, VScotHO1, VPlusHO1 on the wiki page <a href="http://www.fhemwiki.de/wiki/Vitotronic_200_%28Viessmann_Heizungssteuerung%29">http://www.fhemwiki.de/wiki/Vitotronic_200_%28Viessmann_Heizungssteuerung%29</a>.<br><br>
|
||||||
|
|
||||||
The lines of the configuration file can have the following structure:<br><br>
|
The lines of the configuration file can have the following structure:<br><br>
|
||||||
|
|
||||||
@ -1434,7 +1454,7 @@ sub VCONTROL_TimerConv($$){
|
|||||||
<ul>
|
<ul>
|
||||||
Im configfile hat man nun die folgenden Konfigurations Möglichkeiten.<br><br>
|
Im configfile hat man nun die folgenden Konfigurations Möglichkeiten.<br><br>
|
||||||
|
|
||||||
Beispieldateien f¨r die Geräte-Typen V200KW1, VScotHO1, VPlusHO1 sind auf der wiki Seite <a href="http://http://openv.wikispaces.com/">http://openv.wikispaces.com/</a> zu finden.<br><br>
|
Beispieldateien f¨r die Geräte-Typen V200KW1, VScotHO1, VPlusHO1 sind auf der wiki Seite <a href="http://www.fhemwiki.de/wiki/Vitotronic_200_%28Viessmann_Heizungssteuerung%29">http://www.fhemwiki.de/wiki/Vitotronic_200_%28Viessmann_Heizungssteuerung%29</a> zu finden.<br><br>
|
||||||
|
|
||||||
<li>Zeilen die mit "#" beginnen sind Kommentar!<br></li>
|
<li>Zeilen die mit "#" beginnen sind Kommentar!<br></li>
|
||||||
<li>Polling Commandos (POLL) zum Lesen von Werten können konfiguriert werden.<br></li>
|
<li>Polling Commandos (POLL) zum Lesen von Werten können konfiguriert werden.<br></li>
|
||||||
|
Loading…
Reference in New Issue
Block a user