diff --git a/addons/binding/org.openhab.binding.velux/ESH-INF/binding/binding.xml b/addons/binding/org.openhab.binding.velux/ESH-INF/binding/binding.xml index f31b3119bd8a6..916420dfd19cb 100644 --- a/addons/binding/org.openhab.binding.velux/ESH-INF/binding/binding.xml +++ b/addons/binding/org.openhab.binding.velux/ESH-INF/binding/binding.xml @@ -1,21 +1,8 @@ - - - Velux Binding The Velux Binding interacts via a Velux Bridge with the different Velux devices - like controlling window openers, shutters and others. For example a KLF200 can act as interface between the HomeAutomation and the VELUX INTEGRA products with wireless connectivity based on the io-homecontrol standard. +like controlling window openers, shutters and others. For example a KLF200 can act as interface between the HomeAutomation and the VELUX INTEGRA products with wireless connectivity based on the io-homecontrol standard. Guenther Schreiner - diff --git a/addons/binding/org.openhab.binding.velux/ESH-INF/i18n/velux_de.properties b/addons/binding/org.openhab.binding.velux/ESH-INF/i18n/velux_de.properties index 5547188c956b7..a39b8e3336223 100644 --- a/addons/binding/org.openhab.binding.velux/ESH-INF/i18n/velux_de.properties +++ b/addons/binding/org.openhab.binding.velux/ESH-INF/i18n/velux_de.properties @@ -1,55 +1,55 @@ # binding binding.velux.name = Velux Binding -binding.velux.description = Das Velux Binding kommuniziert ueber ein Velux Kopplungselement mit den unterschiedlichen Veluxgeraeten zur Steuerung von Fenstern, Rollaeden und anderen Geraeten. Beispielsweise kann ein KLF 200 als Schnittstelle zwischen Hausleitsystemen und VELUX INTEGRA Produkten mit Funkanbindung basierend auf dem io-homecontrol-Standard eingesetzt werden. +binding.velux.description = Das Velux Binding kommuniziert über ein Velux Kopplungselement mit den unterschiedlichen Velux-Geräten zur Steuerung von Fenstern, Rolläden und anderen Geräten. Beispielsweise kann ein KLF 200 als Schnittstelle zwischen Hausleitsystemen und VELUX INTEGRA Produkten mit Funkanbindung basierend auf dem io-homecontrol-Standard eingesetzt werden. # thing types thing-type.velux.klf200.label = Velux KLF200 -thing-type.velux.klf200.description = Kopplungselement zur Interaktion mit unterschiedlichen Veluxgeraeten. -thing-type.config.velux.klf200.bridgeURL.label = URL des Kopplungselements -thing-type.config.velux.klf200.bridgeURL.description = Basis-URL zum Zugriff auf das Velux KLF200 Kopplungselement. +thing-type.velux.klf200.description = Kopplungselement zur Interaktion mit unterschiedlichen Velux-Geräten. +thing-type.config.velux.klf200.bridgeIPAddress.label = Adresse des Kopplungselements +thing-type.config.velux.klf200.bridgeIPAddress.description = Name oder IP-Adresse zum Zugriff auf das Velux KLF200 Kopplungselement. +thing-type.config.velux.klf200.bridgeTCPPort.label = Port des Kopplungselements +thing-type.config.velux.klf200.bridgeTCPPort.description = TCP Portnummer zum HTTP-Zugriff auf das Velux KLF200 Kopplungselement. thing-type.config.velux.klf200.bridgePassword.label = Passwort thing-type.config.velux.klf200.bridgePassword.description = Password zur Anmeldung an dem Velux KLF200 Kopplungselement. -thing-type.config.velux.klf200.timeoutMsecs.label = Antwortwartezeit +thing-type.config.velux.klf200.timeoutMsecs.label = Zeitüberschreitung thing-type.config.velux.klf200.timeoutMsecs.description = Zeit in Millisekunden. thing-type.config.velux.klf200.retries.label = Wiederholungsversuche -thing-type.config.velux.klf200.retries.description = Anzahl der Verbindungswiederholungen fuer den Binary Exponential Backoff (BEB) Algorithmus. +thing-type.config.velux.klf200.retries.description = Anzahl der Verbindungswiederholungen für den Binary Exponential Backoff (BEB) Algorithmus. thing-type.velux.scene.label = Velux Szene -thing-type.velux.scene.description = Szene als Sammlung von Geraetezustaenden, welche aktiviert werden koennen. +thing-type.velux.scene.description = Szene als Sammlung von Gerätezuständen, welche aktiviert werden können. thing-type.config.velux.scene.sceneName.label = Szenenname thing-type.config.velux.scene.sceneName.description = Name der Szene, welche hier behandelt wird. -thing-type.config.velux.scene.TTL.label = Lebenszeit -thing-type.config.velux.scene.TTL.description = Lebenszeit dieses Objekts in Sekunden (-1 bedeutet unendlich). # channel types -channel-type.velux.STATUS.label = Status -channel-type.velux.STATUS.description = Status des Kopplungselements. -channel-type.velux.FIRMWARE.label = Firmware -channel-type.velux.FIRMWARE.description = Softwareversion des Kopplungselements. -channel-type.velux.IPADDRESS.label = IP-Adresse -channel-type.velux.IPADDRESS.description = IP-Adresse des Kopplungselements. -channel-type.velux.SUBNETMASK.label = Subnetzmaske -channel-type.velux.SUBNETMASK.description = IP-Subnetzmaske des Kopplungselements. -channel-type.velux.DEFAULTGW.label = Gateway-IP-Adresse -channel-type.velux.DEFAULTGW.description = IP-Adresse des Gateways. +channel-type.velux.status.label = Status +channel-type.velux.status.description = Status des Kopplungselements. +channel-type.velux.firmware.label = Firmware +channel-type.velux.firmware.description = Softwareversion des Kopplungselements. +channel-type.velux.ipAddress.label = IP-Adresse +channel-type.velux.ipAddress.description = IP-Adresse des Kopplungselements. +channel-type.velux.subnetMask.label = Subnetzmaske +channel-type.velux.subnetMask.description = IP-Subnetzmaske des Kopplungselements. +channel-type.velux.defaultGW.label = Gateway-IP-Adresse +channel-type.velux.defaultGW.description = IP-Adresse des Gateways. channel-type.velux.DHCP.label = DHCP-Aktivierung channel-type.velux.DHCP.description = Aktivierung der automatischen IP-Konfiguration mittels DHCP. channel-type.velux.WLANSSID.label = WLAN-SSID channel-type.velux.WLANSSID.description = Netzwerkkennung des Wireless-Netzwerks. -channel-type.velux.WLANPASSWORD.label = WLAN-Passwort -channel-type.velux.WLANPASSWORD.description = Passwort zum Zugriff auf das Wireless-Netzwerk. -channel-type.velux.SCENES.label = Identifizierte Szenen -channel-type.velux.SCENES.description = Szenen welche auf dem Kopplungselement definiert sind. -channel-type.velux.PRODUCTS.label = Identifizierte Produkte -channel-type.velux.PRODUCTS.description = Produkte welche auf dem Kopplungselement im Rahmen von Szenen definiert sind. -channel-type.velux.DETECTION.label = Produkterkennung -channel-type.velux.DETECTION.description = Schalter zum Start der Produkterkennung. +channel-type.velux.WLANPassword.label = WLAN-Passwort +channel-type.velux.WLANPassword.description = Passwort zum Zugriff auf das Wireless-Netzwerk. +channel-type.velux.scenes.label = Identifizierte Szenen +channel-type.velux.scenes.description = Szenen welche auf dem Kopplungselement definiert sind. +channel-type.velux.products.label = Identifizierte Produkte +channel-type.velux.products.description = Produkte welche auf dem Kopplungselement im Rahmen von Szenen definiert sind. +channel-type.velux.doDetection.label = Produkterkennung +channel-type.velux.doDetection.description = Schalter zum Start der Produkterkennung. -channel-type.velux.ACTION.label = Szenenstart -channel-type.velux.ACTION.description = Schalter zum Start dieser Szene -channel-type.velux.SILENTMODE.label = Stillmodus -channel-type.velux.SILENTMODE.description = Aktiviert den Leise-Modus auf einer definierten Szene. +channel-type.velux.action.label = Szenenstart +channel-type.velux.action.description = Schalter zum Start dieser Szene +channel-type.velux.silentMode.label = Stillmodus +channel-type.velux.silentMode.description = Aktiviert den Leise-Modus auf einer definierten Szene. # end-of-ESH-INF/i18n/velux_de.properties diff --git a/addons/binding/org.openhab.binding.velux/ESH-INF/thing/bridge.xml b/addons/binding/org.openhab.binding.velux/ESH-INF/thing/bridge.xml index b71e5eade3ac3..3dd755f69ec15 100644 --- a/addons/binding/org.openhab.binding.velux/ESH-INF/thing/bridge.xml +++ b/addons/binding/org.openhab.binding.velux/ESH-INF/thing/bridge.xml @@ -1,6 +1,6 @@ velux123 @@ -57,7 +63,7 @@ true - + Number of retries with timing along the Binary Exponential Backoff (BEB) Algorithm. false 6 diff --git a/addons/binding/org.openhab.binding.velux/ESH-INF/thing/channels.xml b/addons/binding/org.openhab.binding.velux/ESH-INF/thing/channels.xml index 5259bcdd66e8c..0b8b0d6d48e45 100644 --- a/addons/binding/org.openhab.binding.velux/ESH-INF/thing/channels.xml +++ b/addons/binding/org.openhab.binding.velux/ESH-INF/thing/channels.xml @@ -1,6 +1,6 @@ - - - - - Switch - - Activates a set of predefined product settings - Scene - - - - Switch - - Activates the silent mode of the predefined product settings - Scene - - - - - - String - - Software version of the Bridge - Bridge + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0" + xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd"> + + + + + Switch + + Activates a set of predefined product settings + Scene + + + + Switch + + Activates the silent mode of the predefined product settings + Scene + + + + + + String + + Software version of the Bridge + Bridge - - - - String - - Description of current Bridge State - Bridge - - - - - String - - IP address of the Bridge - Bridge - - - - - String - - IP subnetmask of the Bridge - Bridge - - - - - String - - IP address of the Default Gateway of the Bridge - Bridge - - + + + + String + + Description of current Bridge State + Bridge + + + + + String + + IP address of the Bridge + Bridge + + + + + String + + IP subnetmask of the Bridge + Bridge + + + + + String + + IP address of the Default Gateway of the Bridge + Bridge + + - Switch - - Flag whether automatic IP configuration is enabled - Bridge - - + Switch + + Flag whether automatic IP configuration is enabled + Bridge + + - String - - Name of the wireless network - Bridge - - - - - String - - WLAN Authentication Password - Bridge - - - - - Switch - - Start of the Detection Mode - Bridge - - - - String - - Products which are configured on the Bridge - Bridge + String + + Name of the wireless network + Bridge + + + + + String + + WLAN Authentication Password + Bridge + + + + + Switch + + Start of the Detection Mode + Bridge + + + + String + + Products which are configured on the Bridge + Bridge - + - - String - - Scenes which are configured on the Bridge - Bridge + + String + + Scenes which are configured on the Bridge + Bridge - + diff --git a/addons/binding/org.openhab.binding.velux/ESH-INF/thing/thing-types.xml b/addons/binding/org.openhab.binding.velux/ESH-INF/thing/thing-types.xml index 502923a0d61c8..401c757f4a04b 100644 --- a/addons/binding/org.openhab.binding.velux/ESH-INF/thing/thing-types.xml +++ b/addons/binding/org.openhab.binding.velux/ESH-INF/thing/thing-types.xml @@ -1,6 +1,6 @@ - + - - - Provides basic information of the program - + Control a scene on the Velux KLF 200 - - + + - - - - Interval which describes the lifetime of this thing. - false - -1 - true - Name of the scene to be handled. - false + true false - - diff --git a/addons/binding/org.openhab.binding.velux/META-INF/MANIFEST.MF b/addons/binding/org.openhab.binding.velux/META-INF/MANIFEST.MF index a5298cb3b6d03..088e517f75d80 100644 --- a/addons/binding/org.openhab.binding.velux/META-INF/MANIFEST.MF +++ b/addons/binding/org.openhab.binding.velux/META-INF/MANIFEST.MF @@ -1,10 +1,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: velux Binding +Bundle-Name: Velux Binding Bundle-SymbolicName: org.openhab.binding.velux;singleton:=true Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Vendor: openHAB -Bundle-Version: 2.2.0.qualifier +Bundle-Version: 2.3.0.qualifier Bundle-ClassPath: . Import-Package: com.google.common.collect, @@ -12,6 +12,7 @@ Import-Package: org.apache.commons.io, org.apache.commons.lang, org.apache.log4j, + org.eclipse.jdt.annotation;resolution:=optional, org.eclipse.smarthome.config.core, org.eclipse.smarthome.config.core.status, org.eclipse.smarthome.config.discovery, @@ -23,9 +24,17 @@ Import-Package: org.eclipse.smarthome.core.types, org.eclipse.smarthome.io.net.http, org.openhab.binding.velux, + org.openhab.binding.velux.bridge, + org.openhab.binding.velux.bridge.comm, + org.openhab.binding.velux.discovery, + org.openhab.binding.velux.things, org.openhab.binding.velux.handler, org.osgi.framework, org.slf4j Service-Component: OSGI-INF/*.xml Export-Package: org.openhab.binding.velux, - org.openhab.binding.velux.handler + org.openhab.binding.velux.handler, + org.openhab.binding.velux.bridge, + org.openhab.binding.velux.bridge.comm, + org.openhab.binding.velux.discovery, + org.openhab.binding.velux.things diff --git a/addons/binding/org.openhab.binding.velux/OSGI-INF/veluxHandlerFactory.xml b/addons/binding/org.openhab.binding.velux/OSGI-INF/veluxHandlerFactory.xml index b31bec6b391b6..d19e777758057 100644 --- a/addons/binding/org.openhab.binding.velux/OSGI-INF/veluxHandlerFactory.xml +++ b/addons/binding/org.openhab.binding.velux/OSGI-INF/veluxHandlerFactory.xml @@ -1,14 +1,4 @@ - diff --git a/addons/binding/org.openhab.binding.velux/README.md b/addons/binding/org.openhab.binding.velux/README.md index ff413f13bd06f..6967823957c43 100644 --- a/addons/binding/org.openhab.binding.velux/README.md +++ b/addons/binding/org.openhab.binding.velux/README.md @@ -12,27 +12,35 @@ The binding can be configured in the file `services/velux.cfg`. | Property | Default | Required | Description | |----------------|------------------------|:--------:|-------------------------------------------------------| -| bridgeURL | http://velux.bridge:80 | Yes | Basic bridge URL for accessing the Velux Bridge. | +| bridgeIPAddress| 127.0.0.1 | Yes | Name of address for accessing the Velux Bridge. | +| bridgeTCPPort | 80 | No | TCP port for accessing the Velux Bridge. | | bridgePassword | velux123 | Yes | Password for authentication against the Velux Bridge. | | timeoutMsecs | 2000 | No | Initial Connection timeout in milliseconds | | retries | 6 | No | Number of retries during I/O | Advise: if you see a significant number of messages per day like + ``` "communicate(): socket I/O failed continuously (x times)." ``` + please increase the parameters retries or/and timeoutMsecs. Additionaly each scene Thing can process the following parameters: | Property | Default | Required | Description | |----------------|------------------------|:--------:|-------------------------------------------------------| -| sceneName | | No | Name of the scene to be handled. | -| TTL | -1 | No | Interval which describes the lifetime of this thing. | +| sceneName | | Yes | Name of the scene to be handled. | ## Supported Things -The Velux Bridge in API version One (firmware version 0.1.1.0.41.0) allows to activate a set of predefined actions, so called scenes. Therefore beside the bridge, only one main thing exists, the scene element. +The Velux Bridge in API version One (firmware version 0.1.1.*) allows to activate a set of predefined actions, so called scenes. Therefore beside the bridge, only one main thing exists, the scene element. Unfortunatelly even the current firmware version 0.1.1.0.44.0 does not include enhacements on this fact. + +| 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 | N/A | +| 0.1.1.0.44.0 | 2017-12-14 | N/A | ## Discovery @@ -43,13 +51,26 @@ Unfortunatelly there is no way to discover the Velux bridge within the local net The Velux Bridge requires the URL as a configuration value in order for the binding to know how to access it. Additionally, a refresh interval, used to poll the Velux system, can be specified (in seconds). -In the thing file, this looks e.g. like +In the thing file, i.e. velux.things, this looks at least like + +``` +Bridge velux:klf200:home [ bridgeIPAddress="velux-klf200.smile.de" ] +``` + +which allows to discover all scenes and instantiate them manually with GUI. + + +A more complex preconfigured thing file this looks e.g. like + ``` -Bridge velux:klf200:home [ bridgeURL="http://my-klf200.velux.home" ] { - Thing scene karlsruhe [ ] +Bridge velux:klf200:home [ bridgeIPAddress="velux-klf200.smile.de", bridgeTCPPort=15001 ] { + Thing scene windowClosed [ sceneName="V_DG_Window_Mitte_000" ] + Thing scene windowUnlocked [ sceneName="V_DG_Window_Mitte_005" ] + Thing scene windowOpened [ sceneName="V_DG_Window_Mitte_100" ] } ``` + | Thing type | Description | |------------|---------------------------------------------------------------------------| | klf200 | The Velux KLF200 represents a gateway to all Velux devices. | @@ -63,25 +84,27 @@ The only currently available channel is the activation of some combined actions, | Channel Type ID | Item Type | Description | Thing types | |-----------------|-----------|-----------------------------------------------------------------|--------------| -| ACTION | Switch | Activates a set of predefined product settings | scene | -| SILENTMODE | Switch | Modification of the silent mode of the defined product settings | scene | -| STATUS | String | Current Bridge State | klf200 | -| DETECTION | Switch | Start of the product detection mode | klf200 | -| FIRMWARE | String | Software version of the Bridge | klf200 | -| IPADDRESS | String | IP address of the Bridge | klf200 | -| SUBNETMASK | String | IP subnetmask of the Bridge | klf200 | -| DEFAULTGW | String | IP address of the Default Gateway of the Bridge | klf200 | +| action | Switch | Activates a set of predefined product settings | scene | +| silentMode | Switch | Modification of the silent mode of the defined product settings | scene | +| status | String | Current Bridge State | klf200 | +| doDetection | Switch | Start of the product detection mode | klf200 | +| firmware | String | Software version of the Bridge | klf200 | +| ipAddress | String | IP address of the Bridge | klf200 | +| subnetMask | String | IP subnetmask of the Bridge | klf200 | +| defaultGW | String | IP address of the Default Gateway of the Bridge | klf200 | | DHCP | Switch | Flag whether automatic IP configuration is enabled | klf200 | | WLANSSID | String | Name of the wireless network | klf200 | -| WLANPASSWORD | String | WLAN Authentication Password | klf200 | +| WLANPassword | String | WLAN Authentication Password | klf200 | ## Full Example ### Things ``` -Bridge velux:klf200:home [ bridgeURL="http://192.168.0.111:80", bridgePassword="velux123", timeoutMsecs=2000, retries=10 ] { - Thing scene karlsruhe [ TTL=-1 ] +Bridge velux:klf200:home [ bridgeIPAddress="velux-klf200.smile.de", bridgeTCPPort=15001, bridgePassword="velux123", timeoutMsecs=2000, retries=10 ] { + Thing scene windowClosed [ sceneName="V_DG_Window_Mitte_000" ] + Thing scene windowUnlocked [ sceneName="V_DG_Window_Mitte_005" ] + Thing scene windowOpened [ sceneName="V_DG_Window_Mitte_100" ] } ``` @@ -95,33 +118,21 @@ Group:Switch:OR(ON, OFF) gV "PushButton" // Velux Bridge channels -Switch V_BRIDGE_STATUS "Velux Bridge Status" { channel="velux:klf200:home:STATUS" } -String V_BRIDGE_FIRMWARE "Velux Bridge Firmware version" { channel="velux:klf200:home:FIRMWARE" } -String V_BRIDGE_IPADDRESS "Velux Bridge IP Address" { channel="velux:klf200:home:IPADDRESS" } -String V_BRIDGE_SUBNETMASK "Velux Bridge IP Subnet Mask" { channel="velux:klf200:home:SUBNETMASK" } -String V_BRIDGE_DEFAULTGW "Velux Bridge Default Gateway" { channel="velux:klf200:home:DEFAULTGW" } +String V_BRIDGE_STATUS "Velux Bridge Status" { channel="velux:klf200:home:status" } +String V_BRIDGE_FIRMWARE "Velux Bridge Firmware version" { channel="velux:klf200:home:firmware" } +String V_BRIDGE_IPADDRESS "Velux Bridge IP Address" { channel="velux:klf200:home:ipAddress" } +String V_BRIDGE_SUBNETMASK "Velux Bridge IP Subnet Mask" { channel="velux:klf200:home:subnetMask" } +String V_BRIDGE_DEFAULTGW "Velux Bridge Default Gateway" { channel="velux:klf200:home:defaultGW" } String V_BRIDGE_DHCP "Velux Bridge DHCP Enabled" { channel="velux:klf200:home:DHCP" } String V_BRIDGE_WLANSSID "Velux Bridge SSID" { channel="velux:klf200:home:WLANSSID" } -String V_BRIDGE_WLANPASSWD "Velux Bridge WLAN Password" { channel="velux:klf200:home:WLANPASSWORD" } -Switch V_BRIDGE_DETECTION "Velux Bridge Detection mode" (gV) { channel="velux:klf200:home:DETECTION" } +String V_BRIDGE_WLANPASSWD "Velux Bridge WLAN Password" { channel="velux:klf200:home:WLANPassword" } +Switch V_BRIDGE_DO_DETECTION "Velux Bridge Detection mode" (gV) { channel="velux:klf200:home:doDetection" } // Velux Scene channels -Switch V_DG_M_W_OPEN "Velux DG Window open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_100" } -Switch V_DG_M_W_90 "Velux DG Window 90% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_090" } -Switch V_DG_M_W_80 "Velux DG Window 80% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_080" } -Switch V_DG_M_W_70 "Velux DG Window 70% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_070" } -Switch V_DG_M_W_60 "Velux DG Window 60% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_060" } -Switch V_DG_M_W_50 "Velux DG Window 50% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_050" } -Switch V_DG_M_W_40 "Velux DG Window 40% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_040" } -Switch V_DG_M_W_30 "Velux DG Window 30% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_030" } -Switch V_DG_M_W_20 "Velux DG Window 20% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_020" } -Switch V_DG_M_W_10 "Velux DG Window 10% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_010" } -Switch V_DG_M_W_CLOSED "Velux DG Window closed" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_000" } - -Switch V_DG_M_R_OPEN "Velux DG Shutter Open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Shutter_Mitte_000" } -Switch V_DG_M_R_85 "Velux DG Shutter AlmostClosed" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Shutter_Mitte_085" } -Switch V_DG_M_R_CLOSED "Velux DG Shutter Closed" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Shutter_Mitte_100" } +Switch V_DG_M_W_OPEN "Velux DG Window open" (gV) { channel="velux:scene:home:windowOpened:action" } +Switch V_DG_M_W_UNLOCKED "Velux DG Window 05% open" (gV) { channel="velux:scene:home:windowUnlocked:action" } +Switch V_DG_M_W_CLOSED "Velux DG Window closed" (gV) { channel="velux:scene:home:windowClosed:action" } ``` ### Sitemap velux.sitemap @@ -132,20 +143,8 @@ sitemap velux label="Velux Environment" Frame label="Velux Shutter and Window" { Switch item=V_DG_M_W_OPEN - Switch item=V_DG_M_W_90 - Switch item=V_DG_M_W_80 - Switch item=V_DG_M_W_70 - Switch item=V_DG_M_W_60 - Switch item=V_DG_M_W_50 - Switch item=V_DG_M_W_40 - Switch item=V_DG_M_W_30 - Switch item=V_DG_M_W_20 - Switch item=V_DG_M_W_10 + Switch item=V_DG_M_W_UNLOCKED Switch item=V_DG_M_W_CLOSED - - Switch item=V_DG_M_R_OPEN - Switch item=V_DG_M_R_85 - Switch item=V_DG_M_R_CLOSED } Frame label="Velux Bridge" { @@ -219,9 +218,11 @@ log4j.logger.org.openhab.binding.velux = INFO # ``` + For using an IDE like Eclipse please use the specific entries within `logback_debug.xml` within the usual package: ``` + @@ -265,22 +266,39 @@ During startup of normal operations, there should be only some few messages with Another way to see what’s going on in the binding, is to switch the loglevel to DEBUG in the Karaf console: + ``` log:set DEBUG org.openhab.binding.velux ``` + If you want to see even more, switch to TRACE to also see the detailled bridge request/response data: + ``` log:set TRACE org.openhab.binding.velux ``` + To reset the logging back to normal: + ``` log:set INFO org.openhab.binding.velux ``` And finally to identify startup problems, try the following: + ``` stop org.openhab.binding.velux log:set TRACE org.openhab.binding.velux start org.openhab.binding.velux log:tail ``` + +## Famous last words + +All known Velux devices can be handled by this binding. In fact, there might be some new one which will be reported within the logfiles. Therefore, if you recognize an error message like: + +``` +20:59:05.721 [ERROR] [g.velux.things.VeluxProductReference] - PLEASE REPORT THIS TO MAINTAINER: VeluxProductReference(3) has found an unregistered ProductTypeId. +``` + +please pass the appropriate log line back to the maintainer to incorporate the new Velux device type. + diff --git a/addons/binding/org.openhab.binding.velux/cfg/velux.cfg b/addons/binding/org.openhab.binding.velux/cfg/velux.cfg deleted file mode 100644 index adf2cb0c67ce7..0000000000000 --- a/addons/binding/org.openhab.binding.velux/cfg/velux.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# -#/** -# * Copyright 2016-2017 (c) Guenther Schreiner -# * -# * All rights reserved. This program and the accompanying materials -# * are made available under the terms of the Eclipse Public License v1.0 -# * which accompanies this distribution, and is available at -# * http://www.eclipse.org/legal/epl-v10.html -# * -# */ -# - -# velux Binding Default Configuration diff --git a/addons/binding/org.openhab.binding.velux/doc/items/velux.items b/addons/binding/org.openhab.binding.velux/doc/items/velux.items index 2e23aa92d345d..59a991552d4f7 100644 --- a/addons/binding/org.openhab.binding.velux/doc/items/velux.items +++ b/addons/binding/org.openhab.binding.velux/doc/items/velux.items @@ -1,41 +1,43 @@ - -/* Velux Bridge and Devices */ +/** + * Copyright (c) 2010-2018 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + +/** + * OpenHAB item defintion for velux binding: + * Velux Bridge and Devices + * + * @author Guenther Schreiner - Initial contribution + */ // Group for simulating push buttons + Group:Switch:OR(ON, OFF) gV "PushButton" // Velux Bridge channels -String V_BRIDGE_STATUS "Velux Bridge Status" { channel="velux:klf200:home:STATUS" } -String V_BRIDGE_FIRMWARE "Velux Bridge Firmware version" { channel="velux:klf200:home:FIRMWARE" } -String V_BRIDGE_IPADDRESS "Velux Bridge IP Address" { channel="velux:klf200:home:IPADDRESS" } -String V_BRIDGE_SUBNETMASK "Velux Bridge IP Subnet Mask" { channel="velux:klf200:home:SUBNETMASK" } -String V_BRIDGE_DEFAULTGW "Velux Bridge Default Gateway" { channel="velux:klf200:home:DEFAULTGW" } +String V_BRIDGE_STATUS "Velux Bridge Status" { channel="velux:klf200:home:status" } +String V_BRIDGE_FIRMWARE "Velux Bridge Firmware version" { channel="velux:klf200:home:firmware" } +String V_BRIDGE_IPADDRESS "Velux Bridge IP Address" { channel="velux:klf200:home:ipAddress" } +String V_BRIDGE_SUBNETMASK "Velux Bridge IP Subnet Mask" { channel="velux:klf200:home:subnetMask" } +String V_BRIDGE_DEFAULTGW "Velux Bridge Default Gateway" { channel="velux:klf200:home:defaultGW" } String V_BRIDGE_DHCP "Velux Bridge DHCP Enabled" { channel="velux:klf200:home:DHCP" } String V_BRIDGE_WLANSSID "Velux Bridge SSID" { channel="velux:klf200:home:WLANSSID" } -String V_BRIDGE_WLANPASSWD "Velux Bridge WLAN Password" { channel="velux:klf200:home:WLANPASSWORD" } -Switch V_BRIDGE_DETECTION "Velux Bridge Detection mode" (gV) { channel="velux:klf200:home:DETECTION" } -// -// for debugging/initial review of scenes and products: -// String V_BRIDGE_SCENES "Velux Bridge Scenes" { channel="velux:klf200:home:SCENES" } -// String V_BRIDGE_PRODUCTS "Velux Bridge Products" { channel="velux:klf200:home:PRODUCTS" } +String V_BRIDGE_WLANPASSWD "Velux Bridge WLAN Password" { channel="velux:klf200:home:WLANPassword" } +Switch V_BRIDGE_DETECTION "Velux Bridge Detection mode" (gV) { channel="velux:klf200:home:doDetection" } // Velux Scene channels -Switch V_DG_M_W_OPEN "Velux DG Window open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_100" } -Switch V_DG_M_W_90 "Velux DG Window 90% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_090" } -Switch V_DG_M_W_80 "Velux DG Window 80% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_080" } -Switch V_DG_M_W_70 "Velux DG Window 70% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_070" } -Switch V_DG_M_W_60 "Velux DG Window 60% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_060" } -Switch V_DG_M_W_50 "Velux DG Window 50% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_050" } -Switch V_DG_M_W_40 "Velux DG Window 40% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_040" } -Switch V_DG_M_W_30 "Velux DG Window 30% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_030" } -Switch V_DG_M_W_20 "Velux DG Window 20% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_020" } -Switch V_DG_M_W_10 "Velux DG Window 10% open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_010" } -Switch V_DG_M_W_CLOSED "Velux DG Window closed" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Window_Mitte_000" } - -Switch V_DG_M_R_OPEN "Velux DG Shutter Open" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Shutter_Mitte_000" } -Switch V_DG_M_R_85 "Velux DG Shutter AlmostClosed" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Shutter_Mitte_085" } -Switch V_DG_M_R_CLOSED "Velux DG Shutter Closed" (gV) { channel="velux:scene:home:karlsruhe:ACTION#V_DG_Shutter_Mitte_100" } - -// vim: syntax=Xtend +Switch V_DG_M_W_OPEN "Velux DG Window open" (gV) { channel="velux:scene:home:windowOpened:action" } +Switch V_DG_M_W_UNLOCKED "Velux DG Window a little open" (gV) { channel="velux:scene:home:windowUnlocked:action" } +Switch V_DG_M_W_CLOSED "Velux DG Window closed" (gV) { channel="velux:scene:home:windowClosed:action" } + +// +// vim: syntax=Xtend vim: noai:ts=4:sw=4 +// +// end-of-items/velux.items +// diff --git a/addons/binding/org.openhab.binding.velux/doc/rules/velux.rules b/addons/binding/org.openhab.binding.velux/doc/rules/velux.rules index f38d9c8917146..86d6e0077a0e4 100644 --- a/addons/binding/org.openhab.binding.velux/doc/rules/velux.rules +++ b/addons/binding/org.openhab.binding.velux/doc/rules/velux.rules @@ -1,6 +1,18 @@ - /* - * start-of-velux.rules - */ +/** + * Copyright (c) 2010-2018 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + +/** + * OpenHAB rule definition for velux binding: + * simulate push button behaviour for action related items + * + * @author Guenther Schreiner - Initial contribution + */ /** * This is a rules to simulate the push button behaviour... @@ -18,4 +30,8 @@ rule "PushButton of group gV" ] end -// vim: syntax=Xtend +// +// vim: syntax=Xtend vim: noai:ts=4:sw=4 +// +// end-of-rules/velux.rules +// diff --git a/addons/binding/org.openhab.binding.velux/doc/sitemaps/velux.sitemap b/addons/binding/org.openhab.binding.velux/doc/sitemaps/velux.sitemap index 6cefb64f25423..fc4fc6dc6e2c0 100644 --- a/addons/binding/org.openhab.binding.velux/doc/sitemaps/velux.sitemap +++ b/addons/binding/org.openhab.binding.velux/doc/sitemaps/velux.sitemap @@ -1,22 +1,26 @@ +/** + * Copyright (c) 2010-2018 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + +/** + * OpenHAB sitemap definition for velux binding: + * displays most of the Velux items + * + * @author Guenther Schreiner - Initial contribution + */ + sitemap velux label="Velux Environment" { Frame label="Velux Shutter and Window" { Switch item=V_DG_M_W_OPEN - Switch item=V_DG_M_W_90 - Switch item=V_DG_M_W_80 - Switch item=V_DG_M_W_70 - Switch item=V_DG_M_W_60 - Switch item=V_DG_M_W_50 - Switch item=V_DG_M_W_40 - Switch item=V_DG_M_W_30 - Switch item=V_DG_M_W_20 - Switch item=V_DG_M_W_10 + Switch item=V_DG_M_W_UNLOCKED Switch item=V_DG_M_W_CLOSED - - Switch item=V_DG_M_R_OPEN - Switch item=V_DG_M_R_85 - Switch item=V_DG_M_R_CLOSED } Frame label="Velux Bridge" { @@ -28,12 +32,15 @@ sitemap velux label="Velux Environment" Switch item=V_BRIDGE_DHCP Text item=V_BRIDGE_WLANSSID Text item=V_BRIDGE_WLANPASSWD - Switch item=V_BRIDGE_DETECTION + Switch item=V_BRIDGE_DO_DETECTION // Text item=V_BRIDGE_PRODUCTS // Text item=V_BRIDGE_SCENES } } -// vim: syntax=Xtend - +// +// vim: syntax=Xtend vim: noai:ts=4:sw=4 +// +// end-of-sitemap/velux.sitemap +// diff --git a/addons/binding/org.openhab.binding.velux/doc/things/velux.things b/addons/binding/org.openhab.binding.velux/doc/things/velux.things index adff2c0671384..3cce535997e7f 100644 --- a/addons/binding/org.openhab.binding.velux/doc/things/velux.things +++ b/addons/binding/org.openhab.binding.velux/doc/things/velux.things @@ -1,9 +1,32 @@ +/** + * Copyright (c) 2010-2018 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + +/** + * OpenHAB thing definition for velux binding: + * define basic Velux bridge parameters + * + * @author Guenther Schreiner - Initial contribution + */ + // -// Bridge velux:klf200:home +// Definition of Velux bridge velux:klf200:home // -Bridge velux:klf200:home [ bridgeURL="http://127.0.0.1:15001", bridgePassword="velux123", timeoutMsecs=2000, retries=10 ] { - Thing scene karlsruhe [ refreshSecs=120 ] +Bridge velux:klf200:home [ bridgeIPAddress="velux-klf200.smile.de", bridgeTCPPort=15001 ] { + Thing scene windowClosed [ sceneName="V_DG_Window_Mitte_000" ] + Thing scene windowUnlocked [ sceneName="V_DG_Window_Mitte_005" ] + Thing scene windowOpened [ sceneName="V_DG_Window_Mitte_100" ] + Thing scene unknownScene [ sceneName="ThisIsADummySceneName" ] } -// vim: syntax=Xtend +// +// vim: syntax=Xtend vim: noai:ts=4:sw=4 +// +// end-of-things/velux.things +// diff --git a/addons/binding/org.openhab.binding.velux/pom.xml b/addons/binding/org.openhab.binding.velux/pom.xml index 0ab35eb0bf7ba..c0465e86a171b 100644 --- a/addons/binding/org.openhab.binding.velux/pom.xml +++ b/addons/binding/org.openhab.binding.velux/pom.xml @@ -1,37 +1,59 @@ - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> org.openhab.binding pom - 2.2.0-SNAPSHOT + 2.3.0-SNAPSHOT - velux Binding - - - org.openhab.binding.velux - org.openhab.binding.velux - openhab-addon-binding-velux - ${project.name} - - + + org.openhab.binding.velux + org.openhab.binding.velux + openhab-addon-binding-velux + ${project.name} + 4.0.0 org.openhab.binding org.openhab.binding.velux - eclipse-plugin - The Velux Binding interacts via the Velux Bridge with the Velux devices like controlling window openers, shutters and others. + 2.3.0-SNAPSHOT + + + + org.apache.felix + maven-bundle-plugin + 3.3.0 + true + + + org.openhab.binding.velux + org.openhab.binding.velux.handler + org.openhab.binding.velux.bridge + org.openhab.binding.velux.bridge.comm + org.openhab.binding.velux.discovery; + org.openhab.binding.velux.things + org.openhab.binding.velux.internal.VeluxHandlerFactory + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + + + + org.apache.felix + org.osgi.core + 1.4.0 + + - diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/VeluxBindingConstants.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/VeluxBindingConstants.java index 9d1504100b14c..e25f11899bc0f 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/VeluxBindingConstants.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/VeluxBindingConstants.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,6 +8,7 @@ */ package org.openhab.binding.velux; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.smarthome.core.thing.ThingTypeUID; /** @@ -19,35 +20,35 @@ public class VeluxBindingConstants { /** Basis identification */ - public static final String BINDING_ID = "velux"; + public static final @NonNull String BINDING_ID = "velux"; // List of all Strings - public static final String BRIDGE_TYPE = "klf200"; + public static final @NonNull String BRIDGE_TYPE = "klf200"; - public static final String THING_VELUX_SCENE = "scene"; + public static final @NonNull String THING_VELUX_SCENE = "scene"; // List of all Bridge Type UIDs - public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, BRIDGE_TYPE); + public static final @NonNull ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, BRIDGE_TYPE); // List of all Thing Type UIDs - public static final ThingTypeUID THING_TYPE_VELUX_SCENE = new ThingTypeUID(BINDING_ID, THING_VELUX_SCENE); - - // List of all Channel id's (for Bridge) - public static final String CHANNEL_BRIDGE_STATUS = "STATUS"; - public static final String CHANNEL_BRIDGE_DETECTION = "DETECTION"; - public static final String CHANNEL_BRIDGE_FIRMWARE = "FIRMWARE"; - public static final String CHANNEL_BRIDGE_IPADDRESS = "IPADDRESS"; - public static final String CHANNEL_BRIDGE_SUBNETMASK = "SUBNETMASK"; - public static final String CHANNEL_BRIDGE_DEFAULTGW = "DEFAULTGW"; - public static final String CHANNEL_BRIDGE_DHCP = "DHCP"; - public static final String CHANNEL_BRIDGE_WLANSSID = "WLANSSID"; - public static final String CHANNEL_BRIDGE_WLANPASSWORD = "WLANPASSWORD"; - public static final String CHANNEL_BRIDGE_PRODUCTS = "PRODUCTS"; - public static final String CHANNEL_BRIDGE_SCENES = "SCENES"; - - // List of all Channel id's (for each Scene) - public static final String CHANNEL_SCENE_ACTION = "ACTION"; - public static final String CHANNEL_SCENE_SILENTMODE = "SILENTMODE"; + public static final @NonNull ThingTypeUID THING_TYPE_VELUX_SCENE = new ThingTypeUID(BINDING_ID, THING_VELUX_SCENE); + + // List of all bridge channel ids + public static final @NonNull String CHANNEL_BRIDGE_STATUS = "status"; + public static final @NonNull String CHANNEL_BRIDGE_DO_DETECTION = "doDetection"; + public static final @NonNull String CHANNEL_BRIDGE_FIRMWARE = "firmware"; + public static final @NonNull String CHANNEL_BRIDGE_IPADDRESS = "ipAddress"; + public static final @NonNull String CHANNEL_BRIDGE_SUBNETMASK = "subnetMask"; + public static final @NonNull String CHANNEL_BRIDGE_DEFAULTGW = "defaultGW"; + public static final @NonNull String CHANNEL_BRIDGE_DHCP = "DHCP"; + public static final @NonNull String CHANNEL_BRIDGE_WLANSSID = "WLANSSID"; + public static final @NonNull String CHANNEL_BRIDGE_WLANPASSWORD = "WLANPassword"; + public static final @NonNull String CHANNEL_BRIDGE_PRODUCTS = "products"; + public static final @NonNull String CHANNEL_BRIDGE_SCENES = "scenes"; + + // List of all scene channel ids + public static final @NonNull String CHANNEL_SCENE_ACTION = "action"; + public static final @NonNull String CHANNEL_SCENE_SILENTMODE = "silentMode"; } /** diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/VeluxBindingProperties.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/VeluxBindingProperties.java index 79c83e30fad26..e6eff9e62602f 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/VeluxBindingProperties.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/VeluxBindingProperties.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,6 +8,8 @@ */ package org.openhab.binding.velux; +import org.eclipse.jdt.annotation.NonNull; + /** * The {@link VeluxBindingProperties} class defines common constants, which are * used within the property definitions. @@ -15,8 +17,7 @@ * @author Guenther Schreiner - Initial contribution */ public class VeluxBindingProperties { - public static final String PROPERTY_SCENE_NAME = "sceneName"; - public static final String PROPERTY_TTL = "TTL"; + public static final @NonNull String PROPERTY_SCENE_NAME = "sceneName"; } /** diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridge.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridge.java index dcf0a7f937854..8423a9c8c2015 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridge.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridge.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -31,14 +31,21 @@ * @author Guenther Schreiner - Initial contribution. */ public class VeluxBridge { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxBridge.class); + private final Logger logger = LoggerFactory.getLogger(VeluxBridge.class); private static int retries = 5; private static long waitMSecs = 500L; - private static T io(String url, String authentication, Object Request, Class classOfResponse) - throws JsonSyntaxException, IOException { + /* + * Constructor. + */ + + public VeluxBridge() { + logger.trace("Creating a VeluxBridge."); + } + private T io(String url, String authentication, Object Request, Class classOfResponse) + throws JsonSyntaxException, IOException { /** Local handles */ int retryCount = 0; IOException lastIOE; @@ -47,66 +54,7 @@ private static T io(String url, String authentication, Object Request, Class try { com.google.gson.Gson gson = new com.google.gson.Gson(); String jsonRequest = gson.toJson(Request); - LOGGER.trace("io() to {} using request {}.", url, jsonRequest); - - // -------------------------------------------------------------------------------- - // Version A: based on org.apache.http.client.methods and org.apache.http.impl.client - // - // CloseableHttpClient httpClient = HttpClientBuilder.create().build(); - // HttpPost httpRequest = new HttpPost(url); - // httpRequest.addHeader("content-type", "application/json"); - // if (authentication.length() > 0) { - // httpRequest.addHeader("Authorization", String.format("Bearer %s", authentication)); - // } - // StringEntity body = new StringEntity(jsonRequest); - // httpRequest.setEntity(body); - // HttpResponse result = httpClient.execute(httpRequest); - // - // String jsonResponse = EntityUtils.toString(result.getEntity(), "UTF-8"); - // - // httpClient.close(); - // - // end-of-Version A - - // -------------------------------------------------------------------------------- - // Version B: based on org.apache.commons.httpclient.HttpClient - // - // HttpClient httpClient = new HttpClient(); - // PostMethod httpRequest = new PostMethod(url); - // httpRequest.addRequestHeader("content-type", "application/json"); - // if (authentication.length() > 0) { - // httpRequest.addRequestHeader("Authorization", String.format("Bearer %s", authentication)); - // } - // httpRequest.setRequestBody(jsonRequest); - // - // int statusCode = httpClient.executeMethod(httpRequest); - // if (statusCode != HttpStatus.SC_OK) { - // LOGGER.trace("io() got response {}", httpRequest.getStatusLine()); - // } - // - // InputStream inputStream = httpRequest.getResponseBodyAsStream(); - // String jsonResponse = IOUtils.toString(inputStream); - // - // httpRequest.releaseConnection(); - // - // - // needs: MANIFEST adaption: - // Bundle-ClassPath: ., - // lib/httpclient-4.5.2.jar, - // lib/httpcore-4.4.4.jar - // - // build.properties: - // ESH-INF/,\ - // lib/httpclient-4.5.2.jar,\ - // lib/httpcore-4.4.4.jar,\ - // about.html - // - // and, of course, the libraries within ./ib - // - // end-of-Version B - - // -------------------------------------------------------------------------------- - // Version C: based on org.eclipse.smarthome.io.net.http + logger.trace("io() to {} using request {}.", url, jsonRequest); Properties headerItems = new Properties(); if (authentication.length() > 0) { @@ -119,72 +67,57 @@ private static T io(String url, String authentication, Object Request, Class if (jsonResponse == null) { throw new IOException("transport error"); } - LOGGER.trace("io(): wait time {} msecs.", waitMSecs); + logger.trace("io(): wait time {} msecs.", waitMSecs); + // Give the bridge some time to breathe try { Thread.sleep(waitMSecs); } catch (InterruptedException ie) { - LOGGER.trace("io() wait interrupted."); + logger.trace("io() wait interrupted."); } - // end-of-Version C - // -------------------------------------------------------------------------------- - LOGGER.trace("io() got response {}.", jsonResponse.replaceAll("\\p{C}", ".")); + logger.trace("io() got response {}.", jsonResponse.replaceAll("\\p{C}", ".")); jsonResponse = jsonResponse.replaceAll("^.+,\n", ""); // "()]}'," - LOGGER.trace("io() cleaned response {}.", jsonResponse); + logger.trace("io() cleaned response {}.", jsonResponse); try { T response = gson.fromJson(jsonResponse, classOfResponse); return response; } catch (JsonSyntaxException jse) { - LOGGER.info("io(): Exception occurred on deserialization: {}, aborting.", jse.getMessage()); + logger.info("io(): Exception occurred on deserialization: {}, aborting.", jse.getMessage()); throw jse; } - } catch (IOException ioe) { - LOGGER.debug("io(): Exception occurred during I/O: {}.", ioe.getMessage()); + logger.debug("io(): Exception occurred during I/O: {}.", ioe.getMessage()); lastIOE = ioe; // Error Retries with Exponential Backoff long waitTime = ((long) Math.pow(2, retryCount) * waitMSecs); - LOGGER.trace("io(): wait time {} msecs.", waitTime); + logger.trace("io(): wait time {} msecs.", waitTime); try { Thread.sleep(waitTime); } catch (InterruptedException ie) { - LOGGER.trace("io() wait interrupted."); + logger.trace("io() wait interrupted."); } } } while (retryCount++ < retries); - LOGGER.info("io(): socket I/O failed continuously ({} times).", retries); + logger.info("io(): socket I/O failed continuously ({} times).", retries); throw lastIOE; } /** * Initializes an authenticated communication with the {@link VeluxBridge Velux bridge}. * - * @param url - * as String describing the Service Access Point location i.e. http://localhost/api . - * - * @param authentication - * as String providing the Authentication token to be passed with the request header. - * - * @param Request - * as Object representing the structure of the message request body to be converted into JSON. - * - * @param classOfResponse - * as Class representing the expected structure of the message response body to be converted from JSON. - * - * @param - * generic response based on classOfResponse. - * - * @return response - * of type T containing all resulting informations, i.e. device status, errors a.s.o. Will return + * @param url as String describing the Service Access Point location i.e. http://localhost/api . + * @param authentication as String providing the Authentication token to be passed with the request header. + * @param Request as Object representing the structure of the message request body to be converted into JSON. + * @param classOfResponse as Class representing the expected structure of the message response body to be converted + * from JSON. + * @param generic response based on classOfResponse. + * @return response of type T containing all resulting informations, i.e. device status, errors a.s.o. Will + * return * null in case of communication or decoding error. - * - * @throws java.io.IOException - * in case of continuous communication I/O failures. - * - * @throws JsonSyntaxException - * in case of unusual communication failures. + * @throws java.io.IOException in case of continuous communication I/O failures. + * @throws JsonSyntaxException in case of unusual communication failures. */ - public static T ioAuthenticated(String url, String authentication, Object Request, Class classOfResponse) + public T ioAuthenticated(String url, String authentication, Object Request, Class classOfResponse) throws JsonSyntaxException, IOException { return io(url, authentication, Request, classOfResponse); } @@ -192,29 +125,18 @@ public static T ioAuthenticated(String url, String authentication, Object Re /** * Initializes an unauthenticated communication with the {@link VeluxBridge Velux bridge}. * - * @param url - * as String describing the Service Access Point location i.e. http://localhost/api . - * - * @param Request - * as Object representing the structure of the message request body to be converted into JSON. - * - * @param classOfResponse - * as Class representing the expected structure of the message response body to be converted from JSON. - * - * @param - * generic response based on classOfResponse. - * - * @return response - * of type T containing all resulting informations, i.e. device status, errors a.s.o. Will return + * @param url as String describing the Service Access Point location i.e. http://localhost/api . + * @param Request as Object representing the structure of the message request body to be converted into JSON. + * @param classOfResponse as Class representing the expected structure of the message response body to be converted + * from JSON. + * @param generic response based on classOfResponse. + * @return response of type T containing all resulting informations, i.e. device status, errors a.s.o. Will + * return * null in case of communication or decoding error. - * - * @throws java.io.IOException - * in case of continuous communication I/O failures. - * - * @throws JsonSyntaxException - * in case of unusual communication failures. + * @throws java.io.IOException in case of continuous communication I/O failures. + * @throws JsonSyntaxException in case of unusual communication failures. */ - public static T ioUnauthenticated(String url, Object Request, Class classOfResponse) + public T ioUnauthenticated(String url, Object Request, Class classOfResponse) throws JsonSyntaxException, IOException { return io(url, "", Request, classOfResponse); } @@ -223,24 +145,19 @@ public static T ioUnauthenticated(String url, Object Request, Class class * Initializes the communication parameters of {@link VeluxBridge} * for interacting with the {@link VeluxBridge Velux bridge}. * - * @param retries - * as int defining the number of retries before throwing an I/O error. - * - * @param waitIntervalInMSecs - * as long defining the initial time wait interval in milliseconds for the Binary Exponential Backoff + * @param retries as int defining the number of retries before throwing an I/O error. + * @param waitIntervalInMSecs as long defining the initial time wait interval in milliseconds for the Binary + * Exponential Backoff * (BEB) Algorithm for handling of I/O failures. */ - public static void ioSetup(int retries, long waitIntervalInMSecs) { - LOGGER.debug("ioSetup(): retries = {} times, initial wait interval = {} msecs.", retries, waitIntervalInMSecs); + public void ioSetup(int retries, long waitIntervalInMSecs) { + logger.debug("ioSetup(): retries = {} times, initial wait interval = {} msecs.", retries, waitIntervalInMSecs); VeluxBridge.retries = retries; VeluxBridge.waitMSecs = waitIntervalInMSecs; } - private VeluxBridge() { - } - } /** * end-of-VeluxBridge.java diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeDetectProducts.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeDetectProducts.java index 6023fb34aac39..108f326960a14 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeDetectProducts.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeDetectProducts.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -11,6 +11,7 @@ import org.openhab.binding.velux.bridge.comm.BCdetectProducts; import org.openhab.binding.velux.bridge.comm.BCgetDeviceStatus; import org.openhab.binding.velux.handler.VeluxBridgeHandler; +import org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,7 +28,7 @@ * @author Guenther Schreiner - Initial contribution */ public class VeluxBridgeDetectProducts { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxBridgeDetectProducts.class); + private final Logger logger = LoggerFactory.getLogger(VeluxBridgeDetectProducts.class); private static long waitMSecs = 2000L; @@ -35,55 +36,53 @@ public class VeluxBridgeDetectProducts { * Login into bridge, start process to detect (new) products, loop until bridge is idle again and logout from bridge * based on a well-prepared environment of a {@link VeluxBridgeHandler}. * - * @param bridge - * Initialized Velux bridge handler. - * + * @param bridge Initialized Velux bridge handler. * @return success * of type boolean describing the overall result of this interaction. */ - public static boolean detectProducts(VeluxBridgeHandler bridge) { - LOGGER.trace("detectProducts() called."); + public boolean detectProducts(VeluxBridgeHandler bridge) { + logger.trace("detectProducts() called."); boolean success = false; if (!bridge.bridgeLogin()) { - LOGGER.debug("Velux bridge login sequence failed; expecting bridge is OFFLINE."); + logger.debug("Velux bridge login sequence failed; expecting bridge is OFFLINE."); return false; } - LOGGER.trace("detectProducts() About to activate detection."); + logger.trace("detectProducts() About to activate detection."); BCdetectProducts.Response detectResponse = bridge.bridgeCommunicate(new BCdetectProducts()); if (detectResponse != null) { while (true) { - LOGGER.trace("detectProducts() About to query detection status."); + logger.trace("detectProducts() About to query detection status."); BCgetDeviceStatus.Response response = bridge.bridgeCommunicate(new BCgetDeviceStatus()); if ((response == null) || (!response.getResult())) { - LOGGER.trace("detectProducts() finished with failure."); + logger.trace("detectProducts() finished with failure."); break; } String deviceStatus = response.getDeviceStatus(); if (deviceStatus.equals("discovering")) { - LOGGER.trace("detectProducts() bridge is still busy."); + logger.trace("detectProducts() bridge is still busy."); } else if (deviceStatus.equals("IDLE")) { - LOGGER.trace("detectProducts() bridge is idle again, now."); + logger.trace("detectProducts() bridge is idle again, now."); success = true; break; } else { - LOGGER.info("detectProducts() unknown devicestatus ({}) received.", deviceStatus); + logger.info("detectProducts() unknown devicestatus ({}) received.", deviceStatus); } - LOGGER.trace("detectProducts() about to wait {} msecs.", waitMSecs); + logger.trace("detectProducts() about to wait {} msecs.", waitMSecs); try { Thread.sleep(waitMSecs); } catch (InterruptedException ie) { - LOGGER.trace("detectProducts() wait interrupted."); + logger.trace("detectProducts() wait interrupted."); } } } else { - LOGGER.trace("detectProducts() activate detection finished with failure."); + logger.trace("detectProducts() activate detection finished with failure."); } if (!bridge.bridgeLogout()) { - LOGGER.debug("Velux bridge logout sequence failed; expecting bridge is OFFLINE."); + logger.debug("Velux bridge logout sequence failed; expecting bridge is OFFLINE."); } - LOGGER.debug("detectProducts() finished {}.", success ? "successfully" : "with failure"); + logger.debug("detectProducts() finished {}.", success ? "successfully" : "with failure"); return success; } } diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeDeviceStatus.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeDeviceStatus.java index dcdaf6fe1d3ce..b98273dc35a01 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeDeviceStatus.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeDeviceStatus.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -32,11 +32,8 @@ public class VeluxBridgeDeviceStatus { * Login into bridge, query the bridge for device status and logout from bridge * based on a well-prepared environment of a {@link VeluxBridgeHandler}. * - * @param bridge - * Initialized Velux bridge handler. - * - * @return status - * of type String describing the status of the device/bridge. + * @param bridge Initialized Velux bridge handler. + * @return status of type String describing the status of the device/bridge. */ public String retrieve(VeluxBridgeHandler bridge) { diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeExecute.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeExecute.java index e5a8bfc042672..62e21778450f8 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeExecute.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeExecute.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -10,6 +10,7 @@ import org.openhab.binding.velux.bridge.comm.BCrunScene; import org.openhab.binding.velux.handler.VeluxBridgeHandler; +import org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,40 +27,36 @@ * @author Guenther Schreiner - Initial contribution */ public class VeluxBridgeExecute { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxBridgeExecute.class); + private final Logger logger = LoggerFactory.getLogger(VeluxBridgeExecute.class); /** * Login into bridge, executes a scene and logout from bridge based * on a well-prepared environment of a {@link VeluxBridgeHandler}. * - * @param bridge - * Initialized Velux bridge handler. - * - * @param sceneNo - * Number of scene to be executed. - * + * @param bridge Initialized Velux bridge handler. + * @param sceneNo Number of scene to be executed. * @return success * of type boolean describing the overall result of this interaction. */ - public static boolean execute(VeluxBridgeHandler bridge, int sceneNo) { - LOGGER.trace("execute({}) called.", sceneNo); + public boolean execute(VeluxBridgeHandler bridge, int sceneNo) { + logger.trace("execute({}) called.", sceneNo); if (!bridge.bridgeLogin()) { - LOGGER.debug("Velux bridge login sequence failed; expecting bridge is OFFLINE."); + logger.debug("Velux bridge login sequence failed; expecting bridge is OFFLINE."); return false; } BCrunScene.Response response = bridge.bridgeCommunicate(new BCrunScene(sceneNo)); if (response != null) { if (response.getResult()) { - LOGGER.info("execute() finished successfully."); + logger.info("execute() finished successfully."); return true; } } if (!bridge.bridgeLogout()) { - LOGGER.debug("Velux bridge logout sequence failed; expecting bridge is OFFLINE."); + logger.debug("Velux bridge logout sequence failed; expecting bridge is OFFLINE."); return false; } - LOGGER.trace("execute() finished with failure."); + logger.trace("execute() finished with failure."); return false; } } diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeFirmware.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeFirmware.java index 2947e6cf69826..6b41346b6ff1a 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeFirmware.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeFirmware.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -10,13 +10,13 @@ import org.openhab.binding.velux.bridge.comm.BCgetFirmware; import org.openhab.binding.velux.handler.VeluxBridgeHandler; +import org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * The {@link VeluxBridgeFirmware} represents a complete set of transactions - * for retrieving of any available scenes into a structure {@link VeluxExistingScenes} - * defined on the Velux bridge. + * for retrieving of firmware version string on the Velux bridge. *

