diff --git a/bundles/org.openhab.binding.mqtt/README.md b/bundles/org.openhab.binding.mqtt/README.md index b41323a04..02fe39128 100644 --- a/bundles/org.openhab.binding.mqtt/README.md +++ b/bundles/org.openhab.binding.mqtt/README.md @@ -28,6 +28,9 @@ Required configuration parameters are: Additionally the following parameters can be set: +* __hostnameValidated__: Validate hostname from certificate against server hostname for secure connection. Defaults to true. +* __protocol__: The protocol used for communicating with the broker (TCP, WEBSOCKETS). Defaults to TCP. +* __mqttVersion__: The MQTT version used for communicating with the broker (V3, V5). Defaults to V3. * __qos__: Quality of Service. Can be 0, 1 or 2. Please read the MQTT specification for details. Defaults to 0. * __clientID__: Use a fixed client ID. Defaults to empty which means a user ID is generated for this connection. diff --git a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java index 617050e6f..187231220 100644 --- a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java +++ b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java @@ -200,8 +200,8 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba throw new IllegalArgumentException("Host is empty!"); } - final MqttBrokerConnection connection = new MqttBrokerConnection(host, config.port, config.secure, - config.clientID); + final MqttBrokerConnection connection = new MqttBrokerConnection(config.protocol, config.mqttVersion, host, + config.port, config.secure, config.hostnameValidated, config.clientID); final String username = config.username; final String password = config.password; diff --git a/bundles/org.openhab.binding.mqtt/src/main/resources/OH-INF/i18n/mqtt.properties b/bundles/org.openhab.binding.mqtt/src/main/resources/OH-INF/i18n/mqtt.properties index 029ae60fa..dcb27b71a 100644 --- a/bundles/org.openhab.binding.mqtt/src/main/resources/OH-INF/i18n/mqtt.properties +++ b/bundles/org.openhab.binding.mqtt/src/main/resources/OH-INF/i18n/mqtt.properties @@ -26,6 +26,8 @@ thing-type.config.mqtt.broker.enableDiscovery.label = Enable Discovery thing-type.config.mqtt.broker.enableDiscovery.description = If set to true enables this broker for all discovery services. thing-type.config.mqtt.broker.host.label = Broker Hostname/IP thing-type.config.mqtt.broker.host.description = The IP/Hostname of the MQTT broker +thing-type.config.mqtt.broker.hostnameValidated.label = Hostname Validated +thing-type.config.mqtt.broker.hostnameValidated.description = Validate hostname from certificate against server hostname for secure connection. thing-type.config.mqtt.broker.keepAlive.label = Heartbeat thing-type.config.mqtt.broker.keepAlive.description = Keep alive / heartbeat timer in s. It can take up to this time to determine if a server connection is lost. A lower value may keep the broker unnecessarily busy for no or little additional value. thing-type.config.mqtt.broker.lwtMessage.label = Last Will Message @@ -39,10 +41,18 @@ thing-type.config.mqtt.broker.lwtRetain.label = Last Will Retain thing-type.config.mqtt.broker.lwtRetain.description = True if last Will should be retained (defaults to false) thing-type.config.mqtt.broker.lwtTopic.label = Last Will Topic thing-type.config.mqtt.broker.lwtTopic.description = Defaults to empty and therefore disables the last will. +thing-type.config.mqtt.broker.mqttVersion.label = MQTT Version +thing-type.config.mqtt.broker.mqttVersion.description = The MQTT version used for communicating with the broker. +thing-type.config.mqtt.broker.mqttVersion.option.V3 = Version 3 +thing-type.config.mqtt.broker.mqttVersion.option.V5 = Version 5 thing-type.config.mqtt.broker.password.label = Password thing-type.config.mqtt.broker.password.description = The MQTT password thing-type.config.mqtt.broker.port.label = Broker Port thing-type.config.mqtt.broker.port.description = The port is optional, if none is provided, the typical ports 1883 and 8883 (SSL) are used. +thing-type.config.mqtt.broker.protocol.label = Protocol +thing-type.config.mqtt.broker.protocol.description = The protocol used for communicating with the broker. +thing-type.config.mqtt.broker.protocol.option.TCP = TCP +thing-type.config.mqtt.broker.protocol.option.WEBSOCKETS = WebSockets thing-type.config.mqtt.broker.publickey.label = Public Key Hash thing-type.config.mqtt.broker.publickey.description = If **publickeypin** is set this hash is used to verify the connection. Clear to allow a new public key pinning on the next connection attempt. If empty will be filled automatically by the next successful connection. An example input would be `SHA-256:83F9171E06A313118889F7D79302BD1B7A2042EE0CFD029ABF8DD06FFA6CD9D3` thing-type.config.mqtt.broker.publickeypin.label = Public Key Pinning diff --git a/bundles/org.openhab.binding.mqtt/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mqtt/src/main/resources/OH-INF/thing/thing-types.xml index 0f9f5a68a..d818ac8b8 100644 --- a/bundles/org.openhab.binding.mqtt/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mqtt/src/main/resources/OH-INF/thing/thing-types.xml @@ -29,6 +29,35 @@ false + + + Validate hostname from certificate against server hostname for secure connection. + true + true + + + + + The protocol used for communicating with the broker. + + + + + TCP + true + + + + + The MQTT version used for communicating with the broker. + + + + + V3 + true + +