2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 19:36:02 +00:00

36_Vallox: Changed read procedure. Added attributes. Changed default DeviceID.

git-svn-id: https://svn.fhem.de/fhem/trunk@14535 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Skjall 2017-06-18 10:38:40 +00:00
parent b6324d528d
commit c625ff99fc
2 changed files with 447 additions and 352 deletions

View File

@ -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.
- bugfix: 36_Vallox: Changed read. Added attributes. Changed DeviceID.
- bugfix: MQTT: undef patch - bugfix: MQTT: undef patch
- bugfix: ESPEasy: added missing event command (Forum #73291) - bugfix: ESPEasy: added missing event command (Forum #73291)
- bugfix: YAMAHA_AVR: use DSP-based commands for RX-V2065 - bugfix: YAMAHA_AVR: use DSP-based commands for RX-V2065

View File

@ -5,7 +5,7 @@
# #
# @Author Skjall # @Author Skjall
# @Created 21.07.2016 10:18:23 # @Created 21.07.2016 10:18:23
# @Version 1.2.0 # @Version 1.3.0
# #
# The modul reads and writes parameters via RS485 from and to a Vallox # The modul reads and writes parameters via RS485 from and to a Vallox
# ventilation bus. # ventilation bus.
@ -253,8 +253,9 @@ my %Vallox_multiReadingTable_digit = (
################################## ##################################
# Initialize Buffer fillings # Initialize Buffer fillings
################################## ##################################
my $bufferTemp = "00";
my $bufferRead = "00"; my $bufferRead = "00";
my $bufferDevIO = "00";
my $bufferDebug = "--";
################################## ##################################
# basic get commands # basic get commands
@ -282,7 +283,7 @@ sub Vallox_CreateMsg ($@)
my ($hash, $readingIdentifier) = @_; my ($hash, $readingIdentifier) = @_;
my $domain = hex "0x".AttrVal($hash->{NAME}, "ValloxIDDomain", "01"); # Domain (1 by default) my $domain = hex "0x".AttrVal($hash->{NAME}, "ValloxIDDomain", "01"); # Domain (1 by default)
my $sender = hex "0x".AttrVal($hash->{NAME}, "ValloxIDFHEM", "22"); # ID of this FHEM my $sender = hex "0x".AttrVal($hash->{NAME}, "ValloxIDFHEM", "2F"); # ID of this FHEM
my $receiver = hex "0x".AttrVal($hash->{NAME}, "ValloxIDCentral", "11"); # ID of the central my $receiver = hex "0x".AttrVal($hash->{NAME}, "ValloxIDCentral", "11"); # ID of the central
my $datatype = hex "0x".$readingIdentifier; my $datatype = hex "0x".$readingIdentifier;
@ -311,11 +312,43 @@ sub Vallox_ValidateStream ($@)
my $checksum = ($domain + $sender + $receiver + $data_1 + $data_2) % 0x100; my $checksum = ($domain + $sender + $receiver + $data_1 + $data_2) % 0x100;
if (lc($domain) eq 01 && lc(sprintf("%02x", $domain).sprintf("%02x", $sender).sprintf("%02x", $receiver).sprintf("%02x", $data_1).sprintf("%02x", $data_2).sprintf("%02x", $checksum)) eq lc($bufferRead)) { #++$hash->{"CheckCount"};
if (
lc($domain) eq 01 &&
lc(sprintf("%02x", $domain).sprintf("%02x", $sender).sprintf("%02x", $receiver).sprintf("%02x", $data_1).sprintf("%02x", $data_2).sprintf("%02x", $checksum)) eq lc($bufferRead)
) {
#Log3 ($name, 5, "Vallox: Debug: DO ".$domain." - SE ".$sender." - RE ".$receiver." - D1 ".$data_1." - D2 ".$data_2." - CS ".$checksum." NE ".$bufferRead); #Log3 ($name, 5, "Vallox: Debug: DO ".$domain." - SE ".$sender." - RE ".$receiver." - D1 ".$data_1." - D2 ".$data_2." - CS ".$checksum." NE ".$bufferRead);
#++$hash->{"MessageCount"};
#$hash->{"BufferDatagramRatio"} = "1 : ".$hash->{"CheckCount"} / $hash->{"MessageCount"};
if ((
(
$sender >= 17 &&
$sender <= 31
) || (
$sender >= 33 &&
$sender <= 47
)
) && (
(
$receiver >= 16 &&
$receiver <= 31
) || (
$receiver >= 32 &&
$receiver <= 47
)
)) {
return 1; return 1;
} else { } else {
#Log3 ($name, 5, "Vallox: Debug: DO ".$domain." - SE ".$sender." - RE ".$receiver." - D1 ".$data_1." - D2 ".$data_2." - CS ".$checksum." NE ".$bufferRead);
++$hash->{"ErrorCount"};
return 2;
}
} else {
Log3 ($name, 4, "Vallox: Debug: DO ".$domain." - SE ".$sender." - RE ".$receiver." - D1 ".$data_1." - D2 ".$data_2." - CS ".$checksum." NE ".$bufferRead);
return 0; return 0;
} }
} }
@ -364,7 +397,7 @@ Vallox_Initialize($)
# $hash->{ReadyFn} = "Vallox_Ready"; # $hash->{ReadyFn} = "Vallox_Ready";
$hash->{ShutdownFn} = "Vallox_Shutdown"; $hash->{ShutdownFn} = "Vallox_Shutdown";
$hash->{AttrList} = "ValloxIDDomain ValloxIDFHEM ValloxIDCentral ".$readingFnAttributes; $hash->{AttrList} = "ValloxBufferDebug:0,1 ValloxForceBroadcast:0,1 ValloxIDDomain ValloxIDFHEM ValloxIDCentral ".$readingFnAttributes;
} }
@ -475,9 +508,10 @@ sub Vallox_Set($@)
return "\"set Vallox\" needs at least an argument" if ( @a < 2 ); return "\"set Vallox\" needs at least an argument" if ( @a < 2 );
my $domain = hex "0x".AttrVal($hash->{NAME}, "ValloxIDDomain", "01"); # Domain (1 by default) my $domain = hex "0x".AttrVal($hash->{NAME}, "ValloxIDDomain", "01"); # Domain (1 by default)
my $sender = hex "0x".AttrVal($hash->{NAME}, "ValloxIDFHEM", "22"); # ID of this FHEM my $sender = hex "0x".AttrVal($hash->{NAME}, "ValloxIDFHEM", "2F"); # ID of this FHEM
my $receiver = hex "0x".AttrVal($hash->{NAME}, "ValloxIDCentral", "11"); # ID of the central my $receiver = hex "0x".AttrVal($hash->{NAME}, "ValloxIDCentral", "11"); # ID of the central
my $name = shift @a; my $name = shift @a;
my $cmd = shift @a; my $cmd = shift @a;
my $arg = shift @a; my $arg = shift @a;
@ -538,6 +572,19 @@ sub Vallox_Set($@)
DevIo_SimpleWrite ($hash,$msg,1); DevIo_SimpleWrite ($hash,$msg,1);
Log3 ($name, 3, "Vallox: Command ".$msg." has been sent."); Log3 ($name, 3, "Vallox: Command ".$msg." has been sent.");
if (AttrVal($hash->{NAME}, "ValloxForceBroadcast", "0") == 1) {
$checksum = ($domain + $sender + 0x10 + $datatype + $datavalue) % 0x100;
$msg = lc(sprintf("%02x", $domain).sprintf("%02x", $sender). 10 .sprintf("%02x", $datatype).sprintf("%02x", $datavalue).sprintf("%02x", $checksum));
DevIo_SimpleWrite ($hash,$msg,1);
Log3 ($name, 3, "Vallox: Broadcast-Command ".$msg." has been sent.");
$checksum = ($domain + $sender + 0x20 + $datatype + $datavalue) % 0x100;
$msg = lc(sprintf("%02x", $domain).sprintf("%02x", $sender). 20 .sprintf("%02x", $datatype).sprintf("%02x", $datavalue).sprintf("%02x", $checksum));
DevIo_SimpleWrite ($hash,$msg,1);
Log3 ($name, 3, "Vallox: Broadcast-Command ".$msg." has been sent.");
}
return undef; return undef;
} }
@ -572,20 +619,43 @@ sub Vallox_Read($)
my $fineReadingValue = 1; my $fineReadingValue = 1;
my $bufferDebugName = AttrVal($hash->{NAME}, "ValloxBufferDebug", "0");
# read from serial device # read from serial device
my $buf = DevIo_SimpleRead($hash); my $buf = DevIo_SimpleRead($hash);
return "" if ( !defined($buf) ); return "" if ( !defined($buf) );
# Convert read data to hex and fill buffer # Convert read data to hex and add to debug if nessecary
$bufferTemp = unpack ('H*', $buf); if ($bufferDebugName eq 1) {
$hash->{"BufferDebug"} .= unpack ('H*', $buf);
}
$bufferRead .= $bufferTemp; # Convert read data to hex and fill DevIO-Buffer
$bufferDevIO .= unpack ('H*', $buf);
# DO Run Validation until DevIO-Buffer is less than 2 chars long
do {
# If DevIO-Buffer is filled add difference to 14 Chars to ReadBuffer and remove it from DevIO-Buffer
if (length($bufferDevIO) >= 2) {
my $bufferReadSpace = 14 - length($bufferRead);
$bufferRead .= substr($bufferDevIO,0,$bufferReadSpace);
$bufferDevIO = substr($bufferDevIO,$bufferReadSpace);
}
#$hash->{"BufferDevIOLength"} = length($bufferDevIO);
# Once ReadBuffer filled up, remove first Byte
if (length($bufferRead) >= 14) { if (length($bufferRead) >= 14) {
$bufferRead = substr($bufferRead,2,12); $bufferRead = substr($bufferRead,2,12);
} }
if (Vallox_ValidateStream($hash)) { # If ReadBuffer has valid length start validating content
if (length($bufferRead) == 12) {
if (Vallox_ValidateStream($hash) == 1) {
Log3 ($name, 5, "Vallox: Buffer: ".$bufferRead); Log3 ($name, 5, "Vallox: Buffer: ".$bufferRead);
my $datagram = uc($bufferRead); my $datagram = uc($bufferRead);
@ -614,6 +684,10 @@ sub Vallox_Read($)
# Convert Temperatures by the Vallox_temperatureTable # Convert Temperatures by the Vallox_temperatureTable
} elsif ($rawReadingType eq "32" || $rawReadingType eq "33" || $rawReadingType eq "34" || $rawReadingType eq "35" || $rawReadingType eq "A4" || $rawReadingType eq "A7" || $rawReadingType eq "A8" || $rawReadingType eq "AF") { } elsif ($rawReadingType eq "32" || $rawReadingType eq "33" || $rawReadingType eq "34" || $rawReadingType eq "35" || $rawReadingType eq "A4" || $rawReadingType eq "A7" || $rawReadingType eq "A8" || $rawReadingType eq "AF") {
$fineReadingValue = $Vallox_temperatureTable{$rawReadingValue}; $fineReadingValue = $Vallox_temperatureTable{$rawReadingValue};
if (($rawReadingType eq "32" || $rawReadingType eq "33" || $rawReadingType eq "34" || $rawReadingType eq "35") && $fineReadingValue < -40) {
Log3 ($name, 4, "Vallox: Incoming Status-Info (Temperature) invalid: $datagram ($fineReadingValue deg.)");
return;
}
Log3 ($name, 4, "Vallox: Incoming Status-Info (Temperature): $datagram ($fineReadingValue deg.)"); Log3 ($name, 4, "Vallox: Incoming Status-Info (Temperature): $datagram ($fineReadingValue deg.)");
# Convert Percentages by the Vallox_percentageTable # Convert Percentages by the Vallox_percentageTable
@ -791,7 +865,7 @@ sub Vallox_Read($)
Vallox_readingsBulkUpdateMultiReading($hash, $rawReadingType, "FilterGuardIndicator", 4); #RO Vallox_readingsBulkUpdateMultiReading($hash, $rawReadingType, "FilterGuardIndicator", 4); #RO
Vallox_readingsBulkUpdateMultiReading($hash, $rawReadingType, "HeatingIndicator", 5); #RO Vallox_readingsBulkUpdateMultiReading($hash, $rawReadingType, "HeatingIndicator", 5); #RO
Vallox_readingsBulkUpdateMultiReading($hash, $rawReadingType, "FaultIndicator", 6); #RO Vallox_readingsBulkUpdateMultiReading($hash, $rawReadingType, "FaultIndicator", 6); #RO
Vallox_readingsBulkUpdateMultiReading($hash, $rawReadingType, "ServiceReminderIndicator", 7); #RO Vallox_readingsBulkUpdateMultiReading($hash, $rawReadingType, "ServiceReminderIndicator", 7);
readingsEndUpdate($hash, 1); readingsEndUpdate($hash, 1);
@ -855,7 +929,7 @@ sub Vallox_Read($)
if (substr($Vallox_datatypes{$rawReadingType},0,4) eq "Temp") { if (substr($Vallox_datatypes{$rawReadingType},0,4) eq "Temp") {
# If HRC is in Bypass - Efficiency is 0 # If HRC is in Bypass - Efficiency is 0
if (ReadingsVal($name,"DamperMotorPosition",0) == 1) { if (ReadingsVal($name,"DamperMotorPosition",1) == 1) {
readingsSingleUpdate($hash,"EfficiencyIn", 0, 1); readingsSingleUpdate($hash,"EfficiencyIn", 0, 1);
readingsSingleUpdate($hash,"EfficiencyOut", 0, 1); readingsSingleUpdate($hash,"EfficiencyOut", 0, 1);
readingsSingleUpdate($hash,"EfficiencyAverage", 0, 1); readingsSingleUpdate($hash,"EfficiencyAverage", 0, 1);
@ -936,9 +1010,13 @@ sub Vallox_Read($)
} else { } else {
Log3 ($name, 5, "Vallox: Incoming Status-Request: $datagram"); Log3 ($name, 5, "Vallox: Incoming Status-Request: $datagram");
} }
} } elsif (Vallox_ValidateStream($hash) == 2) {
Log3 ($name, 4, "Vallox: Invalid Status-Request: $bufferRead");
} }
}
} while (length($bufferDevIO) >= 2);
}
sub Vallox_Shutdown($) sub Vallox_Shutdown($)
{ {
my ($hash) = @_; my ($hash) = @_;
@ -1032,11 +1110,19 @@ sub Vallox_Shutdown($)
</li><br> </li><br>
<li><code>ValloxIDFHEM &lt; HexValue &gt;</code> <li><code>ValloxIDFHEM &lt; HexValue &gt;</code>
<br> <br>
HexValue is a 2-digit hex number to identify the &QUOT;address&QUOT; of this system as a virtual control terminal. (22 by default)<br> HexValue is a 2-digit hex number to identify the &QUOT;address&QUOT; of this system as a virtual control terminal. (2F by default)<br>
In a normal installation control terminals are in the scope 21 to 29 and are addressed with 20 for broadcast-messages.<br> In a normal installation control terminals are in the scope 21 to 29 and are addressed with 20 for broadcast-messages.<br>
The address must be unique.<br> The address must be unique.<br>
The &QUOT;panel address&QUOT; of the physical control terminal can be set on the settings of it. Possible values are 1-15 which is the second digit of the Hex-Value (1-F). The first digit is always 2.<br> The &QUOT;panel address&QUOT; of the physical control terminal can be set on the settings of it. Possible values are 1-15 which is the second digit of the Hex-Value (1-F). The first digit is always 2.<br>
The physical control terminal is usually 21. The physical control terminal is usually 21.
</li><br>
<li><code>ValloxBufferDebug &lt; 0/1 &gt;</code>
<br>
When 1, modul creates an Internal which fills with the raw Hex-Data from the bus. DEBUG ONLY! (0 by default).
</li><br>
<li><code>ValloxForceBroadcast &lt; 0/1 &gt;</code>
<br>
When 1, modul sends commands not only to the central ventilation unit (11) but to all possible addresses by broadcast (10/20). This is sometimes nessecary for older systems. (0 by default).
</li><br> </li><br>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>
@ -1110,7 +1196,7 @@ sub Vallox_Shutdown($)
<br> <br>
<a name="Valloxattr"></a> <a name="Valloxattr"></a>
<b>Attributes</b> <b>Attribute</b>
<ul><li><code>ValloxIDDomain &lt; HexWert &gt;</code> <ul><li><code>ValloxIDDomain &lt; HexWert &gt;</code>
<br> <br>
HexWert ist eine 2-stellige Hex-Zahl die als &QUOT;Adresse&QUOT; der Bus-Dom&auml;ne dient. (Standard: 01). HexWert ist eine 2-stellige Hex-Zahl die als &QUOT;Adresse&QUOT; der Bus-Dom&auml;ne dient. (Standard: 01).
@ -1118,16 +1204,24 @@ sub Vallox_Shutdown($)
<li><code>ValloxIDCentral &lt; HexWert &gt;</code> <li><code>ValloxIDCentral &lt; HexWert &gt;</code>
<br> <br>
HexWert ist eine 2-stellige Hex-Zahl die als &QUOT;Adresse&QUOT; der zentralen Ventilationseinheit dient. (Standard: 11).<br> HexWert ist eine 2-stellige Hex-Zahl die als &QUOT;Adresse&QUOT; der zentralen Ventilationseinheit dient. (Standard: 11).<br>
In einer normalen Umgebung werden die Ventilationseinheiten mit 11 - 1F adressiert. 10 ist die Broadcast-Adresse.<br>X In einer normalen Umgebung werden die Ventilationseinheiten mit 11 - 1F adressiert. 10 ist die Broadcast-Adresse.<br>
</li><br> </li><br>
<li><code>ValloxIDFHEM &lt; HexWert &gt;</code> <li><code>ValloxIDFHEM &lt; HexWert &gt;</code>
<br> <br>
HexWert ist eine 2-stellige Hex-Zahl die als &QUOT;Adresse&QUOT; dieses Systems als virtuelles Kontrollterminal dient. (Standard: 22).<br> HexWert ist eine 2-stellige Hex-Zahl die als &QUOT;Adresse&QUOT; dieses Systems als virtuelles Kontrollterminal dient. (Standard: 2F).<br>
Sie darf nicht bereits im Bus genutzt werden.<br> Sie darf nicht bereits im Bus genutzt werden.<br>
In einer normalen Umgebung werden die Kontrollterminals mit 21 - 2F adressiert. 20 ist die Broadcast-Adresse.<br> In einer normalen Umgebung werden die Kontrollterminals mit 21 - 2F adressiert. 20 ist die Broadcast-Adresse.<br>
In den Einstellungen der physikalisch vorhandenen Terminals kann die &QUOT;FBD-Adresse&QUOT; des jeweiligen Terminals eingestellt werden.<br> In den Einstellungen der physikalisch vorhandenen Terminals kann die &QUOT;FBD-Adresse&QUOT; des jeweiligen Terminals eingestellt werden.<br>
Hierbei stehen die Werte 1-15 zur Verf&uuml;gung, was der zweiten Stelle dieser Adresse (1-F) entspricht. Die erste Stelle ist immer 2.<br> Hierbei stehen die Werte 1-15 zur Verf&uuml;gung, was der zweiten Stelle dieser Adresse (1-F) entspricht. Die erste Stelle ist immer 2.<br>
Das physikalische Kontrollterminal ist &uuml;blicherweise die 21. Das physikalische Kontrollterminal ist &uuml;blicherweise die 21.
</li><br>
<li><code>ValloxBufferDebug &lt; 0/1 &gt;</code>
<br>
Wenn 1, erzeugt das Modul ein Internal in welches die rohen Hex-Daten aus dem Bus herein geschrieben. NUR ZUM DEBUGGEN! (Standard: 0).
</li><br>
<li><code>ValloxForceBroadcast &lt; 0/1 &gt;</code>
<br>
Wenn 1, sendet das Modul die Befehle nicht nur an die zentrale Ventilationseinheit (11), sondern auch an alle Broadcast-Adressen (10/20). Dies ist manchmal bei &auml;lteren Anlagen notwendig, wenn sich die Anzeige auf den Kontrollterminals nicht mit aktualisiert. (Standard: 0).
</li><br> </li><br>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>