Vbus: Unterschied zwischen den Versionen
(Die Seite wurde neu angelegt: „{{Infobox Modul |Name=THZ |ModPurpose=Anbindung Heizungssteuerung über einen Resol V-Bus Lanadapter |ModType=d <!-- |ModCategory= (noch?) nicht verwendet -->…“) |
Keine Bearbeitungszusammenfassung |
||
Zeile 22: | Zeile 22: | ||
==== Benutzte Dateien ==== | ==== Benutzte Dateien ==== | ||
Code der VBUSIF.pm Datei | |||
<pre> | |||
# $Id: 19_VBUSIF.pm 20160725 2016-07-25 03:54:15Z awk+pejonp $ | |||
# VBUS LAN Adapter Device | |||
# | |||
# (c) 2014 Arno Willig <akw@bytefeed.de> | |||
# (c) 2015 Frank Wurdinger <frank@wurdinger.de> | |||
# (c) 2015 Adrian Freihofer <adrian.freihofer gmail com> | |||
package main; | |||
use strict; | |||
use warnings; | |||
use POSIX; | |||
use Data::Dumper; | |||
use Device::SerialPort; | |||
sub VBUSIF_Read($@); | |||
sub VBUSIF_Write($$$); | |||
sub VBUSIF_Ready($); | |||
sub VBUSIF_getDevList($$); | |||
sub VBUSIF_Initialize($) | |||
{ | |||
my ($hash) = @_; | |||
require "$attr{global}{modpath}/FHEM/DevIo.pm"; | |||
# Provider | |||
$hash->{ReadFn} = "VBUSIF_Read"; | |||
$hash->{WriteFn} = "VBUSIF_Write"; | |||
$hash->{ReadyFn} = "VBUSIF_Ready"; | |||
$hash->{UndefFn} = "VBUSIF_Undef"; | |||
$hash->{ShutdownFn} = "VBUSIF_Undef"; | |||
# Normal devices | |||
$hash->{DefFn} = "VBUSIF_Define"; | |||
$hash->{AttrList} = "dummy:1,0" | |||
."$readingFnAttributes "; | |||
$hash->{AutoCreate} = { "VBUSDEF.*" => { ATTR => "event-min-interval:.*:120 event-on-change-reading:.* ",FILTER => "%NAME"} }; | |||
} | |||
###################################### | |||
sub VBUSIF_Define($$) | |||
{ | |||
my ($hash, $def) = @_; | |||
my @a = split("[ \t]+", $def); | |||
if(@a != 3) { | |||
my $msg = "wrong syntax: define <name> VBUSIF [<hostname:7053> or <dev>]"; | |||
Log3 $hash, 2, $msg; | |||
return $msg; | |||
} | |||
# if(@a != 3) { | |||
# return "wrong syntax: define <name> VBUSIF [<hostname:7053> or <dev>]"; | |||
# } | |||
my $name = $a[0]; | |||
my $dev = $a[2]; | |||
$hash->{Clients} = ":VBUSDEV:"; | |||
my %matchList = ( "1:VBUSDEV" => ".*" ); | |||
$hash->{MatchList} = \%matchList; | |||
Log3 $hash, 4,"$name: VBUSIF_Define: $hash->{MatchList} "; | |||
DevIo_CloseDev($hash); | |||
$hash->{DeviceName} = $dev; | |||
my @dev_name = split('@', $dev); | |||
if ( -c ${dev_name}[0]) { | |||
$hash->{DeviceType} = "Serial"; | |||
} else { | |||
$hash->{DeviceType} = "Net"; | |||
} | |||
my $ret = DevIo_OpenDev($hash, 0, "VBUSIF_DoInit"); | |||
return $ret; | |||
} | |||
############################### | |||
sub VBUSIF_DoInit($) | |||
{ | |||
my $hash = shift; | |||
if ($hash->{DeviceType} eq "Net" ) { | |||
my $name = $hash->{NAME}; | |||
delete $hash->{HANDLE}; # else reregister fails / RELEASE is deadly | |||
my $conn = $hash->{TCPDev}; | |||
$conn->autoflush(1); | |||
$conn->getline(); | |||
$conn->write("PASS vbus\n"); | |||
$conn->getline(); | |||
$conn->write("DATA\n"); | |||
$conn->getline(); | |||
} | |||
Log3 $hash, 4,"VBUSIF_DoInit "; | |||
return undef; | |||
} | |||
sub VBUSIF_Undef($@) | |||
{ | |||
my ($hash, $arg) = @_; | |||
if ($hash->{DeviceType} eq "Net" ) { | |||
VBUSIF_Write($hash, "QUIT\n", ""); # RELEASE | |||
} | |||
DevIo_CloseDev($hash); | |||
return undef; | |||
} | |||
sub VBUSIF_Write($$$) | |||
{ | |||
my ($hash,$fn,$msg) = @_; | |||
DevIo_SimpleWrite($hash, $msg, 1); | |||
} | |||
sub VBUSIF_Read($@) | |||
{ | |||
my ($hash, $local, $regexp) = @_; | |||
my $buf = ($local ? $local : DevIo_SimpleRead($hash)); | |||
return "" if(!defined($buf)); | |||
my $name = $hash->{NAME}; | |||
$buf = unpack('H*', $buf); | |||
my $data = ($hash->{PARTIAL} ? $hash->{PARTIAL} : ""); | |||
$data .= $buf; | |||
my $msg; | |||
my $idx; | |||
$idx = index($data,"aa"); | |||
Log3 $hash, 4,"$name: VBUSIF_Read: index = $data"; | |||
if ($idx>=0) { | |||
$data = substr($data,$idx); # Cut off beginning | |||
$idx = index($data,"aa",2); # Find next message | |||
if ($idx>0) { | |||
$msg = substr($data,0,$idx); | |||
$data = substr($data,$idx); | |||
my $protoVersion = substr($msg,10,2); | |||
Log3 $hash, 4,"$name: VBUSIF_Read: protoVersion : $protoVersion"; | |||
if ($protoVersion == "10" && length($msg)>=20) { | |||
my $frameCount = hex(substr($msg,16,2)); | |||
my $headerCRC = hex(substr($msg,18,2)); | |||
my $crc = 0; | |||
for (my $j = 1; $j<=8;$j++) { | |||
$crc += hex(substr($msg,$j*2,2)); | |||
} | |||
$crc = ($crc ^ 0xff) & 0x7f; | |||
if ($headerCRC != $crc) { | |||
Log3 $hash, 3, "$name: Wrong checksum: $crc != $headerCRC"; | |||
} else { | |||
my $len = 20+12*$frameCount; | |||
#if ($len != length($msg)) { | |||
if ($len != length($msg) && length($msg) != 247) { | |||
Log3 $hash, 4,"$name: Wrong message length: $len != ".length($msg); | |||
} else { | |||
if(length($msg) == 247) { | |||
$msg = $msg."a"; | |||
} | |||
my $payload = VBUSIF_DecodePayload($hash,$msg); | |||
if (defined $payload) { | |||
$msg = substr($msg,0,20).$payload; | |||
$hash->{"${name}_MSGCNT"}++; | |||
$hash->{"${name}_TIME"} = TimeNow(); | |||
$hash->{RAWMSG} = $msg; | |||
my %addvals = (RAWMSG => $msg); | |||
Dispatch($hash, $msg, \%addvals) if($init_done); | |||
} | |||
} | |||
} | |||
} | |||
if ($protoVersion == "20") { | |||
my $command = substr($msg,14,2).substr($msg,12,2); | |||
my $dataPntId = substr($msg,16,4); | |||
my $dataPntVal = substr($msg,20,8); | |||
my $septet = substr($msg,28,2); | |||
my $checksum = substr($msg,30,2); | |||
# TODO use septet | |||
# TODO validate checksum | |||
# TODO Understand protocol | |||
} | |||
} | |||
} | |||
$hash->{PARTIAL} = $data; | |||
# return $msg if(defined($local)); | |||
return undef; | |||
} | |||
sub VBUSIF_Ready($) | |||
{ | |||
my ($hash) = @_; | |||
return DevIo_OpenDev($hash, 1, "VBUSIF_DoInit") if($hash->{STATE} eq "disconnected"); | |||
return 0; | |||
} | |||
sub VBUSIF_DecodePayload($@) | |||
{ | |||
my ($hash, $msg) = @_; | |||
my $name = $hash->{NAME}; | |||
my $frameCount = hex(substr($msg,16,2)); | |||
my $payload = ""; | |||
for (my $i = 0; $i < $frameCount; $i++) { | |||
my $septet = hex(substr($msg,28+$i*12,2)); | |||
my $frameCRC = hex(substr($msg,30+$i*12,2)); | |||
my $crc = (0x7f - $septet) & 0x7f; | |||
for (my $j = 0; $j<4;$j++) { | |||
my $ch = hex(substr($msg,20+$i*12+$j*2,2)); | |||
$ch |= 0x80 if ($septet & (1 << $j)); | |||
$crc = ($crc - $ch) & 0x7f; | |||
$payload .= chr($ch); | |||
} | |||
if ($crc != $frameCRC) { | |||
Log3 $hash, 4,"$name: Wrong checksum: $crc != $frameCRC"; | |||
return undef; | |||
} | |||
} | |||
return unpack('H*', $payload); | |||
} | |||
1; | |||
=pod | |||
=begin html | |||
<a name="VBUSIF"></a> | |||
<h3>VBUSIF</h3> | |||
<ul> | |||
This module connects to the RESOL VBUS LAN or Serial Port adapter. | |||
It serves as the "physical" counterpart to the <a href="#VBUSDevice">VBUSDevice</a> | |||
devices. | |||
<br /><br /> | |||
<a name="VBUSIF_Define"></a> | |||
<b>Define</b> | |||
<ul> | |||
<code>define <name> VBUS <device></code> | |||
<br /> | |||
<br /> | |||
<device> is a <host>:<port> combination, where | |||
<host> is the address of the RESOL LAN Adapter and <port> 7053. | |||
<br /> | |||
Examples: | |||
<ul> | |||
<code>define vbus VBUSIF 192.168.1.69:7053</code> | |||
</ul> | |||
<ul> | |||
<code>define vbus VBUSIF /dev/ttyS0</code> | |||
</ul> | |||
</ul> | |||
<br /> | |||
</ul> | |||
=end html | |||
=cut | |||
</pre> | |||
https://github.com/pejonp/vbus | https://github.com/pejonp/vbus | ||
== Installation RESOL VBUS LAN Gateway == | |||
# Erstmal keine Einstellungen am VBUS/Lan Gateway (Passwort/Port etc) vornehmen | |||
# Die Ip_adresse herausfinden (z.B. am Router) und prüfen ob man per Browser darauf zugreifen kann | |||
# Optional: Testen ob Daten ankommen mit der service center Software von Resol | |||
# Dann nur das VBUSIF als define eintragen | |||
== Definition == | |||
define <name> VBUSIF <IP des VBus-Lan> <Port muss 7053 bleiben> | |||
<pre> | |||
define vbus VBUSIF 192.168.1.25:7053 | |||
attr vbus event-min-interval .*:120 | |||
attr vbus verbose 5 | |||
</pre> | |||
== Features / Funktionen == | == Features / Funktionen == | ||
Zeile 65: | Zeile 353: | ||
== Bekannte Probleme == | == Bekannte Probleme == |
Version vom 10. November 2016, 21:29 Uhr
Vbus | |
---|---|
Zweck / Funktion | |
Anbindung Heizungssteuerung über einen Resol V-Bus Lanadapter | |
Allgemein | |
Typ | Gerätemodul |
Details | |
Dokumentation | EN / DE |
Support (Forum) | Sonstige Systeme |
Modulname | 21_VBUSDEV.pm |
Ersteller | |
Wichtig: sofern vorhanden, gilt im Zweifel immer die (englische) Beschreibung in der commandref! |
Kurzbeschreibung
Das Vbus-Modul verbindet einen Vbus-Lan adapter mit FHEM.
Voraussetzung
Voraussetzung zur Anbindung eines VBus Device an FHEM ist das eine Netzwerkverbindung besteht die zur Verfügung stehenden Module:
19_VBUSIF.pm 21_VBUSDEV.pm
genutzt werden. Diese Dateien müssen in den Ordner /opt/fhem/FHEM kopiert werden und es findet keine aktualisierung beim Update statt.
Benutzte Dateien
Code der VBUSIF.pm Datei
# $Id: 19_VBUSIF.pm 20160725 2016-07-25 03:54:15Z awk+pejonp $ # VBUS LAN Adapter Device # # (c) 2014 Arno Willig <akw@bytefeed.de> # (c) 2015 Frank Wurdinger <frank@wurdinger.de> # (c) 2015 Adrian Freihofer <adrian.freihofer gmail com> package main; use strict; use warnings; use POSIX; use Data::Dumper; use Device::SerialPort; sub VBUSIF_Read($@); sub VBUSIF_Write($$$); sub VBUSIF_Ready($); sub VBUSIF_getDevList($$); sub VBUSIF_Initialize($) { my ($hash) = @_; require "$attr{global}{modpath}/FHEM/DevIo.pm"; # Provider $hash->{ReadFn} = "VBUSIF_Read"; $hash->{WriteFn} = "VBUSIF_Write"; $hash->{ReadyFn} = "VBUSIF_Ready"; $hash->{UndefFn} = "VBUSIF_Undef"; $hash->{ShutdownFn} = "VBUSIF_Undef"; # Normal devices $hash->{DefFn} = "VBUSIF_Define"; $hash->{AttrList} = "dummy:1,0" ."$readingFnAttributes "; $hash->{AutoCreate} = { "VBUSDEF.*" => { ATTR => "event-min-interval:.*:120 event-on-change-reading:.* ",FILTER => "%NAME"} }; } ###################################### sub VBUSIF_Define($$) { my ($hash, $def) = @_; my @a = split("[ \t]+", $def); if(@a != 3) { my $msg = "wrong syntax: define <name> VBUSIF [<hostname:7053> or <dev>]"; Log3 $hash, 2, $msg; return $msg; } # if(@a != 3) { # return "wrong syntax: define <name> VBUSIF [<hostname:7053> or <dev>]"; # } my $name = $a[0]; my $dev = $a[2]; $hash->{Clients} = ":VBUSDEV:"; my %matchList = ( "1:VBUSDEV" => ".*" ); $hash->{MatchList} = \%matchList; Log3 $hash, 4,"$name: VBUSIF_Define: $hash->{MatchList} "; DevIo_CloseDev($hash); $hash->{DeviceName} = $dev; my @dev_name = split('@', $dev); if ( -c ${dev_name}[0]) { $hash->{DeviceType} = "Serial"; } else { $hash->{DeviceType} = "Net"; } my $ret = DevIo_OpenDev($hash, 0, "VBUSIF_DoInit"); return $ret; } ############################### sub VBUSIF_DoInit($) { my $hash = shift; if ($hash->{DeviceType} eq "Net" ) { my $name = $hash->{NAME}; delete $hash->{HANDLE}; # else reregister fails / RELEASE is deadly my $conn = $hash->{TCPDev}; $conn->autoflush(1); $conn->getline(); $conn->write("PASS vbus\n"); $conn->getline(); $conn->write("DATA\n"); $conn->getline(); } Log3 $hash, 4,"VBUSIF_DoInit "; return undef; } sub VBUSIF_Undef($@) { my ($hash, $arg) = @_; if ($hash->{DeviceType} eq "Net" ) { VBUSIF_Write($hash, "QUIT\n", ""); # RELEASE } DevIo_CloseDev($hash); return undef; } sub VBUSIF_Write($$$) { my ($hash,$fn,$msg) = @_; DevIo_SimpleWrite($hash, $msg, 1); } sub VBUSIF_Read($@) { my ($hash, $local, $regexp) = @_; my $buf = ($local ? $local : DevIo_SimpleRead($hash)); return "" if(!defined($buf)); my $name = $hash->{NAME}; $buf = unpack('H*', $buf); my $data = ($hash->{PARTIAL} ? $hash->{PARTIAL} : ""); $data .= $buf; my $msg; my $idx; $idx = index($data,"aa"); Log3 $hash, 4,"$name: VBUSIF_Read: index = $data"; if ($idx>=0) { $data = substr($data,$idx); # Cut off beginning $idx = index($data,"aa",2); # Find next message if ($idx>0) { $msg = substr($data,0,$idx); $data = substr($data,$idx); my $protoVersion = substr($msg,10,2); Log3 $hash, 4,"$name: VBUSIF_Read: protoVersion : $protoVersion"; if ($protoVersion == "10" && length($msg)>=20) { my $frameCount = hex(substr($msg,16,2)); my $headerCRC = hex(substr($msg,18,2)); my $crc = 0; for (my $j = 1; $j<=8;$j++) { $crc += hex(substr($msg,$j*2,2)); } $crc = ($crc ^ 0xff) & 0x7f; if ($headerCRC != $crc) { Log3 $hash, 3, "$name: Wrong checksum: $crc != $headerCRC"; } else { my $len = 20+12*$frameCount; #if ($len != length($msg)) { if ($len != length($msg) && length($msg) != 247) { Log3 $hash, 4,"$name: Wrong message length: $len != ".length($msg); } else { if(length($msg) == 247) { $msg = $msg."a"; } my $payload = VBUSIF_DecodePayload($hash,$msg); if (defined $payload) { $msg = substr($msg,0,20).$payload; $hash->{"${name}_MSGCNT"}++; $hash->{"${name}_TIME"} = TimeNow(); $hash->{RAWMSG} = $msg; my %addvals = (RAWMSG => $msg); Dispatch($hash, $msg, \%addvals) if($init_done); } } } } if ($protoVersion == "20") { my $command = substr($msg,14,2).substr($msg,12,2); my $dataPntId = substr($msg,16,4); my $dataPntVal = substr($msg,20,8); my $septet = substr($msg,28,2); my $checksum = substr($msg,30,2); # TODO use septet # TODO validate checksum # TODO Understand protocol } } } $hash->{PARTIAL} = $data; # return $msg if(defined($local)); return undef; } sub VBUSIF_Ready($) { my ($hash) = @_; return DevIo_OpenDev($hash, 1, "VBUSIF_DoInit") if($hash->{STATE} eq "disconnected"); return 0; } sub VBUSIF_DecodePayload($@) { my ($hash, $msg) = @_; my $name = $hash->{NAME}; my $frameCount = hex(substr($msg,16,2)); my $payload = ""; for (my $i = 0; $i < $frameCount; $i++) { my $septet = hex(substr($msg,28+$i*12,2)); my $frameCRC = hex(substr($msg,30+$i*12,2)); my $crc = (0x7f - $septet) & 0x7f; for (my $j = 0; $j<4;$j++) { my $ch = hex(substr($msg,20+$i*12+$j*2,2)); $ch |= 0x80 if ($septet & (1 << $j)); $crc = ($crc - $ch) & 0x7f; $payload .= chr($ch); } if ($crc != $frameCRC) { Log3 $hash, 4,"$name: Wrong checksum: $crc != $frameCRC"; return undef; } } return unpack('H*', $payload); } 1; =pod =begin html <a name="VBUSIF"></a> <h3>VBUSIF</h3> <ul> This module connects to the RESOL VBUS LAN or Serial Port adapter. It serves as the "physical" counterpart to the <a href="#VBUSDevice">VBUSDevice</a> devices. <br /><br /> <a name="VBUSIF_Define"></a> <b>Define</b> <ul> <code>define <name> VBUS <device></code> <br /> <br /> <device> is a <host>:<port> combination, where <host> is the address of the RESOL LAN Adapter and <port> 7053. <br /> Examples: <ul> <code>define vbus VBUSIF 192.168.1.69:7053</code> </ul> <ul> <code>define vbus VBUSIF /dev/ttyS0</code> </ul> </ul> <br /> </ul> =end html =cut
https://github.com/pejonp/vbus
Installation RESOL VBUS LAN Gateway
- Erstmal keine Einstellungen am VBUS/Lan Gateway (Passwort/Port etc) vornehmen
- Die Ip_adresse herausfinden (z.B. am Router) und prüfen ob man per Browser darauf zugreifen kann
- Optional: Testen ob Daten ankommen mit der service center Software von Resol
- Dann nur das VBUSIF als define eintragen
Definition
define <name> VBUSIF <IP des VBus-Lan> <Port muss 7053 bleiben>
define vbus VBUSIF 192.168.1.25:7053 attr vbus event-min-interval .*:120 attr vbus verbose 5
Features / Funktionen
Es wurden die Module
- DL 2 0050
- DL 3 0053
- Vitosolic200_SD4 1060
- DeltaSol_SL 2251
- WMZ 4010
- SKSC1/2 4211
- DeltaSolC 4212
- Sonnenkraft_SKSC2HE 4214
- DeltaSol_BS4 4278
- DeltaSol_BS_2009 427b
- DeltaTherm_FK 5611
- MSR65_1 6521
- MSR65_2 6522
- SKS3HE 7160
- SKSC3HE_[HK1] 7161
- SKSC3HE_[HK2] 7162
- DeltaSol_M 7311
- DeltaSol_M_HKM 7312
- DeltaSol_M_Volumen 7315
- DeltaSol_M_WMZ1 7316
- DeltaSol_M_WMZ2 7317
- Vitosolic200 7321
- Vitosolic200_WMZ1 7326
- Vitosolic200_WMZ2 7327
- SLR 7331
- CitrinSLR_XT 7341
- DeltaSol_ES 7411
- DeltaSol_BX 7421
- DeltaSolE_Regler 7721
- DeltaSolE_WMZ 7722
- DiemasolC 7751
- Cosmo_Multi_Regler 7821
- Cosmo_Multi_WMZ 7822
- DeltaSol_MX_Regler 7E11
- DeltaSol_MX_Module 7E12
- DeltaSol_MX_HK 7E21
- DeltaSol_MX_WMZ 7E31
Bekannte Probleme
Aktuell ist es nicht möglich die Konfiguration der Steuerungen zu ändern es ist nur ein Abfragen der werte implementiert.
Weblinks
- Resol Protokollbeschreibung [1]