Skip to content

Commit

Permalink
re-import resol binding and rework for 2.5.0 compat
Browse files Browse the repository at this point in the history
resol: switch to vbus-0.3.0

resol: fix compilation errors
  • Loading branch information
codeworkx committed Sep 24, 2019
1 parent 4088272 commit 3b989e5
Show file tree
Hide file tree
Showing 21 changed files with 1,130 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
/bundles/org.openhab.binding.pulseaudio/ @peuter
/bundles/org.openhab.binding.pushbullet/ @hakan42
/bundles/org.openhab.binding.regoheatpump/ @crnjan
/bundles/org.openhab.binding.resol/ @codeworkx

This comment has been minimized.

Copy link
@ramack

ramack Sep 24, 2019

@codeworkx do you know, that I work(ed) on a generic resol binding, that supports "all" solar controllers and "all" channels supported by them (by dynamic channel creation) with device discovery? See https://github.com/ramack/openhab2-addons/tree/master/addons/binding/org.openhab.binding.resol it is not yet cleaned up and therefore I didn't yet submit a PR against the main repo, but it is in production use by me and some other users. I planned to continue the development, but as it is working and available on the marketplace my priorities shifted a little to my heliosventilation binding.

So let me know if you think we can join forces or feel free to just take what I have done and generalize your binding. With what you have I see the issue, that it is quite some effort to add support for a new device, especially if it has many channels (like my DeltaSol MX).

This comment has been minimized.

Copy link
@codeworkx

codeworkx Sep 25, 2019

Author Owner

@ramack Yes, found it yesterday. When i get some time i'll migrate to your solution and help to improve it if needed.

This comment has been minimized.

Copy link
@ramack

ramack Sep 25, 2019

Ok great. If I can help with something let me know.

This comment has been minimized.

Copy link
@codeworkx

codeworkx Sep 25, 2019

Author Owner

Was easier than expected. Detected it as "SKSC2 HE [Regler]" which is correct.
Looks good so far. Thank you.

This comment has been minimized.

Copy link
@ramack

ramack Sep 25, 2019

