forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-import froeling binding and rework for 2.5.0 compat
- Loading branch information
Showing
22 changed files
with
1,514 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?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"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.froeling</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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Froeling Binding | ||
|
||
The Froeling binding is used for reading data from Froeling furnace controllers. | ||
|
||
## Supported Bridges | ||
|
||
Serial-LAN converter | ||
|
||
## Supported Things | ||
|
||
Froeling P3200 controller (Bridge connected to COM1) | ||
|
||
## Discovery | ||
|
||
Discovery is not implemented. | ||
|
||
## Binding Configuration | ||
|
||
No binding configuration required. | ||
|
||
## Thing Configuration | ||
|
||
The Serial-LAN converter bridge needs ip address and telnet port of the Serial-LAN converter. | ||
The Froeling controller thing needs controller type, COM-port of the Froeling furnace controller and a polling interval. | ||
|
||
## Channels | ||
|
||
* **thing** `froeling` | ||
* **channel** `status` (String) | ||
* **channel** `furnacetemperature-current` (Number) | ||
* **channel** `exhaustgastemperature-current` (Number) | ||
* **channel** `furnacecontrolvariable` (Number) | ||
* **channel** `primaryair` (Number) | ||
* **channel** `remainoxygen` (Number) | ||
* **channel** `oxygencontroller` (Number) | ||
* **channel** `secondaryair` (Number) | ||
* **channel** `idfan-setpoint` (Number) | ||
* **channel** `idfan-current` (Number) | ||
* **channel** `exhaustgastemperature-setpoint` (Number) | ||
* **channel** `slidein-current` (Number) | ||
* **channel** `pellet` (Number) | ||
* **channel** `fillinglevel` (Number) | ||
* **channel** `intakespeed` (Number) | ||
* **channel** `deliverypower` (Number) | ||
* **channel** `sensor-1` (Number) | ||
* **channel** `furnacetemperature-setpoint` (Number) | ||
* **channel** `sensor-buffertop` (Number) | ||
* **channel** `sensor-bufferbottom` (Number) | ||
* **channel** `bufferpump` (Number) | ||
* **channel** `sensor-boiler` (Number) | ||
* **channel** `sensor-flow1` (Number) | ||
* **channel** `sensor-flow2` (Number) | ||
* **channel** `heatingcircuitpump1` (Number) | ||
* **channel** `heatingcircuitpump2` (Number) | ||
* **channel** `outdoortemperature` (Number) | ||
* **channel** `collectortemperature` (Number) | ||
* **channel** `operatinghours` (Number) | ||
* **channel** `error` (String) | ||
* **channel** `lastupdate` (DateTime) | ||
|
||
## Full Example | ||
|
||
Items: | ||
``` | ||
String FROELING_Status "Status: [%s]" <icon> (Froeling) { channel="froeling:controller:812d9fcb:status" } | ||
String FROELING_Error "Error: [%s]" <icon> (Froeling) { channel="froeling:controller:812d9fcb:error" } | ||
Number FROELING_Exhaustgastemperature "Exhaustgastemperature: [%d °C]" <icon> (Froeling) { channel="froeling:controller:812d9fcb:exhaustgastemperature-current" } | ||
Number FROELING_Furnacetemperature "Furnacetemperature: [%d °C]" <icon> (Froeling) { channel="froeling:controller:812d9fcb:furnacetemperature-current" } | ||
Number FROELING_Slidein_current "Slidein: [%d %%]" <icon> (Froeling) { channel="froeling:controller:812d9fcb:slidein-current" } | ||
DateTime FROELING_Lastupdate "Last update: [%1$tY-%1$tm-%1$td %1$tT]" <clock> (Froeling) { channel="froeling:controller:812d9fcb:lastupdate" } | ||
``` | ||
812d9fcb = Controller ID as shown in PaperUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.froeling</artifactId> | ||
|
||
<name>openHAB Add-ons :: Bundles :: froeling Binding</name> | ||
|
||
</project> |
9 changes: 9 additions & 0 deletions
9
bundles/org.openhab.binding.froeling/src/main/feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.froeling-${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-froeling" description="froeling Binding" version="${project.version}"> | ||
<feature>openhab-runtime-base</feature> | ||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.froeling/${project.version}</bundle> | ||
</feature> | ||
</features> |
145 changes: 145 additions & 0 deletions
145
....binding.froeling/src/main/java/org/openhab/binding/froeling/handler/IPBridgeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/** | ||
* 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.froeling.handler; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
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.froeling.internal.config.IPBridgeConfiguration; | ||
import org.openhab.binding.froeling.internal.net.TelnetSession; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The {@link IPBridgeHandler} is responsible for communicating with | ||
* a Serial-LAN converter. | ||
* | ||
* @author Daniel Hillenbrand - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class IPBridgeHandler extends BaseBridgeHandler { | ||
|
||
private Logger logger = LoggerFactory.getLogger(IPBridgeHandler.class); | ||
private TelnetSession session = null; | ||
IPBridgeConfiguration config = getThing().getConfiguration().as(IPBridgeConfiguration.class); | ||
|
||
public IPBridgeHandler(Bridge bridge) { | ||
super(bridge); | ||
this.session = new TelnetSession(); | ||
} | ||
|
||
@Override | ||
public void handleCommand(ChannelUID channelUID, Command command) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void initialize() { | ||
this.scheduler.schedule(new Runnable() { | ||
@Override | ||
public void run() { | ||
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; | ||
} | ||
|
||
if (config.getPort() <= 0) { | ||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, | ||
"bridge port not specified"); | ||
return; | ||
} | ||
} | ||
}, 0, TimeUnit.SECONDS); | ||
} | ||
|
||
public synchronized void connect() { | ||
if (this.session != null) { | ||
if (this.session.isConnected()) { | ||
this.logger.info("Already connected to the bridge"); | ||
return; | ||
} | ||
} else { | ||
this.logger.info("TelnetSession is null, creating new session"); | ||
this.session = new TelnetSession(); | ||
} | ||
this.logger.info("Connecting to bridge at {}:{}", config.getIpAddress(), config.getPort()); | ||
try { | ||
this.session.open(config.getIpAddress(), config.getPort()); | ||
} catch (IOException e) { | ||
this.logger.error("Failed to connect to bridge at {}:{}", config.getIpAddress(), config.getPort()); | ||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "failed to connect"); | ||
} | ||
this.logger.debug("Connected to bridge at {}:{}", config.getIpAddress(), config.getPort()); | ||
updateStatus(ThingStatus.ONLINE); | ||
} | ||
|
||
public boolean isConnected() { | ||
if (this.session != null) { | ||
this.logger.info("Bridge state: {}", this.session.isConnected()); | ||
return this.session.isConnected(); | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
public synchronized void disconnect() { | ||
this.logger.info("Disconnecting from bridge"); | ||
try { | ||
if (this.session != null) { | ||
this.session.close(); | ||
} | ||
} catch (Exception e) { | ||
this.logger.error("Error disconnecting from bridge", e); | ||
} | ||
} | ||
|
||
private synchronized void reconnect() { | ||
this.logger.info("Attempting to reconnect to the bridge"); | ||
disconnect(); | ||
connect(); | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
disconnect(); | ||
} | ||
|
||
public String readInput() throws IOException { | ||
String buffer = ""; | ||
if (this.session != null) { | ||
if (!this.session.isConnected()) { | ||
reconnect(); | ||
} else { | ||
buffer = this.session.readline(); | ||
} | ||
} | ||
return buffer; | ||
} | ||
} |
Oops, something went wrong.