00_THZ.pm: wait time introduced for old firmwares

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@8071 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
immiimmi 2015-02-22 18:29:33 +00:00
parent 3258f2b391
commit c3c928f858

View File

@ -2,7 +2,7 @@
# 00_THZ # 00_THZ
# $Id$ # $Id$
# by immi 02/2015 # by immi 02/2015
my $thzversion = "0.135"; my $thzversion = "0.136";
# this code is based on the hard work of Robert; I just tried to port it # this code is based on the hard work of Robert; I just tried to port it
# http://robert.penz.name/heat-pump-lwz/ # http://robert.penz.name/heat-pump-lwz/
######################################################################################## ########################################################################################
@ -843,6 +843,7 @@ sub THZ_Set($@){
last if ((@$parsingrule[$i]->[0]) =~ m/$cmd/); last if ((@$parsingrule[$i]->[0]) =~ m/$cmd/);
$i++; $i++;
} }
select(undef, undef, undef, 0.25);
} }
else { else {
$msg = $cmdHex2 . "0000"; $msg = $cmdHex2 . "0000";
@ -872,7 +873,7 @@ sub THZ_Set($@){
#$err=undef; #$err=undef;
if (defined($err)) { return ($cmdHex2 . "-". $msg ."--" . $err);} if (defined($err)) { return ($cmdHex2 . "-". $msg ."--" . $err);}
else { else {
select(undef, undef, undef, 0.05); select(undef, undef, undef, 0.5);
$msg=THZ_Get($hash, $name, $cmd); $msg=THZ_Get($hash, $name, $cmd);
#take care of program of the week #take care of program of the week
given ($a[1]) { given ($a[1]) {
@ -943,7 +944,7 @@ sub THZ_Get($@){
my ($seconds, $microseconds) = gettimeofday(); my ($seconds, $microseconds) = gettimeofday();
$seconds= abs($seconds - time_str2num(ReadingsTimestamp($name, $parent, "1970-01-01 01:00:00"))); $seconds= abs($seconds - time_str2num(ReadingsTimestamp($name, $parent, "1970-01-01 01:00:00")));
my $risultato=ReadingsVal($name, $parent, 0); my $risultato=ReadingsVal($name, $parent, 0);
$risultato=THZ_Get($hash, $name, $parent) if ($seconds > 29 ); #update of the parent: if under 29sec use the current value $risultato=THZ_Get($hash, $name, $parent) if ($seconds > 15 ); #update of the parent: if under 20sec use the current value
my $parenthash=$gets{$parent}; my $parsingrule = $parsinghash{$parenthash->{type}}; my $parenthash=$gets{$parent}; my $parsingrule = $parsinghash{$parenthash->{type}};
my $i=0; my $i=0;
for (@$parsingrule) { for (@$parsingrule) {
@ -1003,6 +1004,9 @@ sub THZ_Get_Comunication($$) {
Log3 $hash->{NAME}, 5, "THZ_Get_Comunication: Check if port is open. State = '($hash->{STATE})'"; Log3 $hash->{NAME}, 5, "THZ_Get_Comunication: Check if port is open. State = '($hash->{STATE})'";
if (!(($hash->{STATE}) eq "opened")) { return("closed connection", "");} if (!(($hash->{STATE}) eq "opened")) { return("closed connection", "");}
#slow down for old firmwares
select(undef, undef, undef, 0.25) if ((AttrVal($hash->{NAME}, "firmware" , "new") eq "2.06") or (AttrVal($hash->{NAME}, "firmware" , "new") eq "2.14"));
THZ_Write($hash, "02"); # step1 --> STX start of text THZ_Write($hash, "02"); # step1 --> STX start of text
($err, $msg) = THZ_ReadAnswer($hash); ($err, $msg) = THZ_ReadAnswer($hash);
#Expectedanswer1 is "10" DLE data link escape #Expectedanswer1 is "10" DLE data link escape