[homematic] Some fixes and support for new device versions (#10438)

* Removed method that was already marked as deprecated

Signed-off-by: Martin Herbst <develop@mherbst.de>

* Handle HM-ES-TX-WM with firmware version >= 2.0 as different device

The device provides different data points (channels) depending on the
firmware version. Therefore devices with a firmware version >= 2.0 are
handled as a different device.

Fixes #9793

Signed-off-by: Martin Herbst <develop@mherbst.de>

* Don't change uninitialized thing state automatically to online

Signed-off-by: Martin Herbst <develop@mherbst.de>

* Listen to all network interfaces instead of limiting it to only one

This also makes the specification of a separate bind address
superfluous.

Fixes #9855

Fixes #10075

Signed-off-by: Martin Herbst <develop@mherbst.de>

* Add support for HmIP-eTRV-C-2 device

The event messages received for this device are not correctly formatted
and thus some special treatment for at least one data point is required.


Signed-off-by: Martin Herbst <develop@mherbst.de>

* Spotless formatting applied

Signed-off-by: Martin Herbst <develop@mherbst.de>
This commit is contained in:
Martin Herbst 2021-04-04 19:04:37 +02:00 committed by GitHub
parent 15f69b9011
commit 45ec538a40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 33 additions and 45 deletions

View File

@ -130,9 +130,6 @@ Hint for the binding to identify the gateway type (auto|ccu|noccu) (default = "a
- **callbackHost**
Callback network address of the system runtime, default is auto-discovery
- **bindAddress**
The address the XML-/BINRPC server binds to, default is value of "callbackHost"
- **xmlCallbackPort**
Callback port of the binding's XML-RPC server, default is 9125 and counts up for each additional bridge

View File

@ -46,7 +46,6 @@ public class HomematicConfig {
private int groupPort;
private String callbackHost;
private String bindAddress;
private int xmlCallbackPort;
private int binCallbackPort;
@ -88,30 +87,6 @@ public class HomematicConfig {
this.callbackHost = callbackHost;
}
/**
* Returns the bind address.
*/
public String getBindAddress() {
return bindAddress;
}
/**
* Sets the bind address.
*/
public void setBindAddress(String bindAddress) {
this.bindAddress = bindAddress;
}
/**
* Sets the callback host port.
*
* @deprecated use setBinCallbackPort
*/
@Deprecated
public void setCallbackPort(int callbackPort) {
this.binCallbackPort = callbackPort;
}
/**
* Returns the XML-RPC callback host port.
*/
@ -404,11 +379,11 @@ public class HomematicConfig {
@Override
public String toString() {
return String.format(
"%s[gatewayAddress=%s,callbackHost=%s,bindAddress=%s,xmlCallbackPort=%d,binCallbackPort=%d,"
"%s[gatewayAddress=%s,callbackHost=%s,xmlCallbackPort=%d,binCallbackPort=%d,"
+ "gatewayType=%s,rfPort=%d,wiredPort=%d,hmIpPort=%d,cuxdPort=%d,groupPort=%d,timeout=%d,"
+ "discoveryTimeToLive=%d,installModeDuration=%d,socketMaxAlive=%d]",
getClass().getSimpleName(), gatewayAddress, callbackHost, bindAddress, xmlCallbackPort, binCallbackPort,
gatewayType, getRfPort(), getWiredPort(), getHmIpPort(), getCuxdPort(), getGroupPort(), timeout,
discoveryTimeToLive, installModeDuration, socketMaxAlive);
getClass().getSimpleName(), gatewayAddress, callbackHost, xmlCallbackPort, binCallbackPort, gatewayType,
getRfPort(), getWiredPort(), getHmIpPort(), getCuxdPort(), getGroupPort(), timeout, discoveryTimeToLive,
installModeDuration, socketMaxAlive);
}
}

View File

@ -16,6 +16,7 @@ import java.io.IOException;
import java.util.Objects;
import org.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.homematic.internal.misc.HomematicConstants;
import org.openhab.binding.homematic.internal.misc.MiscUtils;
import org.openhab.binding.homematic.internal.model.HmDatapoint;
import org.openhab.binding.homematic.internal.model.HmParamsetType;
@ -179,6 +180,9 @@ public abstract class CommonRpcParser<M, R> implements RpcParser<M, R> {
if (dp.getUnit() == null && dp.getName() != null && dp.getName().startsWith("RSSI_")) {
dp.setUnit("dBm");
}
// Bypass: For at least one device the CCU does not send a unit together with the value
if (dp.getUnit() == null && dp.getName().startsWith(HomematicConstants.DATAPOINT_NAME_OPERATING_VOLTAGE))
dp.setUnit("V");
HmValueType valueType = HmValueType.parse(type);
if (valueType == null || valueType == HmValueType.UNKNOWN) {

View File

@ -47,7 +47,7 @@ public class BinRpcNetworkService implements Runnable {
serverSocket = new ServerSocket();
serverSocket.setReuseAddress(true);
serverSocket.bind(new InetSocketAddress(config.getBindAddress(), config.getBinCallbackPort()));
serverSocket.bind(new InetSocketAddress(config.getBinCallbackPort()));
this.rpcResponseHandler = new RpcResponseHandler<byte[]>(listener) {

View File

@ -79,7 +79,7 @@ public class XmlRpcServer implements RpcServer {
public void start() throws IOException {
logger.debug("Initializing XML-RPC server at port {}", config.getXmlCallbackPort());
InetSocketAddress callbackAddress = new InetSocketAddress(config.getBindAddress(), config.getXmlCallbackPort());
InetSocketAddress callbackAddress = new InetSocketAddress(config.getXmlCallbackPort());
xmlRpcHTTPD = new Server(callbackAddress);
xmlRpcHTTPD.setHandler(jettyResponseHandler);

View File

@ -213,9 +213,6 @@ public class HomematicBridgeHandler extends BaseBridgeHandler implements Homemat
if (homematicConfig.getCallbackHost() == null) {
homematicConfig.setCallbackHost(this.ipv4Address);
}
if (homematicConfig.getBindAddress() == null) {
homematicConfig.setBindAddress(homematicConfig.getCallbackHost());
}
if (homematicConfig.getXmlCallbackPort() == 0) {
homematicConfig.setXmlCallbackPort(portPool.getNextPort());
} else {

View File

@ -417,6 +417,8 @@ public class HomematicThingHandler extends BaseThingHandler {
loadHomematicChannelValues(device.getChannel(0));
ThingStatus oldStatus = thing.getStatus();
if (oldStatus == ThingStatus.UNINITIALIZED)
return;
ThingStatus newStatus = ThingStatus.ONLINE;
ThingStatusDetail newDetail = ThingStatusDetail.NONE;

View File

@ -83,6 +83,7 @@ public class HomematicConstants {
public static final String DATAPOINT_NAME_CALIBRATION = "CALIBRATION";
public static final String DATAPOINT_NAME_LOWBAT_IP = "LOW_BAT";
public static final String DATAPOINT_NAME_CHANNEL_FUNCTION = "CHANNEL_FUNCTION";
public static final String DATAPOINT_NAME_OPERATING_VOLTAGE = "OPERATING_VOLTAGE";
public static final String VIRTUAL_DATAPOINT_NAME_BATTERY_TYPE = "BATTERY_TYPE";
public static final String VIRTUAL_DATAPOINT_NAME_DELETE_DEVICE_MODE = "DELETE_DEVICE_MODE";

View File

@ -19,6 +19,8 @@ import java.util.List;
import java.util.Objects;
import org.openhab.binding.homematic.internal.misc.MiscUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Object that represents a Homematic device.
@ -26,6 +28,8 @@ import org.openhab.binding.homematic.internal.misc.MiscUtils;
* @author Gerhard Riegler - Initial contribution
*/
public class HmDevice {
private final Logger logger = LoggerFactory.getLogger(HmDevice.class);
public static final String TYPE_GATEWAY_EXTRAS = "GATEWAY-EXTRAS";
public static final String ADDRESS_GATEWAY_EXTRAS = "GWE00000000";
@ -43,10 +47,15 @@ public class HmDevice {
String firmware) {
this.address = address;
this.hmInterface = hmInterface;
this.type = type;
this.firmware = firmware;
if ("HM-ES-TX-WM".equals(type) && Float.valueOf(firmware) > 2.0) {
logger.debug("Found HM-ES-TX-WM with firmware version > 2.0, creating virtual type");
this.type = type + "2";
} else {
this.type = type;
}
this.gatewayId = gatewayId;
this.homegearId = homegearId;
this.firmware = firmware;
}
/**

View File

@ -331,6 +331,9 @@ public class MetadataUtils {
return ITEM_TYPE_NUMBER + ":Energy";
case "m3":
return ITEM_TYPE_NUMBER + ":Volume";
case "":
if (dpName.startsWith(DATAPOINT_NAME_OPERATING_VOLTAGE))
return ITEM_TYPE_NUMBER + ":ElectricPotential";
case "s":
case "min":
case "minutes":
@ -338,7 +341,6 @@ public class MetadataUtils {
case "month":
case "year":
case "100%":
case "":
default:
return ITEM_TYPE_NUMBER;
}

View File

@ -37,11 +37,6 @@
<label>Callback Network Address</label>
<description>Callback network address of the runtime, default is auto-discovery</description>
</parameter>
<parameter name="bindAddress" type="text">
<context>network-address</context>
<label>Bind Address</label>
<description>The address the XML-/BINRPC server binds to, default is callbackHost</description>
</parameter>
<parameter name="xmlCallbackPort" type="integer">
<label>XML-RPC Callback Port</label>
<description>Callback port of the binding's XML-RPC server. If no value is specified, xmlCallbackPort starts with

View File

@ -82,6 +82,8 @@ HmIP-WTH=2x AAA/Micro/LR03
HmIP-WRC2=2x AAA/Micro/LR03
HmIP-eTRV=2x AA/Mignon/LR06
HmIP-eTRV-B=2x AA/Mignon/LR06
HmIP-eTRV-C=2x AA/Mignon/LR06
HmIP-eTRV-C-2=2x AA/Mignon/LR06
HmIP-SMI=2x AA/Mignon/LR06
HmIP-SPI=2x AA/Mignon/LR06
HmIP-SPDR=2x AA/Mignon/LR06

View File

@ -4,6 +4,7 @@ HM-LC-Sw1-Pl-2=Wireless Switch Actuator 1-channel, socket adapter
HM-Sec-SD-2=Wireless Smoke Detector
HM-WDS30-OT2-SM-2=Wireless Differential Temperature Sensor
HM-Sen-MDIR-O-2=Wireless Motion Detector, outdoor
HM-ES-TX-WM2=Wireless Transmitter for Energy Meter Sensor Version 2
# MAX!
BC-RT-TRX-CyN=MAX! Radiator thermostat basic
@ -30,6 +31,7 @@ HMIP-eTRV=Homematic IP Radiator thermostat
HMIP-eTRV-2=Homematic IP Radiator thermostat
HMIP-eTRV-B=Homematic IP Radiator thermostat basic
HMIP-eTRV-C=Homematic IP Radiator thermostat compact
HmIP-eTRV-C-2=Homematic IP Radiator thermostat compact
HmIP-SMI=Homematic IP motion detector with brightness sensor
HmIP-SMO=Homematic IP motion detector with brightness sensor - outdoor
HmIP-KRC4=Homematic IP Key Ring Remote Control - 4 buttons

View File

@ -4,6 +4,7 @@ HM-LC-Sw1-Pl-2=Funk-Schaltaktor 1-fach, Zwischenstecker
HM-Sec-SD-2=Funk-Rauchmelder
HM-WDS30-OT2-SM-2=Funk-Temperaturdifferenzsensor
HM-Sen-MDIR-O-2=Funk-Bewegungsmelder außen
HM-ES-TX-WM2=Funk-Sender für Energiezähler-Sensor Version 2
# MAX!
BC-RT-TRX-CyN=MAX! Heizkörperthermostat Basic
@ -30,6 +31,7 @@ HMIP-eTRV=Homematic IP Heizk
HMIP-eTRV-2=Homematic IP Heizkörperthermostat
HMIP-eTRV-B=Homematic IP Heizkörperthermostat Basis
HMIP-eTRV-C=Homematic IP Heizkörperthermostat kompakt
HmIP-eTRV-C-2=Homematic IP Heizkörperthermostat kompakt
HmIP-SMI=Homematic IP Bewegungsmelder mit Dämmerungssensor
HmIP-SMO=Homematic IP Bewegungsmelder mit Dämmerungssensor außen
HmIP-KRC4=Homematic IP Schlüsselbundfernbedienung - 4 Tasten