Skip to content

Commit f3bb1f7

Browse files
committed
Inital with thing structure
1 parent a788ea4 commit f3bb1f7

12 files changed

+640
-598
lines changed

optolink.xml

+165-58
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,166 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<optolink device="2033" name="300P" protocol="300">
3-
4-
<tty>/dev/ttyAMA0</tty>
5-
<ttytimeout>2000</ttytimeout> <!-- milliseconds for reading timeout tty -->
6-
<port>31113</port> <!-- unassigned Port. See: http://www.iana.org -->
7-
<interval>30</interval> <!-- Seconds to poll optolink -->
8-
9-
<!-- Addressen die von diesem "device" unterstützt werden -->
10-
11-
<telegram name="Heating.deviceId" access='r' address="00F8" type="short" />
12-
<telegram name='Heating.SystemTime' access='r' address='088E' type='date' />
13-
<telegram name='Heating.OutsideTemperature' access='r' address='0800' type='short' divider='10'/>
14-
15-
<!--# Puffer-StorageTank -->
16-
17-
<telegram name='StorageTank.HotWaterTemperature' access='r' address='0806' type='short' divider='10'/>
18-
<telegram name='StorageTank.TemperatureUp' access='r' address='0810' type='short' divider='10'/>
19-
<telegram name='StorageTank.TemperatureDown' access='r' address='0804' type='short' divider='10'/>
20-
<telegram name='StorageTank.HotWaterPump' access='r' address='0846' type='boolean' />
21-
22-
<!--# Kessel -->
23-
<telegram name='Furnace.Temperature' access='r' address='A202' type='short' divider='100'/>
24-
<telegram name='Burner.Power' access='r' address='A305' type='ubyte' divider='2'/>
25-
26-
<!-- Brennerstatus ist noch nicht klar Addresse noch gesucht -->
27-
28-
<telegram name='Burner.Status' access='r' address='0962' type='short' />
29-
<telegram name='Burner.Starts' access='r' address='088A' type='ushort'/>
30-
<telegram name='Burner.Hours' access='r' address='08A7' type='uint' divider='3600'/>
31-
<telegram name='Burner.Consumtion.Pellet' access='r' address='08B0' type='uint' divider='1000'/>
32-
<telegram name='StorageTank.LoadPump' access='r' address='0845' type='boolean' />
33-
34-
<!--# Heizkreis 1 -->
35-
<telegram name='Circuit.M1.FlowTemperature' access='r' address='2900' type='short' divider='10'/>
36-
<telegram name='Circuit.M1.Pump' access='r' address='2906' type='boolean' />
37-
<telegram name='Circuit.M1.Gradient' access='r' address='2305' type='byte' divider='10'/>
38-
<telegram name='Circuit.M1.Niveau' access='r' address='2304' type='byte'/>
39-
40-
<!--# Heizkreis 2 -->
41-
<telegram name='Circuit.M2.FlowTemperature' access='r' address='3900' type='short' divider='10'/>
42-
<telegram name='Circuit.M2.Pump' access='r' address='3906' type='boolean' />
43-
<telegram name='Circuit.M2.Gradient' access='r' address='3305' type='byte' divider='10'/>
44-
<telegram name='Circuit.M2.Niveau' access='r' address='3304' type='byte'/>
45-
46-
<!--# Solaranlage # Muss noch ueberprueft werden wenn Sonne scheint -->
47-
<telegram name='Solar.CollectorTemperature' access='r' address='6564' length='2' type='short' divider='10'/>
48-
<telegram name='Solar.StorageTankTemperature' access='r' address='6566' length='2' type='short' divider='10'/>
49-
<telegram name='Solar.Pump' access='r' address='6552' length='1' type='boolean' />
50-
<telegram name='Solar.PumpPower' access='r' address='6553' type='byte'/>
51-
<telegram name='Solar.LoadStatus' access='r' address='6551' type='boolean' />
52-
<telegram name='Solar.Hours' access='r' address='6568' type='ushort'/>
53-
<telegram name='Solar.Power' access='r' address='6560' type='uint'/>
54-
55-
<!--# Sonstiges -->
56-
57-
58-
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Mapping for vitotronic/optoling addresses to openhab thinks.
4+
5+
type = *none
6+
- will not send to openhab but it is posible to ask for this ID on the interface.
7+
- is not implemented in openhab
8+
9+
-->
10+
11+
12+
<optolink device="2033" id="300P" protocol="300">
13+
14+
<adapterID>test</adapterID> <!-- Unique ID on the Network-->
15+
<tty>/dev/ttyAMA0</tty> <!-- serial port of the optolink adapter-->
16+
<ttytimeout>2000</ttytimeout> <!-- milliseconds for reading timeout tty -->
17+
<port>31113</port> <!-- port for incomming communication. See also: http://www.iana.org -->
18+
19+
<!-- Addressen die von diesem 'device' unterst�tzt werden -->
20+
<thing type="heating" id="300p">
21+
<describtion>Viessmann Vitoligno 300P</describtion>
22+
<channel type="systemid" id="deviceId">
23+
<describtion>System ID</describtion>
24+
<telegram address="00F8" type="short"/>
25+
</channel>
26+
<channel type="systemtime" id="systemtime">
27+
<describtion>System Date and Time</describtion>
28+
<telegram address="088E" type="date" />
29+
</channel>
30+
<channel type="temperature" id="outside">
31+
<describtion>Outside Temperature</describtion>
32+
<telegram address="0800" type="short" divider="10"/>
33+
</channel>
34+
</thing>
35+
<!--# Puffer-StorageTank -->
36+
<thing type="storagetank" id="storagetank">
37+
<describtion>Hot Water Storage Tank an Buffer</describtion>
38+
<channel type="temperature" id="hotwater">
39+
<describtion>Hot water temperatur on top of the buffer.</describtion>
40+
<telegram address="0806" type="short" divider="10"/>
41+
</channel>
42+
<channel type="temperature" id="middle">
43+
<describtion>Temperature in the middle of the buffer</describtion>
44+
<telegram address="0810" type="short" divider="10"/>
45+
</channel>
46+
<channel type="temperature" id="bottom">
47+
<describtion>Temperature on the bottom of the buffer</describtion>
48+
<telegram address="0804" type="short" divider="10"/>
49+
</channel>
50+
<channel type="pump" id="hotwater">
51+
<describtion>Cirulation Pump for Hot Water</describtion>
52+
<telegram address="0846" type="boolean" />
53+
</channel>
54+
<channel type="pump" id="load">
55+
<describtion>Loading Pump for Buffer</describtion>
56+
<telegram address="0845" type="boolean" />
57+
</channel>
58+
</thing>
59+
<!--# Kessel -->
60+
61+
<!--# Burner -->
62+
<thing type="burner" id="pelletburner">
63+
<describtion>Burner/Fireplace</describtion>
64+
<channel type="temperature" id="furnace">
65+
<describtion>The furnace temperature of the burner</describtion>
66+
<telegram address="A202" type="short" divider="100"/>
67+
</channel>
68+
<channel type="power" id="Power">
69+
<describtion>The furnace Power in %</describtion>
70+
<telegram address="A305" type="ubyte" divider="2"/>
71+
</channel>
72+
<channel type="*none" id="stat">
73+
<!-- Brennerstatus ist noch nicht klar Addresse noch gesucht -->
74+
<describtion>State of Burner </describtion>
75+
<telegram address="0962" type="short" />
76+
</channel>
77+
<channel type="counter" id="starts">
78+
<describtion>Counts the number of starts sience first start of heating. </describtion>
79+
<telegram address="088A" type="ushort"/>
80+
</channel>
81+
<channel type="time" id="ontime">
82+
<describtion>On time of the burner sience first start of heating. </describtion>
83+
<telegram address="08A7" type="uint" divider="3600"/>
84+
</channel>
85+
<channel type="consumtion" id="consumtion">
86+
<describtion>Consumed Pellets since start of heating in t. </describtion>
87+
<telegram address="08B0" type="uint" divider="1000"/>
88+
</channel>
89+
</thing>
90+
<!--# Heizkreis 1 -->
91+
<thing type="circuit" id="ciruit1">
92+
<describtion>Heading Circuit of the first Floor.</describtion>
93+
<channel type="temperature" id="flow" >
94+
<describtion>Flow temperature</describtion>
95+
<telegram address="2900" type="short" divider="10"/>
96+
</channel>
97+
<channel type="pump" id="pump">
98+
<describtion></describtion>
99+
<telegram address="2906" type="boolean" />
100+
</channel>
101+
<channel type="gradient" id="gradient">
102+
<describtion>The gradient relativ to outseite temperature.</describtion>
103+
<telegram address="2305" type="byte" divider="10"/>
104+
</channel>
105+
<channel type="niveau" id="niveau" >
106+
<describtion>The niveau relativ to outseite temperature.</describtion>
107+
<telegram address="2304" type="byte"/>
108+
</channel>
109+
</thing>
110+
111+
<!--# Heizkreis 2 -->
112+
<thing type="circuit" id="ciruit2">
113+
<describtion>Heading Circuit of the first Floor.</describtion>
114+
<channel type="temperature" id="flow" >
115+
<describtion>Flow temperature</describtion>
116+
<telegram address="3900" type="short" divider="10"/>
117+
</channel>
118+
<channel type="pump" id="pump">
119+
<describtion></describtion>
120+
<telegram address="3906" type="boolean" />
121+
</channel>
122+
<channel type="gradient" id="gradient">
123+
<describtion>The gradient relativ to outseite temperature.</describtion>
124+
<telegram address="3305" type="byte" divider="10"/>
125+
</channel>
126+
<channel type="niveau" id="niveau" >
127+
<describtion>The niveau relativ to outseite temperature.</describtion>
128+
<telegram address="3304" type="byte"/>
129+
</channel>
130+
</thing>
131+
132+
<!--# Solaranlage -->
133+
<thing type="solar" id="solar">
134+
<describtion>Thermo Solar System.</describtion>
135+
<channel type="temperature" id="collector">
136+
<describtion>Collector temperature.</describtion>
137+
<telegram address="6564" length="2" type="short" divider="10"/>
138+
</channel>
139+
<channel type="temperature" id="storagetank">
140+
<describtion>Temperatur of storage tank (same storage tank bottom)</describtion>
141+
<telegram address="6566" length="2" type="short" divider="10"/>
142+
</channel>
143+
<channel type="pump" id="load">
144+
<describtion>Pump to load the storage tank from the solar panel.</describtion>
145+
<telegram address="6552" length="1" type="boolean" />
146+
</channel>
147+
<channel type="*none" id="power">
148+
<!-- unclear -->
149+
<describtion>Maybe the power of the solar pump - TODO check</describtion>
150+
<telegram address="6553" type="byte"/>
151+
</channel>
152+
<channel type="*none" id="loadstat">
153+
<!-- unclear -->
154+
<describtion></describtion>
155+
<telegram address="6551" type="boolean" />
156+
</channel>
157+
<channel type="time" id="ontime">
158+
<describtion>On time of the solar pump in hours.</describtion>
159+
<telegram address="6568" type="ushort"/>
160+
</channel>
161+
<channel type="consumtion" id="power" >
162+
<describtion>Consumed power from the sun in KW. </describtion>
163+
<telegram address="6560" type="uint"/>
164+
</channel>
165+
</thing>
59166
</optolink>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2015, Stefan Andres. All rights reserved.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the GNU Lesser General Public License
6+
* (LGPL) version 3.0 which accompanies this distribution, and is available at
7+
* http://www.gnu.org/licenses/lgpl-3.0.html
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*******************************************************************************/
14+
package de.myandres.optolink;
15+
16+
import java.io.IOException;
17+
import java.net.DatagramPacket;
18+
import java.net.DatagramSocket;
19+
import java.net.InetAddress;
20+
import java.net.SocketException;
21+
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
24+
25+
public class BroadcastListner implements Runnable {
26+
27+
static Logger log = LoggerFactory.getLogger(BroadcastListner.class);
28+
29+
static String BROADCAST_MESSAGE = "@@@@VITOTRONIC@@@@";
30+
int port;
31+
boolean isConnect;
32+
String connectedIP;
33+
34+
35+
36+
BroadcastListner(int port) {
37+
log.debug("Init Broadcast Listener on Port", port);
38+
this.port = port;
39+
isConnect = false;
40+
connectedIP = "";
41+
}
42+
43+
public void connect(String connectedIP) {
44+
this.connectedIP = connectedIP;
45+
isConnect = true;
46+
}
47+
48+
public void disconnect() {
49+
this.connectedIP = "";
50+
isConnect = false;
51+
}
52+
53+
54+
@Override
55+
public void run() {
56+
// Runs Listner
57+
log.debug("Listening for Broadcast....");
58+
DatagramSocket datagramSocket = null;
59+
InetAddress remoteIPAddress;
60+
int remotePort;
61+
byte[] byteArray = new byte[1024];
62+
63+
try {
64+
datagramSocket = new DatagramSocket(port, InetAddress.getByName("0.0.0.0"));
65+
datagramSocket.setBroadcast(true);
66+
67+
68+
String str;
69+
70+
while (true) {
71+
try {
72+
DatagramPacket resivedPacket = new DatagramPacket(byteArray , byteArray.length);
73+
datagramSocket.receive(resivedPacket);
74+
str = new String(resivedPacket.getData()).trim();
75+
log.debug("Resived Broadcast Message: {}", str);
76+
remotePort = resivedPacket.getPort();
77+
log.debug("From Port: {}", remotePort);
78+
remoteIPAddress = resivedPacket.getAddress();
79+
log.debug("From Host: {}",remoteIPAddress.toString());
80+
81+
if (str.startsWith(BROADCAST_MESSAGE)) {
82+
// Someone calls me
83+
if (!isConnect) {
84+
str = BROADCAST_MESSAGE + "[WAIT] CONNECTION";
85+
} else {
86+
str = BROADCAST_MESSAGE + "[BUSY] BY " + connectedIP;
87+
}
88+
byteArray = str.getBytes();
89+
DatagramPacket sendPacket = new DatagramPacket(byteArray,
90+
byteArray.length, remoteIPAddress, remotePort);
91+
log.debug("Send: '{}' to {}:{}", str, remoteIPAddress.getHostAddress(), remotePort );
92+
datagramSocket.send(sendPacket);
93+
94+
95+
} else {
96+
log.debug("Host: {}:{} calls with wrong message: {}",
97+
remoteIPAddress.getHostAddress(),
98+
remotePort,
99+
str);
100+
log.debug("Message will be ignor!");
101+
}
102+
103+
} catch (Exception e) {
104+
// TODO Auto-generated catch block
105+
log.error("Something is wrong in broadcast listner thread!!! Diagnostic {}", e);
106+
log.error("Broadcast Listner die - no again");
107+
108+
} }
109+
110+
} catch (Exception e) {
111+
// TODO Auto-generated catch block
112+
log.error("Something is wrong in broadcast listner thread!!! Diagnostic {}", e);
113+
log.error("Broadcast Listner die - no again");
114+
115+
} finally {
116+
try {
117+
if (datagramSocket != null)
118+
datagramSocket.close();
119+
} catch (Exception e) {
120+
// Ignore
121+
}
122+
}
123+
}
124+
125+
}

0 commit comments

Comments
 (0)