]> git.basschouten.com Git - openhab-addons.git/commitdiff
[homematic] Some fixes and support for new device versions (#10438)
authorMartin Herbst <develop@mherbst.de>
Sun, 4 Apr 2021 17:04:37 +0000 (19:04 +0200)
committerGitHub <noreply@github.com>
Sun, 4 Apr 2021 17:04:37 +0000 (19:04 +0200)
* 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>
14 files changed:
bundles/org.openhab.binding.homematic/README.md
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/common/HomematicConfig.java
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/parser/CommonRpcParser.java
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/server/BinRpcNetworkService.java
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/server/XmlRpcServer.java
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/handler/HomematicBridgeHandler.java
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/handler/HomematicThingHandler.java
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/misc/HomematicConstants.java
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/model/HmDevice.java
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/type/MetadataUtils.java
bundles/org.openhab.binding.homematic/src/main/resources/OH-INF/thing/bridge.xml
bundles/org.openhab.binding.homematic/src/main/resources/homematic/batteries.properties
bundles/org.openhab.binding.homematic/src/main/resources/homematic/extra-descriptions.properties
bundles/org.openhab.binding.homematic/src/main/resources/homematic/extra-descriptions_de.properties

index d0724f662fe2113e8b42003a3736d5f27ee74906..7d2e06ba52d8a38c465796c4c307c95cf00c196c 100644 (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
 
index f8ca3f7bc06c8383ca90b0bd1e409dc5a644eac2..9936668541d133d415f0244c1545f4e85242f71a 100644 (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);
     }
 }
index 2196ea2ce216fa70c6afecb570bc1d9daa46cd47..1c2179e428177fdc4fa32496a0ef8e3f222834ca 100644 (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) {
index b01817fb2ea65940d32faa7efe77ffb80059fc56..8d69f3c6f65305c17b98c8d6ea45f5d887a4ef9b 100644 (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) {
 
index 375363561f7eda03b47dad2b9da54e44e3b73d99..a6b2171098f0baeead4b19e228e00898f8f3aa12 100644 (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);
 
index dd69e1b5e7cb4262fe39333bdc480f2f057dc494..a7f49b0f5a0005fcc3c28dc9c38d8617ee63477a 100644 (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 {
index 05bcf0048d87588f5007c46651fba8366d949a8c..ae09a2d2b799abad276860f3f33cd8d5a15f96ae 100644 (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;
 
index bebcb052405ccf9a576f8f98aea15e061ec246d8..d1560204afbe4d72f649014ab09816bf9bdf1e06 100644 (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";
index abd814f5beb6bb7a56f558882091b31ec2a7a72d..36626549a199766f741005f4cd6760025d51aa17 100644 (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;
     }
 
     /**
index 75e182667e8e1bcf99a79463f4ab2d59987f0173..f288b83963954ce4cc9fc682aa98e87aeb3fd76f 100644 (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;
                 }
index cd8d9b8bd1705134705523efe34c37213795eddd..468b5aa6704284555d4edd4ea3a59dd03f679cd2 100644 (file)
                                <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
index 3cebb5a73e16bc8b64c721f6889c829c28c46a4c..2aa2c6c1aefe298ec197bcd633624f25c2384e36 100644 (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
index a8b345d23780b10948e856cabb83c09dc8bafdfa..75630cfa14edf88fb400c0fb008b4368129bb839 100644 (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
index 92ab34f0597ef999bbc7cd2e707bda248aa98de1..9a6b4893223c3df9a70c0b4ba2f58b53ace5a494 100644 (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