From 64a713e74acf6ea3bf6393f0722226284b71f0cd Mon Sep 17 00:00:00 2001 From: Andrew Fiddian-Green Date: Mon, 28 Sep 2020 17:27:46 +0100 Subject: [PATCH] [velux] fix concurrency bugs, other minor issues, update readme.md (replaces #8493) (#8520) Signed-off-by: Andrew Fiddian-Green --- bundles/org.openhab.binding.velux/README.md | 376 +++++++++--------- .../doc/veluxlogo.jpg | Bin 0 -> 15519 bytes .../velux/internal/VeluxBindingConstants.java | 3 + .../velux/internal/bridge/json/JClogin.java | 4 +- .../internal/bridge/json/JsonBridgeAPI.java | 52 +-- .../internal/bridge/slip/SlipBridgeAPI.java | 76 ++-- .../internal/bridge/slip/SlipVeluxBridge.java | 98 +++-- .../internal/bridge/slip/io/Connection.java | 72 ++-- .../bridge/slip/io/SSLconnection.java | 106 +++-- .../bridge/slip/utils/KLF200Response.java | 8 +- .../bridge/slip/utils/SlipEncoding.java | 4 +- .../discovery/VeluxDiscoveryService.java | 199 ++++----- .../internal/factory/VeluxHandlerFactory.java | 37 +- .../handler/ChannelBridgeWLANconfig.java | 12 +- .../internal/handler/VeluxBindingHandler.java | 10 +- .../internal/handler/VeluxBridgeHandler.java | 9 +- .../velux/internal/things/VeluxKLFAPI.java | 2 +- .../resources/OH-INF/i18n/velux.properties | 1 + .../resources/OH-INF/i18n/velux_de.properties | 1 + .../resources/OH-INF/i18n/velux_dk.properties | 1 + .../resources/OH-INF/i18n/velux_nl.properties | 1 + bundles/pom.xml | 1 + features/openhab-addons/pom.xml | 1 - 23 files changed, 588 insertions(+), 486 deletions(-) create mode 100644 bundles/org.openhab.binding.velux/doc/veluxlogo.jpg diff --git a/bundles/org.openhab.binding.velux/README.md b/bundles/org.openhab.binding.velux/README.md index 35b7ed897..df277da3c 100644 --- a/bundles/org.openhab.binding.velux/README.md +++ b/bundles/org.openhab.binding.velux/README.md @@ -5,6 +5,8 @@ This binding integrates the Velux devices with help of a gateway, the The Velux Binding interacts via the Velux Bridge with any [io-homecontrol](http://www.io-homecontrol.com/)-based devices like window openers, shutters and others. +![Velux](doc/veluxlogo.jpg) + Based on the VELUX API this binding integrates Velux and other io-homecontrol devices directly into the openHAB, avoiding the necessity of any cloud-based mediation infrastructures. The complete home-automation will work even without any Internet connectivity. For details about the features, see the following websites: @@ -12,263 +14,259 @@ For details about the features, see the following websites: - [Velux](http://www.velux.com) - [Velux API](http://www.velux.com/api/klf200) -## Overview +## Supported Things -As the API is widely open, there are several use cases which are supported by the Bridge: -From the complete configuration of a set of io-homecontrol devices including registration, naming, grouping, crypto key setup and exchange, the definition of intended settings, so called scenes, up to the control of single devices, i.e. ```open window of bathroom up to 45%```. +The binding supports the following types of Thing. -The following areas are covered: +| Thing Type | Description | Note | +|---------------|-----------------------------------------------------------------------------------|------| +| bridge | A Velux KLF200 which acts as a gateway to all Velux / IO-home controlled devices. | | +| window | A Velux / IO-home control window. | 1. | +| rollershutter | A Velux / IO-home control roller shutter. | 1. | +| actuator | Generic Velux / IO-home device. | 1. | +| scene | A Velux Scene which commands Velux / IO-home devices to specific positions. | | +| vshutter | A Velux virtual shutter. | 2. | +| information | A Thing that provides overall information about the binding itself. | | -| Topic | Details | -|-------------------------|------------------------------------------------------------------------------------------------------------| -| General bridge commands | SW version(\*), Gateway state(\*), Learn state, Clock, Reboot, FactoryReset, Network Setup(+) | -| Configuration Services | Node Discovery, Node Removal, Controller Copy, Crypto Key Generation, Crypto Key Exchange, Actuator config | -| Information Services | House Monitoring Service(\*), Node information(+), Group information | -| Activation Logging | | -| Command Handling | Command activation(\*), Command interruption(\*), Status Request(\*), Actuator Identification(\*), Limitations | -| Scene Handling | Scene definition, Scene execution(\*), Scene deletion, Scene renaming, Scene Overview(\*) | -| Physical I/O Handling | I/O Port setup | +1. Only supported in hubs with firmware v0.2.x.x or above +2. Only needed in hubs with firmware v0.1.x.x (due to note 1. above) -Items marked with (\*) are fully implemented. Items marked with (+) have only partial support. +## Discovery -## Binding Configuration +To simplify the initial provisioning, the binding provides one thing which can be found by autodiscovery. +Unfortunately there is no way to discover Velux bridges themselves within the local network. +But after configuring a Velux Bridge, it is possible to discover all scenes and actuators like windows and rollershutters in that hub. -To simplify the initial provisioning, the binding provides one thing which can be found by autodiscovery: -This thing named Velux Binding Information establishes one channel named information describing -the current binding state in a (hopefully) human understandable fashion. Additionally it will give three -properties with the version number of the bundle, the number of registered bridges and number of overall -things attached to the bridge(s). +## Thing Configuration -The Velux KLF200 bridge has to be configured with some parameters, at least with the IP address of the bridge. +### Thing Configuration for "bridge" -| Property | Default | Required | Description | -|------------------------|------------------|:--------:|--------------------------------------------------------------| -| ipAddress | | Yes | Hostname or address for accessing the Velux Bridge. | -| protocol | slip | No | Underlying communication protocol (http/https/slip). | -| tcpPort | 51200 | No | TCP port (80 or 51200) for accessing the Velux Bridge. | -| password | velux123 | No | Password for authentication against the Velux Bridge.(\*\*) | -| timeoutMsecs | 1000 | No | Initial Connection timeout in milliseconds. | -| retries | 5 | No | Number of retries during I/O. | -| refreshMsecs | 10000 | No | Refresh interval in milliseconds. | -| isBulkRetrievalEnabled | yes | No | Load all scenes and actuators in one step. | -| isSequentialEnforced | no | No | Enforce Sequential Actuator Control even for long operations.| -| isProtocolTraceEnabled | no | No | Show any protocol interaction (loglevel INFO). | +The bridge Thing connects to the KLF-200 hub (bridge) to communicate with any respective connected Velux or IO-home device Things. +It signs on to the hub using the supplied connection parameters, and it polls the hub at regular intervals to read and write the data for each connected device. +The KLF-200 supports two Application Programming Interfaces "API" (a SLIP based one, and a JSON based one), and this binding can use either of them to communicate with it. +Before the binding can communicate with the hub, the Configuration Parameters `ipAddress` and `password` must be entered. +In addition there are some optional Configuration Parameters. -(\*\*) Note: This password is the API password that is printed on the back of the unit. Normally it differs from the password of the web frontend. +| Configuration Parameter | Default | Required | Description | +|-------------------------|------------------|:--------:|--------------------------------------------------------------| +| ipAddress | | Yes | Hostname or address for accessing the Velux Bridge. | +| password | velux123 | Yes | Password for authentication against the Velux Bridge.(\*\*) | +| timeoutMsecs | 500 | No | Communication timeout in milliseconds. | +| protocol | slip | No | Underlying communication protocol (http/https/slip). | +| tcpPort | 51200 | No | TCP port (80 or 51200) for accessing the Velux Bridge. | +| retries | 5 | No | Number of retries during I/O. | +| refreshMsecs | 10000 | No | Refresh interval in milliseconds. | +| isBulkRetrievalEnabled | yes | No | Load all scenes and actuators in one step. | +| isSequentialEnforced | no | No | Enforce Sequential Actuator Control even for long operations.| +| isProtocolTraceEnabled | no | No | Show any protocol interaction (loglevel INFO). | -Advise: if you see a significant number of messages per day like +(\*\*) Note: This password is the API password that is printed on the back of the unit. +Normally it differs from the password of the web frontend. + +Advice: if you see a significant number of messages per day as follows, you should increase the parameters `retries` or/and `timeoutMsecs`... ``` communicate(): socket I/O failed continuously (x times). ``` -please increase the parameters retries or/and timeoutMsecs. - For your convenience you'll see a log entry for the recognized configuration within the log file i.e. ``` 2018-07-23 20:40:24.746 [INFO ] [.b.velux.internal.VeluxBinding] - veluxConfig[ipAddress=192.168.42.1,tcpPort=80,password=********,timeoutMsecs=2000,retries=10] ``` -The Velux Things (beside the mentioned bridge) are Velux Window, Velux Rollershutter, and a generic Velux Actuator and Velux Scene. The 1st three Things have to be configured with an identification by their serial number. +### Thing Configuration for "actuator", "window", "rollershutter" -| Property | Default | Required | Description | -|----------------|------------------------|:--------:|-----------------------------------------------------------| -| serial | | Yes | Serial number of the io-homecontrol device. | -| name | | No | (Optional) name of the io-homecontrol device. | -| inverted | false | No | Inverts any device values. | +These types of Thing only supported in the Velux Bridge in API version two or higher (firmware version > 0.2.*.*). +These types of Thing are configured by means of their serial number in the hub. +In addition there are some optional Configuration Parameters. -The fourth Thing, the Velux Scene, has to be configured with an identification by their scenename. - -| Property | Default | Required | Description | -|----------------|------------------------|:--------:|-----------------------------------------------------------| -| sceneName | | Yes | Name of the io-homecontrol configuration. | - -The fifth Thing, the Velux Virtual Shutter, has to be configured with pairs of level combined with the appropriate scenenames. - -| Property | Default | Required | Description | -|----------------|------------------------|:--------:|-----------------------------------------------------------| -| sceneLevels | | Yes | ,,,,.... | -| currentLevel | 0 | No | Inverts any device values. | - - -## Discovery - -Unfortunately there is no way to discover the Velux bridge itself within the local network. But after configuring the Velux Bridge, it is possible to discover all scenes and actuators like windows and rollershutters by the binding. - -## Item Configuration - -The Items of a Velux Bridge consists in general of a pair of mastertype and subtype definition. -In the appropriate items file, i.e. velux.items, this looks like - -``` -{ velux="thing=;channel=" } -``` - -Optionally the subtype is enhanced with parameters like the appropriate name of the scene. - -``` -{ velux="thing=;channel=#" } -``` - -| Mastertype | Description | -|---------------|----------------------------------------------------------------------------------| -| binding | Provides informations for easier configuration of this binding. | -| bridge | The Velux KLF200 represents a gateway to all Velux devices. | -| scene | Named ordered set of product states which can be activated for execution. | -| actuator | Generic IO-home controlled device which can be maintained by parameter settings. | -| window | IO-home controlled device of type window. | -| rollershutter | IO-home controlled device of type rollershutter. | -| vshutter | IO-home controlled device of type rollershutter. | - - -### Subtype - - -| Subtype | Item Type | Description | Mastertype | Parameter | -|--------------|---------------|-----------------------------------------------------------------|--------------|-----------| -| information | String | Describes the current state of the binding | binding | N/A | -| status | String | Current Bridge State (\*\*\*) | bridge | N/A | -| reload | Switch | Reload information from bridge into binding | bridge | N/A | -| timestamp | Number | Timestamp of last successful device interaction | bridge | N/A | -| doDetection | Switch | Start of the product detection mode | bridge | N/A | -| firmware | String | Software version of the Bridge | bridge | N/A | -| ipAddress | String | IP address of the Bridge | bridge | N/A | -| subnetMask | String | IP subnetmask of the Bridge | bridge | N/A | -| defaultGW | String | IP address of the Default Gateway of the Bridge | bridge | N/A | -| DHCP | Switch | Flag whether automatic IP configuration is enabled | bridge | N/A | -| WLANSSID | String | Name of the wireless network | bridge | N/A | -| WLANPassword | String | WLAN Authentication Password | bridge | N/A | -| products | String | List of all recognized products | bridge | N/A | -| scenes | String | List of all defined scenes | bridge | N/A | -| check | String | Result of the check of current item configuration | bridge | N/A | -| shutter | Rollershutter | Virtual rollershutter as combination of different scenes | bridge | required | -|--------------|---------------|-----------------------------------------------------------------|--------------|-----------| -| serial | String | IO-Homecontrol'ed device (\*\*\*\*) (\*\*\*\*\*) | actuator | required | -| position | Rollershutter | Position of the IO-Homecontrol'ed device (\*\*\*\*) | actuator | optional | -| state | Switch | State of the IO-Homecontrol'ed device | actuator | optional | -| limitMinimum | Rollershutter | Minimum position of the IO-Homecontrol'ed device (\*\*\*\*) | actuator | optional | -| limitMaximum | Rollershutter | Maximum position of the IO-Homecontrol'ed device (\*\*\*\*) | actuator | optional | -|--------------|---------------|-----------------------------------------------------------------|--------------|-----------| -| serial | String | IO-Homecontrol'ed device (\*\*\*\*) (\*\*\*\*\*) | window | required | -| position | Rollershutter | Position of the IO-Homecontrol'ed device (\*\*\*\*) | window | optional | -| limitMinimum | Rollershutter | Minimum position of the IO-Homecontrol'ed device (\*\*\*\*) | window | optional | -| limitMaximum | Rollershutter | Maximum position of the IO-Homecontrol'ed device (\*\*\*\*) | window | optional | -|--------------|---------------|-----------------------------------------------------------------|--------------|-----------| -| serial | String | IO-Homecontrol'ed device (\*\*\*\*) (\*\*\*\*\*) | rollershutter| required | -| position | Rollershutter | Position of the IO-Homecontrol'ed device (\*\*\*\*) | rollershutter| optional | -| limitMinimum | Rollershutter | Minimum position of the IO-Homecontrol'ed device (\*\*\*\*) | rollershutter| optional | -| limitMaximum | Rollershutter | Maximum position of the IO-Homecontrol'ed device (\*\*\*\*) | rollershutter| optional | -|--------------|---------------|-----------------------------------------------------------------|--------------|-----------| -| sceneName | String | Defines the scene by name according to registration in KLF200 | scene | required | -| action | Switch | Activates a set of predefined product settings | scene | optional | -| silentMode | Switch | Modification of the silent mode of the defined product settings | scene | optional | +| Configuration Parameter | Default | Required | Description | +|-------------------------|------------------------|:--------:|-------------------------------------------------------------------| +| serial | | Yes | Serial number of the io-homecontrol device in the hub. | +| name | | No | (Optional) name of the io-homecontrol device in the hub. | +| inverted | false | No | (Optional) the position is inverted (i.e. 0% translates to 100%). | Notes: -(\*\*\*) The existence of this item triggers the continuous realtime status updates of any Velux item like shutters even if they are manually controlled by other controllers. -(\*\*\*\*) To enable a complete invertion of all parameter values (i.e. for Velux windows), use the property `inverted` or add a trailing star to the eight-byte serial number. For an example, see below at item `Velux DG Window Bathroom`. +1. To enable a complete invertion of all parameter values (i.e. for Velux windows), use the property `inverted` or add a trailing star to the eight-byte serial number. For an example, see below at item `Velux DG Window Bathroom`. -(\*\*\*\*\*) Somfy devices does not provides a valid serial number to the Velux KLF200 gateway: The bridge reports a registration of the serial number 00:00:00:00:00:00:00:00. Therefore the binding implements a fallback to allow an item specification with a actuator name instead of actuator serial number whenever such an invalid serial number occurs. For an example, see below at item `Velux OG Somfy Shutter`. +2. Somfy devices do not provide a valid serial number to the Velux KLF200 gateway. The bridge reports a registration of the serial number 00:00:00:00:00:00:00:00. Therefore the binding implements a fallback to allow an item specification with a actuator `name` instead of actuator serial number whenever such an invalid serial number occurs. For an example, see below at item `Velux OG Somfy Shutter`. +### Thing Configuration for "scene" -### Subtype Parameters +The Velux Bridge in API version one (firmware version 0.1.1.*) allows activating a set of predefined actions, so called scenes. +So besides the bridge, only one real Thing type exists, namely "scene". +This type of Thing is configured by means of its scene name in the hub. -In case of the scene-related subtypes, action and silentMode, the specification of the related scene as parameters is necessary; +| Configuration Parameter | Default | Required | Description | +|-------------------------|------------------------|:--------:|-----------------------------------------------------------| +| sceneName | | Yes | Name of the scene in the hub. | -``` -{ velux="thing=scene;channel=#" } -``` +### Thing Configuration for "vshutter" -The subtype shutter requires an even pair of parameters, each defining the shutter level and the related scene: +The Velux Bridge in API version one (firmware version 0.1.1.*) does not support a real rollershutter interaction. +So besides the bridge, this binding provides a virtual rollershutter Thing consisting of different scenes which set a specific shutter level. +Therefore the respective Item definition contains multiple pairs of rollershutter levels each followed by a scene name. +The virtual shutter Thing must be configured with pairs of level (0..10%) combined with the appropriate scene names (text) as follows. -``` -{ velux="thing=brigde;channel=shutter#,,," } -``` +| Configuration Parameter | Default | Required | Description | +|-------------------------|------------------------|:--------:|-----------------------------------------------------------| +| sceneLevels | | Yes | ,,,,.... | +| currentLevel | 0 | No | Inverts any device values. | -### Rain Sensor +## Supported Channels for Thing Types -Unfortunately Velux has decided to closely integrate the rain sensor into the window device. The rain sensor is therefore not displayed in the device list. On the other hand, the 'limitMinimum' channel of a roof window now provides information about rainy weather: if it is set internally by the Velux control unit to a value other than zero, it rains. +### Channels for "bridge" Things -### Virtual shutter +The supported Channels and their associated channel types are shown below. -As the bridge with firmware version one does not support a real rollershutter interaction, this binding provides a virtual rollershutter consisting of different scenes which set a specific shutter level. Therefore the item definition contains multiple pairs of rollershutter levels each followed by a scene name, which leads to this setting. +| Channel | Data Type | Description | +|-------------|-----------|---------------------------------------------------------------------------------| +| status | String | Description of current Bridge State. | +| reload | Switch | Command to force reload of the bridge information. | +| downtime | Number | Time interval (sec) between last successful and most recent device interaction. | +| doDetection | Switch | Command to activate bridge detection mode. | +### Channels for "window", "rollershutter" Things -### Items +The supported Channels and their associated channel types are shown below. -[Sample items file for textual configuration](doc/conf/items/velux.items) +| Channel | Data Type | Description | +|--------------|---------------|-------------------------------------------------| +| position | Rollershutter | Actual position of the window or device. | +| limitMinimum | Rollershutter | Minimum limit position of the window or device. | +| limitMaximum | Rollershutter | Maximum limit position of the window or device. | -### Sitemap +### Channels for "actuator" Things -[Sample sitemaps file for textual configuration](doc/conf/sitemaps/velux.sitemap) +The supported Channels and their associated channel types are shown below. -### Rules +| Channel | Data Type | Description | +|--------------|---------------|-------------------------------------------------| +| position | Rollershutter | Actual position of the window or device. | +| state | Switch | Device control (ON, OFF). | +| limitMinimum | Rollershutter | Minimum limit position of the window or device. | +| limitMaximum | Rollershutter | Maximum limit position of the window or device. | -[Sample rules file for textual configuration](doc/conf/rules/velux.rules) +### Channels for "scene" Things + +The supported Channels and their associated channel types are shown below. + +| Channel | Data Type | Description | +|------------|-----------|----------------------------------------------------------------| +| action | Switch | Activates the scene (moves devices to their preset positions). | +| silentMode | Switch | Enables silent mode. | + +### Channels for "vshutter" Things + +The supported Channel and its associated channel type is shown below. + +| Channel | Data Type | Description | +|--------------|---------------|-----------------------------------------| +| position | Rollershutter | Position of the virtual roller shutter. | + +### Channels for "information" Thing + +The supported Channel and its associated channel type is shown below. + +| Channel | Data Type | Description | +|-------------|-----------|--------------------------------| +| information | String | Information about the binding. | + +## Rain Sensor + +Unfortunately Velux has decided to closely integrate the rain sensor into the window device. +The rain sensor is therefore not displayed in the device list. +On the other hand, the 'limitMinimum' channel of a roof window provides information about rainy weather: +If it is set internally by the Velux control unit to a value other than zero, it rains. (Joke!!) + +## Properties of the "bridge" Thing + +The bridge Thing provides the following properties. + +| Property | Description | +|-------------------|-----------------------------------------------------------------| +| check | Result of the check of current item configuration | +| connectionAttempt | Date-Time of last connection attampt | +| connectionSuccess | Date-Time of last successful connection attampt | +| defaultGW | IP address of the Default Gateway of the Bridge | +| DHCP | Flag whether automatic IP configuration is enabled | +| firmware | Software version of the Bridge | +| ipAddress | IP address of the Bridge | +| products | List of all recognized products | +| scenes | List of all defined scenes | +| subnetMask | IP subnetmask of the Bridge | +| vendor | Vendow name | +| WLANSSID | Name of the wireless network (not suported any more) | +| WLANPassword | WLAN Authentication Password (not suported any more) | + +## Full Example ### Things -[Sample things file for textual configuration](doc/conf/things/velux.things) +``` +Bridge velux:klf200:g24 "Velux KLF200 Hub" @ "Under Stairs" [ipAddress="192.168.1.xxx", password="secret"] { + Thing window w56-36-13-5A-11-2A-05-70 "Bathroom Roof Window" @ "Bathroom" [serial="56:36:13:5A:11:2A:05:70", inverted=true] +} +``` -## More automation samples +[=> download sample things file for textual configuration](./doc/conf/things/velux.things) -At this point some interesting automation rules are included to demonstrate the power of this gateway to the io-homecontrol world. +### Items +``` +Rollershutter Bathroom_Roof_Window_Position "Bathroom Roof Window Position [%.0f %%]" {channel="velux:window:g24:w56-36-13-5A-11-2A-05-70:position"} +``` -### Closing windows after a period of time +[=> download sample items file for textual configuration](./doc/conf/items/velux.items) +### Sitemap + +``` +Frame label="Velux Windows" { + Slider item=Bathroom_Roof_Window_Position +} +``` + +[=> download sample sitemaps file for textual configuration](./doc/conf/sitemaps/velux.sitemap) + +### Rules + +**Rule for closing windows after a period of time**: Especially in the colder months, it is advisable to close the window after adequate ventilation. Therefore, automatic closing after one minute is good to save on heating costs. However, to allow the case of intentional prolonged opening, an automatic closure is made only with the window fully open. -``` -/* - * Start of imports - */ - -import org.openhab.core.library.types.* - -/* - * Start of rules - */ - +```java rule "V_WINDOW_changed" when Item V_WINDOW changed then logInfo("rules.V_WINDOW", "V_WINDOW_changes() called.") - // // Get the sensor value - // val Number windowState = V_WINDOW.state as DecimalType logWarn("rules.V_WINDOW", "Window state is "+windowState+".") if (windowState < 80) { if (windowState == 0) { logWarn("rules.V_WINDOW", "V-WINDOW changed to fully open.") - var int interval = 1 - - createTimer(now.plusMinutes(interval)) [| - logWarn("rules.V_WINDOW:event", "event-V_WINDOW(): setting V-WINDOW to 100.") - sendCommand(V_WINDOW,100) - V_WINDOW.postUpdate(100) + createTimer(now.plusMinutes(interval)) [ | + logWarn("rules.V_WINDOW:event", "event-V_WINDOW(): setting V-WINDOW to 100.") + sendCommand(V_WINDOW,100) + V_WINDOW.postUpdate(100) logWarn("rules.V_WINDOW:event", "event-V_WINDOW done.") ] } else { logWarn("rules.V_WINDOW", "V-WINDOW changed to partially open.") } } - // // Check type of item - // logDebug("rules.V_WINDOW", "V_WINDOW_changes finished.") end - -/* - * end-of-rules/V_WINDOW.rules - */ ``` +[=> download sample rules file for textual configuration](./doc/conf/rules/velux.rules) + ## Debugging For those who are interested in more detailed insight of the processing of this binding, a deeper look can be achieved by increased loglevel. @@ -352,46 +350,46 @@ However if you have set the configuration parameter isProtocolTraceEnabled to tr [INFO ] [internal.bridge.slip.SlipVeluxBridge] - Received answer GW_GET_NODE_INFORMATION_CFM. [INFO ] [internal.bridge.slip.SlipVeluxBridge] - Received answer GW_GET_NODE_INFORMATION_NTF. [INFO ] [internal.bridge.slip.SlipVeluxBridge] - Sending command GW_GET_LIMITATION_STATUS_REQ. -... ``` - ## Supported/Tested Firmware Revisions -The Velux Bridge in API version one (firmware version 0.1.1.*) allows activating a set of predefined actions, so called scenes. Therefore beside the bridge, only one main thing exists, the scene element. The next-generation firmware version two is not backward compatible, and does not provide a public web frontend, but version two does provide full access to any IO-Home compatible devices not limited to Velux and includes many different features. +The Velux Bridge in API version one (firmware version 0.1.1.*) allows activating a set of predefined actions, so called scenes. +Therefore beside the bridge, only one main thing exists, the scene element. + +The next-generation firmware version two is not backward compatible, and does not provide a public web frontend, but version two does provide full access to any IO-Home compatible devices not limited to Velux and includes many different features. | Firmware revision | Release date | Description | |:-----------------:|:------------:|-------------------------------------------------------------------------| | 0.1.1.0.41.0 | 2016-06-01 | Default factory shipping revision. | | 0.1.1.0.42.0 | 2017-07-01 | Public Web Frontend w/ JSON-API. | | 0.1.1.0.44.0 | 2017-12-14 | Public Web Frontend w/ JSON-API. | -| 2.0.0.71 | 2018-09-27 | Public SLIP-API w/ private-only WLAN-based Web Frontend w/ JSON-API. | +| 0.2.0.0.71.0 | 2018-09-27 | Public SLIP-API w/ private-only WLAN-based Web Frontend w/ JSON-API. | Notes: - Velux bridges cannot be returned to version one of the firmware after being upgraded to version two. - Firmware updates are currently provided at [Velux download area](https://updates2.velux.com/). - ## Is it possible to run the both communication methods in parallel? For environments with the firmware version 0.1.* on the gateway, the interaction with the bridge is limited to the HTTP/JSON based communication, of course. On the other hand, after upgrading the gateway firmware to version 2, it is possible to run the binding either using HTTP/JSON if there is a permanent connectivity towards the WLAN interface of the KLF200 or using SLIP towards the LAN interface of the gateway. For example the Raspberry PI can directly be connected via WLAN to the Velux gateway and providing the other services via the LAN interface (but not vice versa). - ## Known Limitations The communication based on HTTP/JSON is limited to one connection: If the binding is operational, you won't get access to the Web Frontend in parallel. The SLIP communication is limited to two connections in parallel, i.e. two different openHAB bindings - or - one openHAB binding and another platform connection. -Both interfacing methods, HTTP/JSON and SLIP, can be run in parallel. Therefore, on the one hand you can use the Web Frontend for manual control and on the other hand a binding can do all automatic jobs. - +Both interfacing methods, HTTP/JSON and SLIP, can be run in parallel. +Therefore, on the one hand you can use the Web Frontend for manual control and on the other hand a binding can do all automatic jobs. ## Unknown Velux devices -All known Velux devices can be handled by this binding. However, there might be some new ones which will be reported within the logfiles. Therefore, error messages like the one below should be reported to the maintainers so that the new Velux device type can be incorporated." +All known Velux devices can be handled by this binding. +However, there might be some new ones which will be reported within the logfiles. +Therefore, error messages like the one below should be reported to the maintainers so that the new Velux device type can be incorporated. ``` [ERROR] [g.velux.things.VeluxProductReference] - PLEASE REPORT THIS TO MAINTAINER: VeluxProductReference(3) has found an unregistered ProductTypeId. ``` - diff --git a/bundles/org.openhab.binding.velux/doc/veluxlogo.jpg b/bundles/org.openhab.binding.velux/doc/veluxlogo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5a81b081eeacf27c972681121a2e294b9cbf02ef GIT binary patch literal 15519 zcmch;c|4Tw_dk9MStDC2%T)Gkm0g%h2r(ok#8g5|h-_uKi%_-+A&QYDA*QTZC;OIU zmwn4FV;{4A?_Tfa^Ikr`$K&_={_(qKuE)$=_dVx6=Umry&hwme-SlDl6mZx`-%uZ5 zU|;}lK`($l4V=>RcX0v$6BFPx006AeIbMJf`o;jg{yOM1KuhDyot1@!{SZ4l2Pbr}uyJu8;^g}C{ST2p zfB*9@=*`K>!uscm|8EEVE5O4FL^7l^GMoYq@Gvm)FwmO-7$hk(q>n!;`TN0efRTy$ zAjA?o2XsN%VTgT3#sd(u%uGzs)j`mCfQg5h_vG1&2l>ozvz+qeKle259jn--&-DV= zdI;i5cf3N_*pCPvJ$76|Qc7Cpw6cn-n!1Lj?qxlFgDZwc7S}DUkT*xRIap<$K@QCLxBI6TYB_<`mPD#zo%FcP8`ynsCxTLhKyy8n`RYPM_b4zPm zdq;0y|G?nT@XwLync2Bt^9zeh%Nv_p+dI2^#C_5qxflS(zlrrv$^Jtw9!RbO&=@eW z{E>^{fFINtd6<|_o;}EW(VXSBC*P@aPg(gd#l8Dn&nBjHjUaHx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6L;+ zthmYP@yKMkVWIh#`6c*cBl$X(HUu+`EDdEpTsY1q$E7OKZmxUne$=V2b42z>?sg^? zStd4T?W*h6evb}R_<{x~f}SKDh(Y~TNeJquB_U82ckr)a5io+8M=Xqm!jnt%Xuu0- zp{A*fhPoo@SQqbtL&ZsQmqK!3N_@n@q5m*Al6A9e&HXZFVKNp8o`&9w@xMXd4XGaF z^M}Hd092kt?rzz!;ag}4XaZ}nia$5OoTEYOzk zWq2u+uuuKFsg*3Qc?ex7NL=4IUtg6QQKPqE+wyoYqR_T1XD4Q$w^YsSQ={0STGreb zGs^LsKx;8=5o?{>R!xx zvFix7@9h0Z7g1~ss00#rAcsqfLSo>Avwv-Fha``n9{Gn=5m*I_UjJo8D7pV`#(UJ( zu6vTt1R6n;7I_^ibr_=et;=Rc&eGawmug3$G*ZYL+K+UJ9uMVl-C4nyb!F-$ma?jf zq%|WGzC8U)s@tcpz- 0) { - logger.trace("bridgeDirectCommunicate(): sending {} bytes.", sendBytes.length); + logger.trace("bridgeDirectCommunicate() on {}: sending {} bytes.", host, sendBytes.length); if (isProtocolTraceEnabled) { logger.info("Sending command {}.", commandString); } } else { - logger.trace("bridgeDirectCommunicate(): initiating receive-only."); + logger.trace("bridgeDirectCommunicate() on {}: initiating receive-only.", host); } // (Optionally) Send and receive packet. receivedPacket = connection.io(this.bridgeInstance, sendBytes); // Once being sent, it should never be sent again sendBytes = emptyPacket; } catch (Exception e) { - logger.warn("bridgeDirectCommunicate(): connection.io returns {}", e.getMessage()); + logger.warn("bridgeDirectCommunicate() on {}: connection.io returns {}", host, e.getMessage()); break communication; } - logger.trace("bridgeDirectCommunicate(): received packet {}.", new Packet(receivedPacket).toString()); + logger.trace("bridgeDirectCommunicate() on {}: received packet {}.", host, + new Packet(receivedPacket).toString()); byte[] response; try { response = new SlipRFC1055().decode(receivedPacket); } catch (ParseException e) { - logger.warn("bridgeDirectCommunicate(): method SlipRFC1055() raised a decoding error: {}.", - e.getMessage()); + logger.warn("bridgeDirectCommunicate() on {}: method SlipRFC1055() raised a decoding error: {}.", + host, e.getMessage()); break communication; } SlipEncoding tr = new SlipEncoding(response); if (!tr.isValid()) { - logger.warn("bridgeDirectCommunicate(): method SlipEncoding() raised a decoding error."); + logger.warn("bridgeDirectCommunicate() on {}: method SlipEncoding() raised a decoding error.", + host); break communication; } short responseCommand = tr.getCommand(); byte[] responseData = tr.getData(); - logger.debug("bridgeDirectCommunicate(): working on response {} with {} bytes of data.", + logger.debug("bridgeDirectCommunicate() on {}: working on response {} with {} bytes of data.", host, Command.get(responseCommand).toString(), responseData.length); if (isProtocolTraceEnabled) { logger.info("Received answer {}.", Command.get(responseCommand).toString()); @@ -302,63 +307,66 @@ public class SlipVeluxBridge extends VeluxBridge { // Handle some common (unexpected) answers switch (Command.get(responseCommand)) { case GW_NODE_INFORMATION_CHANGED_NTF: - logger.trace("bridgeDirectCommunicate(): received GW_NODE_INFORMATION_CHANGED_NTF."); - logger.trace("bridgeDirectCommunicate(): continue with receiving."); + logger.trace("bridgeDirectCommunicate() on {}: received GW_NODE_INFORMATION_CHANGED_NTF.", + host); + logger.trace("bridgeDirectCommunicate() on {}: continue with receiving.", host); continue; case GW_NODE_STATE_POSITION_CHANGED_NTF: logger.trace( - "bridgeDirectCommunicate(): received GW_NODE_STATE_POSITION_CHANGED_NTF, special processing of this packet."); + "bridgeDirectCommunicate() on {}: received GW_NODE_STATE_POSITION_CHANGED_NTF, special processing of this packet.", + host); SCgetHouseStatus receiver = new SCgetHouseStatus(); receiver.setResponse(responseCommand, responseData, isSequentialEnforced); if (receiver.isCommunicationSuccessful()) { - logger.trace("bridgeDirectCommunicate(): existingProducts().update() called."); + logger.trace("bridgeDirectCommunicate() on {}: existingProducts().update() called.", host); bridgeInstance.existingProducts().update(new ProductBridgeIndex(receiver.getNtfNodeID()), receiver.getNtfState(), receiver.getNtfCurrentPosition(), receiver.getNtfTarget()); } - logger.trace("bridgeDirectCommunicate(): continue with receiving."); + logger.trace("bridgeDirectCommunicate() on {}: continue with receiving.", host); continue; case GW_ERROR_NTF: switch (responseData[0]) { case 0: logger.warn( - "bridgeDirectCommunicate(): received GW_ERROR_NTF on {} (Not further defined error), aborting.", - commandString); + "bridgeDirectCommunicate() on {}: received GW_ERROR_NTF on {} (Not further defined error), aborting.", + host, commandString); break communication; case 1: logger.warn( - "bridgeDirectCommunicate(): received GW_ERROR_NTF (Unknown Command or command is not accepted at this state) on {}, aborting.", - commandString); + "bridgeDirectCommunicate() on {}: received GW_ERROR_NTF (Unknown Command or command is not accepted at this state) on {}, aborting.", + host, commandString); break communication; case 2: logger.warn( - "bridgeDirectCommunicate(): received GW_ERROR_NTF (ERROR on Frame Structure) on {}, aborting.", - commandString); + "bridgeDirectCommunicate() on {}: received GW_ERROR_NTF (ERROR on Frame Structure) on {}, aborting.", + host, commandString); break communication; case 7: logger.trace( - "bridgeDirectCommunicate(): received GW_ERROR_NTF (Busy. Try again later) on {}, retrying.", - commandString); + "bridgeDirectCommunicate() on {}: received GW_ERROR_NTF (Busy. Try again later) on {}, retrying.", + host, commandString); sendBytes = emptyPacket; continue; case 8: logger.warn( - "bridgeDirectCommunicate(): received GW_ERROR_NTF (Bad system table index) on {}, aborting.", - commandString); + "bridgeDirectCommunicate() on {}: received GW_ERROR_NTF (Bad system table index) on {}, aborting.", + host, commandString); break communication; case 12: logger.warn( - "bridgeDirectCommunicate(): received GW_ERROR_NTF (Not authenticated) on {}, aborting.", - commandString); + "bridgeDirectCommunicate() on {}: received GW_ERROR_NTF (Not authenticated) on {}, aborting.", + host, commandString); resetAuthentication(); break communication; default: - logger.warn("bridgeDirectCommunicate(): received GW_ERROR_NTF ({}) on {}, aborting.", - responseData[0], commandString); + logger.warn( + "bridgeDirectCommunicate() on {}: received GW_ERROR_NTF ({}) on {}, aborting.", + host, responseData[0], commandString); break communication; } case GW_ACTIVATION_LOG_UPDATED_NTF: - logger.info("bridgeDirectCommunicate(): received GW_ACTIVATION_LOG_UPDATED_NTF."); - logger.trace("bridgeDirectCommunicate(): continue with receiving."); + logger.info("bridgeDirectCommunicate() on {}: received GW_ACTIVATION_LOG_UPDATED_NTF.", host); + logger.trace("bridgeDirectCommunicate() on {}: continue with receiving.", host); continue; case GW_COMMAND_RUN_STATUS_NTF: @@ -366,19 +374,21 @@ public class SlipVeluxBridge extends VeluxBridge { case GW_SESSION_FINISHED_NTF: if (!isSequentialEnforced) { logger.trace( - "bridgeDirectCommunicate(): response ignored due to activated parallelism, continue with receiving."); + "bridgeDirectCommunicate() on {}: response ignored due to activated parallelism, continue with receiving.", + host); continue; } default: } - logger.trace("bridgeDirectCommunicate(): passes back command {} and data {}.", + logger.trace("bridgeDirectCommunicate() on {}: passes back command {} and data {}.", host, new CommandNumber(responseCommand).toString(), new Packet(responseData).toString()); communication.setResponse(responseCommand, responseData, isSequentialEnforced); } while (!communication.isCommunicationFinished()); success = communication.isCommunicationSuccessful(); } while (false); // communication - logger.debug("bridgeDirectCommunicate({}) returns {}.", commandString, success ? "success" : "failure"); + logger.debug("bridgeDirectCommunicate({}) on {}: returns {}.", commandString, host, + success ? "success" : "failure"); return success; } } diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/io/Connection.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/io/Connection.java index a42d7a12c..d6e32c297 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/io/Connection.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/io/Connection.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.net.ConnectException; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.velux.internal.VeluxBindingConstants; import org.openhab.binding.velux.internal.bridge.VeluxBridgeInstance; import org.openhab.binding.velux.internal.bridge.slip.utils.Packet; import org.slf4j.Logger; @@ -59,6 +60,8 @@ public class Connection { */ private SSLconnection connectivity = SSLconnection.UNKNOWN; + private String host = VeluxBindingConstants.UNKNOWN_IP_ADDRESS; + /* * ************************** * ***** Public Methods ***** @@ -75,7 +78,7 @@ public class Connection { */ public synchronized byte[] io(VeluxBridgeInstance bridgeInstance, byte[] request) throws ConnectException, IOException { - logger.trace("io() called."); + logger.trace("io() on {}: called.", host); lastCommunicationInMSecs = System.currentTimeMillis(); @@ -88,18 +91,18 @@ public class Connection { if (!connectivity.isReady()) { try { // From configuration - String host = bridgeInstance.veluxBridgeConfiguration().ipAddress; + host = bridgeInstance.veluxBridgeConfiguration().ipAddress; int port = bridgeInstance.veluxBridgeConfiguration().tcpPort; int timeoutMsecs = bridgeInstance.veluxBridgeConfiguration().timeoutMsecs; - logger.trace("io(): connecting to {}:{}.", host, port); + logger.trace("io() on {}: connecting to port {}", host, port); connectivity = new SSLconnection(host, port); connectivity.setTimeout(timeoutMsecs); } catch (ConnectException ce) { throw new ConnectException(String .format("raised a non-recoverable error during connection setup: %s", ce.getMessage())); } catch (IOException e) { - logger.warn("io(): raised an error during connection setup: {}.", e.getMessage()); + logger.warn("io() on {}: raised an error during connection setup: {}.", host, e.getMessage()); lastIOE = new IOException(String.format("error during connection setup: %s.", e.getMessage())); continue; } @@ -107,65 +110,68 @@ public class Connection { if (request.length > 0) { try { if (logger.isTraceEnabled()) { - logger.trace("io(): sending packet with {} bytes: {}", request.length, new Packet(request)); + logger.trace("io() on {}: sending packet with {} bytes: {}", host, request.length, + new Packet(request)); } else { - logger.debug("io(): sending packet of size {}.", request.length); + logger.debug("io() on {}: sending packet of size {}.", host, request.length); } if (connectivity.isReady()) { connectivity.send(request); } } catch (IOException e) { - logger.info("io(): raised an error during sending: {}.", e.getMessage()); + logger.info("io() on {}: raised an error during sending: {}.", host, e.getMessage()); break; } // Give the bridge some time to breathe if (bridgeInstance.veluxBridgeConfiguration().timeoutMsecs > 0) { - logger.trace("io(): wait time {} msecs.", + logger.trace("io() on {}: wait time {} msecs.", host, bridgeInstance.veluxBridgeConfiguration().timeoutMsecs); try { Thread.sleep(bridgeInstance.veluxBridgeConfiguration().timeoutMsecs); } catch (InterruptedException ie) { - logger.trace("io() wait interrupted."); + logger.trace("io() on {}: wait interrupted.", host); } } } byte[] packet = new byte[0]; - logger.trace("io(): receiving bytes."); + logger.trace("io() on {}: receiving bytes.", host); if (connectivity.isReady()) { packet = connectivity.receive(); } if (logger.isTraceEnabled()) { - logger.trace("io(): received packet with {} bytes: {}", packet.length, new Packet(packet)); + logger.trace("io() on {}: received packet with {} bytes: {}", host, packet.length, + new Packet(packet)); } else { - logger.debug("io(): received packet with {} bytes.", packet.length); + logger.debug("io() on {}: received packet with {} bytes.", host, packet.length); } lastSuccessfulCommunicationInMSecs = System.currentTimeMillis(); lastCommunicationInMSecs = lastSuccessfulCommunicationInMSecs; - logger.trace("io() finished."); + logger.trace("io() on {}: finished.", host); return packet; } catch (IOException ioe) { - logger.info("io(): Exception occurred during I/O: {}.", ioe.getMessage()); + logger.info("io() on {}: Exception occurred during I/O: {}.", host, ioe.getMessage()); lastIOE = ioe; // Error Retries with Exponential Backoff long waitTime = ((long) Math.pow(2, retryCount) * bridgeInstance.veluxBridgeConfiguration().timeoutMsecs); - logger.trace("io(): wait time {} msecs.", waitTime); + logger.trace("io() on {}: wait time {} msecs.", host, waitTime); try { Thread.sleep(waitTime); } catch (InterruptedException ie) { - logger.trace("io(): wait interrupted."); + logger.trace("io() on {}: wait interrupted.", host); } } } while (retryCount++ < bridgeInstance.veluxBridgeConfiguration().retries); if (retryCount >= bridgeInstance.veluxBridgeConfiguration().retries) { - logger.info("io(): socket I/O failed {} times.", bridgeInstance.veluxBridgeConfiguration().retries); + logger.info("io() on {}: socket I/O failed {} times.", host, + bridgeInstance.veluxBridgeConfiguration().retries); } - logger.trace("io(): shutting down connection."); + logger.trace("io() on {}: shutting down connection.", host); if (connectivity.isReady()) { connectivity.close(); } - logger.trace("io() finishes with failure by throwing exception."); + logger.trace("io() on {}: finishes with failure by throwing exception.", host); throw lastIOE; } @@ -175,7 +181,7 @@ public class Connection { * @return state as boolean. */ public boolean isAlive() { - logger.trace("isAlive(): called."); + logger.trace("isAlive() on {}: called.", host); return connectivity.isReady(); } @@ -185,17 +191,17 @@ public class Connection { * @return state as boolean. */ public synchronized boolean isMessageAvailable() { - logger.trace("isMessageAvailable(): called."); + logger.trace("isMessageAvailable() on {}: called.", host); try { if ((connectivity.isReady()) && (connectivity.available())) { - logger.trace("isMessageAvailable(): there is a message waiting."); + logger.trace("isMessageAvailable() on {}: there is a message waiting.", host); return true; } } catch (IOException e) { - logger.trace("isMessageAvailable(): lost connection due to {}.", e.getMessage()); + logger.trace("isMessageAvailable() on {}: lost connection due to {}.", host, e.getMessage()); resetConnection(); } - logger.trace("isMessageAvailable(): no message waiting."); + logger.trace("isMessageAvailable() on {}: no message waiting.", host); return false; } @@ -223,18 +229,12 @@ public class Connection { * Resets an open connectivity by closing the socket and resetting the authentication information. */ public synchronized void resetConnection() { - logger.trace("resetConnection() called."); - if (connectivity.isReady()) { - logger.trace("resetConnection(): shutting down connection."); - try { - if (connectivity.isReady()) { - connectivity.close(); - } - } catch (IOException e) { - logger.info("resetConnection(): raised an error during connection close: {}.", e.getMessage()); - } - logger.trace("resetConnection(): clearing authentication token."); + logger.trace("resetConnection() on {}: called.", host); + try { + connectivity.close(); + } catch (IOException e) { + logger.info("resetConnection() on {}: raised an error during connection close: {}.", host, e.getMessage()); } - logger.trace("resetConnection() done."); + logger.trace("resetConnection() on {}: done.", host); } } diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/io/SSLconnection.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/io/SSLconnection.java index d53ea0594..b93bfad8f 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/io/SSLconnection.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/io/SSLconnection.java @@ -155,23 +155,43 @@ class SSLconnection { /** * Method to pass a message towards the bridge. + * This method gets called when we are initiating a new SLIP transaction. + *

+ * Note that DataOutputStream and DataInputStream are buffered I/O's. The SLIP protocol requires that prior requests + * should have been fully sent over the socket, and their responses should have been fully read from the buffer + * before the next request is initiated. i.e. Both read and write buffers should already be empty. Nevertheless, + * just in case, we do the following.. + *

+ * 1) Flush from the read buffer any orphan response data that may have been left over from prior transactions, and + * 2) Flush the write buffer directly to the socket to ensure that any exceptions are raised immediately, and the + * KLF starts work immediately * * @param packet as Array of bytes to be transmitted towards the bridge via the established connection. - * @throws java.io.IOException in case of a communication I/O failure. + * @throws java.io.IOException in case of a communication I/O failure, and sets 'ready' = false */ @SuppressWarnings("null") synchronized void send(byte[] packet) throws IOException { logger.trace("send() called, writing {} bytes.", packet.length); - if (!ready || (dOut == null)) { - throw new IOException(); - } - dOut.write(packet, 0, packet.length); - if (logger.isTraceEnabled()) { - StringBuilder sb = new StringBuilder(); - for (byte b : packet) { - sb.append(String.format("%02X ", b)); + try { + if (!ready || (dOut == null) || (dIn == null)) { + throw new IOException(); } - logger.trace("send() finished after having send {} bytes: {}", packet.length, sb.toString()); + // flush the read buffer if (exceptionally) there is orphan response data in it + flushReadBufffer(); + // copy packet data to the write buffer + dOut.write(packet, 0, packet.length); + // force the write buffer data to be written to the socket + dOut.flush(); + if (logger.isTraceEnabled()) { + StringBuilder sb = new StringBuilder(); + for (byte b : packet) { + sb.append(String.format("%02X ", b)); + } + logger.trace("send() finished after having send {} bytes: {}", packet.length, sb.toString()); + } + } catch (IOException e) { + ready = false; + throw e; } } @@ -196,26 +216,31 @@ class SSLconnection { * Method to get a message from the bridge. * * @return packet as Array of bytes as received from the bridge via the established connection. - * @throws java.io.IOException in case of a communication I/O failure. + * @throws java.io.IOException in case of a communication I/O failure, and sets 'ready' = false */ synchronized byte[] receive() throws IOException { logger.trace("receive() called."); - if (!ready || (dIn == null)) { - throw new IOException(); - } - byte[] message = new byte[CONNECTION_BUFFER_SIZE]; - @SuppressWarnings("null") - int messageLength = dIn.read(message, 0, message.length, ioTimeoutMSecs); - byte[] packet = new byte[messageLength]; - System.arraycopy(message, 0, packet, 0, messageLength); - if (logger.isTraceEnabled()) { - StringBuilder sb = new StringBuilder(); - for (byte b : packet) { - sb.append(String.format("%02X ", b)); + try { + if (!ready || (dIn == null)) { + throw new IOException(); } - logger.trace("receive() finished after having read {} bytes: {}", messageLength, sb.toString()); + byte[] message = new byte[CONNECTION_BUFFER_SIZE]; + @SuppressWarnings("null") + int messageLength = dIn.read(message, 0, message.length, ioTimeoutMSecs); + byte[] packet = new byte[messageLength]; + System.arraycopy(message, 0, packet, 0, messageLength); + if (logger.isTraceEnabled()) { + StringBuilder sb = new StringBuilder(); + for (byte b : packet) { + sb.append(String.format("%02X ", b)); + } + logger.trace("receive() finished after having read {} bytes: {}", messageLength, sb.toString()); + } + return packet; + } catch (IOException e) { + ready = false; + throw e; } - return packet; } /** @@ -231,16 +256,19 @@ class SSLconnection { DataInputStreamWithTimeout dInX = dIn; if (dInX != null) { dInX.close(); + dIn = null; } // Just for avoidance of Potential null pointer access DataOutputStream dOutX = dOut; if (dOutX != null) { dOutX.close(); + dOut = null; } // Just for avoidance of Potential null pointer access SSLSocket socketX = socket; if (socketX != null) { socketX.close(); + socket = null; } logger.trace("close() finished."); } @@ -254,4 +282,32 @@ class SSLconnection { logger.debug("setTimeout() set timeout to {} milliseconds.", timeoutMSecs); ioTimeoutMSecs = timeoutMSecs; } + + /** + * Method to flush the input buffer. + * + * @throws java.io.IOException in case of a communication I/O failure. + */ + private void flushReadBufffer() throws IOException { + logger.trace("flushReadBuffer() called."); + DataInputStreamWithTimeout dInX = dIn; + if (!ready || (dInX == null)) { + throw new IOException(); + } + int byteCount = dInX.available(); + if (byteCount > 0) { + byte[] byteArray = new byte[byteCount]; + dInX.readFully(byteArray); + if (logger.isTraceEnabled()) { + StringBuilder stringBuilder = new StringBuilder(); + for (byte currByte : byteArray) { + stringBuilder.append(String.format("%02X ", currByte)); + } + logger.trace("flushReadBuffer(): discarded {} unexpected bytes in the input buffer: {}", byteCount, + stringBuilder.toString()); + } else { + logger.warn("flushReadBuffer(): discarded {} unexpected bytes in the input buffer", byteCount); + } + } + } } diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/utils/KLF200Response.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/utils/KLF200Response.java index d29aa9717..520ce67c7 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/utils/KLF200Response.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/utils/KLF200Response.java @@ -64,9 +64,9 @@ public class KLF200Response { */ public static void errorLogging(Logger logger, short responseCommand) { logger.trace("setResponse(): cannot handle response {} ({}).", Command.get(responseCommand).toString(), - responseCommand); + new CommandNumber(responseCommand).toString()); logger.warn("Gateway response {} ({}) cannot be handled at this point of interaction.", - Command.get(responseCommand).toString(), responseCommand); + Command.get(responseCommand).toString(), new CommandNumber(responseCommand).toString()); } /** @@ -122,10 +122,10 @@ public class KLF200Response { * @return check4matchingAnyID of type boolean which signals the equality. */ private static boolean check4matchingAnyID(Logger logger, String idName, int requestID, int responseID) { - logger.trace("check4matchingAnyID() called for request{} {} and response{} {}.", idName, requestID, idName, + logger.trace("check4matchingAnyID() called for request {} {} and response {} {}.", idName, requestID, idName, responseID); if (requestID != responseID) { - logger.warn("Gateway response with {} {} unexpected as query asked for {} {}.", idName, requestID, idName, + logger.warn("Gateway query for {} {} received unexpected response of {} {}.", idName, requestID, idName, responseID); return false; } diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/utils/SlipEncoding.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/utils/SlipEncoding.java index 704778022..3c4e74064 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/utils/SlipEncoding.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/slip/utils/SlipEncoding.java @@ -47,8 +47,8 @@ public class SlipEncoding { private final Logger logger = LoggerFactory.getLogger(SlipEncoding.class); private static final byte PROTOCOL_ID = 0; - private static boolean encodingValid = false; - private static byte[] message = new byte[0]; + private boolean encodingValid = false; + private byte[] message = new byte[0]; /** * Builds a message based on command and parameters. diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/discovery/VeluxDiscoveryService.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/discovery/VeluxDiscoveryService.java index affd62785..6bf3f1471 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/discovery/VeluxDiscoveryService.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/discovery/VeluxDiscoveryService.java @@ -14,8 +14,10 @@ package org.openhab.binding.velux.internal.discovery; import static org.openhab.binding.velux.internal.VeluxBindingConstants.*; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.velux.internal.VeluxBindingConstants; import org.openhab.binding.velux.internal.VeluxBindingProperties; import org.openhab.binding.velux.internal.handler.VeluxBridgeHandler; @@ -60,7 +62,7 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R private @NonNullByDefault({}) LocaleProvider localeProvider; private @NonNullByDefault({}) TranslationProvider i18nProvider; private Localization localization = Localization.UNKNOWN; - private static @Nullable VeluxBridgeHandler bridgeHandler = null; + private final Set bridgeHandlers = new HashSet<>(); // Private @@ -102,21 +104,11 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R * Initializes the {@link VeluxDiscoveryService} with a reference to the well-prepared environment with a * {@link VeluxBridgeHandler}. * - * @param bridge Initialized Velux bridge handler. * @param localizationHandler Initialized localization handler. */ - public VeluxDiscoveryService(VeluxBridgeHandler bridge, Localization localizationHandler) { + public VeluxDiscoveryService(Localization localizationHandler) { super(VeluxBindingConstants.SUPPORTED_THINGS_ITEMS, DISCOVER_TIMEOUT_SECONDS); - logger.trace("VeluxDiscoveryService(bridge={},locale={},i18n={}) just initialized.", bridge, localeProvider, - i18nProvider); - - if (bridgeHandler == null) { - logger.trace("VeluxDiscoveryService(): registering bridge {} for lateron use for Discovery.", bridge); - } else if (!bridge.equals(bridgeHandler)) { - logger.trace("VeluxDiscoveryService(): replacing already registered bridge {} by {}.", bridgeHandler, - bridge); - } - bridgeHandler = bridge; + logger.trace("VeluxDiscoveryService(locale={},i18n={}) just initialized.", localeProvider, i18nProvider); localization = localizationHandler; } @@ -126,16 +118,14 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R * Initializes the {@link VeluxDiscoveryService} with a reference to the well-prepared environment with a * {@link VeluxBridgeHandler}. * - * @param bridge Initialized Velux bridge handler. * @param locationProvider Provider for a location. * @param localeProvider Provider for a locale. * @param i18nProvider Provider for the internationalization. */ - public VeluxDiscoveryService(VeluxBridgeHandler bridge, LocationProvider locationProvider, - LocaleProvider localeProvider, TranslationProvider i18nProvider) { - this(bridge, new Localization(localeProvider, i18nProvider)); - logger.trace("VeluxDiscoveryService(bridge={},locale={},i18n={}) finished.", bridge, localeProvider, - i18nProvider); + public VeluxDiscoveryService(LocationProvider locationProvider, LocaleProvider localeProvider, + TranslationProvider i18nProvider) { + this(new Localization(localeProvider, i18nProvider)); + logger.trace("VeluxDiscoveryService(locale={},i18n={}) finished.", localeProvider, i18nProvider); } @Override @@ -157,8 +147,8 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R logger.debug("startScan(): registering new thing {}.", discoveryResult); thingDiscovered(discoveryResult); - if (bridgeHandler == null) { - logger.debug("startScan(): VeluxDiscoveryService cannot proceed due to missing Velux bridge."); + if (bridgeHandlers.isEmpty()) { + logger.debug("startScan(): VeluxDiscoveryService cannot proceed due to missing Velux bridge(s)."); } else { logger.debug("startScan(): Starting Velux discovery scan for scenes and actuators."); discoverScenes(); @@ -185,29 +175,25 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R */ private void discoverScenes() { logger.trace("discoverScenes() called."); - // Just for avoidance of Potential null pointer access - VeluxBridgeHandler bridgeHandlerX = bridgeHandler; - if (bridgeHandlerX == null) { - logger.debug("discoverScenes(): VeluxDiscoveryService.bridgeHandler not initialized, aborting discovery."); - return; - } - ThingUID bridgeUID = bridgeHandlerX.getThing().getUID(); - logger.debug("discoverScenes(): discovering all scenes."); - for (VeluxScene scene : bridgeHandlerX.existingScenes().values()) { - String sceneName = scene.getName().toString(); - logger.trace("discoverScenes(): found scene {}.", sceneName); + for (VeluxBridgeHandler bridgeHandlerX : bridgeHandlers) { + ThingUID bridgeUID = bridgeHandlerX.getThing().getUID(); + logger.debug("discoverScenes(): discovering all scenes on bridge {}.", bridgeUID); + for (VeluxScene scene : bridgeHandlerX.existingScenes().values()) { + String sceneName = scene.getName().toString(); + logger.trace("discoverScenes(): found scene {}.", sceneName); - String label = sceneName.replaceAll("\\P{Alnum}", "_"); - logger.trace("discoverScenes(): using label {}.", label); + String label = sceneName.replaceAll("\\P{Alnum}", "_"); + logger.trace("discoverScenes(): using label {}.", label); - ThingTypeUID thingTypeUID = THING_TYPE_VELUX_SCENE; - ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, label); - DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID) - .withProperty(VeluxBindingProperties.PROPERTY_SCENE_NAME, sceneName) - .withRepresentationProperty(VeluxBindingProperties.PROPERTY_SCENE_NAME).withBridge(bridgeUID) - .withLabel(label).build(); - logger.debug("discoverScenes(): registering new thing {}.", discoveryResult); - thingDiscovered(discoveryResult); + ThingTypeUID thingTypeUID = THING_TYPE_VELUX_SCENE; + ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, label); + DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID) + .withProperty(VeluxBindingProperties.PROPERTY_SCENE_NAME, sceneName) + .withRepresentationProperty(VeluxBindingProperties.PROPERTY_SCENE_NAME).withBridge(bridgeUID) + .withLabel(label).build(); + logger.debug("discoverScenes(): registering new thing {}.", discoveryResult); + thingDiscovered(discoveryResult); + } } logger.trace("discoverScenes() finished."); } @@ -217,56 +203,87 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R */ private void discoverProducts() { logger.trace("discoverProducts() called."); - // Just for avoidance of Potential null pointer access - VeluxBridgeHandler bridgeHandlerX = bridgeHandler; - if (bridgeHandlerX == null) { - logger.debug("discoverScenes() VeluxDiscoveryService.bridgeHandlerR not initialized, aborting discovery."); - return; - } - ThingUID bridgeUID = bridgeHandlerX.getThing().getUID(); - logger.debug("discoverProducts(): discovering all actuators."); - for (VeluxProduct product : bridgeHandlerX.existingProducts().values()) { - String serialNumber = product.getSerialNumber(); - String actuatorName = product.getProductName().toString(); - logger.trace("discoverProducts() found actuator {} (name {}).", serialNumber, actuatorName); - String identifier; - if (serialNumber.equals(VeluxProductSerialNo.UNKNOWN)) { - identifier = actuatorName; - } else { - identifier = serialNumber; + for (VeluxBridgeHandler bridgeHandlerX : bridgeHandlers) { + ThingUID bridgeUID = bridgeHandlerX.getThing().getUID(); + logger.debug("discoverProducts(): discovering all actuators on bridge {}.", bridgeUID); + for (VeluxProduct product : bridgeHandlerX.existingProducts().values()) { + String serialNumber = product.getSerialNumber(); + String actuatorName = product.getProductName().toString(); + logger.trace("discoverProducts() found actuator {} (name {}).", serialNumber, actuatorName); + String identifier; + if (serialNumber.equals(VeluxProductSerialNo.UNKNOWN)) { + identifier = actuatorName; + } else { + identifier = serialNumber; + } + String label = actuatorName.replaceAll("\\P{Alnum}", "_"); + logger.trace("discoverProducts(): using label {}.", label); + ThingTypeUID thingTypeUID; + boolean isInverted = false; + logger.trace("discoverProducts() dealing with {} (type {}).", product, product.getProductType()); + switch (product.getProductType()) { + case SLIDER_WINDOW: + logger.trace("discoverProducts(): creating window."); + thingTypeUID = THING_TYPE_VELUX_WINDOW; + isInverted = true; + break; + + case SLIDER_SHUTTER: + logger.trace("discoverProducts(): creating rollershutter."); + thingTypeUID = THING_TYPE_VELUX_ROLLERSHUTTER; + break; + + default: + logger.trace("discoverProducts(): creating actuator."); + thingTypeUID = THING_TYPE_VELUX_ACTUATOR; + } + ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, label); + + DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID) + .withProperty(VeluxBindingProperties.CONFIG_ACTUATOR_SERIALNUMBER, identifier) + .withProperty(VeluxBindingProperties.PROPERTY_ACTUATOR_NAME, actuatorName) + .withProperty(VeluxBindingProperties.PROPERTY_ACTUATOR_INVERTED, isInverted) + .withRepresentationProperty(VeluxBindingProperties.CONFIG_ACTUATOR_SERIALNUMBER) + .withBridge(bridgeUID).withLabel(actuatorName).build(); + logger.debug("discoverProducts(): registering new thing {}.", discoveryResult); + thingDiscovered(discoveryResult); } - String label = actuatorName.replaceAll("\\P{Alnum}", "_"); - logger.trace("discoverProducts(): using label {}.", label); - ThingTypeUID thingTypeUID; - boolean isInverted = false; - logger.trace("discoverProducts() dealing with {} (type {}).", product, product.getProductType()); - switch (product.getProductType()) { - case SLIDER_WINDOW: - logger.trace("discoverProducts(): creating window."); - thingTypeUID = THING_TYPE_VELUX_WINDOW; - isInverted = true; - break; - - case SLIDER_SHUTTER: - logger.trace("discoverProducts(): creating rollershutter."); - thingTypeUID = THING_TYPE_VELUX_ROLLERSHUTTER; - break; - - default: - logger.trace("discoverProducts(): creating actuator."); - thingTypeUID = THING_TYPE_VELUX_ACTUATOR; - } - ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, label); - - DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID) - .withProperty(VeluxBindingProperties.CONFIG_ACTUATOR_SERIALNUMBER, identifier) - .withProperty(VeluxBindingProperties.PROPERTY_ACTUATOR_NAME, actuatorName) - .withProperty(VeluxBindingProperties.PROPERTY_ACTUATOR_INVERTED, isInverted) - .withRepresentationProperty(VeluxBindingProperties.CONFIG_ACTUATOR_SERIALNUMBER) - .withBridge(bridgeUID).withLabel(actuatorName).build(); - logger.debug("discoverProducts(): registering new thing {}.", discoveryResult); - thingDiscovered(discoveryResult); } logger.trace("discoverProducts() finished."); } + + /** + * Add a {@link VeluxBridgeHandler} to the {@link VeluxDiscoveryService} + * + * @param bridge Velux bridge handler. + * @return true if the bridge was added, or false if it was already present + */ + public boolean addBridge(VeluxBridgeHandler bridge) { + if (!bridgeHandlers.contains(bridge)) { + logger.trace("VeluxDiscoveryService(): registering bridge {} for discovery.", bridge); + bridgeHandlers.add(bridge); + return true; + } + logger.trace("VeluxDiscoveryService(): bridge {} already registered for discovery.", bridge); + return false; + } + + /** + * Remove a {@link VeluxBridgeHandler} from the {@link VeluxDiscoveryService} + * + * @param bridge Velux bridge handler. + * @return true if the bridge was removed, or false if it was not present + */ + public boolean removeBridge(VeluxBridgeHandler bridge) { + return bridgeHandlers.remove(bridge); + } + + /** + * Check if the {@link VeluxDiscoveryService} list of {@link VeluxBridgeHandler} is empty + * + * @return true if empty + */ + public boolean isEmpty() { + return bridgeHandlers.isEmpty(); + } } diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java index aff42c6cc..52710a791 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java @@ -12,10 +12,8 @@ */ package org.openhab.binding.velux.internal.factory; -import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; -import java.util.Map; import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -32,7 +30,6 @@ import org.openhab.core.i18n.TranslationProvider; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.BaseThingHandlerFactory; import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.thing.binding.ThingHandlerFactory; @@ -56,7 +53,8 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory { // Class internal - private final Map> discoveryServiceRegistrations = new HashMap<>(); + private @Nullable ServiceRegistration discoveryServiceRegistration = null; + private @Nullable VeluxDiscoveryService discoveryService = null; private Set veluxBindingHandlers = new HashSet<>(); private Set veluxBridgeHandlers = new HashSet<>(); @@ -69,20 +67,25 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory { // Private private void registerDeviceDiscoveryService(VeluxBridgeHandler bridgeHandler) { - VeluxDiscoveryService discoveryService = new VeluxDiscoveryService(bridgeHandler, localization); - ServiceRegistration discoveryServiceReg = bundleContext.registerService(DiscoveryService.class.getName(), - discoveryService, new Hashtable<>()); - discoveryServiceRegistrations.put(bridgeHandler.getThing().getUID(), discoveryServiceReg); + logger.trace("registerDeviceDiscoveryService({}) called.", bridgeHandler); + boolean createNew = (discoveryService == null); + if (createNew) { + discoveryService = new VeluxDiscoveryService(localization); + } + discoveryService.addBridge(bridgeHandler); + if (createNew) { + discoveryServiceRegistration = bundleContext.registerService(DiscoveryService.class.getName(), + discoveryService, new Hashtable<>()); + } } - // Even if the compiler tells, that the value of cannot be null, it is possible! - // Therefore a @SuppressWarnings("null") is needed to suppress the warning - @SuppressWarnings("null") - private synchronized void unregisterDeviceDiscoveryService(ThingUID thingUID) { - logger.trace("unregisterDeviceDiscoveryService({}) called.", thingUID); - ServiceRegistration remove = discoveryServiceRegistrations.remove(thingUID); - if (remove != null) { - remove.unregister(); + private synchronized void unregisterDeviceDiscoveryService(VeluxBridgeHandler bridgeHandler) { + logger.trace("unregisterDeviceDiscoveryService({}) called.", bridgeHandler); + if (discoveryService != null) { + discoveryService.removeBridge(bridgeHandler); + if (discoveryService.isEmpty()) { + discoveryServiceRegistration.unregister(); + } } } @@ -191,7 +194,7 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory { if (thingHandler instanceof VeluxBridgeHandler) { logger.trace("removeHandler() removing bridge '{}'.", thingHandler.toString()); veluxBridgeHandlers.remove(thingHandler); - unregisterDeviceDiscoveryService(thingHandler.getThing().getUID()); + unregisterDeviceDiscoveryService((VeluxBridgeHandler) thingHandler); } else // Handle removal of Things behind the Bridge if (thingHandler instanceof VeluxHandler) { diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelBridgeWLANconfig.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelBridgeWLANconfig.java index 80925dd09..3857f88a6 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelBridgeWLANconfig.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelBridgeWLANconfig.java @@ -19,6 +19,7 @@ import org.openhab.binding.velux.internal.VeluxItemType; import org.openhab.binding.velux.internal.bridge.VeluxBridgeWLANConfig; import org.openhab.binding.velux.internal.handler.utils.StateUtils; import org.openhab.binding.velux.internal.handler.utils.ThingProperty; +import org.openhab.core.library.types.StringType; import org.openhab.core.thing.ChannelUID; import org.openhab.core.types.State; import org.slf4j.Logger; @@ -69,16 +70,15 @@ final class ChannelBridgeWLANconfig extends ChannelHandlerTemplate { if (thisBridgeHandler.bridgeParameters.wlanConfig.isRetrieved) { VeluxItemType itemType = VeluxItemType.getByThingAndChannel(thisBridgeHandler.thingTypeUIDOf(channelUID), channelUID.getId()); + String msg = thisBridgeHandler.localization.getText("config.velux.bridge.unAvailable"); switch (itemType) { case BRIDGE_WLANSSID: - newState = StateUtils.createState(thisBridgeHandler.bridgeParameters.lanConfig.openHABipAddress); - ThingProperty.setValue(thisBridgeHandler, VeluxBindingConstants.PROPERTY_BRIDGE_WLANSSID, - thisBridgeHandler.bridgeParameters.wlanConfig.openHABwlanSSID.toString()); + newState = StateUtils.createState(new StringType(msg)); + ThingProperty.setValue(thisBridgeHandler, VeluxBindingConstants.PROPERTY_BRIDGE_WLANSSID, msg); break; case BRIDGE_WLANPASSWORD: - newState = StateUtils.createState(thisBridgeHandler.bridgeParameters.lanConfig.openHABsubnetMask); - ThingProperty.setValue(thisBridgeHandler, VeluxBindingConstants.PROPERTY_BRIDGE_WLANPASSWORD, - thisBridgeHandler.bridgeParameters.wlanConfig.openHABwlanPassword.toString()); + newState = StateUtils.createState(new StringType(msg)); + ThingProperty.setValue(thisBridgeHandler, VeluxBindingConstants.PROPERTY_BRIDGE_WLANPASSWORD, msg); break; default: } diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBindingHandler.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBindingHandler.java index 29f99de38..ab22f02b4 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBindingHandler.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBindingHandler.java @@ -13,6 +13,7 @@ package org.openhab.binding.velux.internal.handler; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.velux.internal.VeluxBindingConstants; import org.openhab.binding.velux.internal.VeluxBindingProperties; import org.openhab.binding.velux.internal.VeluxItemType; import org.openhab.binding.velux.internal.handler.utils.ExtendedBaseThingHandler; @@ -20,6 +21,7 @@ import org.openhab.binding.velux.internal.handler.utils.StateUtils; import org.openhab.binding.velux.internal.handler.utils.ThingProperty; import org.openhab.binding.velux.internal.utils.Localization; import org.openhab.binding.velux.internal.utils.ManifestInformation; +import org.openhab.core.common.AbstractUID; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; @@ -82,9 +84,13 @@ public class VeluxBindingHandler extends ExtendedBaseThingHandler { * @param channelUID for type {@link ChannelUID}. * @return thingTypeUID of type {@link ThingTypeUID}. */ - @SuppressWarnings("deprecation") private ThingTypeUID thingTypeUIDOf(ChannelUID channelUID) { - return channelUID.getThingUID().getThingTypeUID(); + String[] segments = channelUID.getAsString().split(AbstractUID.SEPARATOR); + if (segments.length > 1) { + return new ThingTypeUID(segments[0], segments[1]); + } + logger.warn("thingTypeUIDOf({}) failed.", channelUID); + return new ThingTypeUID(VeluxBindingConstants.BINDING_ID, VeluxBindingConstants.UNKNOWN_THING_TYPE_ID); } /** diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBridgeHandler.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBridgeHandler.java index 8df63c2e2..c39a3415f 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBridgeHandler.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBridgeHandler.java @@ -49,6 +49,7 @@ import org.openhab.binding.velux.internal.things.VeluxProduct; import org.openhab.binding.velux.internal.things.VeluxProduct.ProductBridgeIndex; import org.openhab.binding.velux.internal.things.VeluxProductPosition; import org.openhab.binding.velux.internal.utils.Localization; +import org.openhab.core.common.AbstractUID; import org.openhab.core.common.ThreadPoolManager; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.OnOffType; @@ -187,9 +188,13 @@ public class VeluxBridgeHandler extends ExtendedBaseBridgeHandler implements Vel * @param channelUID for type {@link ChannelUID}. * @return thingTypeUID of type {@link ThingTypeUID}. */ - @SuppressWarnings("deprecation") ThingTypeUID thingTypeUIDOf(ChannelUID channelUID) { - return channelUID.getThingUID().getThingTypeUID(); + String[] segments = channelUID.getAsString().split(AbstractUID.SEPARATOR); + if (segments.length > 1) { + return new ThingTypeUID(segments[0], segments[1]); + } + logger.warn("thingTypeUIDOf({}) failed.", channelUID); + return new ThingTypeUID(VeluxBindingConstants.BINDING_ID, VeluxBindingConstants.UNKNOWN_THING_TYPE_ID); } // Objects and Methods for interface VeluxBridgeInstance diff --git a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxKLFAPI.java b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxKLFAPI.java index 255beae72..6b064c8fd 100644 --- a/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxKLFAPI.java +++ b/bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxKLFAPI.java @@ -129,7 +129,7 @@ public class VeluxKLFAPI { UNDEFTYPE((short) -1, "Unknown command."), // Special item: Shutdown of the connection GW_OPENHAB_CLOSE((short) -2, "openHAB connection shutdown command."), - // Special item: Shutdown of the connection + // Special item: Empty Command (used to send nothing and process an incoming message only) GW_OPENHAB_RECEIVEONLY((short) -3, "openHAB receive command."), // Velux specific commands GW_ERROR_NTF((short) 0x0000, "Provides information on what triggered the error."), diff --git a/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux.properties b/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux.properties index d6ec46c33..667abb72b 100644 --- a/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux.properties +++ b/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux.properties @@ -68,6 +68,7 @@ config.velux.bridge.isSequentialEnforced.label = Enforce Sequential Mode config.velux.bridge.isSequentialEnforced.description = Enforce Sequential Actuator Control. Determine the mode of operation for long-time actions like running commands or activation of scenes. However the parallelism disables the in-depth protocol handshake processing which does not affect or limit any functionalities. config.velux.bridge.isProtocolTraceEnabled.label = Enable Protocol Trace config.velux.bridge.isProtocolTraceEnabled.description = Provide KLF200 protocol details. +config.velux.bridge.unAvailable = Unavailable # config.velux.thing.scene.sceneName.label = Scene Name config.velux.thing.scene.sceneName.description = Name of the scene to be handled. diff --git a/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_de.properties b/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_de.properties index 7afb26955..5af09f7a7 100644 --- a/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_de.properties +++ b/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_de.properties @@ -69,6 +69,7 @@ config.velux.bridge.isSequentialEnforced.label = Sequentielles Modus config.velux.bridge.isSequentialEnforced.description = Erzwingt den sequentiellen Modus von Operationen, insbesondere von länger andauernden Aktionen, wie der Aktivierung von Szenen. config.velux.bridge.isProtocolTraceEnabled.label = Protokolleinblick config.velux.bridge.isProtocolTraceEnabled.description = Aktiviert KLF200 Protokolldetails. +config.velux.bridge.unAvailable = Nicht verfügbar # config.velux.thing.scene.sceneName.label = Scenenname config.velux.thing.scene.sceneName.description = Name der Szene, wie sie auf dem Kopplungselements definiert wurde. diff --git a/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_dk.properties b/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_dk.properties index c67e8e698..51c444136 100644 --- a/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_dk.properties +++ b/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_dk.properties @@ -65,6 +65,7 @@ config.velux.bridge.isSequentialEnforced.label = HÃ¥ndhæv sekventiel tilstand config.velux.bridge.isSequentialEnforced.description = HÃ¥ndhæv sekventiel aktuatorstyring. Bestem driftsmÃ¥den for handlinger i lang tid som at køre kommandoer eller aktivering af scener. Paralleliteten deaktiverer imidlertid den dybdegÃ¥ende protokolhÃ¥ndtryksbehandling, som ikke pÃ¥virker eller begrænser nogen funktionaliteter. config.velux.bridge.isProtocolTraceEnabled.label = Protocol Insight config.velux.bridge.isProtocolTraceEnabled.description = Aktiverer KLF200-protokoldetaljer. +config.velux.bridge.unAvailable = Utilgængelig # config.velux.thing.scene.sceneName.label = Scenavn config.velux.thing.scene.sceneName.description = Navn pÃ¥ den scene, der skal hÃ¥ndteres. diff --git a/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_nl.properties b/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_nl.properties index 6e26a089a..70e719899 100644 --- a/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_nl.properties +++ b/bundles/org.openhab.binding.velux/src/main/resources/OH-INF/i18n/velux_nl.properties @@ -65,6 +65,7 @@ config.velux.bridge.isSequentialEnforced.label = Opeenvolgende modus afdwingen config.velux.bridge.isSequentialEnforced.description = Handhaving van sequentiële actuatorcontrole. Bepaal de werkingsmodus voor langdurige acties zoals het uitvoeren van opdrachten of het activeren van scènes. Het parallellisme schakelt echter de diepgaande protocolhandshake-verwerking uit die geen enkele functionaliteit beïnvloedt of beperkt. config.velux.bridge.isProtocolTraceEnabled.label = Protocol Insight config.velux.bridge.isProtocolTraceEnabled.description = Schakelt KLF200-protocoldetails in. +config.velux.bridge.unAvailable = Niet beschikbaar # config.velux.thing.scene.sceneName.label = Scènenaam config.velux.thing.scene.sceneName.description = Naam van de te behandelen scène. diff --git a/bundles/pom.xml b/bundles/pom.xml index 8527b7f5e..440974cc5 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -280,6 +280,7 @@ org.openhab.binding.valloxmv org.openhab.binding.vektiva org.openhab.binding.velbus + org.openhab.binding.velux org.openhab.binding.venstarthermostat org.openhab.binding.verisure org.openhab.binding.vigicrues diff --git a/features/openhab-addons/pom.xml b/features/openhab-addons/pom.xml index d0bb948b7..bc6d0afd4 100644 --- a/features/openhab-addons/pom.xml +++ b/features/openhab-addons/pom.xml @@ -52,7 +52,6 @@ -