sounds good. I have had documented some open tasks as issues in my fork I guess some (like ramack#6) will be solve implicitly and some might be kept as future feature requests. Nevertheless it might be worth to look at those.

/bundles/org.openhab.binding.rfxcom/ @martinvw @paulianttila
/bundles/org.openhab.binding.rme/ @kgoderis
/bundles/org.openhab.binding.robonect/ @reyem
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,11 @@
<artifactId>org.openhab.binding.regoheatpump</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.resol</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.rfxcom</artifactId>
Expand Down
33 changes: 33 additions & 0 deletions bundles/org.openhab.binding.resol/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="lib" path="lib/vbus-0.3.0-SNAPSHOT.jar"/>
</classpath>
23 changes: 23 additions & 0 deletions bundles/org.openhab.binding.resol/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.resol</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.resol/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab2-addons
77 changes: 77 additions & 0 deletions bundles/org.openhab.binding.resol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Resol Binding

The Resol binding is used for reading data from Resol solar controllers.

## Supported Bridges

VBus-LAN converter

## Supported Things

Following Resol controllers connected via VBus-LAN converter:
4214 - Sonnenkraft SKSC2
427B - DeltaSol BS 2009

## Discovery

Discovery is not implemented.

## Binding Configuration

No binding configuration required.

## Thing Configuration

The VBus-LAN converter bridge needs ip address of the VBus-LAN converter.
The Resol controller thing needs just a polling interval.

## Channels

* **thing** `resol`
* **channel** `temperature-s1` (Number)
* **channel** `temperature-s2` (Number)
* **channel** `temperature-s3` (Number)
* **channel** `temperature-s4` (Number)
* **channel** `temperature-vfd1` (Number)
* **channel** `volumetricflowrate-vfd1` (Number)
* **channel** `speed-relais1` (Number)
* **channel** `speed-relais2` (Number)
* **channel** `voltage-10v` (Number)
* **channel** `errormask` (String)
* **channel** `operatinghours-relais1` (Number)
* **channel** `operatinghours-relais2` (Number)
* **channel** `heatsupplied` (Number)
* **channel** `sw-version` (String)
* **channel** `variant` (String)
* **channel** `unit-type` (String)
* **channel** `system` (String)
* **channel** `system-time` (String)
* **channel** `s1-broken` (Number)
* **channel** `s2-broken` (Number)
* **channel** `s3-broken` (Number)
* **channel** `s4-broken` (Number)
* **channel** `statusmask` (String)
* **channel** `lastupdate` (DateTime)

NOTE: Not every controller supports all Channels!

## Example

Items:
```
Number RESOL_TemperatureS1 "Temperature S1: [%.1f °C]" <temperature> (Resol) { channel="resol:controller:6d5fc064:temperature-s1" }
Number RESOL_TemperatureS2 "Temperature S2: [%.1f °C]" <temperature> (Resol) { channel="resol:controller:6d5fc064:temperature-s2" }
Number RESOL_TemperatureS3 "Temperature S3: [%.1f °C]" <temperature> (Resol) { channel="resol:controller:6d5fc064:temperature-s3" }
Number RESOL_TemperatureS4 "Temperature S4: [%.1f °C]" <temperature> (Resol) { channel="resol:controller:6d5fc064:temperature-s4" }
Number RESOL_TemperatureVFD1 "Temperature VFD1: [%.1f °C]" <temperature> (Resol) { channel="resol:controller:6d5fc064:temperature-vfd1" }
Number RESOL_VolumetricflowrateVFD1 "Volumetric flow rate VFD1: [%.1f l/h]" <settings> (Resol, Resol_Chart) { channel="resol:controller:6d5fc064:volumetricflowrate-vfd1" }
Number RESOL_Speedrelais1 "Speed relais 1: [%.1f %%]" <settings> (Resol) { channel="resol:controller:6d5fc064:speed-relais1" }
Number RESOL_Speedrelais2 "Speed relaus 2: [%.1f %%]" <settings> (Resol) { channel="resol:controller:6d5fc064:speed-relais2" }
Number RESOL_Voltage10V "Voltage: [%.1f V]" <settings> (Resol) { channel="resol:controller:6d5fc064:voltage-10v" }
String RESOL_Errormask "Error mask: [%s]" <error> (Resol) { channel="resol:controller:6d5fc064:errormask" }
Number RESOL_OperatinghoursRelais1 "Operating hours relais 1: [%.1f h]" <settings> (Resol, Resol_Chart) { channel="resol:controller:6d5fc064:operatinghours-relais1" }
Number RESOL_OperatinghoursRelais2 "Operating hours relais 2: [%.1f h]" <settings> (Resol) { channel="resol:controller:6d5fc064:operatinghours-relais2" }
Number RESOL_Heatsupplied "Heat supplied: [%.1f Wh]" <fire> (Resol) { channel="resol:controller:6d5fc064:heatsupplied" }
DateTime RESOL_Update "Last update: [%1$tY-%1$tm-%1$td %1$tT]" <clock> (Resol) { channel="resol:controller:6d5fc064:lastupdate" }
```
6d5fc064 = Controller ID as shown in PaperUI
8 changes: 8 additions & 0 deletions bundles/org.openhab.binding.resol/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source.. = src/main/java/
output.. = target/classes
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
ESH-INF/,\
lib/,\
about.html
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions bundles/org.openhab.binding.resol/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>2.5.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.resol</artifactId>

<name>openHAB Add-ons :: Bundles :: resol Binding</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.resol-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${project.version}/xml/features</repository>

<feature name="openhab-binding-resol" description="resol Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.resol/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* Copyright (c) 2010-2019 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.resol.handler;

import java.net.InetAddress;

import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.ThingStatus;
import org.eclipse.smarthome.core.thing.ThingStatusDetail;
import org.eclipse.smarthome.core.thing.binding.BaseBridgeHandler;
import org.eclipse.smarthome.core.types.Command;
import org.openhab.binding.resol.internal.config.IPBridgeConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.resol.vbus.Connection;
import de.resol.vbus.TcpDataSource;
import de.resol.vbus.TcpDataSourceProvider;

/**
* @author Daniel Hillenbrand - Initial contribution
*/
public class IPBridgeHandler extends BaseBridgeHandler {

private Logger logger = LoggerFactory.getLogger(IPBridgeHandler.class);
IPBridgeConfiguration config = getThing().getConfiguration().as(IPBridgeConfiguration.class);

private Connection connection;

public IPBridgeHandler(Bridge bridge) {
super(bridge);
// TODO Auto-generated constructor stub
}

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
// TODO Auto-generated method stub

}

@Override
public void initialize() {
updateStatus(ThingStatus.ONLINE);
if (config == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "bridge configuration missing");
return;
}

if (StringUtils.isEmpty(config.getIpAddress())) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "bridge address not specified");
return;
}
}

public Connection connect() {
connection = null;
try {
// Create a connection to a LAN-enabled VBus device
TcpDataSource dataSource = TcpDataSourceProvider
.fetchInformation(InetAddress.getByName(config.getIpAddress()), 500);
dataSource.setLivePassword("vbus");
connection = dataSource.connectLive(0, 0x0020);

// Establish the connection
this.logger.debug("Connecting to bridge");
connection.connect();
updateStatus(ThingStatus.ONLINE);
} catch (Throwable ex) {
this.logger.debug("{}", ex);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Error while connecting to bridge");
}
return connection;
}

public void disconnect() {
try {
if (connection != null) {
this.logger.debug("Disconnecting from bridge");
connection.disconnect();
connection = null;
}
} catch (Exception e) {
this.logger.debug("{}", e);
}
}
}
Loading

0 comments on commit 3b989e5

Please sign in to comment.