* It therefore provides a method *

    @@ -32,7 +32,7 @@ public class VeluxBridgeFirmware { private final Logger logger = LoggerFactory.getLogger(VeluxBridgeFirmware.class); /** - * Wireless network configuration, consisting of: + * Bridge information, (currently only) consisting of: *
      *
    • isRetrieved (boolean flag), *
    • firmwareVersion. @@ -50,9 +50,7 @@ public class Channel { * version and logout from bridge based on a well-prepared environment of a {@link VeluxBridgeHandler}, where the * results are stored within as well in {@link VeluxBridgeFirmware#channel}. * - * @param bridge - * Initialized Velux bridge handler. - * + * @param bridge Initialized Velux bridge handler. * @return channel - or null - * of type {@link VeluxBridgeFirmware.Channel} describing the overall result of this interaction. */ diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeGetProducts.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeGetProducts.java index 73d49ce4c7297..597075f947999 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeGetProducts.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeGetProducts.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -11,6 +11,7 @@ import org.openhab.binding.velux.bridge.comm.BCgetProducts; import org.openhab.binding.velux.bridge.comm.BCproduct; import org.openhab.binding.velux.handler.VeluxBridgeHandler; +import org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration; import org.openhab.binding.velux.things.VeluxExistingProducts; import org.openhab.binding.velux.things.VeluxProduct; import org.slf4j.Logger; @@ -33,7 +34,7 @@ * @author Guenther Schreiner - Initial contribution */ public class VeluxBridgeGetProducts { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxBridgeGetProducts.class); + private final Logger logger = LoggerFactory.getLogger(VeluxBridgeGetProducts.class); /** * Login into bridge, retrieve all products and logout from bridge based @@ -41,32 +42,29 @@ public class VeluxBridgeGetProducts { * are stored within a public structure {@link org.openhab.binding.velux.things.VeluxExistingProducts * VeluxExistingProducts}. * - * @param bridge - * Initialized Velux bridge handler. - * + * @param bridge Initialized Velux bridge handler. * @return success * of type boolean describing the overall result of this interaction. */ - public static boolean getProducts(VeluxBridgeHandler bridge) { - LOGGER.trace("getProducts() called."); + public boolean getProducts(VeluxBridgeHandler bridge) { + logger.trace("getProducts() called."); BCgetProducts.Response response = bridge.bridgeCommunicate(new BCgetProducts()); if (response != null) { for (BCproduct product : response.getDevices()) { - LOGGER.trace("getProducts() found product {} (type {}).", product.getName(), product.getCategory()); + logger.trace("getProducts() found product {} (type {}).", product.getName(), product.getCategory()); VeluxProduct veluxProduct = new VeluxProduct(product); - LOGGER.trace("getProducts() storing product {}.", veluxProduct); + logger.trace("getProducts() storing product {}.", veluxProduct); if (!bridge.existingsProducts.isRegistered(veluxProduct)) { bridge.existingsProducts.register(veluxProduct); } } - LOGGER.debug("getProducts() finally has found products {}.", bridge.existingsProducts); + logger.debug("getProducts() finally has found products {}.", bridge.existingsProducts); return true; - } else { - LOGGER.trace("getProducts() finished with failure."); + logger.trace("getProducts() finished with failure."); return false; } } diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeGetScenes.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeGetScenes.java index ea01dbd0ee2f0..cb0f02f8d9923 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeGetScenes.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeGetScenes.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -10,6 +10,7 @@ import org.openhab.binding.velux.bridge.comm.BCgetScenes; import org.openhab.binding.velux.handler.VeluxBridgeHandler; +import org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration; import org.openhab.binding.velux.things.VeluxExistingScenes; import org.openhab.binding.velux.things.VeluxScene; import org.slf4j.Logger; @@ -32,28 +33,28 @@ * @author Guenther Schreiner - Initial contribution */ public class VeluxBridgeGetScenes { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxBridgeGetScenes.class); + private final Logger logger = LoggerFactory.getLogger(VeluxBridgeGetScenes.class); // - public static boolean getScenes(VeluxBridgeHandler bridge) { - LOGGER.trace("getScenes() called."); + public boolean getScenes(VeluxBridgeHandler bridge) { + logger.trace("getScenes() called."); BCgetScenes.Response response = bridge.bridgeCommunicate(new BCgetScenes()); if (response != null) { for (BCgetScenes.BCscene scene : response.getScenes()) { - LOGGER.trace("getScenes() found scene {}.", scene.getName()); + logger.trace("getScenes() found scene {}.", scene.getName()); VeluxScene veluxScene = new VeluxScene(scene); - LOGGER.trace("getScenes() storing scene {}.", veluxScene); + logger.trace("getScenes() storing scene {}.", veluxScene); if (!bridge.existingsScenes.isRegistered(veluxScene)) { bridge.existingsScenes.register(veluxScene); } - LOGGER.trace("getScenes() stored scene {}.", veluxScene); + logger.trace("getScenes() stored scene {}.", veluxScene); } - LOGGER.debug("getScenes() finally has found scenes {}.", bridge.existingsScenes); + logger.debug("getScenes() finally has found scenes {}.", bridge.existingsScenes); return true; } else { - LOGGER.trace("getScenes() finished with failure."); + logger.trace("getScenes() finished with failure."); return false; } } diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeLANConfig.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeLANConfig.java index 29d2935bb7446..98919212749c2 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeLANConfig.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeLANConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -10,6 +10,7 @@ import org.openhab.binding.velux.bridge.comm.BCgetLANConfig; import org.openhab.binding.velux.handler.VeluxBridgeHandler; +import org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +32,7 @@ public class VeluxBridgeLANConfig { private final Logger logger = LoggerFactory.getLogger(VeluxBridgeLANConfig.class); /** - * Wireless network configuration, consisting of: + * IP Network configuration, consisting of: *
        *
      • isRetrieved (boolean flag), *
      • ipAddress, @@ -56,11 +57,9 @@ public class Channel { * {@link VeluxBridgeHandler}, where the results are stored within as well in * {@link VeluxBridgeLANConfig#channel}. * - * @param bridge - * Initialized Velux bridge handler. - * - * @return channel - or null - - * of type {@link VeluxBridgeLANConfig.Channel} describing the overall result of this interaction. + * @param bridge Initialized Velux bridge handler. + * @return channel - or null - of type {@link VeluxBridgeLANConfig.Channel} describing the overall result of + * this interaction. */ public Channel retrieve(VeluxBridgeHandler bridge) { logger.trace("retrieve() called."); diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeSceneMode.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeSceneMode.java index bd8b44178cdc0..aae3731bb1ed4 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeSceneMode.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeSceneMode.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -27,43 +27,37 @@ * @author Guenther Schreiner - Initial contribution */ public class VeluxBridgeSceneMode { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxBridgeSceneMode.class); + private final Logger logger = LoggerFactory.getLogger(VeluxBridgeSceneMode.class); /** * Login into bridge, executes a scene and logout from bridge based * on a well-prepared environment of a {@link VeluxBridgeHandler}. * - * @param bridge - * Initialized Velux bridge handler. - * - * @param sceneNo - * Number of scene to be executed. - * - * @param silentMode - * Mode of this mentioned scene. - * + * @param bridge Initialized Velux bridge handler. + * @param sceneNo Number of scene to be executed. + * @param silentMode Mode of this mentioned scene. * @return success * of type boolean describing the overall result of this interaction. */ - public static boolean setSilentMode(VeluxBridgeHandler bridge, int sceneNo, boolean silentMode) { - LOGGER.trace("setSilentMode({},{}) called.", sceneNo, silentMode); + public boolean setSilentMode(VeluxBridgeHandler bridge, int sceneNo, boolean silentMode) { + logger.trace("setSilentMode({},{}) called.", sceneNo, silentMode); if (!bridge.bridgeLogin()) { - LOGGER.debug("Velux bridge login sequence failed; expecting bridge is OFFLINE."); + logger.debug("Velux bridge login sequence failed; expecting bridge is OFFLINE."); return false; } BCsetSilentMode.Response response = bridge.bridgeCommunicate(new BCsetSilentMode(sceneNo, silentMode)); if (response != null) { if (response.getResult()) { - LOGGER.info("setSilentMode() finished successfully."); + logger.info("setSilentMode() finished successfully."); return true; } } if (!bridge.bridgeLogout()) { - LOGGER.debug("Velux bridge logout sequence failed; expecting bridge is OFFLINE."); + logger.debug("Velux bridge logout sequence failed; expecting bridge is OFFLINE."); return false; } - LOGGER.trace("setSilentMode() finished with failure."); + logger.trace("setSilentMode() finished with failure."); return false; } } diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeWLANConfig.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeWLANConfig.java index e7ce81cd25c3a..1922fc98991f4 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeWLANConfig.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/VeluxBridgeWLANConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -53,9 +53,7 @@ public class Channel { * {@link VeluxBridgeHandler}, where the results are stored within as well in * {@link VeluxBridgeWLANConfig#channel}. * - * @param bridge - * Initialized Velux bridge handler. - * + * @param bridge Initialized Velux bridge handler. * @return channel - or null - * of type {@link VeluxBridgeWLANConfig.Channel} describing the overall result of this interaction. */ diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCdetectProducts.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCdetectProducts.java index de1dfb3281663..9c63de6245517 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCdetectProducts.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCdetectProducts.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -43,6 +43,9 @@ public BCdetectProducts() { *
              * {"action":"discover","params":{}}
              * 
        + * + * NOTE: the gateway software is extremely sensible to this exact JSON structure. + * Any modifications (like omitting empty params) will lead to an gateway error. */ public static class Request { diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetDeviceStatus.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetDeviceStatus.java index b7337706fe5d0..32acc825c24fa 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetDeviceStatus.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetDeviceStatus.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -43,6 +43,9 @@ public BCgetDeviceStatus() { *
              * {"action":"getDeviceStatus","params":{}}
              * 
        + * + * NOTE: the gateway software is extremely sensible to this exact JSON structure. + * Any modifications (like omitting empty params) will lead to an gateway error. */ public static class Request { diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetFirmware.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetFirmware.java index e46cdc03a9655..20d31cac55bdc 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetFirmware.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetFirmware.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetLANConfig.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetLANConfig.java index d26f016530d7c..88d0f41f93443 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetLANConfig.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetLANConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetProducts.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetProducts.java index 3e8efa2d5674d..db254d783490c 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetProducts.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetProducts.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetScenes.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetScenes.java index 6e3800f710f54..a8ff7f82d4b58 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetScenes.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetScenes.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetWLANConfig.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetWLANConfig.java index 12f1f81ce6db7..7f6c2f55a2157 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetWLANConfig.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCgetWLANConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCidentifyProduct.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCidentifyProduct.java index 204bd3584dc0d..2c22c6fc4f44b 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCidentifyProduct.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCidentifyProduct.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogin.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogin.java index 2b1ea23d9c714..2d6ed4feacb5f 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogin.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogin.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogout.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogout.java index bf0fbd3ee8eac..d2505c03bfc44 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogout.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BClogout.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCproduct.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCproduct.java index a4c7396386b96..731e39e63be27 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCproduct.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCproduct.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCrunScene.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCrunScene.java index 07dd1e823ddcc..f94b992085309 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCrunScene.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCrunScene.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCsetSilentMode.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCsetSilentMode.java index 99c9a9f008302..534c40a8be0cb 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCsetSilentMode.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BCsetSilentMode.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BridgeCommunicationProtocol.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BridgeCommunicationProtocol.java index e107de9b4152b..72d56563f8b7d 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BridgeCommunicationProtocol.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/bridge/comm/BridgeCommunicationProtocol.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -53,40 +53,32 @@ public interface BridgeCommunicationProtocol { /** * Returning the communication status included within the response message. * - * @param response - * From the bridge returned message to be examined. - * @return boolean - * whether the operation according to the request was successful. + * @param response From the bridge returned message to be examined. + * @return boolean whether the operation according to the request was successful. */ public boolean isCommunicationSuccessful(T response); /** * Returning the communication status included within the response message. * - * @param response - * From the bridge returned message to be examined. - * @return authentication token - * as String which can be used for next operations. + * @param response From the bridge returned message to be examined. + * @return authentication token as String which can be used for next operations. */ public String getAuthToken(T response); /** * Returning the communication status included within the response message. * - * @param response - * From the bridge returned message to be examined. - * @return deviceStatus - * as String describing the current status of the bridge. + * @param response From the bridge returned message to be examined. + * @return deviceStatus as String describing the current status of the bridge. */ public String getDeviceStatus(T response); /** * Returning the communication status included within the response message. * - * @param response - * From the bridge returned message to be examined. - * @return errors - * as String[] describing the status of the operation according to the request in depth. + * @param response From the bridge returned message to be examined. + * @return errors as String[] describing the status of the operation according to the request in depth. */ public String[] getErrors(T response); diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/discovery/VeluxDiscoveryService.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/discovery/VeluxDiscoveryService.java index b3aed524cb82f..00792228b8386 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/discovery/VeluxDiscoveryService.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/discovery/VeluxDiscoveryService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,6 +13,8 @@ import java.util.Collections; import java.util.Set; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.smarthome.config.discovery.AbstractDiscoveryService; import org.eclipse.smarthome.config.discovery.DiscoveryResult; import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; @@ -31,10 +33,11 @@ * @author Guenther Schreiner - Initial contribution. */ public class VeluxDiscoveryService extends AbstractDiscoveryService { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxDiscoveryService.class); + private final Logger logger = LoggerFactory.getLogger(VeluxDiscoveryService.class); /** Set of things provided by {@link VeluxDiscoveryService}. */ - public static final Set SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_VELUX_SCENE); + public static final @Nullable Set<@NonNull ThingTypeUID> SUPPORTED_THING_TYPES = Collections + .singleton(THING_TYPE_VELUX_SCENE); private static final int DISCOVER_TIMEOUT_SECONDS = 300; @@ -42,20 +45,18 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService { public VeluxDiscoveryService() { super(SUPPORTED_THING_TYPES, DISCOVER_TIMEOUT_SECONDS); - LOGGER.trace("VeluxDiscoveryService() just initialized."); - + logger.trace("VeluxDiscoveryService() just initialized."); } /** * Initializes the {@link VeluxDiscoveryService} with a reference to the well-prepared environment with a * {@link VeluxBridgeHandler}. * - * @param bridge - * Initialized Velux bridge handler. + * @param bridge Initialized Velux bridge handler. */ public VeluxDiscoveryService(VeluxBridgeHandler bridge) { super(SUPPORTED_THING_TYPES, DISCOVER_TIMEOUT_SECONDS); - LOGGER.trace("VeluxDiscoveryService({}) just initialized.", bridge); + logger.trace("VeluxDiscoveryService({}) just initialized.", bridge); bridgeHandler = bridge; } @@ -63,29 +64,23 @@ public VeluxDiscoveryService(VeluxBridgeHandler bridge) { * Called on component activation. */ public void activate() { - LOGGER.trace("activate() called."); + logger.trace("activate() called."); super.activate(null); } - /** - * {@inheritDoc} - */ @Override public void deactivate() { - LOGGER.trace("deactivate() called."); + logger.trace("deactivate() called."); super.deactivate(); } - /** - * {@inheritDoc} - */ @Override protected void startScan() { - LOGGER.trace("startScan() called."); - LOGGER.debug("Starting Velux discovery scan"); + logger.trace("startScan() called."); + logger.debug("Starting Velux discovery scan"); if (bridgeHandler == null) { - LOGGER.error("VeluxDiscoveryService.startScan() cannot proceed as bridgeHandler is not yet initialized."); + logger.error("VeluxDiscoveryService.startScan() cannot proceed as bridgeHandler is not yet initialized."); return; } @@ -93,10 +88,10 @@ protected void startScan() { for (VeluxScene scene : bridgeHandler.existingsScenes.values()) { String sceneName = scene.getName().toString(); - LOGGER.trace("startScan() found scene {}.", sceneName); + logger.trace("startScan() found scene {}.", sceneName); String label = sceneName.replaceAll("\\P{Alnum}", "_"); - LOGGER.trace("startScan() using name {}.", label); + logger.trace("startScan() using name {}.", label); ThingUID thingUID = new ThingUID(THING_TYPE_VELUX_SCENE, bridgeUID, label); @@ -107,19 +102,16 @@ protected void startScan() { .withLabel(label) .build(); // @formatter:on - LOGGER.trace("startScan() registering new thing {}.", discoveryResult); + logger.trace("startScan() registering new thing {}.", discoveryResult); thingDiscovered(discoveryResult); } - LOGGER.trace("startScan() finished."); + logger.trace("startScan() finished."); stopScan(); } - /** - * {@inheritDoc} - */ @Override public synchronized void stopScan() { - LOGGER.debug("Stopping Velux discovery scan"); + logger.debug("Stopping Velux discovery scan"); super.stopScan(); } diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/handler/VeluxBridgeHandler.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/handler/VeluxBridgeHandler.java index 43021ea2f6e05..869748306d279 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/handler/VeluxBridgeHandler.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/handler/VeluxBridgeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -47,7 +47,7 @@ /** * The {@link VeluxBridgeHandler} is responsible for handling of the communication, - * which is sent via the bridge to support the different channels. + * which is sent via the veluxBridge to support the different channels. *

        * Besides the usual {@link BaseBridgeHandler} methods, it provides three methods * for interaction, @@ -66,6 +66,9 @@ public class VeluxBridgeHandler extends BaseBridgeHandler { /** Configuration options for {@link VeluxBridgeHandler}. */ private VeluxBridgeConfiguration configuration = null; + /** Bridge {@link VeluxBridge}. */ + private VeluxBridge veluxBridge = null; + /** BridgeCommunicationProtocol authentication token for Velux Bridge. */ private String authenticationToken = ""; @@ -100,12 +103,10 @@ public VeluxBridgeHandler(Bridge bridge) { logger.trace("Creating a VeluxBridgeHandler for thing '{}'.", getThing().getUID()); } - /** - * {@inheritDoc} - */ + @SuppressWarnings({ "null", "unused" }) @Override public void initialize() { - logger.info("Initializing Velux bridge handler for '{}'.", getThing().getUID()); + logger.info("Initializing Velux veluxBridge handler for '{}'.", getThing().getUID()); configuration = getConfigAs(VeluxBridgeConfiguration.class); @@ -114,14 +115,20 @@ public void initialize() { configuration = new VeluxBridgeConfiguration(); } - if (configuration.bridgeURL.length() < 6) { // six means minimum of "http:/" - logger.warn("Velux bridge configuration error (missing bridgeURL)."); + if (configuration.bridgeIPAddress.length() < 7) { // seven means minimum of "1.1.1.1" + logger.warn("Velux veluxBridge configuration error (bad bridgeIPAddress)."); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Unable to connect Velux Bridge."); + return; + } + if ((configuration.bridgeTCPPort < 1) || (configuration.bridgeTCPPort > 65535)) { + logger.warn("Velux veluxBridge configuration error (bad bridgeTCPPort)."); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Unable to connect Velux Bridge."); return; } logger.trace("Adjusting communication parameters."); - VeluxBridge.ioSetup(configuration.retries, configuration.timeoutMsecs); + veluxBridge = new VeluxBridge(); + veluxBridge.ioSetup(configuration.retries, configuration.timeoutMsecs); logger.trace("Initializing empty storage for existing products."); existingsProducts = new VeluxExistingProducts(); @@ -132,28 +139,23 @@ public void initialize() { * Try a sequence of Login followed by Logout. */ if (bridgeLogin() && bridgeLogout()) { - - logger.debug("Velux bridge is online, now."); + logger.debug("Velux veluxBridge is online, now."); updateStatus(ThingStatus.ONLINE); /* * Fetch all scenes for further invocations */ logger.trace("Fetch existing scenes."); - VeluxBridgeGetScenes.getScenes(this); - + new VeluxBridgeGetScenes().getScenes(this); } else { - logger.info("Velux bridge login/logout sequence failed; expecting bridge is OFFLINE."); + logger.info("Velux veluxBridge login/logout sequence failed; expecting veluxBridge is OFFLINE."); updateStatus(ThingStatus.OFFLINE); } } - /** - * {@inheritDoc} - */ @Override public synchronized void dispose() { - logger.trace("Shutting down Velux bridge '{}'.", getThing().getUID()); + logger.trace("Shutting down Velux veluxBridge '{}'.", getThing().getUID()); logger.trace("dispose() releasing the authentication session by logging out."); bridgeLogout(); @@ -177,9 +179,6 @@ public void channelLinked(ChannelUID channelUID) { } } - /** - * {@inheritDoc} - */ @Override public void handleCommand(ChannelUID channelUID, Command command) { logger.trace("handleCommand({},{}) called.", channelUID.getAsString(), command); @@ -188,7 +187,6 @@ public void handleCommand(ChannelUID channelUID, Command command) { if (command instanceof RefreshType) { switch (channelId) { - case CHANNEL_BRIDGE_STATUS: String deviceStatus = new VeluxBridgeDeviceStatus().retrieve(this); logger.trace("handleCommand() updating {} to {}.", channelUID, deviceStatus); @@ -287,7 +285,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { case CHANNEL_BRIDGE_PRODUCTS: if (this.existingsProducts.getNoMembers() == 0) { logger.trace("handleCommand() is about to fetch existing products."); - VeluxBridgeGetProducts.getProducts(this); + new VeluxBridgeGetProducts().getProducts(this); } String productInfo = this.existingsProducts.toString(); logger.info("handleCommand() found products {}.", productInfo); @@ -299,15 +297,14 @@ public void handleCommand(ChannelUID channelUID, Command command) { default: logger.trace("handleCommand() cannot handle REFRESH on channel {}.", channelId); } - } else if (command instanceof OnOffType) { switch (channelId) { - case CHANNEL_BRIDGE_DETECTION: + case CHANNEL_BRIDGE_DO_DETECTION: if (command.equals(OnOffType.ON)) { - logger.trace("handleCommand() about to activate bridge detection mode."); - VeluxBridgeDetectProducts.detectProducts(this); + logger.trace("handleCommand() about to activate veluxBridge detection mode."); + new VeluxBridgeDetectProducts().detectProducts(this); } else { logger.trace("handleCommand() ignoring OFF command."); } @@ -320,18 +317,12 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } - /** - * {@inheritDoc} - */ @Override public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) { logger.trace("childHandlerInitialized({},{}) called.", childHandler, childThing); super.childHandlerInitialized(childHandler, childThing); } - /** - * {@inheritDoc} - */ @Override public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) { logger.trace("childHandlerDisposed({},{}) called.", childHandler, childThing); @@ -339,7 +330,7 @@ public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) { } /** - * Prepares an authorization request and communicate it with the Velux bridge. + * Prepares an authorization request and communicate it with the Velux veluxBridge. * In the positive case, the return authorization token will be stored within this class * for any further communication via {@link#bridgeCommunicate} up * to a deauthorization with method {@link VeluxBridgeHandler#bridgeLogout} @@ -363,7 +354,7 @@ public synchronized boolean bridgeLogin() { } /** - * Prepares an (authenticated!) deauthorization request and communicate it with the Velux bridge. + * Prepares an (authenticated!) deauthorization request and communicate it with the Velux veluxBridge. * In any case, the authorization token stored in this class will be destroyed, so that the * next communication has to start with {@link VeluxBridgeHandler#bridgeLogin}. * @@ -389,22 +380,17 @@ public synchronized boolean bridgeLogout() { } /** - * Initializes a client/server communication towards Velux bridge + * Initializes a client/server communication towards Velux veluxBridge * based on the Basic I/O interface {@link VeluxBridge} and parameters * passed as arguments (see below) and provided by {@link VeluxBridgeConfiguration}. * - * @param communication - * Structure of interface type {@link BridgeCommunicationProtocol} describing the intended communication, + * @param communication Structure of interface type {@link BridgeCommunicationProtocol} describing the intended + * communication, * that is request and response interactions as well as appropriate URL definition. - * - * @param - * generic response based on details within communication. - * - * @param useAuthentication - * boolean flag to decide whether to use authenticated communication. - * - * @return response - * of type T containing all resulting informations, i.e. device status, errors a.s.o. Will return + * @param generic response based on details within communication. + * @param useAuthentication boolean flag to decide whether to use authenticated communication. + * @return response of type T containing all resulting informations, i.e. device status, errors a.s.o. Will + * return * null in case of communication or decoding error. */ public synchronized T bridgeCommunicate(BridgeCommunicationProtocol communication, @@ -421,16 +407,18 @@ public synchronized T bridgeCommunicate(BridgeCommunicationProtocol commu } } - String sapURL = configuration.bridgeURL.concat(communication.getURL()); + String sapURL = configuration.bridgeProtocol.concat("://").concat(configuration.bridgeIPAddress).concat(":") + .concat(Integer.toString(configuration.bridgeTCPPort)).concat(communication.getURL()); + logger.trace("bridgeCommunicate(): using SAP {}.", sapURL); Object getRequest = communication.getObjectOfRequest(); Class classOfResponse = communication.getClassOfResponse(); T response; try { if (useAuthentication) { - response = VeluxBridge.ioAuthenticated(sapURL, authenticationToken, getRequest, classOfResponse); + response = veluxBridge.ioAuthenticated(sapURL, authenticationToken, getRequest, classOfResponse); } else { - response = VeluxBridge.ioUnauthenticated(sapURL, getRequest, classOfResponse); + response = veluxBridge.ioUnauthenticated(sapURL, getRequest, classOfResponse); } logger.trace("bridgeCommunicate(): communication result is {}, returning details.", communication.isCommunicationSuccessful(response)); @@ -446,21 +434,18 @@ public synchronized T bridgeCommunicate(BridgeCommunicationProtocol commu } /** - * Initializes a client/server communication towards Velux bridge + * Initializes a client/server communication towards Velux veluxBridge * based on the Basic I/O interface {@link VeluxBridge} and parameters * passed as arguments (see below) and provided by {@link VeluxBridgeConfiguration}. * This method automatically decides to invoke a login communication before the * intended request if there has not been an authentication before. * - * @param communication - * Structure of interface type {@link BridgeCommunicationProtocol} describing the intended communication, + * @param communication Structure of interface type {@link BridgeCommunicationProtocol} describing the intended + * communication, * that is request and response interactions as well as appropriate URL definition. - * - * @param - * generic response based on details within communication. - * - * @return response - * of type T containing all resulting informations, i.e. device status, errors a.s.o. Will return + * @param generic response based on details within communication. + * @return response of type T containing all resulting informations, i.e. device status, errors a.s.o. Will + * return * null in case of communication or decoding error. */ diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/handler/VeluxHandler.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/handler/VeluxHandler.java index adbd4b70f0e05..cfdb013d7519e 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/handler/VeluxHandler.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/handler/VeluxHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -61,13 +61,11 @@ public VeluxHandler(Thing thing) { super(thing); } - /** - * {@inheritDoc} - */ @Override public void initialize() { logger.debug("Initializing thing {}", getThing().getUID()); - initializeThing((getBridge() == null) ? null : getBridge().getStatus()); + Bridge thisBridge = getBridge(); + initializeThing((thisBridge == null) ? null : thisBridge.getStatus()); logger.trace("done with initialization of thing {}", getThing().getUID()); } @@ -107,8 +105,8 @@ private synchronized VeluxBridgeHandler getVeluxBridgeHandler() { return this.bridgeHandler; } + @SuppressWarnings({ "unused", "null" }) private synchronized void initializeProperties() { - configuration = getConfigAs(VeluxThingConfiguration.class); if (configuration == null) { logger.debug("No configuration found, using default values."); @@ -128,18 +126,12 @@ private synchronized void initializeProperties() { } } - /** - * {@inheritDoc} - */ @Override public void dispose() { logger.trace("VeluxHandler disposed."); super.dispose(); } - /** - * {@inheritDoc} - */ @Override public void channelLinked(ChannelUID channelUID) { logger.trace("channelLinked({}) called.", channelUID.getAsString()); @@ -149,9 +141,6 @@ public void channelLinked(ChannelUID channelUID) { } } - /** - * {@inheritDoc} - */ @Override public void handleCommand(ChannelUID channelUID, Command command) { logger.trace("handleCommand({},{}) called.", channelUID.getAsString(), command); @@ -162,7 +151,10 @@ public void handleCommand(ChannelUID channelUID, Command command) { return; } VeluxBridgeHandler veluxBridgeHandler = (VeluxBridgeHandler) veluxBridge.getHandler(); - assert veluxBridgeHandler != null : "veluxBridge.getHandler() returned null."; + if (veluxBridgeHandler == null) { + logger.warn("veluxBridge.getHandler() returned null."); + return; + } String channelId = getChannelId(channelUID.getId()); logger.trace("handleCommand(): working with channelId {}.", channelId); @@ -202,7 +194,6 @@ public void handleCommand(ChannelUID channelUID, Command command) { return; } else if (command instanceof OnOffType) { - switch (channelId) { case CHANNEL_SCENE_ACTION: logger.trace("Try to handle ON/OFF with channelSubId {}.", sceneName); @@ -219,7 +210,9 @@ public void handleCommand(ChannelUID channelUID, Command command) { logger.debug("handleCommand() activating known scene {}.", sceneName); thisScene = veluxBridgeHandler.existingsScenes.get(new SceneName(sceneName)); logger.trace("handleCommand() execution scene {}.", thisScene); - VeluxBridgeExecute.execute(veluxBridgeHandler, thisScene.getBridgeSceneIndex().toInt()); + // was: + // VeluxBridgeExecute.execute(veluxBridgeHandler, thisScene.getBridgeSceneIndex().toInt()); + new VeluxBridgeExecute().execute(veluxBridgeHandler, thisScene.getBridgeSceneIndex().toInt()); logger.trace("handleCommand() execution done."); break; @@ -236,7 +229,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { thisScene = veluxBridgeHandler.existingsScenes.get(new SceneName(sceneName)); logger.trace("handleCommand() execution scene {}.", thisScene); int sceneNumber = thisScene.getBridgeSceneIndex().toInt(); - VeluxBridgeSceneMode.setSilentMode(veluxBridgeHandler, sceneNumber, silentMode); + new VeluxBridgeSceneMode().setSilentMode(veluxBridgeHandler, sceneNumber, silentMode); logger.trace("handleCommand() execution done."); break; diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/VeluxHandlerFactory.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/VeluxHandlerFactory.java index 2fa33ed3b6b72..1ac4b617010f3 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/VeluxHandlerFactory.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/VeluxHandlerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -37,9 +37,6 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory { private final Logger logger = LoggerFactory.getLogger(VeluxHandlerFactory.class); private ServiceRegistration discoveryServiceReg; - /** - * {@inheritDoc} - */ @Override public boolean supportsThingType(ThingTypeUID thingTypeUID) { logger.trace("supportsThingType({}) called and returns {}.", thingTypeUID, @@ -49,17 +46,12 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { || VeluxHandler.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); } - /** - * {@inheritDoc} - */ @Override protected ThingHandler createHandler(Thing thing) { logger.trace("createHandler({}) called.", thing.getLabel()); ThingTypeUID thingTypeUID = thing.getThingTypeUID(); - if (thingTypeUID != null) { - logger.trace("Trying to create a handler for ThingType '{}'", thingTypeUID); // Handle Bridge creation as 1st choice if (VeluxBridgeHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) { @@ -76,8 +68,6 @@ else if (VeluxHandler.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) { logger.warn("ThingHandler not found for {}.", thingTypeUID); return null; } - } - return null; } private void registerDeviceDiscoveryService(VeluxBridgeHandler bridgeHandler) { diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/config/VeluxBridgeConfiguration.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/config/VeluxBridgeConfiguration.java index 01ed9ab73c643..668e6252e4a8a 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/config/VeluxBridgeConfiguration.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/config/VeluxBridgeConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -22,12 +22,15 @@ */ public class VeluxBridgeConfiguration extends Configuration { - public static final String BRIDGE_URL = "bridgeURL"; + public static final String BRIDGE_IPADDRESS = "bridgeIPAddress"; + public static final String BRIDGE_TCPPORT = "bridgeTCPPort"; public static final String BRIDGE_PASSWORD = "bridgePassword"; public static final String BRIDGE_TIMEOUT_MSECS = "timeoutMsecs"; public static final String BRIDGE_RETRIES = "retries"; - public String bridgeURL; + public String bridgeProtocol; + public String bridgeIPAddress; + public int bridgeTCPPort; public String bridgePassword; public int timeoutMsecs; public int retries; @@ -36,7 +39,9 @@ public class VeluxBridgeConfiguration extends Configuration { * Default values - should not be modified */ public VeluxBridgeConfiguration() { - this.bridgeURL = "http://192.168.45.9:80/"; + this.bridgeProtocol = "http"; + this.bridgeIPAddress = "192.168.1.1"; + this.bridgeTCPPort = 80; this.bridgePassword = "velux123"; this.timeoutMsecs = 2000; this.retries = 6; diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/config/VeluxThingConfiguration.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/config/VeluxThingConfiguration.java index 3bd2f8e8117ee..00c2e09f91c99 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/config/VeluxThingConfiguration.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/config/VeluxThingConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -24,17 +24,14 @@ public class VeluxThingConfiguration extends Configuration { public static final String THING_SCENE_NAME = VeluxBindingProperties.PROPERTY_SCENE_NAME; - public static final String THING_TTL_SECS = VeluxBindingProperties.PROPERTY_TTL; public String sceneName; - public long timeToLiveInSeconds; /** * Default values - should not be modified */ public VeluxThingConfiguration() { sceneName = "no-scene"; - timeToLiveInSeconds = -1L; } } diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxExistingProducts.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxExistingProducts.java index 4a1ed2f2909d8..29e7d8fd72d12 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxExistingProducts.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxExistingProducts.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -64,7 +64,7 @@ public boolean register(VeluxProduct newProduct) { if (isRegistered(newProduct)) { return false; } - logger.trace("register() registering new product.", newProduct); + logger.trace("register() registering new product {}.", newProduct); existingProductsByUniqueIndex.put(newProduct.getProductUniqueIndex(), newProduct); memberCount++; return true; @@ -87,9 +87,6 @@ public int getNoMembers() { return memberCount; } - /** - * {@inheritDoc} - */ @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxExistingScenes.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxExistingScenes.java index c4cce76c407fc..bf8a38f8c6b74 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxExistingScenes.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxExistingScenes.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -63,7 +63,7 @@ public boolean register(VeluxScene newScene) { if (isRegistered(newScene)) { return false; } - logger.trace("register() registering new scene.", newScene); + logger.trace("register() registering new scene {}.", newScene); existingScenesBySceneName.put(newScene.getName().toString(), newScene); memberCount++; return true; @@ -103,9 +103,6 @@ public void dummyTest2(SceneName sceneName) { } } - /** - * {@inheritDoc} - */ @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProduct.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProduct.java index 9659d3af039ef..c93ca663e413c 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProduct.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProduct.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -23,7 +23,7 @@ * @author Guenther Schreiner - initial contribution. */ public class VeluxProduct { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxProduct.class); + private final Logger logger = LoggerFactory.getLogger(VeluxProduct.class); // Type definitions @@ -42,6 +42,7 @@ public String toString() { public enum ProductTypeId { ROLLER_SHUTTER(2, 0), + OTHER(3, 0), WINDOW_OPENER(4, 1), UNDEFTYPE(-1); @@ -51,11 +52,11 @@ public enum ProductTypeId { private int subtype; // Reverse-lookup map for getting a ProductTypeId from an TypeId - private static final Map lookupTypeId2Enum = new HashMap(); + private static final Map LOOKUPTYPEID2ENUM = new HashMap(); static { for (ProductTypeId typeId : ProductTypeId.values()) { - lookupTypeId2Enum.put(typeId.getTypeId(), typeId); + LOOKUPTYPEID2ENUM.put(typeId.getTypeId(), typeId); } } @@ -98,7 +99,7 @@ public int getSubtype() { } public static ProductTypeId get(int typeId) { - return lookupTypeId2Enum.get(typeId); + return LOOKUPTYPEID2ENUM.get(typeId); } } @@ -137,12 +138,12 @@ public VeluxProduct(BCproduct productDescr) { try { this.typeId = ProductTypeId.valueOf(productTypeId); } catch (IllegalArgumentException iae) { - LOGGER.error( + logger.error( "PLEASE REPORT THIS TO MAINTAINER: VeluxProduct({},{}) has found an unregistered ProductTypeId.", productTypeId, productDescr.getTypeId()); } if (this.getTypeId().getTypeId() != productDescr.getTypeId()) { - LOGGER.error( + logger.error( "PLEASE REPORT THIS TO MAINTAINER: VeluxProduct({},{}) has found two different typeIds which differ ({} vs. {}.", productTypeId, productDescr.getTypeId(), this.getTypeId().getTypeId(), productDescr.getTypeId()); } @@ -162,9 +163,6 @@ public ProductBridgeIndex getBridgeProductIndex() { return this.bridgeProductIndex; } - /** - * {@inheritDoc} - */ @Override public String toString() { return String.format("Product \"%s\"/%s (bridgeIndex %d)", this.name, this.typeId, diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProductReference.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProductReference.java index 8d7aff6b1bb2d..5fd00d3c6a6c0 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProductReference.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProductReference.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -24,7 +24,7 @@ * @author Guenther Schreiner - initial contribution. */ public class VeluxProductReference { - private static final Logger LOGGER = LoggerFactory.getLogger(VeluxProductReference.class); + private final Logger logger = LoggerFactory.getLogger(VeluxProductReference.class); // Type definitions @@ -44,7 +44,7 @@ public VeluxProductReference(BCproductState productState) { this.name = new ProductName(productState.getName()); this.typeId = ProductTypeId.get(productState.getTypeId()); if (this.typeId == null) { - LOGGER.error( + logger.error( "PLEASE REPORT THIS TO MAINTAINER: VeluxProductReference({}) has found an unregistered ProductTypeId.", productState.getTypeId()); } @@ -65,9 +65,6 @@ public ProductTypeId getTypeId() { return this.typeId; } - /** - * {@inheritDoc} - */ @Override public String toString() { return String.format("Prod.ref. \"%s\"/%s", this.name, this.typeId); diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProductState.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProductState.java index 1273e6f62a045..c4fc8caab814d 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProductState.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxProductState.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -81,9 +81,6 @@ public int getStateAsInt() { return this.state.getState(); } - /** - * {@inheritDoc} - */ @Override public String toString() { return String.format("State (%s, actuator %d, value %d)", this.productReference, this.actuator, this.state); diff --git a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxScene.java b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxScene.java index 1474515b4d26b..69a4b7b009d14 100644 --- a/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxScene.java +++ b/addons/binding/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/things/VeluxScene.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -36,9 +36,6 @@ public SceneName(String name) { this.name = name; } - /** - * {@inheritDoc} - */ public boolean equals(SceneName anotherName) { return this.name.equals(anotherName.toString()); } @@ -100,9 +97,6 @@ public SceneBridgeIndex getBridgeSceneIndex() { return this.bridgeSceneIndex; } - /** - * {@inheritDoc} - */ @Override public String toString() { return String.format("Scene \"%s\" (index %d) with %ssilent mode and %d actions", this.name, diff --git a/features/openhab-addons/pom.xml b/features/openhab-addons/pom.xml index 6237493ca0644..71ec3c407ae8c 100644 --- a/features/openhab-addons/pom.xml +++ b/features/openhab-addons/pom.xml @@ -15,15 +15,6 @@ openHAB 2 Feature Addons openHAB 2 Addons - - - ${project.groupId} - openhab2-addons-external - ${project.version} - pom - provided - - @@ -42,6 +33,11 @@ + + + + +