[innogysmarthome] Remove binding (replaced by livisismarthome) (#14675)

Remove binding (replaced by livisismarthome)

Signed-off-by: Sven Strohschein <sven.strohschein@gmail.com>
Signed-off-by: Sven Strohschein <novanic@gmx.de>
This commit is contained in:
Sven Strohschein 2023-03-26 17:49:17 +02:00 committed by GitHub
parent a8d91b3950
commit 2c710a2a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
111 changed files with 0 additions and 14033 deletions

View File

@ -144,7 +144,6 @@
/bundles/org.openhab.binding.icalendar/ @daMihe /bundles/org.openhab.binding.icalendar/ @daMihe
/bundles/org.openhab.binding.icloud/ @openhab/add-ons-maintainers /bundles/org.openhab.binding.icloud/ @openhab/add-ons-maintainers
/bundles/org.openhab.binding.ihc/ @paulianttila /bundles/org.openhab.binding.ihc/ @paulianttila
/bundles/org.openhab.binding.innogysmarthome/ @ollie-dev
/bundles/org.openhab.binding.insteon/ @robnielsen /bundles/org.openhab.binding.insteon/ @robnielsen
/bundles/org.openhab.binding.intesis/ @hmerk /bundles/org.openhab.binding.intesis/ @hmerk
/bundles/org.openhab.binding.ipcamera/ @Skinah /bundles/org.openhab.binding.ipcamera/ @Skinah

View File

@ -716,11 +716,6 @@
<artifactId>org.openhab.binding.ihc</artifactId> <artifactId>org.openhab.binding.ihc</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.innogysmarthome</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.openhab.addons.bundles</groupId> <groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.insteon</artifactId> <artifactId>org.openhab.binding.insteon</artifactId>

View File

@ -1,40 +0,0 @@
This content is produced and maintained by the openHAB project.
* Project home: https://www.openhab.org
== Declared Project Licenses
This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.
== Source Code
https://github.com/openhab/openhab-addons
== Third-party Content
google-http-java-client
* License: Apache 2.0 License
* Project: https://developers.google.com/api-client-library/java/google-http-java-client
* Source: https://github.com/googleapis/google-http-java-client
google-oauth-java-client
* License: Apache 2.0 License
* Project: https://developers.google.com/api-client-library/java/google-oauth-java-client
* Source: https://github.com/googleapis/google-oauth-java-client
httpclient
* License: Apache 2.0 License
* Project: https://hc.apache.org/httpcomponents-client-ga
* Source: https://hc.apache.org/httpcomponents-client-ga
httpcore
* License: Apache 2.0 License
* Project: http://hc.apache.org/httpcomponents-core-ga
* Source: http://hc.apache.org/httpcomponents-core-ga
jackson
* License: Apache 2.0 License
* Project: https://github.com/FasterXML/jackson
* Source: https://github.com/FasterXML/jackson

View File

@ -1,252 +0,0 @@
# innogy SmartHome Binding
The binding integrates the [innogy SmartHome](https://innogy.com/smarthome) system into openHAB.
It uses the official API 1.1 as provided by innogy as cloud service.
As all status updates and commands have to go through the API, a permanent internet connection is required.
_Notice!_
_This binding is deprecated!_
_LIVISI (formally innogy) has implemented a local API on their SHC from Software Version 1.2.XX.XXX.
Please migrate to the "LIVISI SmartHome Binding" which is using the new local API and requires neither the LIVISI-cloud-servers nor an internet connection._
## Supported things
### Bridge
The innogy SmartHome Controller (SHC) is the bridge, that provides the central communication with the devices.
Without the SHC, you cannot communicate with the devices.
This binding supports both the SHC and the SHC2 (with support for Bluetooth devices).
### Devices
The following table shows all supported and tested devices and their channels.
The channels are described in detail in the next chapter.
| Device | Description | Supported channels |
|--------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| BRC8 | Basic Remote Controller | button1 ... button8, button1_count ... button8_count, battery_low |
| ISC2 | In Wall Smart Controller | button1, button2, button1_count, button2_count |
| ISD2 | In Wall Smart Dimmer | button1, button2, button1_count, button2_count, dimmer |
| ISR2 | In Wall Smart Rollershutter | button1, button2, button1_count, button2_count, rollershutter |
| ISS2 | In Wall Smart Switch | button1, button2, button1_count, button2_count, switch |
| PSD | Pluggable Smart Dimmer | dimmer |
| PSS | Pluggable Smart Switch, indoor | switch |
| PSSO | Pluggable Smart Switch, outdoor | switch |
| BT-PSS | Bluetooth Pluggable Smart Switch, indoor | switch |
| RST | Radiator Mounted Smart Thermostat | set_temperature, temperature, frost_warning, humidity, mold_warning, operation_mode, window_reduction_active, battery_low |
| RST2 | Radiator Mounted Smart Thermostat (newer two battery version since 2018) | set_temperature, temperature, frost_warning, humidity, mold_warning, operation_mode, window_reduction_active, battery_low |
| | VariableActuator | switch |
| WDS | Window Door Sensor | contact, battery_low |
| WMD | Wall Mounted Motion Detector, indoor | motion_count, luminance, battery_low |
| WMDO | Wall Mounted Motion Detector, outdoor | motion_count, luminance, battery_low |
| WRT | Wall Mounted Room Thermostat | set_temperature, temperature, humidity, battery_low |
| WSC2 | Wall Mounted Smart Controller | button1, button2, button1_count, button2_count, battery_low |
| WSD | Wall Mounted Smoke Detector, old version | smoke, alarm, battery_low |
| WSD2 | Wall Mounted Smoke Detector, new version | smoke, alarm, battery_low |
Powermeter devices
| Device | Description | Supported channels |
|-----------------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| AnalogMeter | The Analog Meter from the innogy EnergyControl product | energy_consumption_month_kwh, absolute_energy_consumption, energy_consumption_month_euro, energy_consumption_day_euro, energy_consumption_day_kwh |
| GenerationMeter | The Generation Meter from the innogy PowerControlSolar product | energy_generation_month_kwh, total_energy_generation, energy_generation_month_euro, energy_generation_day_euro, energy_generation_day_kwh, power_generation_watt |
| SmartMeter | The Smart Meter from the innogy PowerControl product. | energy_consumption_month_kwh, absolute_energy_consumption, energy_consumption_month_euro, energy_consumption_day_euro, energy_consumption_day_kwh, power_consumption_watt |
| Two-Way-Meter | The Two-Way-Meter from the innogy PowerControlSolar product | energy_month_kwh, total_energy, energy_month_euro, energy_day_euro, energy_day_kwh, energy_feed_month_kwh, total_energy_fed, energy_feed_month_euro, energy_feed_day_euro, energy_feed_day_kwh, power_watt |
## Discovery
If the bridge (SHC) is located in the same LAN as the openHAB server, the bridge should be discovered automatically by mDNS.
However, this can sometimes take a couple of minutes.
If the bridge is not found, it can be added manually (see below under "Configuration").
After the bridge is added, devices are discovered automatically.
As there is no background discovery implemented at the moment, you have to start the discovery manually.
However, only devices will appear that are added in the innogy SmartHome app before, as the innogy Binding does not support the coupling of devices to the bridge.
## Channels
| Channel Type ID | Item Type | Description | Available on thing |
|-------------------------|---------------|-----------------------------------------------------------------------|-------------------------------------------------|
| alarm | Switch | Switches the alarm (ON/OFF) | WSD, WSD2 |
| battery_low | Switch | Indicates, if the battery is low (ON/OFF) | BRC8, RST, WDS, WMD, WMD0, WRT, WSC2, WSD, WSD2 |
| contact | Contact | Indicates the contact state (OPEN/CLOSED) | WDS |
| dimmer | Dimmer | Allows to dimm a light device | ISD2, PSD |
| frost_warning | Switch | active, if the measured temperature is too low (ON/OFF) | RST |
| humidity | Number | Relative humidity in percent | RST, WRT |
| button1 | - | trigger channel for rules, fires with each push | BRC8, ISC2, ISD2, ISR2, ISS2, WSC2 |
| button2 | - | trigger channel for rules, fires with each push | BRC8, ISC2, ISD2, ISR2, ISS2, WSC2 |
| button3 | - | trigger channel for rules, fires with each push | BRC8 |
| button4 | - | trigger channel for rules, fires with each push | BRC8 |
| button5 | - | trigger channel for rules, fires with each push | BRC8 |
| button6 | - | trigger channel for rules, fires with each push | BRC8 |
| button7 | - | trigger channel for rules, fires with each push | BRC8 |
| button8 | - | trigger channel for rules, fires with each push | BRC8 |
| button1_count | Number | number of button pushes for button 1, increased with each push | BRC8, ISC2, ISD2, ISR2, ISS2, WSC2 |
| button2_count | Number | number of button pushes for button 2, increased with each push | BRC8, ISC2, ISD2, ISR2, ISS2, WSC2 |
| button3_count | Number | number of button pushes for button 3, increased with each push | BRC8 |
| button4_count | Number | number of button pushes for button 4, increased with each push | BRC8 |
| button5_count | Number | number of button pushes for button 5, increased with each push | BRC8 |
| button6_count | Number | number of button pushes for button 6, increased with each push | BRC8 |
| button7_count | Number | number of button pushes for button 7, increased with each push | BRC8 |
| button8_count | Number | number of button pushes for button 8, increased with each push | BRC8 |
| luminance | Number | Indicates the measured luminance in percent | WMD, WMD0 |
| mold_warning | Switch | active, if the measured humidity is too low (ON/OFF) | RST |
| motion_count | Number | Number of detected motions, increases with each detected motion | WMD, WMDO |
| operation_mode | String | the mode of a thermostat (auto/manual) | RST |
| rollershutter* | Rollershutter | Controls a roller shutter | ISR2 |
| set_temperature | Number | Sets the target temperature in °C | RST, WRT |
| smoke | Switch | Indicates, if smoke was detected (ON/OFF) | WSD, WSD2 |
| switch | Switch | A switch to turn the device or variable on/off (ON/OFF) | ISS2, PSS, PSSO, VariableActuator |
| temperature | Number | Holds the actual temperature in °C | RST, WRT |
| window_reduction_active | Switch | indicates if a linked window is open and temperature reduced (ON/OFF) | RST |
The `rollershutter` channel has a `boolean` parameter `invert`.
It is `false` by default.
This means `100` on innogy is `UP` and `0` is `DOWN`.
When `invert` is `true` than `0` on innogy is `UP` and `100` is `DOWN`.
## Thing configuration
### Configuring the SmartHome Controller (SHC)
The SmartHome Controller (SHC) can be configured in the UI as follows:
After the "innogy SmartHome Controller" is added via the Inbox, edit the controller and add the "Authorization code" by following the hints in the description.
Save your changes.
The SHC should now login and go online.
Be sure it is connected to the Internet.
### Obtaining the authorization code and tokens
Authorization is done as oauth2 workflow with the innogy API.
To receive the auth-code, go to one of the following URLs depending on your brand and login with your credentials (you can find this link also in the SHC thing in the UI, if you edit it):
`https://auth.services-smarthome.de/AUTH`
- [innogy SmartHome authorization page](https://auth.services-smarthome.de/AUTH/authorize?response_type=code&client_id=24635748&redirect_uri=https%3A%2F%2Fwww.openhab.org%2Foauth%2Finnogy%2Finnogy-smarthome.html&scope&lang=de-DE)
- [SmartHome Austria authorization page](https://auth.services-smarthome.de/AUTH/authorize?response_type=code&client_id=24635749&redirect_uri=https%3A%2F%2Fwww.openhab.org%2Foauth%2Finnogy%2Fsmarthome-austria.html&scope&lang=de-DE)
- [Start SmartHome authorization page](https://auth.services-smarthome.de/AUTH/authorize?response_type=code&client_id=24635750&redirect_uri=https%3A%2F%2Fwww.openhab.org%2Foauth%2Finnogy%2Fstart-smarthome.html&scope&lang=de-DE)
You will be redirected to openhab.org and the auth-code will be displayed.
Copy and paste it into your SHC configuration and you are done.
The binding then requests the access and refresh tokens and saves them in the SHC configuration.
The auth-code can only be used once and therefore is dropped.
The access token is then used to login at the innogy API, but is valid only for a couple of hours.
The binding automatically requests a new access token as needed by using the refresh token.
So the refresh token is the relevant credential.
**Never give it to anybody!**
### Discovering devices
All devices bound to the bridge are found by the discovery service once the SHC is online.
As device discovery is not implemented as a background service, you should start it manually in the Inbox to find all devices.
Now you can add all devices from your Inbox as things.
### File based configuration
As an alternative to using automatic discovery, innogy things can be configured using .things files.
The innogy SmartHome Controller (SHC) can be configured using the following syntax:
```java
Bridge innogysmarthome:bridge:<bridge-id> []
```
Then the required authcode is retrieved and set **automatically**:
```java
Bridge innogysmarthome:bridge:<bridge-id> [ authcode="<authcode>" ]
```
** _Security warning!_*
As the refresh-token is THE one and only credential one needs to access the innogy webservice with all device data, you have to make sure it is never given to another person.
Thus it is recommended to remove the line from the openhab.log and/or make sure, the logfile is definitely never accessible by others!
All other innogy devices can be added using the following syntax:
```java
Thing WDS <thing-id> "<thing-name>" @ "<room-name>" [ id="<the-device-id>" ]
```
The device ID (e.g. e9a74941a3807b57332214f346fb1129) can be found in the Inbox, as you find it below all things there in the form `innogysmarthome:<device-type>:<bridge-id>:<the-device-id>` (example: `innogysmarthome:WSC2:SMARTHOME01:e9a74941a3807b57332214f346fb1129`).
However, a full example .things configuration look like this:
```java
Bridge innogysmarthome:bridge:mybride "innogy SmartHome Controller" {
Thing ISD2 myDimmer "Dimmer Kitchen" @ "Kitchen" [ id="<device-id>" ]
Thing ISS2 myLightSwitch "Light Livingroom" @ "Livingroom" [ id="<device-id>" ]
Thing PSS myTVSwitch "TV" @ "Livingroom" [ id="<device-id>" ]
Thing RST myHeating "Thermostat Livingroom" @ "Livingroom" [ id="<device-id>" ]
Thing VariableActuator myInnogyVariable "My Variable" [ id="<device-id>" ]
Thing WDS myWindowContact "Window Kitchen" @ "Kitchen" [ id="<device-id>" ]
Thing WMD myMotionSensor "Motion entry" @ "Entry" [ id="<device-id>" ]
Thing WSC2 myPushButton "Pushbutton" @ "Living" [ id="<device-id>" ]
Thing WSD mySmokeDetector "Smoke detector Livingroom" @ "Living" [ id="<device-id>" ]
}
```
## Items configuration
You can then configure your items in your *.items config files as usual, for example:
```java
Contact myWindowContact "Kitchen" <window> {channel="innogysmarthome:WDS:mybridge:myWindowContact:contact"}
Switch myWindowContactBattery "Battery low" <battery> {channel="innogysmarthome:WDS:mybridge:myWindowContact:battery_low"}
Number myHeatingTemp "Bath [%.1f °C]" <temperature> {channel="innogysmarthome:RST:mybridge:myHeating:temperature"}
Number myHeatingModeTempTarget "Settemp bath [%.1f °C]" <temperature> {channel="innogysmarthome:RST:mybridge:myHeating:set_temperature"}
String myHeatingMode "Mode bath [%s]" <temperature> {channel="innogysmarthome:RST:mybridge:myHeating:operation_mode"}
Number myHeatingHumidity "Bath [%.1f %%]" <humidity> {channel="innogysmarthome:RST:mybridge:myHeating:humidity"}
```
## Sitemap configuration
The site configuration works a usual. One special example
```perl
sitemap default label="Home" {
Frame {
Text item=myHeatingTemp label="Temperature"
Text item=myHeatingHumidity label="Humidity"
Switch item=myHeatingMode label="Mode" mappings=[Manu="Manual", Auto="Auto"]
Setpoint item=myHeatingModeTempTarget label="Target temperature" minValue=16 maxValue=25 step=1
}
}
```
## Rules example for pushbuttons
Pushbuttons provide trigger channels, that can only be used in rules.
Here is an example rule:
```java
rule "Button triggered rule"
when
Channel 'innogysmarthome:WSC2:mybridge:myPushButton:button1' triggered PRESSED
then
// do something...
logInfo("testlogger", "Button 1 pressed")
end
```
## Resolving certificate issues
If the bridge stays offline with the following status shown in the UI, the reason could be an expired certificate:
`OFFLINE - COMMUNICATION_ERROR sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target`
To solve this on a Linux system, follow this steps:
1. Download the certificates (.cer-files) of <https://home.innogy-smarthome.de> and <https://innogy.com> including the "DigiCert Global Root G2" to your computer.
As this depends on the used browser and operating system, please use a web search engine to find out how to achieve this for your situation.
1. On your Linux system, goto your Java Machine's certificate store, e.g. `/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/security`.
The path should include a file called `cacerts` (this is the certificate store) and may differ depending on the system used.
1. Copy the .cer-files from step 1 into this directory.
1. Import each certificate with the command: `sudo keytool importcert alias “innogysmarthome” keystore cacerts file innogy.cer`
(alias can be freely chosen but must be unique; replace innogy.cer with the filename of the downloaded certificate)
1. Restart the JVM and openHAB.
The default password of the certificate store is "changeit".

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.binding.innogysmarthome</artifactId>
<name>openHAB Add-ons :: Bundles :: innogy Smarthome Binding</name>
</project>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.innogysmarthome-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
<feature name="openhab-binding-innogysmarthome" description="innogy Smarthome Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-http</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.innogysmarthome/${project.version}</bundle>
</feature>
</features>

View File

@ -1,192 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;
/**
* The {@link InnogyBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Oliver Kuhl - Initial contribution
*/
@NonNullByDefault
public class InnogyBindingConstants {
public static final String BINDING_ID = "innogysmarthome";
// brands and client ids
public static final String BRAND_INNOGY_SMARTHOME = "innogy_smarthome";
public static final String DEFAULT_BRAND = BRAND_INNOGY_SMARTHOME;
public static final String CLIENT_ID_INNOGY_SMARTHOME = "24635748";
public static final String CLIENT_SECRET_INNOGY_SMARTHOME = "no secret";
public static final String REDIRECT_URL_INNOGY_SMARTHOME = "https://www.openhab.org/oauth/innogy/innogy-smarthome.html";
public static final String CONFIG_AUTH_CODE = "authcode";
public static final long REINITIALIZE_DELAY_SECONDS = 30;
// API URLs
public static final String API_VERSION = "1.1";
public static final String WEBSOCKET_API_URL_EVENTS = "wss://api.services-smarthome.de/API/" + API_VERSION
+ "/events?token={token}";
// properties
public static final String PROPERTY_ID = "id";
public static final String PROPERTY_VERSION = "Version";
public static final String PROPERTY_LOCATION = "Location";
public static final String PROPERTY_GEOLOCATION = "Geo Location";
public static final String PROPERTY_SOFTWARE_VERSION = "Software version";
public static final String PROPERTY_IP_ADDRESS = "IP address";
public static final String PROPERTY_REGISTRATION_TIME = "Registration Time";
public static final String PROPERTY_TIME_OF_ACCEPTANCE = "Time of acceptance";
public static final String PROPERTY_TIME_OF_DISCOVERY = "Time of discovery";
public static final String PROPERTY_BATTERY_POWERED = "Battery powered";
public static final String PROPERTY_DEVICE_TYPE = "Device Type";
public static final String PROPERTY_CONFIGURATION_STATE = "Configuration state";
public static final String PROPERTY_SHC_TYPE = "Controller Type";
public static final String PROPERTY_TIME_ZONE = "Time Zone";
public static final String PROPERTY_CURRENT_UTC_OFFSET = "Current UTC offset (minutes)";
public static final String PROPERTY_PROTOCOL_ID = "Protocol ID";
public static final String PROPERTY_BACKEND_CONNECTION_MONITORED = "Backend connection monitored";
public static final String PROPERTY_RFCOM_FAILURE_NOTIFICATION = "RFComm failure notification";
public static final String PROPERTY_DISPLAY_CURRENT_TEMPERATURE = "Display current temperature";
public static final String PROPERTY_METER_ID = "Meter ID";
public static final String PROPERTY_METER_FIRMWARE_VERSION = "Meter firmware version";
// List of main device types
public static final String DEVICE_SHC = "SHC"; // smarthome controller - the bridge
public static final String DEVICE_SHCA = "SHCA"; // smarthome controller version 2
public static final String DEVICE_PSS = "PSS"; // pluggable smart switch
public static final String DEVICE_PSSO = "PSSO"; // pluggable smart switch outdoor
public static final String DEVICE_BT_PSS = "BT-PSS"; // Bluetooth pluggable smart switch
public static final String DEVICE_VARIABLE_ACTUATOR = "VariableActuator";
public static final String DEVICE_RST = "RST"; // radiator mounted smart thermostat
public static final String DEVICE_RST2 = "RST2"; // radiator mounted smart thermostat (newer version)
public static final String DEVICE_WRT = "WRT"; // wall mounted room thermostat
public static final String DEVICE_WDS = "WDS"; // window door sensor
public static final String DEVICE_ISS2 = "ISS2"; // inwall smart switch
public static final String DEVICE_WSD = "WSD"; // wall mounted smoke detector
public static final String DEVICE_WSD2 = "WSD2"; // wall mounted smoke detector
public static final String DEVICE_WMD = "WMD"; // wall mounted motion detector indoor
public static final String DEVICE_WMDO = "WMDO"; // wall mounted motion detector outdoor
public static final String DEVICE_WSC2 = "WSC2"; // wall mounted smart controller (2 buttons)
public static final String DEVICE_BRC8 = "BRC8"; // basic remote controller (8 buttons)
public static final String DEVICE_ISC2 = "ISC2"; // in wall smart controller (2 buttons)
public static final String DEVICE_ISD2 = "ISD2"; // in wall smart dimmer (2 buttons)
public static final String DEVICE_ISR2 = "ISR2"; // in wall smart rollershutter (2 buttons)
public static final String DEVICE_PSD = "PSD"; // pluggable smart dimmer
public static final String DEVICE_ANALOG_METER = "AnalogMeter";
public static final String DEVICE_GENERATION_METER = "GenerationMeter";
public static final String DEVICE_SMART_METER = "SmartMeter";
public static final String DEVICE_TWO_WAY_METER = "TwoWayMeter";
public static final Set<String> SUPPORTED_DEVICES = Collections.unmodifiableSet(Stream
.of(DEVICE_SHC, DEVICE_SHCA, DEVICE_PSS, DEVICE_PSSO, DEVICE_BT_PSS, DEVICE_VARIABLE_ACTUATOR, DEVICE_RST,
DEVICE_RST2, DEVICE_WRT, DEVICE_WDS, DEVICE_ISS2, DEVICE_WSD, DEVICE_WSD2, DEVICE_WMD, DEVICE_WMDO,
DEVICE_WSC2, DEVICE_BRC8, DEVICE_ISC2, DEVICE_ISD2, DEVICE_ISR2, DEVICE_PSD, DEVICE_ANALOG_METER,
DEVICE_GENERATION_METER, DEVICE_SMART_METER, DEVICE_TWO_WAY_METER)
.collect(Collectors.toSet()));
public static final Set<String> BATTERY_POWERED_DEVICES = Collections
.unmodifiableSet(Stream.of(DEVICE_RST, DEVICE_RST2, DEVICE_WRT, DEVICE_WDS, DEVICE_WSD, DEVICE_WSD2,
DEVICE_WMD, DEVICE_WMDO, DEVICE_WSC2, DEVICE_BRC8).collect(Collectors.toSet()));
// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");
public static final ThingTypeUID THING_TYPE_PSS = new ThingTypeUID(BINDING_ID, DEVICE_PSS);
public static final ThingTypeUID THING_TYPE_PSSO = new ThingTypeUID(BINDING_ID, DEVICE_PSSO);
public static final ThingTypeUID THING_TYPE_BT_PSS = new ThingTypeUID(BINDING_ID, DEVICE_BT_PSS);
public static final ThingTypeUID THING_TYPE_VARIABLE_ACTUATOR = new ThingTypeUID(BINDING_ID,
DEVICE_VARIABLE_ACTUATOR);
public static final ThingTypeUID THING_TYPE_RST = new ThingTypeUID(BINDING_ID, DEVICE_RST);
public static final ThingTypeUID THING_TYPE_RST2 = new ThingTypeUID(BINDING_ID, DEVICE_RST2);
public static final ThingTypeUID THING_TYPE_WRT = new ThingTypeUID(BINDING_ID, DEVICE_WRT);
public static final ThingTypeUID THING_TYPE_WDS = new ThingTypeUID(BINDING_ID, DEVICE_WDS);
public static final ThingTypeUID THING_TYPE_ISS2 = new ThingTypeUID(BINDING_ID, DEVICE_ISS2);
public static final ThingTypeUID THING_TYPE_WSD = new ThingTypeUID(BINDING_ID, DEVICE_WSD);
public static final ThingTypeUID THING_TYPE_WSD2 = new ThingTypeUID(BINDING_ID, DEVICE_WSD2);
public static final ThingTypeUID THING_TYPE_WMD = new ThingTypeUID(BINDING_ID, DEVICE_WMD);
public static final ThingTypeUID THING_TYPE_WMDO = new ThingTypeUID(BINDING_ID, DEVICE_WMDO);
public static final ThingTypeUID THING_TYPE_WSC2 = new ThingTypeUID(BINDING_ID, DEVICE_WSC2);
public static final ThingTypeUID THING_TYPE_BRC8 = new ThingTypeUID(BINDING_ID, DEVICE_BRC8);
public static final ThingTypeUID THING_TYPE_ISC2 = new ThingTypeUID(BINDING_ID, DEVICE_ISC2);
public static final ThingTypeUID THING_TYPE_ISD2 = new ThingTypeUID(BINDING_ID, DEVICE_ISD2);
public static final ThingTypeUID THING_TYPE_ISR2 = new ThingTypeUID(BINDING_ID, DEVICE_ISR2);
public static final ThingTypeUID THING_TYPE_PSD = new ThingTypeUID(BINDING_ID, DEVICE_PSD);
public static final ThingTypeUID THING_TYPE_ANALOG_METER = new ThingTypeUID(BINDING_ID, DEVICE_ANALOG_METER);
public static final ThingTypeUID THING_TYPE_GENERATION_METER = new ThingTypeUID(BINDING_ID,
DEVICE_GENERATION_METER);
public static final ThingTypeUID THING_TYPE_SMART_METER = new ThingTypeUID(BINDING_ID, DEVICE_SMART_METER);
public static final ThingTypeUID THING_TYPE_TWO_WAY_METER = new ThingTypeUID(BINDING_ID, DEVICE_TWO_WAY_METER);
public static final Set<ThingTypeUID> SUPPORTED_DEVICE_THING_TYPES = Collections.unmodifiableSet(
Stream.of(THING_TYPE_PSS, THING_TYPE_PSSO, THING_TYPE_BT_PSS, THING_TYPE_VARIABLE_ACTUATOR, THING_TYPE_RST,
THING_TYPE_RST2, THING_TYPE_WRT, THING_TYPE_WDS, THING_TYPE_ISS2, THING_TYPE_WSD, THING_TYPE_WSD2,
THING_TYPE_WMD, THING_TYPE_WMDO, THING_TYPE_WSC2, THING_TYPE_BRC8, THING_TYPE_ISC2, THING_TYPE_ISD2,
THING_TYPE_ISR2, THING_TYPE_PSD, THING_TYPE_ANALOG_METER, THING_TYPE_GENERATION_METER,
THING_TYPE_SMART_METER, THING_TYPE_TWO_WAY_METER).collect(Collectors.toSet()));
// List of all Channel ids
public static final String CHANNEL_SWITCH = "switch";
public static final String CHANNEL_SET_TEMPERATURE = "set_temperature";
public static final String CHANNEL_TEMPERATURE = "temperature";
public static final String CHANNEL_HUMIDITY = "humidity";
public static final String CHANNEL_CONTACT = "contact";
public static final String CHANNEL_SMOKE = "smoke";
public static final String CHANNEL_ALARM = "alarm";
public static final String CHANNEL_MOTION_COUNT = "motion_count";
public static final String CHANNEL_LUMINANCE = "luminance";
public static final String CHANNEL_OPERATION_MODE = "operation_mode";
public static final String CHANNEL_FROST_WARNING = "frost_warning";
public static final String CHANNEL_MOLD_WARNING = "mold_warning";
public static final String CHANNEL_WINDOW_REDUCTION_ACTIVE = "window_reduction_active";
public static final String CHANNEL_BUTTON = "button";
public static final String CHANNEL_BUTTON_COUNT = "button%d_count";
public static final String CHANNEL_DIMMER = "dimmer";
public static final String CHANNEL_ROLLERSHUTTER = "rollershutter";
public static final String CHANNEL_BATTERY_LOW = "battery_low";
public static final String CHANNEL_ENERGY_CONSUMPTION_MONTH_KWH = "energy_consumption_month_kwh";
public static final String CHANNEL_ABOLUTE_ENERGY_CONSUMPTION = "absolute_energy_consumption";
public static final String CHANNEL_ENERGY_CONSUMPTION_MONTH_EURO = "energy_consumption_month_euro";
public static final String CHANNEL_ENERGY_CONSUMPTION_DAY_EURO = "energy_consumption_day_euro";
public static final String CHANNEL_ENERGY_CONSUMPTION_DAY_KWH = "energy_consumption_day_kwh";
public static final String CHANNEL_POWER_CONSUMPTION_WATT = "power_consumption_watt";
public static final String CHANNEL_ENERGY_GENERATION_MONTH_KWH = "energy_generation_month_kwh";
public static final String CHANNEL_TOTAL_ENERGY_GENERATION = "total_energy_generation";
public static final String CHANNEL_ENERGY_GENERATION_MONTH_EURO = "energy_generation_month_euro";
public static final String CHANNEL_ENERGY_GENERATION_DAY_EURO = "energy_generation_day_euro";
public static final String CHANNEL_ENERGY_GENERATION_DAY_KWH = "energy_generation_day_kwh";
public static final String CHANNEL_POWER_GENERATION_WATT = "power_generation_watt";
public static final String CHANNEL_ENERGY_MONTH_KWH = "energy_month_kwh";
public static final String CHANNEL_TOTAL_ENERGY = "total_energy";
public static final String CHANNEL_ENERGY_MONTH_EURO = "energy_month_euro";
public static final String CHANNEL_ENERGY_DAY_EURO = "energy_day_euro";
public static final String CHANNEL_ENERGY_DAY_KWH = "energy_day_kwh";
public static final String CHANNEL_ENERGY_FEED_MONTH_KWH = "energy_feed_month_kwh";
public static final String CHANNEL_TOTAL_ENERGY_FED = "total_energy_fed";
public static final String CHANNEL_ENERGY_FEED_MONTH_EURO = "energy_feed_month_euro";
public static final String CHANNEL_ENERGY_FEED_DAY_EURO = "energy_feed_day_euro";
public static final String CHANNEL_ENERGY_FEED_DAY_KWH = "energy_feed_day_kwh";
public static final String CHANNEL_POWER_WATT = "power_watt";
public static final String CHANNEL_CPU = "cpu";
public static final String CHANNEL_DISK = "disk";
public static final String CHANNEL_MEMORY = "memory";
}

View File

@ -1,81 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.innogysmarthome.internal.handler.InnogyBridgeHandler;
import org.openhab.binding.innogysmarthome.internal.handler.InnogyDeviceHandler;
import org.openhab.core.auth.client.oauth2.OAuthFactory;
import org.openhab.core.io.net.http.HttpClientFactory;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link InnogyHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Oliver Kuhl - Initial contribution
* @author Hilbrand Bouwkamp - Refactored to use openHAB http and oauth2 libraries
*/
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.innogysmarthome")
@NonNullByDefault
public class InnogyHandlerFactory extends BaseThingHandlerFactory implements ThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Stream
.concat(InnogyBridgeHandler.SUPPORTED_THING_TYPES.stream(),
InnogyDeviceHandler.SUPPORTED_THING_TYPES.stream())
.collect(Collectors.toSet());
private final Logger logger = LoggerFactory.getLogger(InnogyHandlerFactory.class);
private final OAuthFactory oAuthFactory;
private final HttpClient httpClient;
@Activate
public InnogyHandlerFactory(@Reference OAuthFactory oAuthFactory, @Reference HttpClientFactory httpClientFactory) {
this.oAuthFactory = oAuthFactory;
httpClient = httpClientFactory.getCommonHttpClient();
}
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES.contains(thingTypeUID);
}
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
if (InnogyBridgeHandler.SUPPORTED_THING_TYPES.contains(thing.getThingTypeUID())) {
return new InnogyBridgeHandler((Bridge) thing, oAuthFactory, httpClient);
} else if (InnogyDeviceHandler.SUPPORTED_THING_TYPES.contains(thing.getThingTypeUID())) {
return new InnogyDeviceHandler(thing);
} else {
logger.debug("Unsupported thing {}.", thing.getThingTypeUID());
return null;
}
}
}

View File

@ -1,157 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal;
import java.net.URI;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.openhab.binding.innogysmarthome.internal.handler.InnogyBridgeHandler;
import org.openhab.binding.innogysmarthome.internal.listener.EventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link InnogyWebSocket} implements the websocket for receiving constant updates
* from the innogy SmartHome web service.
*
* @author Oliver Kuhl - Initial contribution
*/
@NonNullByDefault
@WebSocket
public class InnogyWebSocket {
private final Logger logger = LoggerFactory.getLogger(InnogyWebSocket.class);
private final EventListener eventListener;
private final URI webSocketURI;
private final int maxIdleTimeout;
private @Nullable Session session;
private @Nullable WebSocketClient client;
private boolean closing;
/**
* Constructs the {@link InnogyWebSocket}.
*
* @param eventListener the responsible {@link InnogyBridgeHandler}
* @param webSocketURI the {@link URI} of the websocket endpoint
* @param maxIdleTimeout
*/
public InnogyWebSocket(EventListener eventListener, URI webSocketURI, int maxIdleTimeout) {
this.eventListener = eventListener;
this.webSocketURI = webSocketURI;
this.maxIdleTimeout = maxIdleTimeout;
}
/**
* Starts the {@link InnogyWebSocket}.
*
* @throws Exception
*/
public synchronized void start() throws Exception {
if (client == null || client.isStopped()) {
client = startWebSocketClient();
}
if (session != null) {
session.close();
}
logger.debug("Connecting to innogy WebSocket...");
session = client.connect(this, webSocketURI).get();
}
/**
* Stops the {@link InnogyWebSocket}.
*/
public synchronized void stop() {
this.closing = true;
if (isRunning()) {
logger.debug("Closing session...");
session.close();
session = null;
} else {
session = null;
logger.trace("Stopping websocket ignored - was not running.");
}
if (client != null) {
try {
client.stop();
client.destroy();
} catch (Exception e) {
logger.debug("Stopping websocket failed", e);
}
client = null;
}
}
/**
* Return true, if the websocket is running.
*
* @return
*/
public synchronized boolean isRunning() {
return session != null && session.isOpen();
}
@OnWebSocketConnect
public void onConnect(Session session) {
this.closing = false;
logger.info("Connected to innogy Webservice.");
logger.trace("innogy Websocket session: {}", session);
}
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
if (statusCode == StatusCode.NORMAL) {
logger.info("Connection to innogy Webservice was closed normally.");
} else if (!closing) {
// An additional reconnect attempt is only required when the close/stop wasn't executed by the binding.
logger.info("Connection to innogy Webservice was closed abnormally (code: {}). Reason: {}", statusCode,
reason);
eventListener.connectionClosed();
}
}
@OnWebSocketError
public void onError(Throwable cause) {
logger.debug("innogy WebSocket onError() - {}", cause.getMessage());
eventListener.onError(cause);
}
@OnWebSocketMessage
public void onMessage(String msg) {
logger.debug("innogy WebSocket onMessage() - {}", msg);
if (closing) {
logger.debug("innogy WebSocket onMessage() - ignored, WebSocket is closing...");
} else {
eventListener.onEvent(msg);
}
}
WebSocketClient startWebSocketClient() throws Exception {
WebSocketClient client = new WebSocketClient(new SslContextFactory.Client());
client.setMaxIdleTimeout(this.maxIdleTimeout);
client.start();
return client;
}
}

View File

@ -1,53 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Holds necessary constants for the innogy API.
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public final class Constants {
// API URLs
public static final String API_HOST = "api.services-smarthome.de";
public static final String AUTH_HOST = "auth.services-smarthome.de";
public static final String API_VERSION = "1.1";
public static final String API_URL_BASE = "https://" + API_HOST + "/API/" + API_VERSION;
public static final String API_URL_TOKEN = "https://" + AUTH_HOST + "/AUTH/token";
public static final String API_URL_STATUS = API_URL_BASE + "/status";
public static final String API_URL_DEVICE = API_URL_BASE + "/device";
public static final String API_URL_DEVICE_ID = API_URL_DEVICE + "/{id}";
public static final String API_URL_DEVICE_ID_STATE = API_URL_DEVICE_ID + "/state";
public static final String API_URL_DEVICE_CAPABILITIES = API_URL_DEVICE + "/{id}/capabilities";
public static final String API_URL_DEVICE_STATES = API_URL_DEVICE + "/states";
public static final String API_URL_LOCATION = API_URL_BASE + "/location";
public static final String API_URL_CAPABILITY = API_URL_BASE + "/capability";
public static final String API_URL_CAPABILITY_STATES = API_URL_CAPABILITY + "/states";
public static final String API_URL_MESSAGE = API_URL_BASE + "/message";
public static final String API_URL_ACTION = API_URL_BASE + "/action";
private Constants() {
// Constants class
}
}

View File

@ -1,424 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client;
import static org.openhab.binding.innogysmarthome.internal.client.Constants.*;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.util.StringContentProvider;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants;
import org.openhab.binding.innogysmarthome.internal.client.entity.StatusResponse;
import org.openhab.binding.innogysmarthome.internal.client.entity.action.Action;
import org.openhab.binding.innogysmarthome.internal.client.entity.action.ShutterAction;
import org.openhab.binding.innogysmarthome.internal.client.entity.action.StateActionSetter;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.CapabilityState;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.DeviceState;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Gateway;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.State;
import org.openhab.binding.innogysmarthome.internal.client.entity.error.ErrorResponse;
import org.openhab.binding.innogysmarthome.internal.client.entity.location.Location;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
import org.openhab.binding.innogysmarthome.internal.client.exception.ApiException;
import org.openhab.binding.innogysmarthome.internal.client.exception.AuthenticationException;
import org.openhab.binding.innogysmarthome.internal.client.exception.ControllerOfflineException;
import org.openhab.binding.innogysmarthome.internal.client.exception.InvalidActionTriggeredException;
import org.openhab.binding.innogysmarthome.internal.client.exception.RemoteAccessNotAllowedException;
import org.openhab.binding.innogysmarthome.internal.client.exception.ServiceUnavailableException;
import org.openhab.binding.innogysmarthome.internal.client.exception.SessionExistsException;
import org.openhab.binding.innogysmarthome.internal.client.exception.SessionNotFoundException;
import org.openhab.core.auth.client.oauth2.AccessTokenResponse;
import org.openhab.core.auth.client.oauth2.OAuthClientService;
import org.openhab.core.auth.client.oauth2.OAuthException;
import org.openhab.core.auth.client.oauth2.OAuthResponseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
/**
* The main client that handles the communication with the innogy SmartHome API service.
*
* @author Oliver Kuhl - Initial contribution
* @author Hilbrand Bouwkamp - Refactored to use openHAB http and oauth2 libraries
*
*/
@NonNullByDefault
public class InnogyClient {
private static final String BEARER = "Bearer ";
private static final String CONTENT_TYPE = "application/json";
private static final int HTTP_REQUEST_TIMEOUT_SECONDS = 10;
private static final int HTTP_REQUEST_IDLE_TIMEOUT_SECONDS = 20;
private final Logger logger = LoggerFactory.getLogger(InnogyClient.class);
/**
* date format as used in json in API. Example: 2016-07-11T10:55:52.3863424Z
*/
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
private final Gson gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
private final OAuthClientService oAuthService;
private final HttpClient httpClient;
private @Nullable Gateway bridgeDetails;
private String configVersion = "";
public InnogyClient(final OAuthClientService oAuthService, final HttpClient httpClient) {
this.oAuthService = oAuthService;
this.httpClient = httpClient;
}
/**
* Gets the status
*
* As the API returns the details of the SmartHome controller (SHC), the data is saved in {@link #bridgeDetails} and
* the {@link #configVersion} is set.
*
* @throws SessionExistsException thrown, if a session already exists
*/
public void refreshStatus() throws IOException, ApiException, AuthenticationException {
logger.debug("Get innogy SmartHome status...");
final StatusResponse status = executeGet(API_URL_STATUS, StatusResponse.class);
bridgeDetails = status.gateway;
configVersion = bridgeDetails.getConfigVersion();
logger.debug("innogy SmartHome Status loaded. Configuration version is {}.", configVersion);
}
/**
* Executes a HTTP GET request with default headers and returns data as object of type T.
*
* @param url request URL
* @param clazz type of data to return
* @return response content
*/
private <T> T executeGet(final String url, final Class<T> clazz)
throws IOException, AuthenticationException, ApiException {
final ContentResponse response = request(httpClient.newRequest(url).method(HttpMethod.GET));
return gson.fromJson(response.getContentAsString(), clazz);
}
/**
* Executes a HTTP GET request with default headers and returns data as List of type T.
*
* @param url request URL
* @param clazz array type of data to return as list
* @return response content (as a List)
*/
private <T> List<T> executeGetList(final String url, final Class<T[]> clazz)
throws IOException, AuthenticationException, ApiException {
return Arrays.asList(executeGet(url, clazz));
}
/**
* Executes a HTTP POST request with the given {@link Action} as content.
*
* @param url request URL
* @param action action to execute
*/
private void executePost(final String url, final Action action)
throws IOException, AuthenticationException, ApiException {
final String json = gson.toJson(action);
logger.debug("Action {} JSON: {}", action.getType(), json);
request(httpClient.newRequest(url).method(HttpMethod.POST)
.content(new StringContentProvider(json), CONTENT_TYPE).accept(CONTENT_TYPE));
}
private ContentResponse request(final Request request) throws IOException, AuthenticationException, ApiException {
final ContentResponse response;
try {
final AccessTokenResponse accessTokenResponse = getAccessTokenResponse();
response = request.header(HttpHeader.ACCEPT, CONTENT_TYPE)
.header(HttpHeader.AUTHORIZATION, BEARER + accessTokenResponse.getAccessToken())
.idleTimeout(HTTP_REQUEST_IDLE_TIMEOUT_SECONDS, TimeUnit.SECONDS)
.timeout(HTTP_REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS).send();
} catch (InterruptedException | TimeoutException | ExecutionException e) {
throw new IOException(e);
}
handleResponseErrors(response, request.getURI());
return response;
}
public AccessTokenResponse getAccessTokenResponse() throws AuthenticationException, IOException {
@Nullable
final AccessTokenResponse accessTokenResponse;
try {
accessTokenResponse = oAuthService.getAccessTokenResponse();
} catch (OAuthException | OAuthResponseException e) {
throw new AuthenticationException("Error fetching access token: " + e.getMessage());
}
if (accessTokenResponse == null || accessTokenResponse.getAccessToken() == null
|| accessTokenResponse.getAccessToken().isBlank()) {
throw new AuthenticationException("No innogy accesstoken. Is this thing authorized?");
}
return accessTokenResponse;
}
/**
* Handles errors from the {@link ContentResponse} and throws the following errors:
*
* @param response response
* @param uri uri of api call made
* @throws ControllerOfflineException thrown, if the innogy SmartHome controller (SHC) is offline.
*/
private void handleResponseErrors(final ContentResponse response, final URI uri) throws IOException, ApiException {
String content = "";
switch (response.getStatus()) {
case HttpStatus.OK_200:
logger.debug("Statuscode is OK: [{}]", uri);
return;
case HttpStatus.SERVICE_UNAVAILABLE_503:
logger.debug("innogy service is unavailabe (503).");
throw new ServiceUnavailableException("innogy service is unavailabe (503).");
default:
logger.debug("Statuscode {} is NOT OK: [{}]", response.getStatus(), uri);
try {
content = response.getContentAsString();
logger.trace("Response error content: {}", content);
final ErrorResponse error = gson.fromJson(content, ErrorResponse.class);
if (error == null) {
logger.debug("Error without JSON message, code: {} / message: {}", response.getStatus(),
response.getReason());
throw new ApiException("Error code: " + response.getStatus());
}
switch (error.getCode()) {
case ErrorResponse.ERR_SESSION_EXISTS:
logger.debug("Session exists: {}", error);
throw new SessionExistsException(error.getDescription());
case ErrorResponse.ERR_SESSION_NOT_FOUND:
logger.debug("Session not found: {}", error);
throw new SessionNotFoundException(error.getDescription());
case ErrorResponse.ERR_CONTROLLER_OFFLINE:
logger.debug("Controller offline: {}", error);
throw new ControllerOfflineException(error.getDescription());
case ErrorResponse.ERR_REMOTE_ACCESS_NOT_ALLOWED:
logger.debug(
"Remote access not allowed. Access is allowed only from the SHC device network.");
throw new RemoteAccessNotAllowedException(
"Remote access not allowed. Access is allowed only from the SHC device network.");
case ErrorResponse.ERR_INVALID_ACTION_TRIGGERED:
logger.debug("Invalid action triggered. Message: {}", error.getMessages());
throw new InvalidActionTriggeredException(error.getDescription());
default:
logger.debug("Unknown error: {}", error);
throw new ApiException("Unknown error: " + error);
}
} catch (final JsonSyntaxException e) {
throw new ApiException("Invalid JSON syntax in error response: " + content);
}
}
}
/**
* Sets a new state of a SwitchActuator.
*/
public void setSwitchActuatorState(final String capabilityId, final boolean state)
throws IOException, ApiException, AuthenticationException {
executePost(API_URL_ACTION, new StateActionSetter(capabilityId, Capability.TYPE_SWITCHACTUATOR, state));
}
/**
* Sets the dimmer level of a DimmerActuator.
*/
public void setDimmerActuatorState(final String capabilityId, final int dimLevel)
throws IOException, ApiException, AuthenticationException {
executePost(API_URL_ACTION, new StateActionSetter(capabilityId, Capability.TYPE_DIMMERACTUATOR, dimLevel));
}
/**
* Sets the roller shutter level of a RollerShutterActuator.
*/
public void setRollerShutterActuatorState(final String capabilityId, final int rollerShutterLevel)
throws IOException, ApiException, AuthenticationException {
executePost(API_URL_ACTION,
new StateActionSetter(capabilityId, Capability.TYPE_ROLLERSHUTTERACTUATOR, rollerShutterLevel));
}
/**
* Starts or stops moving a RollerShutterActuator
*/
public void setRollerShutterAction(final String capabilityId,
final ShutterAction.ShutterActions rollerShutterAction)
throws IOException, ApiException, AuthenticationException {
executePost(API_URL_ACTION, new ShutterAction(capabilityId, rollerShutterAction));
}
/**
* Sets a new state of a VariableActuator.
*/
public void setVariableActuatorState(final String capabilityId, final boolean state)
throws IOException, ApiException, AuthenticationException {
executePost(API_URL_ACTION, new StateActionSetter(capabilityId, Capability.TYPE_VARIABLEACTUATOR, state));
}
/**
* Sets the point temperature.
*/
public void setPointTemperatureState(final String capabilityId, final double pointTemperature)
throws IOException, ApiException, AuthenticationException {
executePost(API_URL_ACTION,
new StateActionSetter(capabilityId, Capability.TYPE_THERMOSTATACTUATOR, pointTemperature));
}
/**
* Sets the operation mode to "Auto" or "Manu".
*/
public void setOperationMode(final String capabilityId, final boolean autoMode)
throws IOException, ApiException, AuthenticationException {
executePost(API_URL_ACTION,
new StateActionSetter(capabilityId, Capability.TYPE_THERMOSTATACTUATOR,
autoMode ? CapabilityState.STATE_VALUE_OPERATION_MODE_AUTO
: CapabilityState.STATE_VALUE_OPERATION_MODE_MANUAL));
}
/**
* Sets the alarm state.
*/
public void setAlarmActuatorState(final String capabilityId, final boolean alarmState)
throws IOException, ApiException, AuthenticationException {
executePost(API_URL_ACTION, new StateActionSetter(capabilityId, Capability.TYPE_ALARMACTUATOR, alarmState));
}
/**
* Load the device and returns a {@link List} of {@link Device}s..
* VariableActuators are returned additionally (independent from the device ids),
* because VariableActuators are everytime available and never have a device state.
*
* @param deviceIds Ids of the devices to return
* @return List of Devices
*/
public List<Device> getDevices(Collection<String> deviceIds)
throws IOException, ApiException, AuthenticationException {
logger.debug("Loading innogy devices...");
List<Device> devices = executeGetList(API_URL_DEVICE, Device[].class);
return devices.stream().filter(d -> isDeviceUsable(d, deviceIds)).collect(Collectors.toList());
}
/**
* Loads the {@link Device} with the given deviceId.
*/
public Device getDeviceById(final String deviceId) throws IOException, ApiException, AuthenticationException {
logger.debug("Loading device with id {}...", deviceId);
return executeGet(API_URL_DEVICE_ID.replace("{id}", deviceId), Device.class);
}
/**
* Loads the states for all {@link Device}s.
*/
public List<DeviceState> getDeviceStates() throws IOException, ApiException, AuthenticationException {
logger.debug("Loading device states...");
return executeGetList(API_URL_DEVICE_STATES, DeviceState[].class);
}
/**
* Loads the device state for the given deviceId.
*/
public State getDeviceStateByDeviceId(final String deviceId)
throws IOException, ApiException, AuthenticationException {
logger.debug("Loading device states for device id {}...", deviceId);
return executeGet(API_URL_DEVICE_ID_STATE.replace("{id}", deviceId), State.class);
}
/**
* Loads the locations and returns a {@link List} of {@link Location}s.
*
* @return a List of Devices
*/
public List<Location> getLocations() throws IOException, ApiException, AuthenticationException {
logger.debug("Loading locations...");
return executeGetList(API_URL_LOCATION, Location[].class);
}
/**
* Loads and returns a {@link List} of {@link Capability}s for the given deviceId.
*
* @param deviceId the id of the {@link Device}
* @return capabilities of the device
*/
public List<Capability> getCapabilitiesForDevice(final String deviceId)
throws IOException, ApiException, AuthenticationException {
logger.debug("Loading capabilities for device {}...", deviceId);
return executeGetList(API_URL_DEVICE_CAPABILITIES.replace("{id}", deviceId), Capability[].class);
}
/**
* Loads and returns a {@link List} of all {@link Capability}s.
*/
public List<Capability> getCapabilities() throws IOException, ApiException, AuthenticationException {
logger.debug("Loading capabilities...");
return executeGetList(API_URL_CAPABILITY, Capability[].class);
}
/**
* Loads and returns a {@link List} of all {@link Capability}States.
*/
public List<CapabilityState> getCapabilityStates() throws IOException, ApiException, AuthenticationException {
logger.debug("Loading capability states...");
return executeGetList(API_URL_CAPABILITY_STATES, CapabilityState[].class);
}
/**
* Returns a {@link List} of all {@link Message}s.
*/
public List<Message> getMessages() throws IOException, ApiException, AuthenticationException {
logger.debug("Loading messages...");
return executeGetList(API_URL_MESSAGE, Message[].class);
}
/**
* @return the configVersion
*/
public String getConfigVersion() {
return configVersion;
}
/**
* Decides if a (discovered) device is usable (available and supported).
*
* @param device device to check
* @param activeDeviceIds active device id (devices with an according available device state)
* @return true when usable, otherwise false
*/
private static boolean isDeviceUsable(Device device, Collection<String> activeDeviceIds) {
return activeDeviceIds.contains(device.getId())
|| InnogyBindingConstants.DEVICE_VARIABLE_ACTUATOR.equals(device.getType());
}
}

View File

@ -1,36 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Utility class with commonly used methods.
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public final class Util {
private Util() {
// Util class.
}
public static ZonedDateTime convertZuluTimeStringToDate(String timeString) {
return ZonedDateTime.parse(timeString, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
}
}

View File

@ -1,28 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity;
/**
* The {@link Constant} entity is used for {@link Action}s.
*
*
* @author Oliver Kuhl - Initial contribution
*/
public class Constant {
public Object value;
public Constant(Object value) {
this.value = value;
}
}

View File

@ -1,84 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity;
/**
* Defines a {@link Property}, that is a basic key/value structure used for several data types in the innogy API.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Property {
private String name;
private Object value;
private String lastchanged;
public Property() {
// used for serialization
}
/**
* Constructs a new {@link Property} with the given name and value.
*
* @param name
* @param value
*/
public Property(String name, Object value) {
this.name = name;
this.value = value;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the value
*/
public Object getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Object value) {
this.value = value;
}
/**
* @return the lastchanged
*/
public String getLastchanged() {
return lastchanged;
}
/**
* @param lastchanged the lastchanged to set
*/
public void setLastchanged(String lastchanged) {
this.lastchanged = lastchanged;
}
}

View File

@ -1,27 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Gateway;
/**
* Defines the structure of the status response
*
* @author Oliver Kuhl - Initial contribution
*/
public class StatusResponse {
/**
* The innogy SmartHome gateway. Can be null in case there is no registered for the current logged in user.
*/
public Gateway gateway;
}

View File

@ -1,128 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.action;
import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
/**
* Implements the Action structure needed to send JSON actions to the innogy backend. They are used to e.g. switch the
* state of a device.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Action {
public static final String ACTION_TYPE_SETSTATE = "SetState";
private static final String NAMESPACE_CORE_RWE = "core.RWE";
/**
* Specifies the type of the action.
*/
private String type;
/**
* Link to the entity supposed to execute the action.
*/
private String target;
/**
* The product (context) that should handle (execute) the action. Defaults to {@link Action#NAMESPACE_CORE_RWE}.
*/
private String namespace = NAMESPACE_CORE_RWE;
/**
* Dictionary of functions required for the intended execution of the action.
*/
private ActionParams params;
/**
* Default constructor, used by serialization.
*/
public Action() {
// used by serialization
}
/**
* Sets the type of the action. Usual action type is {@link Action#ACTION_TYPE_SETSTATE}.
*
* @param type
*/
public Action(String type) {
this.type = type;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the link to the target capability
*/
public String getTarget() {
return target;
}
/**
* @param target the link to the target capability to set
*/
public void setTarget(String target) {
this.target = target;
}
/**
* @return the namespace
*/
public String getNamespace() {
return namespace;
}
/**
* @param namespace the namespace to set
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* Sets the link target to the given capability id.
*
* @param capabilityId String with the 32 character long id
*/
public void setTargetCapabilityById(String capabilityId) {
setTarget(Link.LINK_TYPE_CAPABILITY + capabilityId);
}
/**
* @return the params
*/
public ActionParams getParams() {
return params;
}
/**
* @param params the params to set
*/
public void setParams(ActionParams params) {
this.params = params;
}
}

View File

@ -1,134 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.action;
/**
* Defines the {@link ActionParams} data structure needed to pass parameters within an {@link Action} to the innogy
* SmartHome backend.
*
* @author Oliver Kuhl - Initial contribution
*/
public class ActionParams {
private BooleanActionParam onState;
private BooleanActionParam value;
private DoubleActionParam pointTemperature;
private IntegerActionParam dimLevel;
private IntegerActionParam shutterLevel;
private StringActionParam operationMode;
private StringActionParam rampDirection;
/**
* @return the onState
*/
public BooleanActionParam getOnState() {
return onState;
}
/**
* @param state the state to set
*/
public void setOnState(BooleanActionParam state) {
this.onState = state;
}
/**
* @return the onState
*/
public BooleanActionParam getValue() {
return value;
}
/**
* @param state the state to set
*/
public void setValue(BooleanActionParam state) {
this.value = state;
}
/**
* @return the pointTemperature
*/
public DoubleActionParam getPointTemperature() {
return pointTemperature;
}
/**
* @param pointTemperature the pointTemperature to set
*/
public void setPointTemperature(DoubleActionParam pointTemperature) {
this.pointTemperature = pointTemperature;
}
/**
* @return the dimLevel
*/
public IntegerActionParam getDimLevel() {
return dimLevel;
}
/**
* @param dimLevel the dimLevel to set
*/
public void setDimLevel(IntegerActionParam dimLevel) {
this.dimLevel = dimLevel;
}
/**
* @return the shutterLevel
*/
public IntegerActionParam getShutterLevel() {
return shutterLevel;
}
/**
* @param shutterLevel the shutterLevel to set
*/
public void setShutterLevel(IntegerActionParam shutterLevel) {
this.shutterLevel = shutterLevel;
}
/**
* @return the operationMode
*/
public StringActionParam getOperationMode() {
return operationMode;
}
/**
* @param operationMode the operationMode to set
*/
public void setOperationMode(StringActionParam operationMode) {
this.operationMode = operationMode;
}
/**
* @return the rampDirection
*/
public StringActionParam getRampDirection() {
return rampDirection;
}
/**
* @param rampDirection the rampDirection to set
*/
public void setRampDirection(StringActionParam rampDirection) {
this.rampDirection = rampDirection;
}
}

View File

@ -1,62 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.action;
/**
* Defines the structure of a {@link BooleanActionParam}.
*
* @author Oliver Kuhl - Initial contribution
*/
public class BooleanActionParam {
private String type;
private boolean value;
/**
* @param type
* @param value
*/
BooleanActionParam(String type, boolean value) {
this.type = type;
this.value = value;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the value
*/
public boolean isValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(boolean value) {
this.value = value;
}
}

View File

@ -1,62 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.action;
/**
* Defines the structure of a {@link DoubleActionParam}.
*
* @author Oliver Kuhl - Initial contribution
*/
public class DoubleActionParam {
private String type;
private double value;
/**
* @param type
* @param value
*/
DoubleActionParam(String type, double value) {
this.type = type;
this.value = value;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the value
*/
public double isValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(double value) {
this.value = value;
}
}

View File

@ -1,62 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.action;
/**
* Defines the structure of an {@link IntegerActionParam}.
*
* @author Oliver Kuhl - Initial contribution
*/
public class IntegerActionParam {
private String type;
private int value;
/**
* @param type
* @param value
*/
IntegerActionParam(String type, int value) {
this.type = type;
this.value = value;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the value
*/
public int isValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(int value) {
this.value = value;
}
}

View File

@ -1,57 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.action;
/**
* Special {@link Action} needed to control shutters.
*
* @author Marco Mans - Initial contribution
*/
public class ShutterAction extends Action {
public enum ShutterActions {
UP,
DOWN,
STOP
}
private static final String TYPE_STOP_RAMP = "StopRamp";
private static final String TYPE_START_RAMP = "StartRamp";
private static final String DIRECTION_RAMP_UP = "RampUp";
private static final String DIRECTION_RAMP_DOWN = "RampDown";
private static final String CONSTANT = "Constant";
private static final String NAMESPACE_COSIP = "CosipDevices.RWE";
/**
* Describes a Shutteraction
*
* @param capabilityId String of the 32 character capability id
* @param action Which action to perform (UP, DOWN, STOP)
*/
public ShutterAction(String capabilityId, ShutterActions action) {
setTargetCapabilityById(capabilityId);
setNamespace(NAMESPACE_COSIP);
final ActionParams params = new ActionParams();
if (ShutterActions.STOP.equals(action)) {
setType(TYPE_STOP_RAMP);
} else if (ShutterActions.UP.equals(action)) {
setType(TYPE_START_RAMP);
params.setRampDirection(new StringActionParam(CONSTANT, DIRECTION_RAMP_UP));
} else if (ShutterActions.DOWN.equals(action)) {
setType(TYPE_START_RAMP);
params.setRampDirection(new StringActionParam(CONSTANT, DIRECTION_RAMP_DOWN));
}
setParams(params);
}
}

View File

@ -1,105 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.action;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
/**
* Special {@link Action} needed to set a state of a device.
*
* @author Oliver Kuhl - Initial contribution
*/
public class StateActionSetter extends Action {
private static final String CONSTANT = "Constant";
/**
* Constructs a new {@link StateActionSetter}.
*
* @param capabilityId String of the 32 character capability id
* @param capabilityType the type of the {@link Capability}, {@link Capability#TYPE_SWITCHACTUATOR} or
* {@link Capability#TYPE_VARIABLEACTUATOR}
* @param state the new state as boolean (true=on, false=off)
*/
public StateActionSetter(String capabilityId, String capabilityType, boolean state) {
setType(ACTION_TYPE_SETSTATE);
setTargetCapabilityById(capabilityId);
final ActionParams params = new ActionParams();
if (Capability.TYPE_SWITCHACTUATOR.equals(capabilityType)) {
params.setOnState(new BooleanActionParam(CONSTANT, state));
} else if (Capability.TYPE_VARIABLEACTUATOR.equals(capabilityType)) {
params.setValue(new BooleanActionParam(CONSTANT, state));
} else if (Capability.TYPE_ALARMACTUATOR.equals(capabilityType)) {
params.setOnState(new BooleanActionParam(CONSTANT, state));
}
setParams(params);
}
/**
* Constructs a new {@link StateActionSetter}.
*
* @param capabilityId String of the 32 character capability id
* @param capabilityType the type of the {@link Capability}, {@link Capability#TYPE_THERMOSTATACTUATOR}
* @param newValue the new double value
*/
public StateActionSetter(String capabilityId, String capabilityType, double newValue) {
setType(ACTION_TYPE_SETSTATE);
setTargetCapabilityById(capabilityId);
final ActionParams params = new ActionParams();
if (Capability.TYPE_THERMOSTATACTUATOR.equals(capabilityType)) {
params.setPointTemperature(new DoubleActionParam(CONSTANT, newValue));
}
setParams(params);
}
/**
* Constructs a new {@link StateActionSetter}.
*
* @param capabilityId String of the 32 character capability id
* @param capabilityType the type of the {@link Capability}, {@link Capability#TYPE_DIMMERACTUATOR}
* @param newValue the new int value
*/
public StateActionSetter(String capabilityId, String capabilityType, int newValue) {
setType(ACTION_TYPE_SETSTATE);
setTargetCapabilityById(capabilityId);
final ActionParams params = new ActionParams();
if (Capability.TYPE_DIMMERACTUATOR.equals(capabilityType)) {
params.setDimLevel(new IntegerActionParam(CONSTANT, newValue));
} else if (Capability.TYPE_ROLLERSHUTTERACTUATOR.equals(capabilityType)) {
params.setShutterLevel(new IntegerActionParam(CONSTANT, newValue));
}
setParams(params);
}
/**
* Constructs a new {@link StateActionSetter}.
*
* @param capabilityId String of the 32 character capability id
* @param capabilityType the type of the {@link Capability}, {@link Capability#TYPE_THERMOSTATACTUATOR}
* @param newValue the new string value
*/
public StateActionSetter(String capabilityId, String capabilityType, String newValue) {
setType(ACTION_TYPE_SETSTATE);
setTargetCapabilityById(capabilityId);
final ActionParams params = new ActionParams();
if (Capability.TYPE_THERMOSTATACTUATOR.equals(capabilityType)) {
params.setOperationMode(new StringActionParam(CONSTANT, newValue));
}
setParams(params);
}
}

View File

@ -1,62 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.action;
/**
* Defines the structure of a {@link StringActionParam}.
*
* @author Oliver Kuhl - Initial contribution
*/
public class StringActionParam {
private String type;
private String value;
/**
* @param type
* @param value
*/
StringActionParam(String type, String value) {
this.type = type;
this.value = value;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the value
*/
public String isValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
}

View File

@ -1,355 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.capability;
/**
* Defines the structure of a {@link Capability}. A capability is a specific functionality of a device like a
* temperature sensor.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Capability {
/** capability types */
public static final String TYPE_SWITCHACTUATOR = "SwitchActuator";
public static final String TYPE_VARIABLEACTUATOR = "BooleanStateActuator";
public static final String TYPE_THERMOSTATACTUATOR = "ThermostatActuator";
public static final String TYPE_TEMPERATURESENSOR = "TemperatureSensor";
public static final String TYPE_HUMIDITYSENSOR = "HumiditySensor";
public static final String TYPE_WINDOWDOORSENSOR = "WindowDoorSensor";
public static final String TYPE_SMOKEDETECTORSENSOR = "SmokeDetectorSensor";
public static final String TYPE_ALARMACTUATOR = "AlarmActuator";
public static final String TYPE_MOTIONDETECTIONSENSOR = "MotionDetectionSensor";
public static final String TYPE_LUMINANCESENSOR = "LuminanceSensor";
public static final String TYPE_PUSHBUTTONSENSOR = "PushButtonSensor";
public static final String TYPE_DIMMERACTUATOR = "DimmerActuator";
public static final String TYPE_ROLLERSHUTTERACTUATOR = "RollerShutterActuator";
public static final String TYPE_ENERGYCONSUMPTIONSENSOR = "EnergyConsumptionSensor";
public static final String TYPE_POWERCONSUMPTIONSENSOR = "PowerConsumptionSensor";
public static final String TYPE_GENERATIONMETERENERGYSENSOR = "GenerationMeterEnergySensor";
public static final String TYPE_GENERATIONMETERPOWERCONSUMPTIONSENSOR = "GenerationMeterPowerConsumptionSensor";
public static final String TYPE_TWOWAYMETERENERGYCONSUMPTIONSENSOR = "TwoWayMeterEnergyConsumptionSensor";
public static final String TYPE_TWOWAYMETERENERGYFEEDSENSOR = "TwoWayMeterEnergyFeedSensor";
public static final String TYPE_TWOWAYMETERPOWERCONSUMPTIONSENSOR = "TwoWayMeterPowerConsumptionSensor";
/**
* Unique id for the Capability.
*/
private String id;
/**
* Type of the capability must be unique per device, since the device links to the capability via the type.
*/
private String type;
/**
* Contains the link to the parent device, which offers the capability.
*/
private String device;
/**
* This represents a container of all configuration properties.
*/
private CapabilityConfig config;
private CapabilityState capabilityState;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return
*/
public String getDeviceLink() {
return device;
}
/**
* @param deviceLink
*/
public void setDeviceLink(String deviceLink) {
this.device = deviceLink;
}
/**
* @return the config
*/
public CapabilityConfig getConfig() {
return config;
}
/**
* @param config the config to set
*/
public void setConfig(CapabilityConfig config) {
this.config = config;
}
/**
* Returns the {@link CapabilityState}. Only available, if capability has a state. Better check with
* {@link Capability#hasState()} first!
*
* @return the capabilityState or null
*/
public CapabilityState getCapabilityState() {
return capabilityState;
}
/**
* @param capabilityState the capabilityState to set
*/
public void setCapabilityState(CapabilityState capabilityState) {
this.capabilityState = capabilityState;
}
/**
* Returns, if the capability has a state. Not all capabilities have a state.
*
* @return
*/
public boolean hasState() {
return (capabilityState != null) && (capabilityState.getState() != null);
}
/**
* Returns the name of the {@link Capability}.
*
* @return
*/
public String getName() {
return getConfig().getName();
}
/**
* Returns, if the activity log is active for the {@link Capability}.
*
* @return boolean or null, if the {@link Capability} does not have this property.
*/
public boolean getActivityLogActive() {
return getConfig().getActivityLogActive();
}
/**
* Returns the number of pushbuttons for the {@link Capability}.
*
* @return int or null, if the {@link Capability} does not have this property.
*/
public int getPushButtons() {
return getConfig().getPushButtons();
}
/**
* Returns true, if the {@link Capability} is of type VariableActuator.
*
* @return
*/
public boolean isTypeVariableActuator() {
return TYPE_VARIABLEACTUATOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type SwitchActuator.
*
* @return
*/
public boolean isTypeSwitchActuator() {
return TYPE_SWITCHACTUATOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type ThermostatActuator.
*
* @return
*/
public boolean isTypeThermostatActuator() {
return TYPE_THERMOSTATACTUATOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type TemperatureSensor.
*
* @return
*/
public boolean isTypeTemperatureSensor() {
return TYPE_TEMPERATURESENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type HumiditySensor.
*
* @return
*/
public boolean isTypeHumiditySensor() {
return TYPE_HUMIDITYSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type WindowDoorSensor.
*
* @return
*/
public boolean isTypeWindowDoorSensor() {
return TYPE_WINDOWDOORSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type SmokeDetectorSensor.
*
* @return
*/
public boolean isTypeSmokeDetectorSensor() {
return TYPE_SMOKEDETECTORSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type AlarmActuator.
*
* @return
*/
public boolean isTypeAlarmActuator() {
return TYPE_ALARMACTUATOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type MotionDetectionSensor.
*
* @return
*/
public boolean isTypeMotionDetectionSensor() {
return TYPE_MOTIONDETECTIONSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type LuminanceSensor.
*
* @return
*/
public boolean isTypeLuminanceSensor() {
return TYPE_LUMINANCESENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type PushButtonSensor.
*
* @return
*/
public boolean isTypePushButtonSensor() {
return TYPE_PUSHBUTTONSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type DimmerActuator.
*
* @return
*/
public boolean isTypeDimmerActuator() {
return TYPE_DIMMERACTUATOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type RollerShutterActuator.
*
* @return
*/
public boolean isTypeRollerShutterActuator() {
return TYPE_ROLLERSHUTTERACTUATOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type EnergyConsumptionSensor.
*
* @return
*/
public boolean isTypeEnergyConsumptionSensor() {
return TYPE_ENERGYCONSUMPTIONSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type PowerConsumptionSensor.
*
* @return
*/
public boolean isTypePowerConsumptionSensor() {
return TYPE_POWERCONSUMPTIONSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type GenerationMeterEnergySensor.
*
* @return
*/
public boolean isTypeGenerationMeterEnergySensor() {
return TYPE_GENERATIONMETERENERGYSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type GenerationMeterPowerConsumptionSensor.
*
* @return
*/
public boolean isTypeGenerationMeterPowerConsumptionSensor() {
return TYPE_GENERATIONMETERPOWERCONSUMPTIONSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type TwoWayMeterEnergyConsumptionSensor.
*
* @return
*/
public boolean isTypeTwoWayMeterEnergyConsumptionSensor() {
return TYPE_TWOWAYMETERENERGYCONSUMPTIONSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type TwoWayMeterEnergyFeedSensor.
*
* @return
*/
public boolean isTypeTwoWayMeterEnergyFeedSensor() {
return TYPE_TWOWAYMETERENERGYFEEDSENSOR.equals(getType());
}
/**
* Returns true, if the {@link Capability} is of type TwoWayMeterPowerConsumptionSensor.
*
* @return
*/
public boolean isTypeTwoWayMeterPowerConsumptionSensor() {
return TYPE_TWOWAYMETERPOWERCONSUMPTIONSENSOR.equals(getType());
}
}

View File

@ -1,639 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.capability;
/**
* Holds the Capability configuration.
*
* @author Oliver Kuhl - Initial contribution
*
*/
public class CapabilityConfig {
/**
* Name of the capability
*/
private String name;
/**
* Specifies if the activity logging is enabled
*/
private Boolean activityLogActive;
/**
* Specifies if the activity logging is enabled
*/
private Integer pushButtons;
/**
* The valve index
*/
private Integer valveIndex;
/**
* The valve type
*/
private String valveType;
/**
* The valve control mode: Heating or Cooling
*/
private String controlMode;
/**
* Dimmer: Programmed on the device as maximum/minimum and not used for UI representation
*/
private Integer technicalMaxValue;
/**
* Dimmer: Programmed on the device as maximum/minimum and not used for UI representation
*/
private Integer technicalMinValue;
/**
* Rollershutter: How long it takes for the shutter to open completely when it's completely closed (in tenth of
* second)
*/
private Integer timeFullUp;
/**
* Rollershutter: How long it takes for the shutter to close completely when it's completely open (in tenth of
* second)
*/
private Integer timeFullDown;
/**
* Rollershutter: Flag indicating the ISR is in the calibration mode or not.
*/
private Boolean isCalibrating;
/**
* Switchactuator:
* "different types of current sensing behavior the ISS can have:
* Enabled - Factory default value, current sensing is enabled; (default)
* DisabledNormal - Current sensing disabled, uses output 1;
* DisabledReversed - Current sensing disabled, uses output 2"
*/
private String sensingBehavior;
/**
* Thermostatactuator: The max temperature
*/
private Double maxTemperature;
/**
* Thermostatactuator: The min temperature
*/
private Double minTemperature;
/**
* Thermostatactuator: Indicating whether the device is locked
*/
private Boolean childLock;
/**
* Thermostatactuator: The window open temperature
*/
private Double windowOpenTemperature;
/**
* Thermostatactuator: default PointTemperature
*/
private String vRCCSetPoint;
/**
* Temperaturesensor: Indicating whether the device has freeze protection activated
*/
private Boolean isFreezeProtectionActivated;
/**
* Temperaturesensor: The freeze protection temperature, default 6 °C
*/
private Double freezeProtection;
/**
* Temperaturesensor: default Temperature
*/
private String vRCCTemperature;
/**
* HumiditySensor: Indicating whether the device has mold protection activated
*/
private Boolean isMoldProtectionActivated;
/**
* HumiditySensor: The humidity mold protection
*/
private Double humidityMoldProtection;
/**
* HumiditySensor: default Humidity
*/
private String vRCCHumidity;
/**
* SirenActuator: Alarm Sound Id
*/
private String alarmSoundId;
/**
* SirenActuator: Notification Sound Id
*/
private String notificationSoundId;
/**
* SirenActuator: Feedback Sound Id
*/
private String feedbackSoundId;
/**
* RoomSetPoint/RoomTemperature/RoomHumidity: List of capability ids, which are linked to the VRCC
*/
private String underlyingCapabilityIds;
/**
* WindowsDoorSensor: Time before the changed status is sent after the window/door is opened (in seconds)
*/
private Integer eventFilterTime;
/**
* Medion ThermostatActuator: Specifies the temperature threshold that will denote a window open event. 0 = window
* reduction disabled 1-12 = 1/12 °C, 2/12 °C,, 12/12 °C
*/
private Integer windowOpenThreshold;
/**
* Medion ThermostatActuator: Duration in minutes for how long after the threshold was overstepped the valve will be
* closed (target temperature = OFF). After the set time, the temperature will jump back to the previous set target
* temperature.
*/
private Integer windowOpenTimer;
/**
* Medion MotionDetectionSensor sensitivityControl
*/
private Integer sensitivityControl;
/**
* Medion WindowDoorShockSensor: shockDetectorThreshold
*/
private Integer shockDetectorThreshold;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(final String name) {
this.name = name;
}
/**
* @return the activityLogActive
*/
public Boolean getActivityLogActive() {
return activityLogActive;
}
/**
* @param activityLogActive the activityLogActive to set
*/
public void setActivityLogActive(final Boolean activityLogActive) {
this.activityLogActive = activityLogActive;
}
/**
* @return the pushButtons
*/
public Integer getPushButtons() {
return pushButtons;
}
/**
* @param pushButtons the pushButtons to set
*/
public void setPushButtons(final Integer pushButtons) {
this.pushButtons = pushButtons;
}
/**
* @return the valveIndex
*/
public Integer getValveIndex() {
return valveIndex;
}
/**
* @param valveIndex the valveIndex to set
*/
public void setValveIndex(final Integer valveIndex) {
this.valveIndex = valveIndex;
}
/**
* @return the valveType
*/
public String getValveType() {
return valveType;
}
/**
* @param valveType the valveType to set
*/
public void setValveType(final String valveType) {
this.valveType = valveType;
}
/**
* @return the controlMode
*/
public String getControlMode() {
return controlMode;
}
/**
* @param controlMode the controlMode to set
*/
public void setControlMode(final String controlMode) {
this.controlMode = controlMode;
}
/**
* @return the technicalMaxValue
*/
public Integer getTechnicalMaxValue() {
return technicalMaxValue;
}
/**
* @param technicalMaxValue the technicalMaxValue to set
*/
public void setTechnicalMaxValue(final Integer technicalMaxValue) {
this.technicalMaxValue = technicalMaxValue;
}
/**
* @return the technicalMinValue
*/
public Integer getTechnicalMinValue() {
return technicalMinValue;
}
/**
* @param technicalMinValue the technicalMinValue to set
*/
public void setTechnicalMinValue(final Integer technicalMinValue) {
this.technicalMinValue = technicalMinValue;
}
/**
* @return the timeFullUp
*/
public Integer getTimeFullUp() {
return timeFullUp;
}
/**
* @param timeFullUp the timeFullUp to set
*/
public void setTimeFullUp(final Integer timeFullUp) {
this.timeFullUp = timeFullUp;
}
/**
* @return the timeFullDown
*/
public Integer getTimeFullDown() {
return timeFullDown;
}
/**
* @param timeFullDown the timeFullDown to set
*/
public void setTimeFullDown(final Integer timeFullDown) {
this.timeFullDown = timeFullDown;
}
/**
* @return the isCalibrating
*/
public Boolean getIsCalibrating() {
return isCalibrating;
}
/**
* @param isCalibrating the isCalibrating to set
*/
public void setIsCalibrating(final Boolean isCalibrating) {
this.isCalibrating = isCalibrating;
}
/**
* @return the sensingBehavior
*/
public String getSensingBehavior() {
return sensingBehavior;
}
/**
* @param sensingBehavior the sensingBehavior to set
*/
public void setSensingBehavior(final String sensingBehavior) {
this.sensingBehavior = sensingBehavior;
}
/**
* @return the maxTemperature
*/
public Double getMaxTemperature() {
return maxTemperature;
}
/**
* @param maxTemperature the maxTemperature to set
*/
public void setMaxTemperature(final Double maxTemperature) {
this.maxTemperature = maxTemperature;
}
/**
* @return the minTemperature
*/
public Double getMinTemperature() {
return minTemperature;
}
/**
* @param minTemperature the minTemperature to set
*/
public void setMinTemperature(final Double minTemperature) {
this.minTemperature = minTemperature;
}
/**
* @return the childLock
*/
public Boolean getChildLock() {
return childLock;
}
/**
* @param childLock the childLock to set
*/
public void setChildLock(final Boolean childLock) {
this.childLock = childLock;
}
/**
* @return the windowOpenTemperature
*/
public Double getWindowOpenTemperature() {
return windowOpenTemperature;
}
/**
* @param windowOpenTemperature the windowOpenTemperature to set
*/
public void setWindowOpenTemperature(final Double windowOpenTemperature) {
this.windowOpenTemperature = windowOpenTemperature;
}
/**
* @return the vRCCSetPoint
*/
public String getvRCCSetPoint() {
return vRCCSetPoint;
}
/**
* @param vRCCSetPoint the vRCCSetPoint to set
*/
public void setvRCCSetPoint(final String vRCCSetPoint) {
this.vRCCSetPoint = vRCCSetPoint;
}
/**
* @return the isFreezeProtectionActivated
*/
public Boolean getIsFreezeProtectionActivated() {
return isFreezeProtectionActivated;
}
/**
* @param isFreezeProtectionActivated the isFreezeProtectionActivated to set
*/
public void setIsFreezeProtectionActivated(final Boolean isFreezeProtectionActivated) {
this.isFreezeProtectionActivated = isFreezeProtectionActivated;
}
/**
* @return the freezeProtection
*/
public Double getFreezeProtection() {
return freezeProtection;
}
/**
* @param freezeProtection the freezeProtection to set
*/
public void setFreezeProtection(final Double freezeProtection) {
this.freezeProtection = freezeProtection;
}
/**
* @return the vRCCTemperature
*/
public String getvRCCTemperature() {
return vRCCTemperature;
}
/**
* @param vRCCTemperature the vRCCTemperature to set
*/
public void setvRCCTemperature(final String vRCCTemperature) {
this.vRCCTemperature = vRCCTemperature;
}
/**
* @return the isMoldProtectionActivated
*/
public Boolean getIsMoldProtectionActivated() {
return isMoldProtectionActivated;
}
/**
* @param isMoldProtectionActivated the isMoldProtectionActivated to set
*/
public void setIsMoldProtectionActivated(final Boolean isMoldProtectionActivated) {
this.isMoldProtectionActivated = isMoldProtectionActivated;
}
/**
* @return the humidityMoldProtection
*/
public Double getHumidityMoldProtection() {
return humidityMoldProtection;
}
/**
* @param humidityMoldProtection the humidityMoldProtection to set
*/
public void setHumidityMoldProtection(final Double humidityMoldProtection) {
this.humidityMoldProtection = humidityMoldProtection;
}
/**
* @return the vRCCHumidity
*/
public String getvRCCHumidity() {
return vRCCHumidity;
}
/**
* @param vRCCHumidity the vRCCHumidity to set
*/
public void setvRCCHumidity(final String vRCCHumidity) {
this.vRCCHumidity = vRCCHumidity;
}
/**
* @return the alarmSoundId
*/
public String getAlarmSoundId() {
return alarmSoundId;
}
/**
* @param alarmSoundId the alarmSoundId to set
*/
public void setAlarmSoundId(final String alarmSoundId) {
this.alarmSoundId = alarmSoundId;
}
/**
* @return the notificationSoundId
*/
public String getNotificationSoundId() {
return notificationSoundId;
}
/**
* @param notificationSoundId the notificationSoundId to set
*/
public void setNotificationSoundId(final String notificationSoundId) {
this.notificationSoundId = notificationSoundId;
}
/**
* @return the feedbackSoundId
*/
public String getFeedbackSoundId() {
return feedbackSoundId;
}
/**
* @param feedbackSoundId the feedbackSoundId to set
*/
public void setFeedbackSoundId(final String feedbackSoundId) {
this.feedbackSoundId = feedbackSoundId;
}
/**
* @return the underlyingCapabilityIds
*/
public String getUnderlyingCapabilityIds() {
return underlyingCapabilityIds;
}
/**
* @param underlyingCapabilityIds the underlyingCapabilityIds to set
*/
public void setUnderlyingCapabilityIds(final String underlyingCapabilityIds) {
this.underlyingCapabilityIds = underlyingCapabilityIds;
}
/**
* @return the eventFilterTime
*/
public Integer getEventFilterTime() {
return eventFilterTime;
}
/**
* @param eventFilterTime the eventFilterTime to set
*/
public void setEventFilterTime(final Integer eventFilterTime) {
this.eventFilterTime = eventFilterTime;
}
/**
* @return the windowOpenThreshold
*/
public Integer getWindowOpenThreshold() {
return windowOpenThreshold;
}
/**
* @param windowOpenThreshold the windowOpenThreshold to set
*/
public void setWindowOpenThreshold(final Integer windowOpenThreshold) {
this.windowOpenThreshold = windowOpenThreshold;
}
/**
* @return the windowOpenTimer
*/
public Integer getWindowOpenTimer() {
return windowOpenTimer;
}
/**
* @param windowOpenTimer the windowOpenTimer to set
*/
public void setWindowOpenTimer(final Integer windowOpenTimer) {
this.windowOpenTimer = windowOpenTimer;
}
/**
* @return the sensitivityControl
*/
public Integer getSensitivityControl() {
return sensitivityControl;
}
/**
* @param sensitivityControl the sensitivityControl to set
*/
public void setSensitivityControl(final Integer sensitivityControl) {
this.sensitivityControl = sensitivityControl;
}
/**
* @return the shockDetectorThreshold
*/
public Integer getShockDetectorThreshold() {
return shockDetectorThreshold;
}
/**
* @param shockDetectorThreshold the shockDetectorThreshold to set
*/
public void setShockDetectorThreshold(final Integer shockDetectorThreshold) {
this.shockDetectorThreshold = shockDetectorThreshold;
}
}

View File

@ -1,407 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.capability;
/**
* Defines the {@link CapabilityState}, that holds the state of a {@link Capability}, e.g. a temperature.
*
* @author Oliver Kuhl - Initial contribution
*/
public class CapabilityState {
public static final String STATE_VALUE_OPERATION_MODE_AUTO = "Auto";
public static final String STATE_VALUE_OPERATION_MODE_MANUAL = "Manu";
/**
* id of the {@link Capability}
*/
private String id;
/**
* class containing all states
*/
private State state;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(final String id) {
this.id = id;
}
/**
* @return the state
*/
public State getState() {
return state;
}
/**
* @param state the state to set
*/
public void setState(final State state) {
this.state = state;
}
public Boolean getVariableActuatorState() {
return getState().getValueState().getValue();
}
public void setVariableActuatorState(final Boolean on) {
getState().getValueState().setValue(on);
}
public Boolean getSwitchActuatorState() {
return getState().getOnState().getValue();
}
public void setSwitchActuatorState(final Boolean on) {
getState().getOnState().setValue(on);
}
public Double getTemperatureSensorTemperatureState() {
return getState().getTemperatureState().getValue();
}
public void setTemperatureSensorTemperatureState(final Double temperature) {
getState().getTemperatureState().setValue(temperature);
}
public Boolean getTemperatureSensorFrostWarningState() {
return getState().getFrostWarningState().getValue();
}
public void setTemperatureSensorFrostWarningState(final Boolean frostWarning) {
getState().getFrostWarningState().setValue(frostWarning);
}
public Double getThermostatActuatorPointTemperatureState() {
return getState().getPointTemperatureState().getValue();
}
public void setThermostatActuatorPointTemperatureState(final Double pointTemperature) {
getState().getPointTemperatureState().setValue(pointTemperature);
}
public String getThermostatActuatorOperationModeState() {
return getState().getOperationModeState().getValue();
}
public void setThermostatActuatorOperationModeState(final String operationMode) {
getState().getOperationModeState()
.setValue(STATE_VALUE_OPERATION_MODE_MANUAL.equals(operationMode) ? STATE_VALUE_OPERATION_MODE_MANUAL
: STATE_VALUE_OPERATION_MODE_AUTO);
}
public Boolean getThermostatActuatorWindowReductionActiveState() {
return getState().getWindowReductionActiveState().getValue();
}
public void setThermostatActuatorWindowReductionActiveState(final Boolean windowReductionActive) {
getState().getWindowReductionActiveState().setValue(windowReductionActive);
}
public Double getHumiditySensorHumidityState() {
return getState().getHumidityState().getValue();
}
public void setHumiditySensorHumidityState(final Double humidity) {
getState().getHumidityState().setValue(humidity);
}
public Boolean getHumiditySensorMoldWarningState() {
return getState().getMoldWarningState().getValue();
}
public void setHumiditySensorMoldWarningState(final Boolean moldWarning) {
getState().getMoldWarningState().setValue(moldWarning);
}
public Boolean getWindowDoorSensorState() {
return getState().getIsOpenState().getValue();
}
public void setWindowDoorSensorState(final Boolean open) {
getState().getIsOpenState().setValue(open);
}
public Boolean getSmokeDetectorSensorState() {
return getState().getIsSmokeAlarmState().getValue();
}
public void setSmokeDetectorSensorState(final Boolean on) {
getState().getIsSmokeAlarmState().setValue(on);
}
public Boolean getAlarmActuatorState() {
return getState().getOnState().getValue();
}
public void setAlarmActuatorState(final Boolean on) {
getState().getOnState().setValue(on);
}
public Integer getMotionDetectionSensorState() {
return getState().getMotionDetectedCountState().getValue();
}
public void setMotionDetectionSensorState(final Integer numberOfMotions) {
getState().getMotionDetectedCountState().setValue(numberOfMotions);
}
public Double getLuminanceSensorState() {
return getState().getLuminanceState().getValue();
}
public void setLuminanceSensorState(final Double luminance) {
getState().getLuminanceState().setValue(luminance);
}
public Integer getPushButtonSensorCounterState() {
return getState().getLastKeyPressCounterState().getValue();
}
public void setPushButtonSensorCounterState(final Integer numberOfPresses) {
getState().getLastKeyPressCounterState().setValue(numberOfPresses);
}
public Integer getPushButtonSensorButtonIndexState() {
return getState().getLastPressedButtonIndex().getValue();
}
public void setPushButtonSensorButtonIndexState(final Integer buttonIndex) {
getState().getLastPressedButtonIndex().setValue(buttonIndex);
}
public String getPushButtonSensorButtonIndexType() {
return getState().getLastKeyPressType().getValue();
}
public void setPushButtonSensorButtonIndexType(String lastKeyPressType) {
getState().getLastKeyPressType().setValue(lastKeyPressType);
}
public Integer getDimmerActuatorState() {
return getState().getDimLevelState().getValue();
}
public void setDimmerActuatorState(final Integer DimLevel) {
getState().getDimLevelState().setValue(DimLevel);
}
public Integer getRollerShutterActuatorState() {
return getState().getShutterLevelState().getValue();
}
public void setRollerShutterActuatorState(final Integer rollerShutterLevel) {
getState().getShutterLevelState().setValue(rollerShutterLevel);
}
// ENERGY CONSUMPTION SENSOR
public Double getEnergyConsumptionSensorEnergyConsumptionMonthKWhState() {
return getState().getEnergyConsumptionMonthKWhState().getValue();
}
public void setEnergyConsumptionSensorEnergyConsumptionMonthKWhState(final Double state) {
getState().getEnergyConsumptionMonthKWhState().setValue(state);
}
public Double getEnergyConsumptionSensorAbsoluteEnergyConsumptionState() {
return getState().getAbsoluteEnergyConsumptionState().getValue();
}
public void setEnergyConsumptionSensorAbsoluteEnergyConsumptionState(final Double state) {
getState().getAbsoluteEnergyConsumptionState().setValue(state);
}
public Double getEnergyConsumptionSensorEnergyConsumptionMonthEuroState() {
return getState().getEnergyConsumptionMonthEuroState().getValue();
}
public void setEnergyConsumptionSensorEnergyConsumptionMonthEuroState(final Double state) {
getState().getEnergyConsumptionMonthEuroState().setValue(state);
}
public Double getEnergyConsumptionSensorEnergyConsumptionDayEuroState() {
return getState().getEnergyConsumptionDayEuroState().getValue();
}
public void setEnergyConsumptionSensorEnergyConsumptionDayEuroState(final Double state) {
getState().getEnergyConsumptionDayEuroState().setValue(state);
}
public Double getEnergyConsumptionSensorEnergyConsumptionDayKWhState() {
return getState().getEnergyConsumptionDayKWhState().getValue();
}
public void setEnergyConsumptionSensorEnergyConsumptionDayKWhState(final Double state) {
getState().getEnergyConsumptionDayKWhState().setValue(state);
}
// POWER CONSUMPTION SENSOR
public Double getPowerConsumptionSensorPowerConsumptionWattState() {
return getState().getPowerConsumptionWattState().getValue();
}
public void setPowerConsumptionSensorPowerConsumptionWattState(final Double state) {
getState().getPowerConsumptionWattState().setValue(state);
}
// GENERATION METER ENGERY SENSOR
public Double getGenerationMeterEnergySensorEnergyPerMonthInKWhState() {
return getState().getEnergyPerMonthInKWhState().getValue();
}
public void setGenerationMeterEnergySensorEnergyPerMonthInKWhState(final Double state) {
getState().getEnergyPerMonthInKWhState().setValue(state);
}
public Double getGenerationMeterEnergySensorTotalEnergyState() {
return getState().getTotalEnergyState().getValue();
}
public void setGenerationMeterEnergySensorTotalEnergyState(final Double state) {
getState().getTotalEnergyState().setValue(state);
}
public Double getGenerationMeterEnergySensorEnergyPerMonthInEuroState() {
return getState().getEnergyPerMonthInEuroState().getValue();
}
public void setGenerationMeterEnergySensorEnergyPerMonthInEuroState(final Double state) {
getState().getEnergyPerMonthInEuroState().setValue(state);
}
public Double getGenerationMeterEnergySensorEnergyPerDayInEuroState() {
return getState().getEnergyPerDayInEuroState().getValue();
}
public void setGenerationMeterEnergySensorEnergyPerDayInEuroState(final Double state) {
getState().getEnergyPerDayInEuroState().setValue(state);
}
public Double getGenerationMeterEnergySensorEnergyPerDayInKWhState() {
return getState().getEnergyPerDayInKWhState().getValue();
}
public void setGenerationMeterEnergySensorEnergyPerDayInKWhState(final Double state) {
getState().getEnergyPerDayInKWhState().setValue(state);
}
// GENERATION METER POWER CONSUMPTION SENSOR
public Double getGenerationMeterPowerConsumptionSensorPowerInWattState() {
return getState().getPowerInWattState().getValue();
}
public void setGenerationMeterPowerConsumptionSensorPowerInWattState(final Double state) {
getState().getPowerInWattState().setValue(state);
}
// TWO WAY METER ENERGY CONSUMPTION SENSOR
public Double getTwoWayMeterEnergyConsumptionSensorEnergyPerMonthInKWhState() {
return getState().getEnergyPerMonthInKWhState().getValue();
}
public void setTwoWayMeterEnergyConsumptionSensorEnergyPerMonthInKWhState(final Double state) {
getState().getEnergyPerMonthInKWhState().setValue(state);
}
public Double getTwoWayMeterEnergyConsumptionSensorTotalEnergyState() {
return getState().getTotalEnergyState().getValue();
}
public void setTwoWayMeterEnergyConsumptionSensorTotalEnergyState(final Double state) {
getState().getTotalEnergyState().setValue(state);
}
public Double getTwoWayMeterEnergyConsumptionSensorEnergyPerMonthInEuroState() {
return getState().getEnergyPerMonthInEuroState().getValue();
}
public void setTwoWayMeterEnergyConsumptionSensorEnergyPerMonthInEuroState(final Double state) {
getState().getEnergyPerMonthInEuroState().setValue(state);
}
public Double getTwoWayMeterEnergyConsumptionSensorEnergyPerDayInEuroState() {
return getState().getEnergyPerDayInEuroState().getValue();
}
public void setTwoWayMeterEnergyConsumptionSensorEnergyPerDayInEuroState(final Double state) {
getState().getEnergyPerDayInEuroState().setValue(state);
}
public Double getTwoWayMeterEnergyConsumptionSensorEnergyPerDayInKWhState() {
return getState().getEnergyPerDayInKWhState().getValue();
}
public void setTwoWayMeterEnergyConsumptionSensorEnergyPerDayInKWhState(final Double state) {
getState().getEnergyPerDayInKWhState().setValue(state);
}
// TWO WAY METER ENERGY FEED SENSOR
public Double getTwoWayMeterEnergyFeedSensorEnergyPerMonthInKWhState() {
return getState().getEnergyPerMonthInKWhState().getValue();
}
public void setTwoWayMeterEnergyFeedSensorEnergyPerMonthInKWhState(final Double state) {
getState().getEnergyPerMonthInKWhState().setValue(state);
}
public Double getTwoWayMeterEnergyFeedSensorTotalEnergyState() {
return getState().getTotalEnergyState().getValue();
}
public void setTwoWayMeterEnergyFeedSensorTotalEnergyState(final Double state) {
getState().getTotalEnergyState().setValue(state);
}
public Double getTwoWayMeterEnergyFeedSensorEnergyPerMonthInEuroState() {
return getState().getEnergyPerMonthInEuroState().getValue();
}
public void setTwoWayMeterEnergyFeedSensorEnergyPerMonthInEuroState(final Double state) {
getState().getEnergyPerMonthInEuroState().setValue(state);
}
public Double getTwoWayMeterEnergyFeedSensorEnergyPerDayInEuroState() {
return getState().getEnergyPerDayInEuroState().getValue();
}
public void setTwoWayMeterEnergyFeedSensorEnergyPerDayInEuroState(final Double state) {
getState().getEnergyPerDayInEuroState().setValue(state);
}
public Double getTwoWayMeterEnergyFeedSensorEnergyPerDayInKWhState() {
return getState().getEnergyPerDayInKWhState().getValue();
}
public void setTwoWayMeterEnergyFeedSensorEnergyPerDayInKWhState(final Double state) {
getState().getEnergyPerDayInKWhState().setValue(state);
}
// TWO WAY METER POWER CONSUMPTION SENSOR
public Double getTwoWayMeterPowerConsumptionSensorPowerInWattState() {
return getState().getPowerInWattState().getValue();
}
public void setTwoWayMeterPowerConsumptionSensorPowerInWattState(final Double state) {
getState().getPowerInWattState().setValue(state);
}
}

View File

@ -1,757 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.BooleanState;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.DateTimeState;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.DoubleState;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.IntegerState;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.StringState;
import com.google.gson.annotations.SerializedName;
/**
* Holds the Capability state.
*
* @author Oliver Kuhl - Initial contribution
*
*/
public class State {
@SerializedName("absoluteEnergyConsumption")
private DoubleState absoluteEnergyConsumptionState;
@SerializedName("activeChannel")
private StringState activeChannelState;
@SerializedName("dimLevel")
private IntegerState dimLevelState;
@SerializedName("energyConsumptionDayEuro")
private DoubleState energyConsumptionDayEuroState;
@SerializedName("energyConsumptionDayKWh")
private DoubleState energyConsumptionDayKWhState;
@SerializedName("energyConsumptionMonthEuro")
private DoubleState energyConsumptionMonthEuroState;
@SerializedName("energyConsumptionMonthKWh")
private DoubleState energyConsumptionMonthKWhState;
@SerializedName("energyPerDayInEuro")
private DoubleState energyPerDayInEuroState;
@SerializedName("energyPerDayInKWh")
private DoubleState energyPerDayInKWhState;
@SerializedName("energyPerMonthInEuro")
private DoubleState energyPerMonthInEuroState;
@SerializedName("energyPerMonthInKWh")
private DoubleState energyPerMonthInKWhState;
@SerializedName("frostWarning")
private BooleanState frostWarningState;
@SerializedName("humidity")
private DoubleState humidityState;
@SerializedName("isDay")
private BooleanState isDayState;
@SerializedName("isOn")
private BooleanState isOnState;
@SerializedName("isOpen")
private BooleanState isOpenState;
@SerializedName("isSmokeAlarm")
private BooleanState isSmokeAlarmState;
@SerializedName("lastKeyPressCounter")
private IntegerState lastKeyPressCounterState;
@SerializedName("lastPressedButtonIndex")
private IntegerState lastPressedButtonIndex;
private StringState lastPressedButtonIndexState;
@SerializedName("luminance")
private DoubleState luminanceState;
@SerializedName("moldWarning")
private BooleanState moldWarningState;
@SerializedName("motionDetectedCount")
private IntegerState motionDetectedCountState;
@SerializedName("nextSunrise")
private DateTimeState nextSunrise;
@SerializedName("nextSunset")
private DateTimeState nextSunsetState;
@SerializedName("nextTimeEvent")
private DateTimeState nextTimeEventState;
@SerializedName("onState")
private BooleanState onState;
@SerializedName("operationMode")
private StringState operationModeState;
@SerializedName("pointTemperature")
private DoubleState pointTemperatureState;
@SerializedName("powerConsumptionWatt")
private DoubleState powerConsumptionWattState;
@SerializedName("powerInWatt")
private DoubleState powerInWattState;
@SerializedName("shutterLevel")
private IntegerState shutterLevelState;
@SerializedName("supplyValueInCubicMetterPerDay")
private DoubleState supplyValueInCubicMetterPerDayState;
@SerializedName("supplyValueInCubicMetterPerMonth")
private DoubleState supplyValueInCubicMetterPerMonthState;
@SerializedName("supplyValueInCurrencyPerDay")
private DoubleState supplyValueInCurrencyPerDayState;
@SerializedName("supplyValueInCurrencyPerMonth")
private DoubleState supplyValueInCurrencyPerMonthState;
@SerializedName("supplyValueInLitrePerDay")
private DoubleState supplyValueInLitrePerDayState;
@SerializedName("supplyValueInLitrePerMonth")
private DoubleState supplyValueInLitrePerMonthState;
@SerializedName("temperature")
private DoubleState temperatureState;
@SerializedName("totalEnergy")
private DoubleState totalEnergyState;
@SerializedName("value")
private BooleanState valueState;
@SerializedName("valvePosition")
private BooleanState valvePositionState;
@SerializedName("windowReductionActive")
private BooleanState windowReductionActiveState;
/**
* @return the absoluteEnergyConsumptionState
*/
public DoubleState getAbsoluteEnergyConsumptionState() {
return absoluteEnergyConsumptionState;
}
/**
* @param state the absoluteEnergyConsumptionState to set
*/
public void setAbsoluteEnergyConsumptionState(DoubleState state) {
this.absoluteEnergyConsumptionState = state;
}
/**
* @return the activeChannelState
*/
public StringState getActiveChannelState() {
return activeChannelState;
}
/**
* @param state the activeChannelState to set
*/
public void setActiveChannelState(StringState state) {
this.activeChannelState = state;
}
/**
* @return the dimLevelState
*/
public IntegerState getDimLevelState() {
return dimLevelState;
}
/**
* @param state the dimLevelState to set
*/
public void setDimLevelState(IntegerState state) {
this.dimLevelState = state;
}
/**
* @return the energyConsumptionDayEuroState
*/
public DoubleState getEnergyConsumptionDayEuroState() {
return energyConsumptionDayEuroState;
}
/**
* @param state the energyConsumptionDayEuroState to set
*/
public void setEnergyConsumptionDayEuroState(DoubleState state) {
this.energyConsumptionDayEuroState = state;
}
/**
* @return the energyConsumptionDayKWhState
*/
public DoubleState getEnergyConsumptionDayKWhState() {
return energyConsumptionDayKWhState;
}
/**
* @param state the energyConsumptionDayKWhState to set
*/
public void setEnergyConsumptionDayKWhState(DoubleState state) {
this.energyConsumptionDayKWhState = state;
}
/**
* @return the energyConsumptionMonthEuroState
*/
public DoubleState getEnergyConsumptionMonthEuroState() {
return energyConsumptionMonthEuroState;
}
/**
* @param state the energyConsumptionMonthEuroState to set
*/
public void setEnergyConsumptionMonthEuroState(DoubleState state) {
this.energyConsumptionMonthEuroState = state;
}
/**
* @return the energyConsumptionMonthKWhState
*/
public DoubleState getEnergyConsumptionMonthKWhState() {
return energyConsumptionMonthKWhState;
}
/**
* @param state the energyConsumptionMonthKWhState to set
*/
public void setEnergyConsumptionMonthKWhState(DoubleState state) {
this.energyConsumptionMonthKWhState = state;
}
/**
* @return the energyPerDayInEuroState
*/
public DoubleState getEnergyPerDayInEuroState() {
return energyPerDayInEuroState;
}
/**
* @param state the energyPerDayInEuroState to set
*/
public void setEnergyPerDayInEuroState(DoubleState state) {
this.energyPerDayInEuroState = state;
}
/**
* @return the energyPerDayInKWhState
*/
public DoubleState getEnergyPerDayInKWhState() {
return energyPerDayInKWhState;
}
/**
* @param state the energyPerDayInKWhState to set
*/
public void setEnergyPerDayInKWhState(DoubleState state) {
this.energyPerDayInKWhState = state;
}
/**
* @return the energyPerMonthInEuroState
*/
public DoubleState getEnergyPerMonthInEuroState() {
return energyPerMonthInEuroState;
}
/**
* @param state the energyPerMonthInEuroState to set
*/
public void setEnergyPerMonthInEuroState(DoubleState state) {
this.energyPerMonthInEuroState = state;
}
/**
* @return the energyPerMonthInKWhState
*/
public DoubleState getEnergyPerMonthInKWhState() {
return energyPerMonthInKWhState;
}
/**
* @param state the energyPerMonthInKWhState to set
*/
public void setEnergyPerMonthInKWhState(DoubleState state) {
this.energyPerMonthInKWhState = state;
}
/**
* @return the frostWarningState
*/
public BooleanState getFrostWarningState() {
return frostWarningState;
}
/**
* @param state the frostWarningState to set
*/
public void setFrostWarningState(BooleanState state) {
this.frostWarningState = state;
}
/**
* @return the humidityState
*/
public DoubleState getHumidityState() {
return humidityState;
}
/**
* @param state the humidityState to set
*/
public void setHumidityState(DoubleState state) {
this.humidityState = state;
}
/**
* @return the isDayState
*/
public BooleanState getIsDayState() {
return isDayState;
}
/**
* @param state the isDayState to set
*/
public void setIsDayState(BooleanState state) {
this.isDayState = state;
}
/**
* @return the isOnState
*/
public BooleanState getIsOnState() {
return isOnState;
}
/**
* @param state the isOnState to set
*/
public void setIsOnState(BooleanState state) {
this.isOnState = state;
}
/**
* @return the isOpenState
*/
public BooleanState getIsOpenState() {
return isOpenState;
}
/**
* @param state the isOpenState to set
*/
public void setIsOpenState(BooleanState state) {
this.isOpenState = state;
}
/**
* @return the isSmokeAlarmState
*/
public BooleanState getIsSmokeAlarmState() {
return isSmokeAlarmState;
}
/**
* @param state the isSmokeAlarmState to set
*/
public void setIsSmokeAlarmState(BooleanState state) {
this.isSmokeAlarmState = state;
}
/**
* @return the lastKeyPressCounterState
*/
public IntegerState getLastKeyPressCounterState() {
return lastKeyPressCounterState;
}
/**
* @param state the lastKeyPressCounterState to set
*/
public void setLastKeyPressCounterState(IntegerState state) {
this.lastKeyPressCounterState = state;
}
/**
* @return the lastPressedButtonIndex
*/
public IntegerState getLastPressedButtonIndex() {
return lastPressedButtonIndex;
}
/**
* @param state the lastPressedButtonIndex to set
*/
public void setLastPressedButtonIndex(IntegerState state) {
this.lastPressedButtonIndex = state;
}
public StringState getLastKeyPressType() {
if (lastPressedButtonIndexState == null) {
lastPressedButtonIndexState = new StringState();
}
return lastPressedButtonIndexState;
}
public void setLastKeyPressType(StringState lastPressedButtonIndexState) {
this.lastPressedButtonIndexState = lastPressedButtonIndexState;
}
/**
* @return the luminanceState
*/
public DoubleState getLuminanceState() {
return luminanceState;
}
/**
* @param state the luminanceState to set
*/
public void setLuminanceState(DoubleState state) {
this.luminanceState = state;
}
/**
* @return the moldWarningState
*/
public BooleanState getMoldWarningState() {
return moldWarningState;
}
/**
* @param state the moldWarningState to set
*/
public void setMoldWarningState(BooleanState state) {
this.moldWarningState = state;
}
/**
* @return the motionDetectedCountState
*/
public IntegerState getMotionDetectedCountState() {
return motionDetectedCountState;
}
/**
* @param state the motionDetectedCountState to set
*/
public void setMotionDetectedCountState(IntegerState state) {
this.motionDetectedCountState = state;
}
/**
* @return the nextSunrise
*/
public DateTimeState getNextSunrise() {
return nextSunrise;
}
/**
* @param state the nextSunrise to set
*/
public void setNextSunrise(DateTimeState state) {
this.nextSunrise = state;
}
/**
* @return the nextSunsetState
*/
public DateTimeState getNextSunsetState() {
return nextSunsetState;
}
/**
* @param state the nextSunsetState to set
*/
public void setNextSunsetState(DateTimeState state) {
this.nextSunsetState = state;
}
/**
* @return the nextTimeEventState
*/
public DateTimeState getNextTimeEventState() {
return nextTimeEventState;
}
/**
* @param state the nextTimeEventState to set
*/
public void setNextTimeEventState(DateTimeState state) {
this.nextTimeEventState = state;
}
/**
* @return the onState
*/
public BooleanState getOnState() {
return onState;
}
/**
* @param state the onState to set
*/
public void setOnState(BooleanState state) {
this.onState = state;
}
/**
* @return the operationModeState
*/
public StringState getOperationModeState() {
return operationModeState;
}
/**
* @param state the operationModeState to set
*/
public void setOperationModeState(StringState state) {
this.operationModeState = state;
}
/**
* @return the pointTemperatureState
*/
public DoubleState getPointTemperatureState() {
return pointTemperatureState;
}
/**
* @param state the pointTemperatureState to set
*/
public void setPointTemperatureState(DoubleState state) {
this.pointTemperatureState = state;
}
/**
* @return the powerConsumptionWattState
*/
public DoubleState getPowerConsumptionWattState() {
return powerConsumptionWattState;
}
/**
* @param state the powerConsumptionWattState to set
*/
public void setPowerConsumptionWattState(DoubleState state) {
this.powerConsumptionWattState = state;
}
/**
* @return the powerInWattState
*/
public DoubleState getPowerInWattState() {
return powerInWattState;
}
/**
* @param state the powerInWattState to set
*/
public void setPowerInWattState(DoubleState state) {
this.powerInWattState = state;
}
/**
* @return the shutterLevelState
*/
public IntegerState getShutterLevelState() {
return shutterLevelState;
}
/**
* @param state the shutterLevelState to set
*/
public void setShutterLevelState(IntegerState state) {
this.shutterLevelState = state;
}
/**
* @return the supplyValueInCubicMetterPerDayState
*/
public DoubleState getSupplyValueInCubicMetterPerDayState() {
return supplyValueInCubicMetterPerDayState;
}
/**
* @param state the supplyValueInCubicMetterPerDayState to set
*/
public void setSupplyValueInCubicMetterPerDayState(DoubleState state) {
this.supplyValueInCubicMetterPerDayState = state;
}
/**
* @return the supplyValueInCubicMetterPerMonthState
*/
public DoubleState getSupplyValueInCubicMetterPerMonthState() {
return supplyValueInCubicMetterPerMonthState;
}
/**
* @param state the supplyValueInCubicMetterPerMonthState to set
*/
public void setSupplyValueInCubicMetterPerMonthState(DoubleState state) {
this.supplyValueInCubicMetterPerMonthState = state;
}
/**
* @return the supplyValueInCurrencyPerDayState
*/
public DoubleState getSupplyValueInCurrencyPerDayState() {
return supplyValueInCurrencyPerDayState;
}
/**
* @param state the supplyValueInCurrencyPerDayState to set
*/
public void setSupplyValueInCurrencyPerDayState(DoubleState state) {
this.supplyValueInCurrencyPerDayState = state;
}
/**
* @return the supplyValueInCurrencyPerMonthState
*/
public DoubleState getSupplyValueInCurrencyPerMonthState() {
return supplyValueInCurrencyPerMonthState;
}
/**
* @param state the supplyValueInCurrencyPerMonthState to set
*/
public void setSupplyValueInCurrencyPerMonthState(DoubleState state) {
this.supplyValueInCurrencyPerMonthState = state;
}
/**
* @return the supplyValueInLitrePerDayState
*/
public DoubleState getSupplyValueInLitrePerDayState() {
return supplyValueInLitrePerDayState;
}
/**
* @param state the supplyValueInLitrePerDayState to set
*/
public void setSupplyValueInLitrePerDayState(DoubleState state) {
this.supplyValueInLitrePerDayState = state;
}
/**
* @return the supplyValueInLitrePerMonthState
*/
public DoubleState getSupplyValueInLitrePerMonthState() {
return supplyValueInLitrePerMonthState;
}
/**
* @param state the supplyValueInLitrePerMonthState to set
*/
public void setSupplyValueInLitrePerMonthState(DoubleState state) {
this.supplyValueInLitrePerMonthState = state;
}
/**
* @return the temperatureState
*/
public DoubleState getTemperatureState() {
return temperatureState;
}
/**
* @param state the temperatureState to set
*/
public void setTemperatureState(DoubleState state) {
this.temperatureState = state;
}
/**
* @return the totalEnergyState
*/
public DoubleState getTotalEnergyState() {
return totalEnergyState;
}
/**
* @param state the totalEnergyState to set
*/
public void setTotalEnergyState(DoubleState state) {
this.totalEnergyState = state;
}
/**
* @return the valueState
*/
public BooleanState getValueState() {
return valueState;
}
/**
* @param state the valueState to set
*/
public void setValueState(BooleanState state) {
this.valueState = state;
}
/**
* @return the valvePositionState
*/
public BooleanState getValvePositionState() {
return valvePositionState;
}
/**
* @param state the valvePositionState to set
*/
public void setValvePositionState(BooleanState state) {
this.valvePositionState = state;
}
/**
* @return the windowReductionActiveState
*/
public BooleanState getWindowReductionActiveState() {
return windowReductionActiveState;
}
/**
* @param state the windowReductionActiveState to set
*/
public void setWindowReductionActiveState(BooleanState state) {
this.windowReductionActiveState = state;
}
}

View File

@ -1,516 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.device;
import static org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.location.Location;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
import com.google.gson.annotations.SerializedName;
/**
* Defines the structure of a {@link Device}.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Device {
public static final String DEVICE_MANUFACTURER_RWE = "RWE";
public static final String DEVICE_MANUFACTURER_INNOGY = "innogy";
protected static final String PROTOCOL_ID_COSIP = "Cosip";
protected static final String PROTOCOL_ID_VIRTUAL = "Virtual";
protected static final String PROTOCOL_ID_WMBUS = "wMBus";
/**
* Unique id for the device, always available in model.
*/
private String id;
/**
* Identifier of the manufacturer, always available in model
*/
private String manufacturer;
/**
* Version number of the device for the domain model.
*
* If the functionality of the device changes, the version must
* be increased to indicate that there are new or changed attributes
* of the device. Always available in model.
*/
private String version;
/**
* Defines the product, which is used as an identifier for selecting the
* right add-in to support the functionality of the device.
* Remark: one add-in can support multiple devices, e.g.
* core.RWE, which supports all RWE hardware devices (also referred to as core devices).
* Always available in model.
*/
private String product;
/**
* Device number or id like SGTIN given by the manufacturer. Optional.
*/
private String serialnumber;
/**
* Specifies the type of the device, which is defined by the manufacturer. The triple of device type, manufacturer
* and the version must be unique.
* Always available in model.
*/
private String type;
private DeviceConfig config;
private List<String> capabilities;
private Map<String, Capability> capabilityMap;
private DeviceState deviceState;
/**
* The tag container can contain any number of properties for grouping of the devices in the client, e.g. category
* of device like security related. The tags can be freely chosen by the client and will not be considered by the
* system for any business logic.
*
* Optional.
*/
// @Key("tags")
// private List<Property> tagList;
/**
* The location contains the link to the location of the device. Optional.
*/
@SerializedName("location")
private String locationLink;
private transient Location location;
private List<Message> messageList;
private boolean lowBattery;
/**
* Stores, if the {@link Device} is battery powered.
*/
private boolean batteryPowered = false;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the manufacturer
*/
public String getManufacturer() {
return manufacturer;
}
/**
* @param manufacturer the manufacturer to set
*/
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
/**
* @return the version
*/
public String getVersion() {
return version;
}
/**
* @param version the version to set
*/
public void setVersion(String version) {
this.version = version;
}
/**
* @return the product
*/
public String getProduct() {
return product;
}
/**
* @param product the product to set
*/
public void setProduct(String product) {
this.product = product;
}
/**
* @return the serialnumber
*/
public String getSerialnumber() {
return serialnumber;
}
/**
* @param serialnumber the serialnumber to set
*/
public void setSerialnumber(String serialnumber) {
this.serialnumber = serialnumber;
}
/**
* Returns true, if the {@link Device} has a serial number.
*
* @return
*/
public boolean hasSerialNumber() {
return serialnumber != null && !serialnumber.isEmpty();
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the config
*/
public DeviceConfig getConfig() {
return config;
}
/**
* @param config the config to set
*/
public void setConfig(DeviceConfig config) {
this.config = config;
}
/**
* Returns the {@link DeviceState}. Only available, if device has a state. Better check with
* {@link Device#hasDeviceState()} first!
*
* @return the entityState or null
*/
public DeviceState getDeviceState() {
return deviceState;
}
/**
* @param deviceState the deviceState to set
*/
public void setDeviceState(DeviceState deviceState) {
this.deviceState = deviceState;
}
/**
* Returns, if the {@link Device} has a state. Not all {@link Device}s have a state.
*
* @return
*/
public boolean hasDeviceState() {
return deviceState != null;
}
/**
* @return the capabilityList
*/
public List<String> getCapabilities() {
return Objects.requireNonNullElse(capabilities, Collections.emptyList());
}
/**
* @param capabilityList the capabilityList to set
*/
public void setCapabilities(List<String> capabilityList) {
this.capabilities = capabilityList;
}
/**
* @param capabilityMap the capabilityMap to set
*/
public void setCapabilityMap(Map<String, Capability> capabilityMap) {
this.capabilityMap = capabilityMap;
}
/**
* @return the capabilityMap
*/
public Map<String, Capability> getCapabilityMap() {
return this.capabilityMap;
}
/**
* Returns the {@link Capability} with the given id.
*
* @param id
* @return
*/
public Capability getCapabilityWithId(String id) {
return this.capabilityMap.get(id);
}
/**
* @return the locationLink
*/
public String getLocationLink() {
return locationLink;
}
/**
* @param locationLink the locationList to set
*/
public void setLocation(String locationLink) {
this.locationLink = locationLink;
}
/**
* Returns the id of the {@link Location}
*
* @return
*/
public String getLocationId() {
if (locationLink != null) {
return locationLink.replace("/location/", "");
}
return null;
}
/**
* Returns the {@link Location} of the {@link Device}. Better check with {@link Device#hasLocation()} first, as not
* all devices have one.
*
* @return the location
*/
public Location getLocation() {
return location;
}
/**
* @param location the location to set
*/
public void setLocation(Location location) {
this.location = location;
}
/**
* Returns, if the {@link Device} has a {@link Location}. Not all devices have a {@link Location}...
*
* @return boolean true, if a {@link Location} is set, else false
*/
public boolean hasLocation() {
return location != null;
}
/**
* @return the messageList
*/
public List<Message> getMessageList() {
return messageList;
}
/**
* @param messageList the messageList to set
*/
public void setMessageList(List<Message> messageList) {
this.messageList = messageList;
applyMessageList(messageList);
}
private void applyMessageList(List<Message> messageList) {
if (messageList != null && !messageList.isEmpty()) {
boolean isUnreachableMessageFound = false;
boolean isLowBatteryMessageFound = false;
for (final Message message : messageList) {
switch (message.getType()) {
case Message.TYPE_DEVICE_UNREACHABLE:
isUnreachableMessageFound = true;
break;
case Message.TYPE_DEVICE_LOW_BATTERY:
isLowBatteryMessageFound = true;
break;
}
}
if (isUnreachableMessageFound) {
setReachable(false); // overwrite only when there is a corresponding message (to keep the state of the
// API in other cases)
}
if (isLowBatteryMessageFound) {
setLowBattery(true); // overwrite only when there is a corresponding message (to keep the state of the
// API in other cases)
}
}
}
/**
* Sets if the {@link Device} is reachable;
*
* @param isReachable
*/
private void setReachable(boolean isReachable) {
if (getDeviceState().hasIsReachableState()) {
getDeviceState().setReachable(isReachable);
}
}
/**
* Returns if the {@link Device} is reachable.
*
* @return
*/
public boolean isReachable() {
return getDeviceState().getState().getIsReachable().getValue();
}
/**
* Sets the low battery state for the {@link Device}.
*
* @param hasLowBattery
*/
private void setLowBattery(boolean hasLowBattery) {
this.lowBattery = hasLowBattery;
}
/**
* Returns true if the {@link Device} has a low battery warning. Only available on battery devices.
*
* @return
*/
public boolean hasLowBattery() {
return lowBattery;
}
/**
* Returns true, if the {@link Device} is battery powered.
*
* @return
*/
public boolean isBatteryPowered() {
return batteryPowered;
}
/**
* Sets if the device is battery powered.
*
* @param hasBattery
*/
public void setIsBatteryPowered(boolean hasBattery) {
batteryPowered = hasBattery;
}
/**
* Returns true, if the {@link Device} has {@link Message}s.
*
* @return
*/
public boolean hasMessages() {
return (messageList != null && !messageList.isEmpty());
}
/**
* Returns true if the device is a controller (SHC).
*
* @return
*/
public boolean isController() {
return DEVICE_SHC.equals(type) || DEVICE_SHCA.equals(type);
}
/**
* Returns true, if the device is made by RWE.
*
* @return
*/
public boolean isRWEDevice() {
return DEVICE_MANUFACTURER_RWE.equals(manufacturer);
}
/**
* Returns true, if the device is made by innogy.
*
* @return
*/
public boolean isInnogyDevice() {
return DEVICE_MANUFACTURER_INNOGY.equals(manufacturer);
}
/**
* Returns true, if the {@link Device} is a virtual device (e.g. a VariableActuator).
*
* @return
*/
public boolean isVirtualDevice() {
return PROTOCOL_ID_VIRTUAL.equals(getConfig().getProtocolId());
}
/**
* Returns true, if the {@link Device} is a radio device.
*
* @return
*/
public boolean isRadioDevice() {
return PROTOCOL_ID_COSIP.equals(getConfig().getProtocolId())
|| PROTOCOL_ID_WMBUS.equals(getConfig().getProtocolId());
}
/**
* Returns true, if the {@link Device} is a CoSip device.
*
* @return
*/
public boolean isCoSipDevice() {
return PROTOCOL_ID_COSIP.equals(getConfig().getProtocolId());
}
/**
* Returns true, if the {@link Device} is a W-Mbus device.
*
* @return
*/
public boolean isWMBusDevice() {
return PROTOCOL_ID_WMBUS.equals(getConfig().getProtocolId());
}
@Override
public String toString() {
final String string = "Device [" + "id=" + getId() + " manufacturer=" + getManufacturer() + " version="
+ getVersion() + " product=" + getProduct() + " serialnumber=" + getSerialnumber() + " type="
+ getType() + " name=" + getConfig().getName() + "]";
return string;
}
}

View File

@ -1,411 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.device;
import java.time.ZonedDateTime;
import org.openhab.binding.innogysmarthome.internal.client.Util;
import com.google.gson.annotations.SerializedName;
/**
* Holds the configuration of the Device.
*
* @author Oliver Kuhl - Initial contribution
*
*/
public class DeviceConfig {
private String name;
private String protocolId;
private String timeOfAcceptance;
private String timeOfDiscovery;
private String hardwareVersion;
private String softwareVersion;
private String firmwareVersion;
private String hostName;
private boolean activityLogEnabled;
private String configurationState;
@SerializedName("IPAddress")
private String ipAddress;
@SerializedName("MACAddress")
private String macAddress;
private String registrationTime;
private String timeZone;
private String shcType;
private String geoLocation;
private Double currentUTCOffset;
private Boolean backendConnectionMonitored;
@SerializedName("RFCommFailureNotification")
private Boolean rfCommFailureNotification;
private String displayCurrentTemperature;
private String underlyingDeviceIds;
private String meterId;
private String meterFirmwareVersion;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the protocolId
*/
public String getProtocolId() {
return protocolId;
}
/**
* @param protocolId the protocolId to set
*/
public void setProtocolId(String protocolId) {
this.protocolId = protocolId;
}
/**
* Returns the time, when the {@link Device} was added to the SHC configuration.
*
* @return
*/
public ZonedDateTime getTimeOfAcceptance() {
if (timeOfAcceptance == null) {
return null;
}
return Util.convertZuluTimeStringToDate(timeOfAcceptance);
}
/**
* @param timeOfAcceptance the timeOfAcceptance to set
*/
public void setTimeOfAcceptance(String timeOfAcceptance) {
this.timeOfAcceptance = timeOfAcceptance;
}
/**
* Returns the time, when the {@link Device} was discovered by the SHC.
*
* @return
*/
public ZonedDateTime getTimeOfDiscovery() {
if (timeOfDiscovery == null) {
return null;
}
return Util.convertZuluTimeStringToDate(timeOfDiscovery);
}
/**
* @param timeOfDiscovery the timeOfDiscovery to set
*/
public void setTimeOfDiscovery(String timeOfDiscovery) {
this.timeOfDiscovery = timeOfDiscovery;
}
/**
* @return the hardwareVersion
*/
public String getHardwareVersion() {
return hardwareVersion;
}
/**
* @param hardwareVersion the hardwareVersion to set
*/
public void setHardwareVersion(String hardwareVersion) {
this.hardwareVersion = hardwareVersion;
}
/**
* @return the softwareVersion
*/
public String getSoftwareVersion() {
return softwareVersion;
}
/**
* @param softwareVersion the softwareVersion to set
*/
public void setSoftwareVersion(String softwareVersion) {
this.softwareVersion = softwareVersion;
}
/**
* @return the firmwareVersion
*/
public String getFirmwareVersion() {
return firmwareVersion;
}
/**
* @param firmwareVersion the firmwareVersion to set
*/
public void setFirmwareVersion(String firmwareVersion) {
this.firmwareVersion = firmwareVersion;
}
/**
* @return the hostName
*/
public String getHostName() {
return hostName;
}
/**
* @param hostName the hostName to set
*/
public void setHostName(String hostName) {
this.hostName = hostName;
}
/**
* @return the activityLogEnabled
*/
public boolean isActivityLogEnabled() {
return activityLogEnabled;
}
/**
* @param activityLogEnabled the activityLogEnabled to set
*/
public void setActivityLogEnabled(boolean activityLogEnabled) {
this.activityLogEnabled = activityLogEnabled;
}
/**
* @return the configurationState
*/
public String getConfigurationState() {
return configurationState;
}
/**
* @param configurationState the configurationState to set
*/
public void setConfigurationState(String configurationState) {
this.configurationState = configurationState;
}
/**
* @return the iPAddress
*/
public String getIPAddress() {
return ipAddress;
}
/**
* @param ipAddress the ipAddress to set
*/
public void setIPAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
/**
* @return the mACAddress
*/
public String getMACAddress() {
return macAddress;
}
/**
* @param mACAddress the mACAddress to set
*/
public void setMACAddress(String mACAddress) {
this.macAddress = mACAddress;
}
/**
* @return the registrationTime
*/
public ZonedDateTime getRegistrationTime() {
if (registrationTime == null) {
return null;
}
return Util.convertZuluTimeStringToDate(registrationTime);
}
/**
* @param registrationTime the registrationTime to set
*/
public void setRegistrationTime(String registrationTime) {
this.registrationTime = registrationTime;
}
/**
* @return the timeZone
*/
public String getTimeZone() {
return timeZone;
}
/**
* @param timeZone the timeZone to set
*/
public void setTimeZone(String timeZone) {
this.timeZone = timeZone;
}
/**
* @return the shcType
*/
public String getShcType() {
return shcType;
}
/**
* @param shcType the shcType to set
*/
public void setShcType(String shcType) {
this.shcType = shcType;
}
/**
* @return the geoLocation
*/
public String getGeoLocation() {
return geoLocation;
}
/**
* @param geoLocation the geoLocation to set
*/
public void setGeoLocation(String geoLocation) {
this.geoLocation = geoLocation;
}
/**
* @return the currentUTCOffset
*/
public Double getCurrentUTCOffset() {
return currentUTCOffset;
}
/**
* @param currentUTCOffset the currentUTCOffset to set
*/
public void setCurrentUTCOffset(Double currentUTCOffset) {
this.currentUTCOffset = currentUTCOffset;
}
/**
* @return the backendConnectionMonitored
*/
public Boolean getBackendConnectionMonitored() {
return backendConnectionMonitored;
}
/**
* @param backendConnectionMonitored the backendConnectionMonitored to set
*/
public void setBackendConnectionMonitored(Boolean backendConnectionMonitored) {
this.backendConnectionMonitored = backendConnectionMonitored;
}
/**
* @return the rFCommFailureNotification
*/
public Boolean getRFCommFailureNotification() {
return rfCommFailureNotification;
}
/**
* @param rFCommFailureNotification the rFCommFailureNotification to set
*/
public void setRFCommFailureNotification(Boolean rFCommFailureNotification) {
rfCommFailureNotification = rFCommFailureNotification;
}
/**
* @return the displayCurrentTemperature
*/
public String getDisplayCurrentTemperature() {
return displayCurrentTemperature;
}
/**
* @param displayCurrentTemperature the displayCurrentTemperature to set
*/
public void setDisplayCurrentTemperature(String displayCurrentTemperature) {
this.displayCurrentTemperature = displayCurrentTemperature;
}
/**
* @return the underlyingDeviceIds
*/
public String getUnderlyingDeviceIds() {
return underlyingDeviceIds;
}
/**
* @param underlyingDeviceIds the underlyingDeviceIds to set
*/
public void setUnderlyingDeviceIds(String underlyingDeviceIds) {
this.underlyingDeviceIds = underlyingDeviceIds;
}
/**
* @return the meterId
*/
public String getMeterId() {
return meterId;
}
/**
* @param meterId the meterId to set
*/
public void setMeterId(String meterId) {
this.meterId = meterId;
}
/**
* @return the meterFirmwareVersion
*/
public String getMeterFirmwareVersion() {
return meterFirmwareVersion;
}
/**
* @param meterFirmwareVersion the meterFirmwareVersion to set
*/
public void setMeterFirmwareVersion(String meterFirmwareVersion) {
this.meterFirmwareVersion = meterFirmwareVersion;
}
}

View File

@ -1,171 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.device;
import java.util.HashMap;
import org.openhab.binding.innogysmarthome.internal.client.entity.Property;
/**
* Defines the {@link DeviceState}, e.g. if the device is reachable.
*
* @author Oliver Kuhl - Initial contribution
*/
public class DeviceState {
protected static final String DEVICE_INCLUSION_STATE_INCLUDED = "Included";
protected static final String DEVICE_INCLUSION_STATE_PENDING = "InclusionPending";
protected static final String DEVICE_UPDATE_STATE_UPTODATE = "UpToDate";
protected static final String PROTOCOL_ID_WMBUS = "wMBus";
protected static final String PROTOCOL_ID_VIRTUAL = "Virtual";
protected static final String PROTOCOL_ID_COSIP = "Cosip";
private String id;
private State state;
private HashMap<String, Property> stateMap;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the state
*/
public State getState() {
return state;
}
/**
* @param state the state to set
*/
public void setState(State state) {
this.state = state;
}
/**
* Returns true if the device is reachable, false otherwise.
*
* @return true or false for "reachable" {@link Device}s, else null.
*/
public Boolean isReachable() {
return getState().getIsReachable().getValue();
}
/**
* Returns if the {@link State} "isReachable" is available for the current {@link Device}.
*
* @return
*/
public Boolean hasIsReachableState() {
return getState().getIsReachable() != null;
}
/**
* Sets if the {@link Device} is reachable.
*
* @param isReachable
*/
public void setReachable(boolean isReachable) {
getState().getIsReachable().setValue(isReachable);
}
/**
* Returns the configuration state of the device.
*
* @return the configuration state
*/
public String getDeviceConfigurationState() {
return getState().getDeviceConfigurationState().getValue();
}
/**
* Returns the device inclusion state.
*
* @return the device inclusion state
*/
public String getDeviceInclusionState() {
return getState().getDeviceInclusionState().getValue();
}
/**
* Returns true, if the device is included.
*
* @return true, if the {@link Device} is "Included"
*/
public boolean deviceIsIncluded() {
return DEVICE_INCLUSION_STATE_INCLUDED.equals(getState().getDeviceInclusionState().getValue());
}
/**
* @return the stateMap
*/
public HashMap<String, Property> getStateMap() {
return stateMap;
}
/**
* @param stateMap the stateMap to set
*/
public void setStateMap(HashMap<String, Property> stateMap) {
this.stateMap = stateMap;
}
/**
* Returns true, if the device inclusion state is "InclusionPending".
*
* @return true, if the inclusion state is "InclusionPending"
*/
public Boolean deviceInclusionIsPending() {
return DEVICE_INCLUSION_STATE_PENDING.equals(getDeviceInclusionState());
}
/**
* Return the update state of the {@link Device}.
*
* @return the update state
*/
public String getDeviceUpdateState() {
return getState().getUpdateState().getValue();
}
/**
* Returns true if the {@link Device} is up to date.
*
* @return true, if the deviceUpdateState is "UpToDate"
*/
public Boolean deviceIsUpToDate() {
return DEVICE_UPDATE_STATE_UPTODATE.equals(getDeviceUpdateState());
}
/**
* Returns the firmware version of the {@link Device}.
*
* @return the firmware version
*/
public String getFirmwareVersion() {
return getState().getFirmwareVersion().getValue();
}
}

View File

@ -1,116 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.device;
/**
* Defines the {@link Gateway} structure.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Gateway {
/**
* Serial number of the gateway
*/
private String serialNumber;
/**
* Connected status
*/
private Boolean connected;
/**
* Version of the app
*/
private String appVersion;
/**
* Version of the operating system
*/
private String osVersion;
/**
* Version of the configuration. Changes each time the configuration was changed via the innogy client app.
*/
private String configVersion;
/**
* @return the serial number
*/
public String getSerialNumber() {
return serialNumber;
}
/**
* @param serialNumber the serial number to set
*/
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
/**
* @return if the gateway is connected
*/
public Boolean getConnected() {
return connected;
}
/**
* @param connected the connected state to set, true if connected
*/
public void setConnected(Boolean connected) {
this.connected = connected;
}
/**
* @return the app version
*/
public String getAppVersion() {
return appVersion;
}
/**
* @param appVersion the app version to set
*/
public void setAppVersion(String appVersion) {
this.appVersion = appVersion;
}
/**
* @return the os version
*/
public String getOsVersion() {
return osVersion;
}
/**
* @param osVersion the os version to set
*/
public void setOsVersion(String osVersion) {
this.osVersion = osVersion;
}
/**
* @return the configuration version
*/
public String getConfigVersion() {
return configVersion;
}
/**
* @param configVersion the config version to set
*/
public void setConfigVersion(String configVersion) {
this.configVersion = configVersion;
}
}

View File

@ -1,458 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.device;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.BooleanState;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.DateTimeState;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.DoubleState;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.IntegerState;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.StringState;
import com.google.gson.annotations.SerializedName;
/**
* Holds the state of the Device.
*
* @author Oliver Kuhl - Initial contribution
*
*/
public class State {
/** Standard device states */
@SerializedName("deviceInclusionState")
private StringState deviceInclusionState;
@SerializedName("deviceConfigurationState")
private StringState deviceConfigurationState;
private BooleanState isReachable;
private StringState updateState;
private StringState firmwareVersion;
@SerializedName("WHRating")
private DoubleState wHRating;
/** SHC device states */
// Removed updateAvailable because it is different between version 1 and 2 devices and not used anyway
// Related to openhab-addons #6613
// private StringState updateAvailable
private DateTimeState lastReboot;
private IntegerState memoryLoad;
@SerializedName("CPULoad")
private IntegerState cpuLoad;
@SerializedName("LBDongleAttached")
private BooleanState lBDongleAttached;
@SerializedName("MBusDongleAttached")
private BooleanState mBusDongleAttached;
private IntegerState configVersion;
@SerializedName("OSState")
private StringState oSState;
private IntegerState wifiSignalStrength;
private StringState ethIpAddress;
private StringState wifiIpAddress;
private StringState ethMacAddress;
private StringState wifiMacAddress;
private StringState inUseAdapter;
private BooleanState innogyLayerAttached;
private BooleanState discoveryActive;
private StringState operationStatus;
private DoubleState currentUtcOffset;
private DoubleState cpuUsage;
private DoubleState diskUsage;
private DoubleState memoryUsage;
/**
* @return the deviceInclusionState
*/
public StringState getDeviceInclusionState() {
return deviceInclusionState;
}
/**
* @param deviceInclusionState the deviceInclusionState to set
*/
public void setDeviceInclusionState(StringState deviceInclusionState) {
this.deviceInclusionState = deviceInclusionState;
}
/**
* @return the deviceConfigurationState
*/
public StringState getDeviceConfigurationState() {
return deviceConfigurationState;
}
/**
* @param deviceConfigurationState the deviceConfigurationState to set
*/
public void setDeviceConfigurationState(StringState deviceConfigurationState) {
this.deviceConfigurationState = deviceConfigurationState;
}
/**
* @return the isReachable
*/
public BooleanState getIsReachable() {
return isReachable;
}
/**
* @param isReachable the isReachable to set
*/
public void setIsReachable(BooleanState isReachable) {
this.isReachable = isReachable;
}
/**
* @return the updateState
*/
public StringState getUpdateState() {
return updateState;
}
/**
* @param updateState the updateState to set
*/
public void setUpdateState(StringState updateState) {
this.updateState = updateState;
}
/**
* @return the firmwareVersion
*/
public StringState getFirmwareVersion() {
return firmwareVersion;
}
/**
* @param firmwareVersion the firmwareVersion to set
*/
public void setFirmwareVersion(StringState firmwareVersion) {
this.firmwareVersion = firmwareVersion;
}
/**
* @return the wHRating
*/
public DoubleState getWHRating() {
return wHRating;
}
/**
* @param wHRating the wHRating to set
*/
public void setWHRating(DoubleState wHRating) {
this.wHRating = wHRating;
}
/**
* @return the lastReboot
*/
public DateTimeState getLastReboot() {
return lastReboot;
}
/**
* @param lastReboot the lastReboot to set
*/
public void setLastReboot(DateTimeState lastReboot) {
this.lastReboot = lastReboot;
}
/**
* @return the memoryLoad
*/
public IntegerState getMemoryLoad() {
return memoryLoad;
}
/**
* @param memoryLoad the memoryLoad to set
*/
public void setMemoryLoad(IntegerState memoryLoad) {
this.memoryLoad = memoryLoad;
}
/**
* @return the cPULoad
*/
public IntegerState getCPULoad() {
return cpuLoad;
}
/**
* @param cpuLoad the cPULoad to set
*/
public void setCPULoad(IntegerState cpuLoad) {
this.cpuLoad = cpuLoad;
}
/**
* @return the lBDongleAttached
*/
public BooleanState getLBDongleAttached() {
return lBDongleAttached;
}
/**
* @param lBDongleAttached the lBDongleAttached to set
*/
public void setLBDongleAttached(BooleanState lBDongleAttached) {
this.lBDongleAttached = lBDongleAttached;
}
/**
* @return the mBusDongleAttached
*/
public BooleanState getMBusDongleAttached() {
return mBusDongleAttached;
}
/**
* @param mBusDongleAttached the mBusDongleAttached to set
*/
public void setMBusDongleAttached(BooleanState mBusDongleAttached) {
this.mBusDongleAttached = mBusDongleAttached;
}
/**
* @return the configVersion
*/
public IntegerState getConfigVersion() {
return configVersion;
}
/**
* @param configVersion the configVersion to set
*/
public void setConfigVersion(IntegerState configVersion) {
this.configVersion = configVersion;
}
/**
* @return the oSState
*/
public StringState getOSState() {
return oSState;
}
/**
* @param oSState the oSState to set
*/
public void setOSState(StringState oSState) {
this.oSState = oSState;
}
/**
* @return the wifiSignalStrength
*/
public IntegerState getWifiSignalStrength() {
return wifiSignalStrength;
}
/**
* @param wifiSignalStrength the wifiSignalStrength to set
*/
public void setWifiSignalStrength(IntegerState wifiSignalStrength) {
this.wifiSignalStrength = wifiSignalStrength;
}
/**
* @return the ethIpAddress
*/
public StringState getEthIpAddress() {
return ethIpAddress;
}
/**
* @param ethIpAddress the ethIpAddress to set
*/
public void setEthIpAddress(StringState ethIpAddress) {
this.ethIpAddress = ethIpAddress;
}
/**
* @return the wifiIpAddress
*/
public StringState getWifiIpAddress() {
return wifiIpAddress;
}
/**
* @param wifiIpAddress the wifiIpAddress to set
*/
public void setWifiIpAddress(StringState wifiIpAddress) {
this.wifiIpAddress = wifiIpAddress;
}
/**
* @return the ethMacAddress
*/
public StringState getEthMacAddress() {
return ethMacAddress;
}
/**
* @param ethMacAddress the ethMacAddress to set
*/
public void setEthMacAddress(StringState ethMacAddress) {
this.ethMacAddress = ethMacAddress;
}
/**
* @return the wifiMacAddress
*/
public StringState getWifiMacAddress() {
return wifiMacAddress;
}
/**
* @param wifiMacAddress the wifiMacAddress to set
*/
public void setWifiMacAddress(StringState wifiMacAddress) {
this.wifiMacAddress = wifiMacAddress;
}
/**
* @return the inUseAdapter
*/
public StringState getInUseAdapter() {
return inUseAdapter;
}
/**
* @param inUseAdapter the inUseAdapter to set
*/
public void setInUseAdapter(StringState inUseAdapter) {
this.inUseAdapter = inUseAdapter;
}
/**
* @return the innogyLayerAttached
*/
public BooleanState getInnogyLayerAttached() {
return innogyLayerAttached;
}
/**
* @param innogyLayerAttached the innogyLayerAttached to set
*/
public void setInnogyLayerAttached(BooleanState innogyLayerAttached) {
this.innogyLayerAttached = innogyLayerAttached;
}
/**
* @return the discoveryActive
*/
public BooleanState getDiscoveryActive() {
return discoveryActive;
}
/**
* @param discoveryActive the discoveryActive to set
*/
public void setDiscoveryActive(BooleanState discoveryActive) {
this.discoveryActive = discoveryActive;
}
/**
* @return the operationStatus
*/
public StringState getOperationStatus() {
return operationStatus;
}
/**
* @param operationStatus the operationStatus to set
*/
public void setOperationStatus(StringState operationStatus) {
this.operationStatus = operationStatus;
}
/**
* @return the currentUtcOffset
*/
public DoubleState getCurrentUtcOffset() {
return currentUtcOffset;
}
/**
* @param currentUtcOffset the currentUtcOffset to set
*/
public void setCurrentUtcOffset(DoubleState currentUtcOffset) {
this.currentUtcOffset = currentUtcOffset;
}
/**
* @return the cpuUsage
*/
public DoubleState getCpuUsage() {
return cpuUsage;
}
/**
* @param cpuUsage the cpuUsage to set
*/
public void setCpuUsage(DoubleState cpuUsage) {
this.cpuUsage = cpuUsage;
}
/**
* @return the diskUsage
*/
public DoubleState getDiskUsage() {
return diskUsage;
}
/**
* @param diskUsage the diskUsage to set
*/
public void setDiskUsage(DoubleState diskUsage) {
this.diskUsage = diskUsage;
}
/**
* @return the memoryUsage
*/
public DoubleState getMemoryUsage() {
return memoryUsage;
}
/**
* @param memoryUsage the memoryUsage to set
*/
public void setMemoryUsage(DoubleState memoryUsage) {
this.memoryUsage = memoryUsage;
}
}

View File

@ -1,144 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.error;
import java.util.List;
import com.google.gson.annotations.SerializedName;
/**
* Error response object from the innogy SmartHome api.
*
* @author Oliver Kuhl - Initial contribution
*
*/
public class ErrorResponse {
// General errors
public static final int ERR_UNKNOWN = 1000;
public static final int ERR_SERVICE_UNAVAILABLE = 1001;
public static final int ERR_SERVICE_TIMEOUT = 1002;
public static final int ERR_INTERNAL_API_ERROR = 1003;
public static final int ERR_INVALID_SHC_OPERATION = 1004;
public static final int ERR_MISSING_ARGUMENT_OR_WRONG_VALUE = 1005;
public static final int ERR_SERVICE_TOO_BUSY = 1006;
// Authentication and authorization errors
public static final int ERR_UNKNOWN_AUTHENTICATION_ERROR = 2000;
public static final int ERR_ACCESS_NOT_ALLOWED = 2001;
public static final int ERR_INVALID_TOKEN_REQUEST = 2002;
public static final int ERR_INVALID_CLIENT_CREDENTIALS = 2003;
public static final int ERR_INVALID_TOKEN_SIGNATURE = 2004;
public static final int ERR_SESSION_INITIALIZATION_FAILED = 2005;
public static final int ERR_SESSION_EXISTS = 2006;
public static final int ERR_TOKEN_EXPIRED = 2007;
public static final int ERR_LOGIN_FROM_DIFFERENT_CLIENT = 2008;
public static final int ERR_INVALID_USER_CREDENTIALS = 2009;
public static final int ERR_REMOTE_ACCESS_NOT_ALLOWED = 2010;
public static final int ERR_INSUFFICIENT_PERMISSIONS = 2011;
public static final int ERR_SESSION_NOT_FOUND = 2012;
public static final int ERR_ACCOUNT_TEMPORARY_LOCKED = 2013;
// Entities
public static final int ERR_ENTITY_DOES_NOT_EXIST = 3000;
public static final int ERR_INVALID_REQUEST_CONTENT = 3001;
public static final int ERR_NO_CHANGE_PERFORMED = 3002;
public static final int ERR_ENTITY_ALREADY_EXISTS = 3003;
public static final int ERR_INVALID_INTERACTION = 3004;
// Products
public static final int ERR_PREMIUM_SERVICE_CANNOT_BE_ENABLED_DIRECTLY = 3500;
public static final int ERR_CANNOT_REMOVE_A_PRODUCT_THAT_WAS_PAID = 3501;
// Actions
public static final int ERR_INVALID_ACTION_TRIGGERED = 4000;
public static final int ERR_INVALID_PARAMETER = 4001;
public static final int ERR_TRIGGER_ACTION_NOT_ALLOWED = 4002;
public static final int ERR_UNSUPPORTED_ACTION_TYPE = 4003;
// Configuration
public static final int ERR_ERROR_UPDATING_CONFIG = 5000;
public static final int ERR_CONFIG_LOCKED_BY_OTHER_PROCESS = 5001;
public static final int ERR_COMMUNICATION_WITH_SHC_FAILED = 5002;
public static final int ERR_LATEST_TERMS_AND_CONDITIONS_NOT_ACCEPTED_BY_USER = 5003;
public static final int ERR_ONE_SHC_ALREADY_REGISTERED = 5004;
public static final int ERR_USER_HAS_NO_REGISTERED_SHC = 5005;
public static final int ERR_CONTROLLER_OFFLINE = 5006;
public static final int ERR_REGISTRATION_FAILURE = 5009;
// Smart codes
public static final int ERR_SMARTCODE_REQUEST_NOT_ALLOWED = 6000;
public static final int ERR_SMARTCODE_CANNOT_BE_REDEEMED = 6001;
public static final int ERR_RESTRICTED_ACCESS = 6002;
@SerializedName("errorcode")
private int code;
@SerializedName("description")
private String description;
@SerializedName("messages")
private List<String> messages;
/**
* @return the error code
*/
public int getCode() {
return code;
}
/**
* @param code the error code to set
*/
public void setCode(int code) {
this.code = code;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the messages
*/
public List<String> getMessages() {
return messages;
}
/**
* @param messages the messages to set
*/
public void setMessages(List<String> messages) {
this.messages = messages;
}
@Override
public String toString() {
String stringRepresentation = "ErrorResponse [code=" + code + ", description=" + description;
if (messages != null) {
stringRepresentation += ", messages=" + messages.toString();
}
stringRepresentation += "]";
return stringRepresentation;
}
}

View File

@ -1,152 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.event;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class BaseEvent {
public static final String TYPE_STATE_CHANGED = "StateChanged";// "device/SHC.RWE/1.0/event/StateChanged";
public static final String TYPE_NEW_MESSAGE_RECEIVED = "NewMessageReceived"; // "device/SHC.RWE/1.0/event/NewMessageReceived";
public static final String TYPE_MESSAGE_CREATED = "MessageCreated";
public static final String TYPE_MESSAGE_DELETED = "MessageDeleted"; // "device/SHC.RWE/1.0/event/MessageDeleted";
public static final String TYPE_DISCONNECT = "Disconnect"; // "/event/Disconnect";
public static final String TYPE_CONFIGURATION_CHANGED = "ConfigurationChanged"; // "device/SHC.RWE/1.0/event/ConfigChanged";
public static final String TYPE_CONTROLLER_CONNECTIVITY_CHANGED = "/event/ControllerConnectivityChanged"; // "device/SHC.RWE/1.0/event/ControllerConnectivityChanged";
public static final String TYPE_BUTTON_PRESSED = "ButtonPressed";
public static final Set<String> SUPPORTED_EVENT_TYPES = Collections
.unmodifiableSet(Stream.of(TYPE_STATE_CHANGED, TYPE_NEW_MESSAGE_RECEIVED, TYPE_MESSAGE_CREATED,
TYPE_MESSAGE_DELETED, TYPE_DISCONNECT, TYPE_CONFIGURATION_CHANGED,
TYPE_CONTROLLER_CONNECTIVITY_CHANGED, TYPE_BUTTON_PRESSED).collect(Collectors.toSet()));
/**
* The event sequence number the gateway keeps track and adds a sequence number to each event for the client to
* identify order and missing events
*/
private Integer sequenceNumber;
/**
* Specifies the type of the event. The type must be the full path to uniquely reference the event definition.
* Always available.
*/
private String type;
/**
* Date and time when the event occurred in the system. Always available.
*/
private String timestamp;
/**
* @return the sequenceNumber
*/
public Integer getSequenceNumber() {
return sequenceNumber;
}
/**
* @return the timestamp
*/
public String getTimestamp() {
return timestamp;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param sequenceNumber the sequenceNumber to set
*/
public void setSequenceNumber(Integer sequenceNumber) {
this.sequenceNumber = sequenceNumber;
}
/**
* @param timestamp the timestamp to set
*/
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* Returns true, if the {@link Event} is a ConfigChanged event.
*
* @return
*/
public boolean isConfigChangedEvent() {
return TYPE_CONFIGURATION_CHANGED.equals(getType());
}
/**
* Returns true, if the {@link Event} is a ControllerConnectivityChanged event.
*
* @return
*/
public boolean isControllerConnectivityChangedEvent() {
return TYPE_CONTROLLER_CONNECTIVITY_CHANGED.equals(getType());
}
/**
* Returns true, if the {@link Event} is a Disconnect event.
*
* @return
*/
public boolean isDisconnectedEvent() {
return TYPE_DISCONNECT.equals(getType());
}
/**
* Returns true, if the {@link Event} is a MessageDeletedEvent.
*
* @return
*/
public boolean isMessageDeletedEvent() {
return TYPE_MESSAGE_DELETED.equals(getType());
}
/**
* Returns true, if the {@link Event} is a NewMessageReceivedEvent.
*
* @return
*/
public boolean isNewMessageReceivedEvent() {
return TYPE_NEW_MESSAGE_RECEIVED.equals(getType());
}
/**
* Returns true, if the {@link Event} is a StateChangedEvent.
*
* @return
*/
public boolean isStateChangedEvent() {
return TYPE_STATE_CHANGED.equals(getType());
}
}

View File

@ -1,199 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.event;
import java.util.HashMap;
import org.openhab.binding.innogysmarthome.internal.client.entity.Property;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
/**
* Defines the {@link Event}, which is sent by the innogy websocket to inform the clients about changes.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Event extends BaseEvent {
public static final String EVENT_PROPERTY_CONFIGURATION_VERSION = "ConfigurationVersion";
public static final String EVENT_PROPERTY_IS_CONNECTED = "IsConnected";
/**
* Reference to the associated entity (instance or metadata) for the given event. Always available.
*/
private String source;
/**
* The product (context) that generated the event.
*/
private String namespace;
/**
* This container includes only properties, e.g. for the changed state properties. If there is other data than
* properties to be transported, the data container will be used.
* Optional.
*/
private EventProperties properties;
protected HashMap<String, Property> propertyMap;
/**
* Data for the event, The data container can contain any type of entity dependent on the event type. For example,
* the DeviceFound events contains the entire Device entity rather than selected properties.
* Optional.
*/
private EventData data;
/**
* @return the link to the source
*/
public String getSource() {
return source;
}
/**
* @param source the link to the source to set
*/
public void setSource(String source) {
this.source = source;
}
/**
* @return the namespace
*/
public String getNamespace() {
return namespace;
}
/**
* @param namespace the namespace to set
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* @return the properties
*/
public EventProperties getProperties() {
return properties;
}
/**
* @param propertyList the propertyList to set
*/
public void setProperties(EventProperties properties) {
this.properties = properties;
}
/**
* @return the dataList
*/
public EventData getData() {
return data;
}
/**
* @param dataList the dataList to set
*/
public void setData(EventData data) {
this.data = data;
}
/**
* Returns the id of the link or null, if there is no link or the link does not have an id.
*
* @return String the id of the link or null
*/
public String getSourceId() {
final String linkType = getSourceLinkType();
if (linkType != null && !Link.LINK_TYPE_UNKNOWN.equals(linkType) && !Link.LINK_TYPE_SHC.equals(linkType)) {
if (source != null) {
return source.replace(linkType, "");
}
}
return null;
}
/**
* Returns the Type of the {@link Link} in the {@link Event}.
*
* @return
*/
public String getSourceLinkType() {
if (source != null) {
return Link.getLinkType(source);
}
return null;
}
/**
* Returns true, if the {@link Link} points to a {@link Capability}.
*
* @return
*/
public Boolean isLinkedtoCapability() {
return source == null ? false : Link.isTypeCapability(source);
}
/**
* Returns true, if the {@link Link} points to a {@link Device}.
*
* @return
*/
public Boolean isLinkedtoDevice() {
return source == null ? false : Link.isTypeDevice(source);
}
/**
* Returns true, if the {@link Link} points to a {@link Message}.
*
* @return
*/
public Boolean isLinkedtoMessage() {
return source == null ? false : Link.isTypeMessage(source);
}
/**
* Returns true, if the {@link Link} points to the SHC {@link Device}.
*
* @return
*/
public Boolean isLinkedtoSHC() {
return source == null ? false : Link.isTypeSHC(source);
}
/**
* Returns the configurationVersion or null, if this {@link Property} is not available in the event.
*
* @return
*/
public Integer getConfigurationVersion() {
return getData().getConfigVersion();
}
/**
* Returns the isConnected {@link Property} value. Only available for event of type ControllerConnectivityChanged
*
* @return {@link Boolean} or <code>null</code>, if {@link Property} is not available or {@link Event} is not of
* type ControllerConnectivityChanged.
*/
public Boolean getIsConnected() {
if (!isControllerConnectivityChangedEvent()) {
return null;
}
return getProperties().getIsConnected();
}
}

View File

@ -1,45 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.event;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class EventData {
private Integer configVersion;
private String id;
/**
* @return the configVersion
*/
public Integer getConfigVersion() {
return configVersion;
}
/**
* @param configVersion the configVersion to set
*/
public void setConfigVersion(Integer configVersion) {
this.configVersion = configVersion;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

View File

@ -1,582 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.event;
import com.google.gson.annotations.SerializedName;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class EventProperties {
/** SHC Properties **/
private Integer configVersion;
private Boolean isConnected;
/** Writable capability properties **/
private Integer dimLevel;
private Boolean onState;
private String operationMode;
private Double pointTemperature;
private Integer shutterLevel;
private Boolean value;
/** readable capability properties **/
private Double absoluteEnergyConsumption;
private Double energyConsumptionDayEuro;
private Double energyConsumptionDayKWh;
private Double energyConsumptionMonthEuro;
private Double energyConsumptionMonthKWh;
private Double energyPerDayInEuro;
private Double energyPerDayInKWh;
private Double energyPerMonthInEuro;
private Double energyPerMonthInKWh;
private Boolean frostWarning;
private Double humidity;
private Boolean isOpen;
private Boolean isSmokeAlarm;
private Integer lastKeyPressCounter;
private Integer lastPressedButtonIndex;
/**
* Key press type
*/
@SerializedName("type")
private String lastKeyPressType;
private Double luminance;
private Boolean moldWarning;
private Integer motionDetectedCount;
private Double powerConsumptionWatt;
private Double powerInWatt;
private Double temperature;
private Double totalEnergy;
private Boolean windowReductionActive;
private Double cpuUsage;
private Double diskUsage;
private Double memoryUsage;
/**
* @return the configurationVersion
*/
public Integer getConfigVersion() {
return configVersion;
}
/**
* @param configVersion the configurationVersion to set
*/
public void setConfigVersion(final Integer configVersion) {
this.configVersion = configVersion;
}
/**
* @return the isConnected
*/
public Boolean getIsConnected() {
return isConnected;
}
/**
* @param isConnected the isConnected to set
*/
public void setIsConnected(final Boolean isConnected) {
this.isConnected = isConnected;
}
/**
* @return the dimLevel
*/
public Integer getDimLevel() {
return dimLevel;
}
/**
* @param dimLevel the dimLevel to set
*/
public void setDimLevel(final Integer dimLevel) {
this.dimLevel = dimLevel;
}
/**
* @return the onState
*/
public Boolean getOnState() {
return onState;
}
/**
* @param onState the onState to set
*/
public void setOnState(final Boolean onState) {
this.onState = onState;
}
/**
* @return the operationMode
*/
public String getOperationMode() {
return operationMode;
}
/**
* @param operationMode the operationMode to set
*/
public void setOperationMode(final String operationMode) {
this.operationMode = operationMode;
}
/**
* @return the pointTemperature
*/
public Double getPointTemperature() {
return pointTemperature;
}
/**
* @param pointTemperature the pointTemperature to set
*/
public void setPointTemperature(final Double pointTemperature) {
this.pointTemperature = pointTemperature;
}
/**
* @return the shutterLevel
*/
public Integer getShutterLevel() {
return shutterLevel;
}
/**
* @param shutterLevel the shutterLevel to set
*/
public void setShutterLevel(final Integer shutterLevel) {
this.shutterLevel = shutterLevel;
}
/**
* @return the value
*/
public Boolean getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(final Boolean value) {
this.value = value;
}
/**
* @return the absoluteEnergyConsumption
*/
public Double getAbsoluteEnergyConsumption() {
return absoluteEnergyConsumption;
}
/**
* @param absoluteEnergyConsumption the absoluteEnergyConsumption to set
*/
public void setAbsoluteEnergyConsumption(final Double absoluteEnergyConsumption) {
this.absoluteEnergyConsumption = absoluteEnergyConsumption;
}
/**
* @return the energyConsumptionDayEuro
*/
public Double getEnergyConsumptionDayEuro() {
return energyConsumptionDayEuro;
}
/**
* @param energyConsumptionDayEuro the energyConsumptionDayEuro to set
*/
public void setEnergyConsumptionDayEuro(final Double energyConsumptionDayEuro) {
this.energyConsumptionDayEuro = energyConsumptionDayEuro;
}
/**
* @return the energyConsumptionDayKWh
*/
public Double getEnergyConsumptionDayKWh() {
return energyConsumptionDayKWh;
}
/**
* @param energyConsumptionDayKWh the energyConsumptionDayKWh to set
*/
public void setEnergyConsumptionDayKWh(final Double energyConsumptionDayKWh) {
this.energyConsumptionDayKWh = energyConsumptionDayKWh;
}
/**
* @return the energyConsumptionMonthEuro
*/
public Double getEnergyConsumptionMonthEuro() {
return energyConsumptionMonthEuro;
}
/**
* @param energyConsumptionMonthEuro the energyConsumptionMonthEuro to set
*/
public void setEnergyConsumptionMonthEuro(final Double energyConsumptionMonthEuro) {
this.energyConsumptionMonthEuro = energyConsumptionMonthEuro;
}
/**
* @return the energyConsumptionMonthKWh
*/
public Double getEnergyConsumptionMonthKWh() {
return energyConsumptionMonthKWh;
}
/**
* @param energyConsumptionMonthKWh the energyConsumptionMonthKWh to set
*/
public void setEnergyConsumptionMonthKWh(final Double energyConsumptionMonthKWh) {
this.energyConsumptionMonthKWh = energyConsumptionMonthKWh;
}
/**
* @return the energyPerDayInEuro
*/
public Double getEnergyPerDayInEuro() {
return energyPerDayInEuro;
}
/**
* @param energyPerDayInEuro the energyPerDayInEuro to set
*/
public void setEnergyPerDayInEuro(final Double energyPerDayInEuro) {
this.energyPerDayInEuro = energyPerDayInEuro;
}
/**
* @return the energyPerDayInKWh
*/
public Double getEnergyPerDayInKWh() {
return energyPerDayInKWh;
}
/**
* @param energyPerDayInKWh the energyPerDayInKWh to set
*/
public void setEnergyPerDayInKWh(final Double energyPerDayInKWh) {
this.energyPerDayInKWh = energyPerDayInKWh;
}
/**
* @return the energyPerMonthInEuro
*/
public Double getEnergyPerMonthInEuro() {
return energyPerMonthInEuro;
}
/**
* @param energyPerMonthInEuro the energyPerMonthInEuro to set
*/
public void setEnergyPerMonthInEuro(final Double energyPerMonthInEuro) {
this.energyPerMonthInEuro = energyPerMonthInEuro;
}
/**
* @return the energyPerMonthInKWh
*/
public Double getEnergyPerMonthInKWh() {
return energyPerMonthInKWh;
}
/**
* @param energyPerMonthInKWh the energyPerMonthInKWh to set
*/
public void setEnergyPerMonthInKWh(final Double energyPerMonthInKWh) {
this.energyPerMonthInKWh = energyPerMonthInKWh;
}
/**
* @return the frostWarning
*/
public Boolean getFrostWarning() {
return frostWarning;
}
/**
* @param frostWarning the frostWarning to set
*/
public void setFrostWarning(final Boolean frostWarning) {
this.frostWarning = frostWarning;
}
/**
* @return the humidity
*/
public Double getHumidity() {
return humidity;
}
/**
* @param humidity the humidity to set
*/
public void setHumidity(final Double humidity) {
this.humidity = humidity;
}
/**
* @return the isOpen
*/
public Boolean getIsOpen() {
return isOpen;
}
/**
* @param isOpen the isOpen to set
*/
public void setIsOpen(final Boolean isOpen) {
this.isOpen = isOpen;
}
/**
* @return the isSmokeAlarm
*/
public Boolean getIsSmokeAlarm() {
return isSmokeAlarm;
}
/**
* @param isSmokeAlarm the isSmokeAlarm to set
*/
public void setIsSmokeAlarm(final Boolean isSmokeAlarm) {
this.isSmokeAlarm = isSmokeAlarm;
}
/**
* @return the lastKeyPressCounter
*/
public Integer getLastKeyPressCounter() {
return lastKeyPressCounter;
}
/**
* @param lastKeyPressCounter the lastKeyPressCounter to set
*/
public void setLastKeyPressCounter(final Integer lastKeyPressCounter) {
this.lastKeyPressCounter = lastKeyPressCounter;
}
/**
* @return the lastPressedButtonIndex
*/
public Integer getLastPressedButtonIndex() {
return lastPressedButtonIndex;
}
/**
* @param lastPressedButtonIndex the lastPressedButtonIndex to set
*/
public void setLastPressedButtonIndex(final Integer lastPressedButtonIndex) {
this.lastPressedButtonIndex = lastPressedButtonIndex;
}
public String getLastKeyPressType() {
return lastKeyPressType;
}
public void setLastKeyPressType(final String lastKeyPressType) {
this.lastKeyPressType = lastKeyPressType;
}
/**
* @return the luminance
*/
public Double getLuminance() {
return luminance;
}
/**
* @param luminance the luminance to set
*/
public void setLuminance(final Double luminance) {
this.luminance = luminance;
}
/**
* @return the moldWarning
*/
public Boolean getMoldWarning() {
return moldWarning;
}
/**
* @param moldWarning the moldWarning to set
*/
public void setMoldWarning(final Boolean moldWarning) {
this.moldWarning = moldWarning;
}
/**
* @return the motionDetectedCount
*/
public Integer getMotionDetectedCount() {
return motionDetectedCount;
}
/**
* @param motionDetectedCount the motionDetectedCount to set
*/
public void setMotionDetectedCount(final Integer motionDetectedCount) {
this.motionDetectedCount = motionDetectedCount;
}
/**
* @return the powerConsumptionWatt
*/
public Double getPowerConsumptionWatt() {
return powerConsumptionWatt;
}
/**
* @param powerConsumptionWatt the powerConsumptionWatt to set
*/
public void setPowerConsumptionWatt(final Double powerConsumptionWatt) {
this.powerConsumptionWatt = powerConsumptionWatt;
}
/**
* @return the powerInWatt
*/
public Double getPowerInWatt() {
return powerInWatt;
}
/**
* @param powerInWatt the powerInWatt to set
*/
public void setPowerInWatt(final Double powerInWatt) {
this.powerInWatt = powerInWatt;
}
/**
* @return the temperature
*/
public Double getTemperature() {
return temperature;
}
/**
* @param temperature the temperature to set
*/
public void setTemperature(final Double temperature) {
this.temperature = temperature;
}
/**
* @return the totalEnergy
*/
public Double getTotalEnergy() {
return totalEnergy;
}
/**
* @param totalEnergy the totalEnergy to set
*/
public void setTotalEnergy(final Double totalEnergy) {
this.totalEnergy = totalEnergy;
}
/**
* @return the windowReductionActive
*/
public Boolean getWindowReductionActive() {
return windowReductionActive;
}
/**
* @param windowReductionActive the windowReductionActive to set
*/
public void setWindowReductionActive(final Boolean windowReductionActive) {
this.windowReductionActive = windowReductionActive;
}
/**
* @param cpuUsage the cpuUsage to set
*/
public void setCpuUsage(final Double cpuUsage) {
this.cpuUsage = cpuUsage;
}
/**
* @return the cpuUsage
*/
public Double getCpuUsage() {
return cpuUsage;
}
/**
* @param diskUsage the diskUsage to set
*/
public void setDiskUsage(final Double diskUsage) {
this.diskUsage = diskUsage;
}
/**
* @return the diskUsage
*/
public Double getDiskUsage() {
return diskUsage;
}
/**
* @param memoryUsage the memoryUsage to set
*/
public void setMemoryUsage(final Double memoryUsage) {
this.memoryUsage = memoryUsage;
}
/**
* @return the memoryUsage
*/
public Double getMemoryUsage() {
return memoryUsage;
}
}

View File

@ -1,155 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.event;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
/**
* Defines the {@link Event}, which is sent by the innogy websocket to inform the clients about changes.
*
* @author Oliver Kuhl - Initial contribution
*/
public class MessageEvent extends BaseEvent {
public static final String EVENT_PROPERTY_CONFIGURATION_VERSION = "ConfigurationVersion";
public static final String EVENT_PROPERTY_IS_CONNECTED = "IsConnected";
/**
* Reference to the associated entity (instance or metadata) for the given event. Always available.
*/
private String source;
/**
* The product (context) that generated the event.
*/
private String namespace;
/**
* Data for the event, The data container can contain any type of entity dependent on the event type. For example,
* the DeviceFound events contains the entire Device entity rather than selected properties.
* Optional.
*/
private Message data;
/**
* @return the link to the source
*/
public String getSource() {
return source;
}
/**
* @param source the link to the source to set
*/
public void setSource(String source) {
this.source = source;
}
/**
* @return the namespace
*/
public String getNamespace() {
return namespace;
}
/**
* @param namespace the namespace to set
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* @return the dataList
*/
public Message getData() {
return data;
}
/**
* @param message the message to set
*/
public void setData(Message data) {
this.data = data;
}
public Message getMessage() {
return data;
}
/**
* Returns the id of the link or null, if there is no link or the link does not have an id.
*
* @return String the id of the link or null
*/
public String getSourceId() {
final String linkType = getSourceLinkType();
if (linkType != null && !Link.LINK_TYPE_UNKNOWN.equals(linkType) && !Link.LINK_TYPE_SHC.equals(linkType)) {
if (source != null) {
return source.replace(linkType, "");
}
}
return null;
}
/**
* Returns the Type of the {@link Link} in the {@link Event}.
*
* @return
*/
public String getSourceLinkType() {
if (source != null) {
return Link.getLinkType(source);
}
return null;
}
/**
* Returns true, if the {@link Link} points to a {@link Capability}.
*
* @return
*/
public Boolean isLinkedtoCapability() {
return source == null ? false : Link.isTypeCapability(source);
}
/**
* Returns true, if the {@link Link} points to a {@link Device}.
*
* @return
*/
public Boolean isLinkedtoDevice() {
return source == null ? false : Link.isTypeDevice(source);
}
/**
* Returns true, if the {@link Link} points to a {@link Message}.
*
* @return
*/
public Boolean isLinkedtoMessage() {
return source == null ? false : Link.isTypeMessage(source);
}
/**
* Returns true, if the {@link Link} points to the SHC {@link Device}.
*
* @return
*/
public Boolean isLinkedtoSHC() {
return source == null ? false : Link.isTypeSHC(source);
}
}

View File

@ -1,112 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.link;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
/**
* Defines the data structure for a {@link Link}. This is the basic component used to link different data types in the
* innogy API.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Link {
public static final String LINK_TYPE_CAPABILITY = "/capability/";
public static final String LINK_TYPE_DEVICE = "/device/";
public static final String LINK_TYPE_MESSAGE = "/message/";
public static final String LINK_TYPE_SHC = "/desc/device/SHC.RWE/";
public static final String LINK_TYPE_UNKNOWN = "unknown";
/**
* Returns the Type of the {@link Link}.
*
* @return {@link #LINK_TYPE_CAPABILITY},{@link #LINK_TYPE_DEVICE}, {@link #LINK_TYPE_MESSAGE},
* {@link #LINK_TYPE_SHC} or {@link #LINK_TYPE_UNKNOWN}
*/
public static String getLinkType(String link) {
if (link.startsWith(LINK_TYPE_CAPABILITY)) {
return LINK_TYPE_CAPABILITY;
} else if (link.startsWith(LINK_TYPE_DEVICE)) {
return LINK_TYPE_DEVICE;
} else if (link.startsWith(LINK_TYPE_MESSAGE)) {
return LINK_TYPE_MESSAGE;
} else if (link.startsWith(LINK_TYPE_SHC)) {
return LINK_TYPE_SHC;
} else {
return LINK_TYPE_UNKNOWN;
}
}
/**
* Returns the id of the {@link Link} or null, if the link does not have an id or even no value.
*
* @return String the id of the link or null
*/
public static String getId(String link) {
if (link != null) {
final String linkType = getLinkType(link);
if (linkType != null && !Link.LINK_TYPE_UNKNOWN.equals(linkType) && !Link.LINK_TYPE_SHC.equals(linkType)) {
return link.replace(linkType, "");
}
}
return null;
}
/**
* Returns true, if the {@link Link} points to a {@link Capability}.
*
* @return
*/
public static boolean isTypeCapability(String link) {
return LINK_TYPE_CAPABILITY.equals(Link.getLinkType(link));
}
/**
* Returns true, if the {@link Link} points to a {@link Device}.
*
* @return
*/
public static boolean isTypeDevice(String link) {
return LINK_TYPE_DEVICE.equals(Link.getLinkType(link));
}
/**
* Returns true, if the {@link Link} points to a {@link Message}.
*
* @return
*/
public static boolean isTypeMessage(String link) {
return LINK_TYPE_MESSAGE.equals(Link.getLinkType(link));
}
/**
* Returns true, if the {@link Link} points to a SHC.
*
* @return
*/
public static boolean isTypeSHC(String link) {
return LINK_TYPE_SHC.equals(Link.getLinkType(link));
}
/**
* Returns true, if the {@link Link} points to something unknown.
*
* @return
*/
public static boolean isTypeUnknown(String link) {
return LINK_TYPE_UNKNOWN.equals(Link.getLinkType(link));
}
}

View File

@ -1,73 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.location;
/**
* Defines a {@link Location} structure.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Location {
/**
* Identifier of the location must be unique.
*/
private String id;
/**
* Configuration properties of the {@link Location}.
*/
private LocationConfig config;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the config
*/
public LocationConfig getConfig() {
return config;
}
/**
* @param config the config to set
*/
public void setConfig(LocationConfig config) {
this.config = config;
}
/**
* @return the location name
*/
public String getName() {
return getConfig().getName();
}
/**
* @return the location type
*/
public String getType() {
return getConfig().getType();
}
}

View File

@ -1,58 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.location;
/**
* Defines the structure of the configuration of a {@link Location}.
*
* @author Oliver Kuhl - Initial contribution
*/
public class LocationConfig {
/**
* Name of the {@link Location}
*/
private String name;
/**
* Type of the {@link Location}
*/
private String type;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
}

View File

@ -1,253 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.message;
import java.util.List;
import com.google.gson.annotations.SerializedName;
/**
* Defines the structure of a {@link Message}. Messages are part of the innogy system and besides other things are used
* to raise battery warnings.
*
* @author Oliver Kuhl - Initial contribution
*/
public class Message {
/** device related messages */
public static final String TYPE_DEVICE_UNREACHABLE = "DeviceUnreachable";
public static final String TYPE_DEVICE_ACTIVITY_LOGGING_ENABLED = "DeviceActivityLoggingEnabled";
public static final String TYPE_DEVICE_FACTORY_RESET = "DeviceFactoryReset";
public static final String TYPE_DEVICE_LOW_BATTERY = "DeviceLowBattery";
public static final String TYPE_DEVICE_MOLD = "DeviceMold";
public static final String TYPE_DEVICE_LOW_RF_QUALITY = "DeviceLowRfQuality";
public static final String TYPE_DEVICE_FREEZE = "DeviceFreeze";
public static final String TYPE_SH_DEVICE_UPDATE_AVAILABLE = "ShDeviceUpdateAvailable";
public static final String TYPE_SH_DEVICE_UPDATE_FAILED = "ShDeviceUpdateFailed";
/** user related messages */
public static final String TYPE_USER_EMAIL_ADDRESS_NOT_VALIDATED = "UserEmailAddressNotValidated";
public static final String TYPE_USER_INVITATION_ACCEPTED = "UserInvitiationAccepted";
public static final String TYPE_USER_FOREIGN_DELETION = "UserForeignDeletion";
/** SHC related messages */
public static final String TYPE_SHC_REMOTE_REBOOTED = "ShcRemoteRebooted";
public static final String TYPE_SHC_UPDATE_COMPLETED = "ShcUpdateCompleted";
public static final String TYPE_SHC_UPDATE_CANCELED = "ShcUpdateCanceled";
public static final String TYPE_SHC_DEFERRABLE_UPDATE = "ShcDeferrableUpdate";
public static final String TYPE_SHC_REAL_TIME_CLOCK_LOST = "ShcRealTimeClockLost";
public static final String TYPE_SHC_ONLINE_SWITCH_IS_OFF = "ShcOnlineSwitchIsOff";
public static final String TYPE_SHC_MANDATORY_UPDATE = "ShcMandatoryUpdate";
public static final String TYPE_SHC_NO_CONNECTION_TO_BACKEND = "ShcNoConnectionToBackend";
/** app related messages */
public static final String TYPE_APP_ADDED_TO_SHC = "AppAddedToShc";
public static final String TYPE_APP_UPDATED_ON_SHC = "AppUpdatedOnShc";
public static final String TYPE_APP_TOKEN_SYNC_FAILURE = "AppTokenSyncFailure";
public static final String TYPE_APP_DOWNLOAD_FAILED = "AppDownloadFailed";
public static final String TYPE_APPLICATION_LOADING_ERROR = "ApplicationLoadingError";
public static final String TYPE_APPLICATION_EXPIRED = "ApplicationExpired";
public static final String TYPE_INVALID_CUSTOM_APP = "InvalidCustomApp";
public static final String TYPE_CUSTOM_APP_WAS_UPGRADED = "CustomAppWasUpgraded";
public static final String TYPE_CUSTOM_APP_UPGRADE_FAILED = "CustomAppUpgradeFailed";
/** others */
public static final String TYPE_BID_COS_INCLUSION_TIMEOUT = "BidCosInclusionTimeout";
public static final String TYPE_ADDRESS_COLLISION = "AddressCollision";
public static final String TYPE_BACKEND_CONFIG_OUT_OF_SYNC = "BackendConfigOutOfSync";
public static final String TYPE_SMOKE_DETECTED = "SmokeDetected";
public static final String TYPE_LEMON_BEAT_DONGLE_INITIALIZATION_FAILED = "LemonBeatDongleInitializationFailed";
public static final String TYPE_USB_DEVICE_UNPLUGGED = "USBDeviceUnplugged";
public static final String TYPE_INVALID_AES_KEY = "InvalidAesKey";
public static final String TYPE_MEMORY_SHORTAGE = "MemoryShortage";
public static final String TYPE_LOG_LEVEL_CHANGED = "LogLevelChanged";
public static final String TYPE_RULE_EXCEPTION_FAILED = "RuleExecutionFailed";
public static final String TYPE_SEND_MESSAGE_LIMIT_EXCEEDED = "SendMessageLimitExceeded";
public static final String TYPE_CONFIG_FIX_ENTITY_DELETED = "ConfigFixEntityDeleted";
/**
* Identifier of the message must be unique.
*/
private String id;
/**
* Specifies the type of the message.
*/
private String type;
/**
* Defines whether the message has been viewed by a user.
*/
@SerializedName("read")
private boolean isRead;
/**
* Defines whether it is an alert or a message, default is message.
*/
@SerializedName("class")
private String messageClass;
/**
* Timestamp when the message was created.
*
* Optional.
*/
private String timestamp;
/**
* Reference to the underlying devices, which the message relates to.
*
* Optional.
*/
private List<String> devices;
/**
* Container for all parameters of the message. The parameters are contained in Property entities.
*
* Optional.
*/
private MessageProperties properties;
/**
* The product (context) that generated the message.
*/
private String namespace;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the messageClass
*/
public String getMessageClass() {
return messageClass;
}
/**
* @param messageClass the messageClass to set
*/
public void setMessageClass(String messageClass) {
this.messageClass = messageClass;
}
/**
* @return the timestamp
*/
public String getTimestamp() {
return timestamp;
}
/**
* @param timestamp the timestamp to set
*/
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
/**
* @return the isRead
*/
public boolean isRead() {
return isRead;
}
/**
* @param isRead the isRead to set
*/
public void setRead(boolean isRead) {
this.isRead = isRead;
}
/**
* @return the devices
*/
public List<String> getDevices() {
return devices;
}
/**
* @param devices the devices to set
*/
public void setDevices(List<String> devices) {
this.devices = devices;
}
/**
* @return the dataPropertyList
*/
public MessageProperties getProperties() {
return properties;
}
/**
* @param properties the dataPropertyList to set
*/
public void setProperties(MessageProperties properties) {
this.properties = properties;
}
/**
* @return the namespace
*/
public String getNamespace() {
return namespace;
}
/**
* @param namespace the namespace to set
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* Returns true, if the message is of type "DeviceUnreachable".
*
* @return
*/
public boolean isTypeDeviceUnreachable() {
return TYPE_DEVICE_UNREACHABLE.equals(type);
}
/**
* Returns true, if the message is of type "DeviceLowBattery".
*
* @return
*/
public boolean isTypeDeviceLowBattery() {
return TYPE_DEVICE_LOW_BATTERY.equals(type);
}
}

View File

@ -1,78 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.message;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class MessageProperties {
/**
* Name of the referenced {@link Device}
*/
private String deviceName;
/**
* Serialnumber of the referenced {@link Device}
*/
private String serialNumber;
/**
* Locationname of the referenced {@link Device}
*/
private String locationName;
/**
* @return the deviceName
*/
public String getDeviceName() {
return deviceName;
}
/**
* @param deviceName the deviceName to set
*/
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
/**
* @return the serialNumber
*/
public String getSerialNumber() {
return serialNumber;
}
/**
* @param serialNumber the serialNumber to set
*/
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
/**
* @return the locationName
*/
public String getLocationName() {
return locationName;
}
/**
* @param locationName the locationName to set
*/
public void setLocationName(String locationName) {
this.locationName = locationName;
}
}

View File

@ -1,35 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.state;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public abstract class BaseState {
private String lastChanged;
/**
* @return the lastChanged
*/
public String getLastChanged() {
return lastChanged;
}
/**
* @param lastChanged the lastChanged to set
*/
public void setLastChanged(String lastChanged) {
this.lastChanged = lastChanged;
}
}

View File

@ -1,35 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.state;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class BooleanState extends BaseState {
private Boolean value;
/**
* @return the value
*/
public Boolean getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Boolean value) {
this.value = value;
}
}

View File

@ -1,35 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.state;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class DateTimeState extends BaseState {
private String value;
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
}

View File

@ -1,35 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.state;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class DoubleState extends BaseState {
private Double value;
/**
* @return the value
*/
public Double getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Double value) {
this.value = value;
}
}

View File

@ -1,35 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.state;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class IntegerState extends BaseState {
private Integer value;
/**
* @return the value
*/
public Integer getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Integer value) {
this.value = value;
}
}

View File

@ -1,35 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.state;
/**
* @author Oliver Kuhl - Initial contribution
*
*/
public class StringState extends BaseState {
private String value;
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
}

View File

@ -1,33 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.exception;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Thrown, when the innogy SmartHome Client API returns an unknown error.
*
* @author Oliver Kuhl - Initial contribution
*/
@NonNullByDefault
public class ApiException extends Exception {
private static final long serialVersionUID = 1L;
public ApiException() {
}
public ApiException(String message) {
super(message);
}
}

View File

@ -1,34 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.exception;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Thrown, if an authentication error is given.
*
* @author Hilbrand Bouwkamp - Initial contribution
*
*/
@NonNullByDefault
public class AuthenticationException extends Exception {
private static final long serialVersionUID = 1L;
public AuthenticationException() {
}
public AuthenticationException(String message) {
super(message);
}
}

View File

@ -1,36 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.exception;
import java.io.IOException;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Thrown, if the innogy SmartHome controller (SHC) is offline.
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public class ControllerOfflineException extends IOException {
private static final long serialVersionUID = 1L;
public ControllerOfflineException() {
}
public ControllerOfflineException(String message) {
super(message);
}
}

View File

@ -1,34 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.exception;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Thrown, if an action was called with invalid parameters.
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public class InvalidActionTriggeredException extends ApiException {
private static final long serialVersionUID = 1L;
public InvalidActionTriggeredException() {
}
public InvalidActionTriggeredException(String message) {
super(message);
}
}

View File

@ -1,34 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.exception;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Thrown, when the authorization fails with a "remote access not allowed" error.
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public class RemoteAccessNotAllowedException extends ApiException {
private static final long serialVersionUID = 1L;
public RemoteAccessNotAllowedException() {
}
public RemoteAccessNotAllowedException(String message) {
super(message);
}
}

View File

@ -1,31 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.exception;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Thrown, if the innogy service is unavailable (HTTP response 503).
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public class ServiceUnavailableException extends ApiException {
private static final long serialVersionUID = -9148687420729079329L;
public ServiceUnavailableException(String message) {
super(message);
}
}

View File

@ -1,37 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.exception;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Thrown, when a session already exists while initializing a new session.
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public class SessionExistsException extends ApiException {
private static final long serialVersionUID = 1L;
public SessionExistsException() {
}
/**
* @param message
*/
public SessionExistsException(String message) {
super(message);
}
}

View File

@ -1,34 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.exception;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Thrown, if the session is not initialized or disconnected.
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public class SessionNotFoundException extends ApiException {
private static final long serialVersionUID = 1L;
public SessionNotFoundException() {
}
public SessionNotFoundException(String message) {
super(message);
}
}

View File

@ -1,78 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.discovery;
import static org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants.THING_TYPE_BRIDGE;
import java.util.Collections;
import java.util.Set;
import javax.jmdns.ServiceInfo;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link InnogyBridgeDiscoveryParticipant} is responsible for discovering
* the innogy SmartHome bridge.
*
* @author Oliver Kuhl - Initial contribution
*/
@Component(service = MDNSDiscoveryParticipant.class, configurationPid = "mdnsdiscovery.innogysmarthome")
@NonNullByDefault
public class InnogyBridgeDiscoveryParticipant implements MDNSDiscoveryParticipant {
private final Logger logger = LoggerFactory.getLogger(InnogyBridgeDiscoveryParticipant.class);
@Override
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
return Collections.singleton(THING_TYPE_BRIDGE);
}
@Override
public String getServiceType() {
return "_http._tcp.local.";
}
@Override
public @Nullable DiscoveryResult createResult(ServiceInfo service) {
ThingUID uid = getThingUID(service);
if (uid != null) {
DiscoveryResult result = DiscoveryResultBuilder.create(uid)
.withLabel("innogy SmartHome Controller (" + service.getName() + ")").build();
return result;
}
return null;
}
@Override
public @Nullable ThingUID getThingUID(@Nullable ServiceInfo service) {
if (service != null) {
String serviceName = service.getName();
if (serviceName.startsWith("SMARTHOME")) {
logger.debug("Found innogy bridge via mDNS:{} v4:{} v6:{}", service.getName(),
service.getInet4Addresses(), service.getInet6Addresses());
return new ThingUID(THING_TYPE_BRIDGE, serviceName);
}
}
return null;
}
}

View File

@ -1,164 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.discovery;
import static org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.handler.InnogyBridgeHandler;
import org.openhab.binding.innogysmarthome.internal.handler.InnogyDeviceHandler;
import org.openhab.binding.innogysmarthome.internal.listener.DeviceStatusListener;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.config.discovery.DiscoveryService;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link InnogyDeviceDiscoveryService} is responsible for discovering new devices.
*
* @author Oliver Kuhl - Initial contribution
*/
@NonNullByDefault
public class InnogyDeviceDiscoveryService extends AbstractDiscoveryService
implements DiscoveryService, ThingHandlerService {
private static final int SEARCH_TIME_SECONDS = 60;
private final Logger logger = LoggerFactory.getLogger(InnogyDeviceDiscoveryService.class);
private @Nullable InnogyBridgeHandler bridgeHandler;
/**
* Construct an {@link InnogyDeviceDiscoveryService}.
*/
public InnogyDeviceDiscoveryService() {
super(SEARCH_TIME_SECONDS);
}
/**
* Deactivates the {@link InnogyDeviceDiscoveryService} by unregistering it as {@link DeviceStatusListener} on the
* {@link InnogyBridgeHandler}. Older discovery results will be removed.
*
* @see org.openhab.core.config.discovery.AbstractDiscoveryService#deactivate()
*/
@Override
public void deactivate() {
removeOlderResults(new Date().getTime());
}
@Override
public Set<ThingTypeUID> getSupportedThingTypes() {
return InnogyDeviceHandler.SUPPORTED_THING_TYPES;
}
@Override
protected void startScan() {
logger.debug("SCAN for new innogy devices started...");
if (bridgeHandler != null) {
for (final Device d : bridgeHandler.loadDevices()) {
onDeviceAdded(d);
}
}
}
@Override
protected synchronized void stopScan() {
super.stopScan();
removeOlderResults(getTimestampOfLastScan());
}
public void onDeviceAdded(Device device) {
if (bridgeHandler == null) {
return;
}
final ThingUID bridgeUID = bridgeHandler.getThing().getUID();
final ThingUID thingUID = getThingUID(bridgeUID, device);
final ThingTypeUID thingTypeUID = getThingTypeUID(device);
if (thingUID != null && thingTypeUID != null) {
String name = device.getConfig().getName();
if (name.isEmpty()) {
name = device.getSerialnumber();
}
final Map<String, Object> properties = new HashMap<>();
properties.put(PROPERTY_ID, device.getId());
final String label;
if (device.hasLocation()) {
label = device.getType() + ": " + name + " (" + device.getLocation().getName() + ")";
} else {
label = device.getType() + ": " + name;
}
final DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID)
.withProperties(properties).withBridge(bridgeUID).withLabel(label).build();
thingDiscovered(discoveryResult);
} else {
logger.debug("Discovered unsupported device of type '{}' and name '{}' with id {}", device.getType(),
device.getConfig().getName(), device.getId());
}
}
/**
* Returns the {@link ThingUID} for the given {@link Device} or null, if the device type is not available.
*
* @param device
* @return
*/
private @Nullable ThingUID getThingUID(ThingUID bridgeUID, Device device) {
final ThingTypeUID thingTypeUID = getThingTypeUID(device);
if (thingTypeUID != null && getSupportedThingTypes().contains(thingTypeUID)) {
return new ThingUID(thingTypeUID, bridgeUID, device.getId());
}
return null;
}
/**
* Returns a {@link ThingTypeUID} for the given {@link Device} or null, if the device type is not available.
*
* @param device
* @return
*/
private @Nullable ThingTypeUID getThingTypeUID(Device device) {
final String thingTypeId = device.getType();
return thingTypeId != null ? new ThingTypeUID(BINDING_ID, thingTypeId) : null;
}
@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof InnogyBridgeHandler) {
bridgeHandler = (InnogyBridgeHandler) handler;
}
}
@Override
public @Nullable ThingHandler getThingHandler() {
return bridgeHandler;
}
}

View File

@ -1,32 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.handler;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants;
/**
*
* @author Hilbrand Bouwkamp - Initial contribution
*/
@NonNullByDefault
public class InnogyBridgeConfiguration {
public String brand = InnogyBindingConstants.DEFAULT_BRAND;
public String authcode = "";
public int websocketidletimeout = 900;
public String clientId = InnogyBindingConstants.CLIENT_ID_INNOGY_SMARTHOME;
public String clientSecret = InnogyBindingConstants.CLIENT_SECRET_INNOGY_SMARTHOME;
public String redirectUrl = InnogyBindingConstants.REDIRECT_URL_INNOGY_SMARTHOME;
}

View File

@ -1,991 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.handler;
import static org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants.*;
import static org.openhab.binding.innogysmarthome.internal.client.Constants.API_URL_TOKEN;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.innogysmarthome.internal.InnogyWebSocket;
import org.openhab.binding.innogysmarthome.internal.client.InnogyClient;
import org.openhab.binding.innogysmarthome.internal.client.entity.action.ShutterAction;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.DeviceConfig;
import org.openhab.binding.innogysmarthome.internal.client.entity.event.BaseEvent;
import org.openhab.binding.innogysmarthome.internal.client.entity.event.Event;
import org.openhab.binding.innogysmarthome.internal.client.entity.event.MessageEvent;
import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
import org.openhab.binding.innogysmarthome.internal.client.exception.ApiException;
import org.openhab.binding.innogysmarthome.internal.client.exception.AuthenticationException;
import org.openhab.binding.innogysmarthome.internal.client.exception.ControllerOfflineException;
import org.openhab.binding.innogysmarthome.internal.client.exception.InvalidActionTriggeredException;
import org.openhab.binding.innogysmarthome.internal.client.exception.RemoteAccessNotAllowedException;
import org.openhab.binding.innogysmarthome.internal.client.exception.SessionExistsException;
import org.openhab.binding.innogysmarthome.internal.discovery.InnogyDeviceDiscoveryService;
import org.openhab.binding.innogysmarthome.internal.listener.DeviceStatusListener;
import org.openhab.binding.innogysmarthome.internal.listener.EventListener;
import org.openhab.binding.innogysmarthome.internal.manager.DeviceStructureManager;
import org.openhab.binding.innogysmarthome.internal.manager.FullDeviceManager;
import org.openhab.binding.innogysmarthome.internal.util.ExceptionUtils;
import org.openhab.core.auth.client.oauth2.AccessTokenRefreshListener;
import org.openhab.core.auth.client.oauth2.AccessTokenResponse;
import org.openhab.core.auth.client.oauth2.OAuthClientService;
import org.openhab.core.auth.client.oauth2.OAuthException;
import org.openhab.core.auth.client.oauth2.OAuthFactory;
import org.openhab.core.auth.client.oauth2.OAuthResponseException;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseBridgeHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.openhab.core.types.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
/**
* The {@link InnogyBridgeHandler} is responsible for handling the innogy SmartHome controller including the connection
* to the innogy backend for all communications with the innogy {@link Device}s.
* <p/>
* It implements the {@link AccessTokenRefreshListener} to handle updates of the oauth2 tokens and the
* {@link EventListener} to handle {@link Event}s, that are received by the {@link InnogyWebSocket}.
* <p/>
* The {@link Device}s are organized by the {@link DeviceStructureManager}, which is also responsible for the connection
* to the innogy SmartHome webservice via the {@link InnogyClient}.
*
* @author Oliver Kuhl - Initial contribution
* @author Hilbrand Bouwkamp - Refactored to use openHAB http and oauth2 libraries
*/
@NonNullByDefault
public class InnogyBridgeHandler extends BaseBridgeHandler
implements AccessTokenRefreshListener, EventListener, DeviceStatusListener {
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
private final Logger logger = LoggerFactory.getLogger(InnogyBridgeHandler.class);
private final Gson gson = new Gson();
private final Object lock = new Object();
private final Set<DeviceStatusListener> deviceStatusListeners = new CopyOnWriteArraySet<>();
private final OAuthFactory oAuthFactory;
private final HttpClient httpClient;
private @Nullable InnogyClient client;
private @Nullable InnogyWebSocket webSocket;
private @Nullable DeviceStructureManager deviceStructMan;
private @Nullable String bridgeId;
private @Nullable ScheduledFuture<?> reinitJob;
private @NonNullByDefault({}) InnogyBridgeConfiguration bridgeConfiguration;
private @Nullable OAuthClientService oAuthService;
/**
* Constructs a new {@link InnogyBridgeHandler}.
*
* @param bridge Bridge thing to be used by this handler
* @param oAuthFactory Factory class to get OAuth2 service
* @param httpClient httpclient instance
*/
public InnogyBridgeHandler(final Bridge bridge, final OAuthFactory oAuthFactory, final HttpClient httpClient) {
super(bridge);
this.oAuthFactory = oAuthFactory;
this.httpClient = httpClient;
}
@Override
public void handleCommand(final ChannelUID channelUID, final Command command) {
// not needed
}
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(InnogyDeviceDiscoveryService.class);
}
@Override
public void initialize() {
logger.debug("Initializing innogy SmartHome BridgeHandler...");
logger.warn(
"The innogy SmartHome binding is deprecated and discontinued and will be removed with the next release of OpenHAB! Please migrate to the newer LIVISI SmartHome binding (which uses a local API which requires no backend servers and no internet connection).");
final InnogyBridgeConfiguration bridgeConfiguration = getConfigAs(InnogyBridgeConfiguration.class);
if (checkConfig(bridgeConfiguration)) {
this.bridgeConfiguration = bridgeConfiguration;
getScheduler().execute(this::initializeClient);
}
}
/**
* Checks bridge configuration. If configuration is valid returns true.
*
* @return true if the configuration if valid
*/
private boolean checkConfig(final InnogyBridgeConfiguration bridgeConfiguration) {
if (BRAND_INNOGY_SMARTHOME.equals(bridgeConfiguration.brand)) {
return true;
} else {
logger.debug("Invalid brand '{}'. Make sure to select a brand in the SHC thing configuration!",
bridgeConfiguration.brand);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Invalid brand '"
+ bridgeConfiguration.brand + "'. Make sure to select a brand in the SHC thing configuration!");
return false;
}
}
/**
* Initializes the services and InnogyClient.
*/
private void initializeClient() {
final OAuthClientService oAuthService = oAuthFactory.createOAuthClientService(thing.getUID().getAsString(),
API_URL_TOKEN, API_URL_TOKEN, bridgeConfiguration.clientId, bridgeConfiguration.clientSecret, null,
true);
this.oAuthService = oAuthService;
if (checkOnAuthCode()) {
final InnogyClient localClient = createInnogyClient(oAuthService, httpClient);
client = localClient;
deviceStructMan = new DeviceStructureManager(createFullDeviceManager(localClient));
oAuthService.addAccessTokenRefreshListener(this);
registerDeviceStatusListener(InnogyBridgeHandler.this);
scheduleRestartClient(false);
}
}
/**
* Fetches the OAuth2 tokens from innogy SmartHome service if the auth code is set in the configuration and if
* successful removes the auth code. Returns true if the auth code was not set or if the authcode was successfully
* used to get a new refresh and access token.
*
* @return true if success
*/
private boolean checkOnAuthCode() {
if (!bridgeConfiguration.authcode.isBlank()) {
logger.debug("Trying to get access and refresh tokens");
try {
oAuthService.getAccessTokenResponseByAuthorizationCode(bridgeConfiguration.authcode,
bridgeConfiguration.redirectUrl);
final Configuration configuration = editConfiguration();
configuration.put(CONFIG_AUTH_CODE, "");
updateConfiguration(configuration);
} catch (IOException | OAuthException | OAuthResponseException e) {
logger.debug("Error fetching access tokens. Invalid authcode! Please generate a new one. Detail: {}",
e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Cannot connect to innogy SmartHome service. Please set auth-code!");
return false;
}
}
return true;
}
/**
* Initializes the client and connects to the innogy SmartHome service via Client API. Based on the provided
* {@Link Configuration} while constructing {@Link InnogyClient}, the given oauth2 access and refresh tokens are
* used or - if not yet available - new tokens are fetched from the service using the provided auth code.
*/
private void startClient() {
try {
logger.debug("Initializing innogy SmartHome client...");
final InnogyClient localClient = this.client;
if (localClient != null) {
localClient.refreshStatus();
}
} catch (AuthenticationException | ApiException | IOException e) {
if (handleClientException(e)) {
// If exception could not be handled properly it's no use to continue so we won't continue start
logger.debug("Error initializing innogy SmartHome client.", e);
return;
}
}
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
try {
deviceStructMan.refreshDevices();
} catch (IOException | ApiException | AuthenticationException e) {
if (handleClientException(e)) {
// If exception could not be handled properly it's no use to continue so we won't continue start
logger.debug("Error starting device structure manager.", e);
return;
}
}
Device bridgeDevice = deviceStructMan.getBridgeDevice();
if (bridgeDevice == null) {
logger.debug("Failed to get bridge device, re-scheduling startClient.");
scheduleRestartClient(true);
return;
}
setBridgeProperties(bridgeDevice);
bridgeId = bridgeDevice.getId();
startWebsocket();
}
/**
* Start the websocket connection for receiving permanent update {@link Event}s from the innogy API.
*/
private void startWebsocket() {
try {
InnogyWebSocket localWebSocket = createWebSocket();
if (this.webSocket != null && this.webSocket.isRunning()) {
this.webSocket.stop();
this.webSocket = null;
}
logger.debug("Starting innogy websocket.");
this.webSocket = localWebSocket;
localWebSocket.start();
updateStatus(ThingStatus.ONLINE);
} catch (final Exception e) { // Catch Exception because websocket start throws Exception
logger.warn("Error starting websocket.", e);
handleClientException(e);
}
}
InnogyWebSocket createWebSocket() throws IOException, AuthenticationException {
final AccessTokenResponse accessTokenResponse = client.getAccessTokenResponse();
final String webSocketUrl = WEBSOCKET_API_URL_EVENTS.replace("{token}", accessTokenResponse.getAccessToken());
logger.debug("WebSocket URL: {}...{}", webSocketUrl.substring(0, 70),
webSocketUrl.substring(webSocketUrl.length() - 10));
return new InnogyWebSocket(this, URI.create(webSocketUrl), bridgeConfiguration.websocketidletimeout * 1000);
}
@Override
public void onAccessTokenResponse(final AccessTokenResponse credential) {
scheduleRestartClient(true);
}
/**
* Schedules a re-initialization in the given future.
*
* @param delayed when it is scheduled delayed, it starts with a delay of
* {@link org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants#REINITIALIZE_DELAY_SECONDS}
* seconds,
* otherwise it starts directly
*/
private synchronized void scheduleRestartClient(final boolean delayed) {
@Nullable
final ScheduledFuture<?> localReinitJob = reinitJob;
if (localReinitJob != null && isAlreadyScheduled(localReinitJob)) {
logger.debug("Scheduling reinitialize - ignored: already triggered in {} seconds.",
localReinitJob.getDelay(TimeUnit.SECONDS));
return;
}
final long seconds = delayed ? REINITIALIZE_DELAY_SECONDS : 0;
logger.debug("Scheduling reinitialize in {} seconds.", seconds);
reinitJob = getScheduler().schedule(this::startClient, seconds, TimeUnit.SECONDS);
}
private void setBridgeProperties(final Device bridgeDevice) {
final DeviceConfig config = bridgeDevice.getConfig();
logger.debug("Setting Bridge Device Properties for Bridge of type '{}' with ID '{}'", config.getName(),
bridgeDevice.getId());
final Map<String, String> properties = editProperties();
setPropertyIfPresent(Thing.PROPERTY_VENDOR, bridgeDevice.getManufacturer(), properties);
setPropertyIfPresent(Thing.PROPERTY_SERIAL_NUMBER, bridgeDevice.getSerialnumber(), properties);
setPropertyIfPresent(PROPERTY_ID, bridgeDevice.getId(), properties);
setPropertyIfPresent(Thing.PROPERTY_FIRMWARE_VERSION, config.getFirmwareVersion(), properties);
setPropertyIfPresent(Thing.PROPERTY_HARDWARE_VERSION, config.getHardwareVersion(), properties);
setPropertyIfPresent(PROPERTY_SOFTWARE_VERSION, config.getSoftwareVersion(), properties);
setPropertyIfPresent(PROPERTY_IP_ADDRESS, config.getIPAddress(), properties);
setPropertyIfPresent(Thing.PROPERTY_MAC_ADDRESS, config.getMACAddress(), properties);
if (config.getRegistrationTime() != null) {
properties.put(PROPERTY_REGISTRATION_TIME,
config.getRegistrationTime().format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)));
}
setPropertyIfPresent(PROPERTY_CONFIGURATION_STATE, config.getConfigurationState(), properties);
setPropertyIfPresent(PROPERTY_SHC_TYPE, bridgeDevice.getType(), properties);
setPropertyIfPresent(PROPERTY_TIME_ZONE, config.getTimeZone(), properties);
setPropertyIfPresent(PROPERTY_PROTOCOL_ID, config.getProtocolId(), properties);
setPropertyIfPresent(PROPERTY_GEOLOCATION, config.getGeoLocation(), properties);
setPropertyIfPresent(PROPERTY_CURRENT_UTC_OFFSET, config.getCurrentUTCOffset(), properties);
setPropertyIfPresent(PROPERTY_BACKEND_CONNECTION_MONITORED, config.getBackendConnectionMonitored(), properties);
setPropertyIfPresent(PROPERTY_RFCOM_FAILURE_NOTIFICATION, config.getRFCommFailureNotification(), properties);
updateProperties(properties);
}
private void setPropertyIfPresent(final String key, final @Nullable Object data,
final Map<String, String> properties) {
if (data != null) {
properties.put(key, data instanceof String ? (String) data : data.toString());
}
}
@Override
public void dispose() {
logger.debug("Disposing innogy SmartHome bridge handler '{}'", getThing().getUID().getId());
unregisterDeviceStatusListener(this);
cancelReinitJob();
if (webSocket != null) {
webSocket.stop();
webSocket = null;
}
client = null;
deviceStructMan = null;
super.dispose();
logger.debug("innogy SmartHome bridge handler shut down.");
}
private synchronized void cancelReinitJob() {
ScheduledFuture<?> reinitJob = this.reinitJob;
if (reinitJob != null) {
reinitJob.cancel(true);
this.reinitJob = null;
}
}
/**
* Registers a {@link DeviceStatusListener}.
*
* @param deviceStatusListener
* @return true, if successful
*/
public boolean registerDeviceStatusListener(final DeviceStatusListener deviceStatusListener) {
return deviceStatusListeners.add(deviceStatusListener);
}
/**
* Unregisters a {@link DeviceStatusListener}.
*
* @param deviceStatusListener
* @return true, if successful
*/
public boolean unregisterDeviceStatusListener(final DeviceStatusListener deviceStatusListener) {
return deviceStatusListeners.remove(deviceStatusListener);
}
/**
* Loads a Collection of {@link Device}s from the bridge and returns them.
*
* @return a Collection of {@link Device}s
*/
public Collection<Device> loadDevices() {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
final Collection<Device> devices;
if (deviceStructMan == null) {
devices = Collections.emptyList();
} else {
devices = deviceStructMan.getDeviceList();
}
return devices;
}
/**
* Returns the {@link Device} with the given deviceId.
*
* @param deviceId
* @return {@link Device} or null, if it does not exist or no {@link DeviceStructureManager} is available
*/
public @Nullable Device getDeviceById(final String deviceId) {
if (deviceStructMan != null) {
return deviceStructMan.getDeviceById(deviceId);
}
return null;
}
/**
* Refreshes the {@link Device} with the given id, by reloading the full device from the innogy webservice.
*
* @param deviceId
* @return the {@link Device} or null, if it does not exist or no {@link DeviceStructureManager} is available
*/
public @Nullable Device refreshDevice(final String deviceId) {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return null;
}
Device device = null;
try {
deviceStructMan.refreshDevice(deviceId);
device = deviceStructMan.getDeviceById(deviceId);
} catch (IOException | ApiException | AuthenticationException e) {
handleClientException(e);
}
return device;
}
@Override
public void onDeviceStateChanged(final Device device) {
synchronized (this.lock) {
if (!bridgeId.equals(device.getId())) {
logger.trace("DeviceId {} not relevant for this handler (responsible for id {})", device.getId(),
bridgeId);
return;
}
logger.debug("onDeviceStateChanged called with device {}/{}", device.getConfig().getName(), device.getId());
// DEVICE STATES
if (device.hasDeviceState()) {
final Double cpuUsage = device.getDeviceState().getState().getCpuUsage().getValue();
if (cpuUsage != null) {
logger.debug("-> CPU usage state: {}", cpuUsage);
updateState(CHANNEL_CPU, new DecimalType(cpuUsage));
}
final Double diskUsage = device.getDeviceState().getState().getDiskUsage().getValue();
if (diskUsage != null) {
logger.debug("-> Disk usage state: {}", diskUsage);
updateState(CHANNEL_DISK, new DecimalType(diskUsage));
}
final Double memoryUsage = device.getDeviceState().getState().getMemoryUsage().getValue();
if (memoryUsage != null) {
logger.debug("-> Memory usage state: {}", memoryUsage);
updateState(CHANNEL_MEMORY, new DecimalType(memoryUsage));
}
}
}
}
@Override
public void onDeviceStateChanged(final Device device, final Event event) {
synchronized (this.lock) {
if (!bridgeId.equals(device.getId())) {
logger.trace("DeviceId {} not relevant for this handler (responsible for id {})", device.getId(),
bridgeId);
return;
}
logger.trace("DeviceId {} relevant for this handler.", device.getId());
if (event.isLinkedtoDevice() && DEVICE_SHCA.equals(device.getType())) {
device.getDeviceState().getState().getCpuUsage().setValue(event.getProperties().getCpuUsage());
device.getDeviceState().getState().getDiskUsage().setValue(event.getProperties().getDiskUsage());
device.getDeviceState().getState().getMemoryUsage().setValue(event.getProperties().getMemoryUsage());
onDeviceStateChanged(device);
}
}
}
@Override
public void onEvent(final String msg) {
logger.trace("onEvent called. Msg: {}", msg);
try {
final BaseEvent be = gson.fromJson(msg, BaseEvent.class);
logger.debug("Event no {} found. Type: {}", be.getSequenceNumber(), be.getType());
if (!BaseEvent.SUPPORTED_EVENT_TYPES.contains(be.getType())) {
logger.debug("Event type {} not supported. Skipping...", be.getType());
} else {
final Event event = gson.fromJson(msg, Event.class);
switch (event.getType()) {
case BaseEvent.TYPE_STATE_CHANGED:
case BaseEvent.TYPE_BUTTON_PRESSED:
handleStateChangedEvent(event);
break;
case BaseEvent.TYPE_DISCONNECT:
logger.debug("Websocket disconnected.");
scheduleRestartClient(true);
break;
case BaseEvent.TYPE_CONFIGURATION_CHANGED:
if (client.getConfigVersion().equals(event.getConfigurationVersion().toString())) {
logger.debug(
"Ignored configuration changed event with version '{}' as current version is '{}' the same.",
event.getConfigurationVersion(), client.getConfigVersion());
} else {
logger.info("Configuration changed from version {} to {}. Restarting innogy binding...",
client.getConfigVersion(), event.getConfigurationVersion());
scheduleRestartClient(false);
}
break;
case BaseEvent.TYPE_CONTROLLER_CONNECTIVITY_CHANGED:
handleControllerConnectivityChangedEvent(event);
break;
case BaseEvent.TYPE_NEW_MESSAGE_RECEIVED:
case BaseEvent.TYPE_MESSAGE_CREATED:
final MessageEvent messageEvent = gson.fromJson(msg, MessageEvent.class);
handleNewMessageReceivedEvent(Objects.requireNonNull(messageEvent));
break;
case BaseEvent.TYPE_MESSAGE_DELETED:
handleMessageDeletedEvent(event);
break;
default:
logger.debug("Unsupported eventtype {}.", event.getType());
break;
}
}
} catch (IOException | ApiException | AuthenticationException | RuntimeException e) {
logger.debug("Error with Event: {}", e.getMessage(), e);
handleClientException(e);
}
}
@Override
public void onError(final Throwable cause) {
if (cause instanceof Exception) {
handleClientException((Exception) cause);
}
}
/**
* Handles the event that occurs, when the state of a device (like reachability) or a capability (like a temperature
* value) has changed.
*
* @param event
* @throws ApiException
* @throws IOException
* @throws AuthenticationException
*/
public void handleStateChangedEvent(final Event event) throws ApiException, IOException, AuthenticationException {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
// CAPABILITY
if (event.isLinkedtoCapability()) {
logger.trace("Event is linked to capability");
final Device device = deviceStructMan.getDeviceByCapabilityId(event.getSourceId());
if (device != null) {
for (final DeviceStatusListener deviceStatusListener : deviceStatusListeners) {
deviceStatusListener.onDeviceStateChanged(device, event);
}
} else {
logger.debug("Unknown/unsupported device for capability {}.", event.getSource());
}
// DEVICE
} else if (event.isLinkedtoDevice()) {
logger.trace("Event is linked to device");
if (!event.getSourceId().equals(deviceStructMan.getBridgeDevice().getId())) {
deviceStructMan.refreshDevice(event.getSourceId());
}
final Device device = deviceStructMan.getDeviceById(event.getSourceId());
if (device != null) {
for (final DeviceStatusListener deviceStatusListener : deviceStatusListeners) {
deviceStatusListener.onDeviceStateChanged(device, event);
}
} else {
logger.debug("Unknown/unsupported device {}.", event.getSourceId());
}
} else {
logger.debug("link type {} not supported (yet?)", event.getSourceLinkType());
}
}
/**
* Handles the event that occurs, when the connectivity of the bridge has changed.
*
* @param event
* @throws ApiException
* @throws IOException
* @throws AuthenticationException
*/
public void handleControllerConnectivityChangedEvent(final Event event)
throws ApiException, IOException, AuthenticationException {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
final Boolean connected = event.getIsConnected();
if (connected != null) {
logger.debug("SmartHome Controller connectivity changed to {}.", connected ? "online" : "offline");
if (connected) {
deviceStructMan.refreshDevices();
updateStatus(ThingStatus.ONLINE);
} else {
updateStatus(ThingStatus.OFFLINE);
}
} else {
logger.warn("isConnected property missing in event! (returned null)");
}
}
/**
* Handles the event that occurs, when a new message was received. Currently only handles low battery messages.
*
* @param event
* @throws ApiException
* @throws IOException
* @throws AuthenticationException
*/
public void handleNewMessageReceivedEvent(final MessageEvent event)
throws ApiException, IOException, AuthenticationException {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
final Message message = event.getMessage();
if (logger.isTraceEnabled()) {
logger.trace("Message: {}", gson.toJson(message));
logger.trace("Messagetype: {}", message.getType());
}
if (Message.TYPE_DEVICE_LOW_BATTERY.equals(message.getType()) && message.getDevices() != null) {
for (final String link : message.getDevices()) {
deviceStructMan.refreshDevice(Link.getId(link));
final Device device = deviceStructMan.getDeviceById(Link.getId(link));
if (device != null) {
for (final DeviceStatusListener deviceStatusListener : deviceStatusListeners) {
deviceStatusListener.onDeviceStateChanged(device);
}
} else {
logger.debug("Unknown/unsupported device {}.", event.getSourceId());
}
}
} else {
logger.debug("Message received event not yet implemented for Messagetype {}.", message.getType());
}
}
/**
* Handle the event that occurs, when a message was deleted. In case of a low battery message this means, that the
* device is back to normal. Currently, only messages linked to devices are handled by refreshing the device data
* and informing the {@link InnogyDeviceHandler} about the changed device.
*
* @param event
* @throws ApiException
* @throws IOException
* @throws AuthenticationException
*/
public void handleMessageDeletedEvent(final Event event) throws ApiException, IOException, AuthenticationException {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
final String messageId = event.getData().getId();
logger.debug("handleMessageDeletedEvent with messageId '{}'", messageId);
Device device = deviceStructMan.getDeviceWithMessageId(messageId);
if (device != null) {
String id = device.getId();
deviceStructMan.refreshDevice(id);
device = deviceStructMan.getDeviceById(id);
if (device != null) {
for (final DeviceStatusListener deviceStatusListener : deviceStatusListeners) {
deviceStatusListener.onDeviceStateChanged(device);
}
} else {
logger.debug("No device with id {} found after refresh.", id);
}
} else {
logger.debug("No device found with message id {}.", messageId);
}
}
@Override
public void connectionClosed() {
scheduleRestartClient(true);
}
/**
* Sends the command to switch the {@link Device} with the given id to the new state. Is called by the
* {@link InnogyDeviceHandler} for switch devices like the VariableActuator, PSS, PSSO or ISS2.
*
* @param deviceId
* @param state
*/
public void commandSwitchDevice(final String deviceId, final boolean state) {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
try {
// VariableActuator
final String deviceType = deviceStructMan.getDeviceById(deviceId).getType();
if (DEVICE_VARIABLE_ACTUATOR.equals(deviceType)) {
final String capabilityId = deviceStructMan.getCapabilityId(deviceId, Capability.TYPE_VARIABLEACTUATOR);
if (capabilityId == null) {
return;
}
client.setVariableActuatorState(capabilityId, state);
// PSS / PSSO / ISS2
} else if (DEVICE_PSS.equals(deviceType) || DEVICE_PSSO.equals(deviceType)
|| DEVICE_ISS2.equals(deviceType)) {
final String capabilityId = deviceStructMan.getCapabilityId(deviceId, Capability.TYPE_SWITCHACTUATOR);
if (capabilityId == null) {
return;
}
client.setSwitchActuatorState(capabilityId, state);
}
} catch (IOException | ApiException | AuthenticationException e) {
handleClientException(e);
}
}
/**
* Sends the command to update the point temperature of the {@link Device} with the given deviceId. Is called by the
* {@link InnogyDeviceHandler} for thermostat {@link Device}s like RST or WRT.
*
* @param deviceId
* @param pointTemperature
*/
public void commandUpdatePointTemperature(final String deviceId, final double pointTemperature) {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
try {
final String capabilityId = deviceStructMan.getCapabilityId(deviceId, Capability.TYPE_THERMOSTATACTUATOR);
if (capabilityId == null) {
return;
}
client.setPointTemperatureState(capabilityId, pointTemperature);
} catch (IOException | ApiException | AuthenticationException e) {
handleClientException(e);
}
}
/**
* Sends the command to turn the alarm of the {@link Device} with the given id on or off. Is called by the
* {@link InnogyDeviceHandler} for smoke detector {@link Device}s like WSD or WSD2.
*
* @param deviceId
* @param alarmState
*/
public void commandSwitchAlarm(final String deviceId, final boolean alarmState) {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
try {
final String capabilityId = deviceStructMan.getCapabilityId(deviceId, Capability.TYPE_ALARMACTUATOR);
if (capabilityId == null) {
return;
}
client.setAlarmActuatorState(capabilityId, alarmState);
} catch (IOException | ApiException | AuthenticationException e) {
handleClientException(e);
}
}
/**
* Sends the command to set the operation mode of the {@link Device} with the given deviceId to auto (or manual, if
* false). Is called by the {@link InnogyDeviceHandler} for thermostat {@link Device}s like RST.
*
* @param deviceId
* @param autoMode true activates the automatic mode, false the manual mode.
*/
public void commandSetOperationMode(final String deviceId, final boolean autoMode) {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
try {
final String capabilityId = deviceStructMan.getCapabilityId(deviceId, Capability.TYPE_THERMOSTATACTUATOR);
if (capabilityId == null) {
return;
}
client.setOperationMode(capabilityId, autoMode);
} catch (IOException | ApiException | AuthenticationException e) {
handleClientException(e);
}
}
/**
* Sends the command to set the dimm level of the {@link Device} with the given id. Is called by the
* {@link InnogyDeviceHandler} for {@link Device}s like ISD2 or PSD.
*
* @param deviceId
* @param dimLevel
*/
public void commandSetDimmLevel(final String deviceId, final int dimLevel) {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
try {
final String capabilityId = deviceStructMan.getCapabilityId(deviceId, Capability.TYPE_DIMMERACTUATOR);
if (capabilityId == null) {
return;
}
client.setDimmerActuatorState(capabilityId, dimLevel);
} catch (IOException | ApiException | AuthenticationException e) {
handleClientException(e);
}
}
/**
* Sends the command to set the rollershutter level of the {@link Device} with the given id. Is called by the
* {@link InnogyDeviceHandler} for {@link Device}s like ISR2.
*
* @param deviceId
* @param rollerSchutterLevel
*/
public void commandSetRollerShutterLevel(final String deviceId, final int rollerSchutterLevel) {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
try {
final String capabilityId = deviceStructMan.getCapabilityId(deviceId,
Capability.TYPE_ROLLERSHUTTERACTUATOR);
if (capabilityId == null) {
return;
}
client.setRollerShutterActuatorState(capabilityId, rollerSchutterLevel);
} catch (IOException | ApiException | AuthenticationException e) {
handleClientException(e);
}
}
/**
* Sends the command to start or stop moving the rollershutter (ISR2) in a specified direction
*
* @param deviceId
* @param action
*/
public void commandSetRollerShutterStop(final String deviceId, ShutterAction.ShutterActions action) {
final DeviceStructureManager deviceStructMan = this.deviceStructMan;
if (deviceStructMan == null) {
return;
}
try {
final String capabilityId = deviceStructMan.getCapabilityId(deviceId,
Capability.TYPE_ROLLERSHUTTERACTUATOR);
if (capabilityId == null) {
return;
}
client.setRollerShutterAction(capabilityId, action);
} catch (IOException | ApiException | AuthenticationException e) {
handleClientException(e);
}
}
ScheduledExecutorService getScheduler() {
return scheduler;
}
FullDeviceManager createFullDeviceManager(InnogyClient client) {
return new FullDeviceManager(client);
}
InnogyClient createInnogyClient(final OAuthClientService oAuthService, final HttpClient httpClient) {
return new InnogyClient(oAuthService, httpClient);
}
/**
* Handles all Exceptions of the client communication. For minor "errors" like an already existing session, it
* returns true to inform the binding to continue running. In other cases it may e.g. schedule a reinitialization of
* the binding.
*
* @param e the Exception
* @return boolean true, if binding should continue.
*/
private boolean handleClientException(final Exception e) {
boolean isReinitialize = true;
if (e instanceof SessionExistsException) {
logger.debug("Session already exists. Continuing...");
isReinitialize = false;
} else if (e instanceof InvalidActionTriggeredException) {
logger.debug("Error triggering action: {}", e.getMessage());
isReinitialize = false;
} else if (e instanceof RemoteAccessNotAllowedException) {
// Remote access not allowed (usually by IP address change)
logger.debug("Remote access not allowed. Dropping access token and reinitializing binding...");
refreshAccessToken();
} else if (e instanceof ControllerOfflineException) {
logger.debug("innogy SmartHome Controller is offline.");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, e.getMessage());
} else if (e instanceof AuthenticationException) {
logger.debug("OAuthenticaton error, refreshing tokens: {}", e.getMessage());
refreshAccessToken();
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
} else if (e instanceof IOException) {
logger.debug("IO error: {}", e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
} else if (e instanceof ApiException) {
logger.warn("Unexpected API error: {}", e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
} else if (e instanceof TimeoutException) {
logger.debug("WebSocket timeout: {}", e.getMessage());
} else if (e instanceof SocketTimeoutException) {
logger.debug("Socket timeout: {}", e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
} else if (e instanceof InterruptedException) {
isReinitialize = false;
Thread.currentThread().interrupt();
} else if (e instanceof ExecutionException) {
logger.debug("ExecutionException: {}", ExceptionUtils.getRootThrowable(e).getMessage());
updateStatus(ThingStatus.OFFLINE);
} else {
logger.debug("Unknown exception", e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, e.getMessage());
}
if (isReinitialize) {
scheduleRestartClient(true);
return true;
}
return false;
}
private void refreshAccessToken() {
try {
final OAuthClientService localOAuthService = this.oAuthService;
if (localOAuthService != null) {
oAuthService.refreshToken();
}
} catch (IOException | OAuthResponseException | OAuthException e) {
logger.debug("Could not refresh tokens", e);
}
}
/**
* Checks if the job is already (re-)scheduled.
*
* @param job job to check
* @return true, when the job is already (re-)scheduled, otherwise false
*/
private static boolean isAlreadyScheduled(ScheduledFuture<?> job) {
return job.getDelay(TimeUnit.SECONDS) > 0;
}
}

View File

@ -1,968 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.handler;
import static org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants.*;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.innogysmarthome.internal.client.entity.action.ShutterAction;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.CapabilityState;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.event.Event;
import org.openhab.binding.innogysmarthome.internal.listener.DeviceStatusListener;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.StopMoveType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.types.UpDownType;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.CommonTriggerEvents;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingStatusInfo;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.types.Command;
import org.openhab.core.types.RefreshType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link InnogyDeviceHandler} is responsible for handling the {@link Device}s and their commands, which are
* sent to one of the channels.
*
* @author Oliver Kuhl - Initial contribution
*/
@NonNullByDefault
public class InnogyDeviceHandler extends BaseThingHandler implements DeviceStatusListener {
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = SUPPORTED_DEVICE_THING_TYPES;
private static final String DEBUG = "DEBUG";
private static final String LONG_PRESS = "LongPress";
private static final String SHORT_PRESS = "ShortPress";
private final Logger logger = LoggerFactory.getLogger(InnogyDeviceHandler.class);
private final Object lock = new Object();
private String deviceId = "";
private @Nullable InnogyBridgeHandler bridgeHandler;
/**
* Constructs a new {@link InnogyDeviceHandler} for the given {@link Thing}.
*
* @param thing
*/
public InnogyDeviceHandler(final Thing thing) {
super(thing);
}
@Override
public void handleCommand(final ChannelUID channelUID, final Command command) {
logger.debug("handleCommand called for channel '{}' of type '{}' with command '{}'", channelUID,
getThing().getThingTypeUID().getId(), command);
@Nullable
final InnogyBridgeHandler innogyBridgeHandler = getInnogyBridgeHandler();
if (innogyBridgeHandler == null) {
logger.warn("BridgeHandler not found. Cannot handle command without bridge.");
return;
}
if (!ThingStatus.ONLINE.equals(innogyBridgeHandler.getThing().getStatus())) {
logger.debug("Cannot handle command - bridge is not online. Command ignored.");
return;
}
if (command instanceof RefreshType) {
@Nullable
final Device device = innogyBridgeHandler.getDeviceById(deviceId);
if (device != null) {
onDeviceStateChanged(device);
}
return;
}
// SWITCH
if (CHANNEL_SWITCH.equals(channelUID.getId())) {
// DEBUGGING HELPER
// ----------------
@Nullable
final Device device = innogyBridgeHandler.getDeviceById(deviceId);
if (device != null && DEBUG.equals(device.getConfig().getName())) {
logger.debug("DEBUG SWITCH ACTIVATED!");
if (OnOffType.ON.equals(command)) {
innogyBridgeHandler.onEvent(
"{\"sequenceNumber\": -1,\"type\": \"MessageCreated\",\"desc\": \"/desc/event/MessageCreated\",\"namespace\": \"core.RWE\",\"timestamp\": \"2019-07-07T18:41:47.2970000Z\",\"source\": \"/desc/device/SHC.RWE/1.0\",\"data\": {\"id\": \"6e5ce2290cd247208f95a5b53736958b\",\"type\": \"DeviceLowBattery\",\"read\": false,\"class\": \"Alert\",\"timestamp\": \"2019-07-07T18:41:47.232Z\",\"devices\": [\"/device/fe51785319854f36a621d0b4f8ea0e25\"],\"properties\": {\"deviceName\": \"Heizkörperthermostat\",\"serialNumber\": \"914110165056\",\"locationName\": \"Bad\"},\"namespace\": \"core.RWE\"}}");
} else {
innogyBridgeHandler.onEvent(
"{\"sequenceNumber\": -1,\"type\": \"MessageDeleted\",\"desc\": \"/desc/event/MessageDeleted\",\"namespace\": \"core.RWE\",\"timestamp\": \"2019-07-07T19:15:39.2100000Z\",\"data\": { \"id\": \"6e5ce2290cd247208f95a5b53736958b\" }}");
}
return;
}
// ----------------
if (command instanceof OnOffType) {
innogyBridgeHandler.commandSwitchDevice(deviceId, OnOffType.ON.equals(command));
}
// DIMMER
} else if (CHANNEL_DIMMER.equals(channelUID.getId())) {
if (command instanceof DecimalType) {
final DecimalType dimLevel = (DecimalType) command;
innogyBridgeHandler.commandSetDimmLevel(deviceId, dimLevel.intValue());
} else if (command instanceof OnOffType) {
if (OnOffType.ON.equals(command)) {
innogyBridgeHandler.commandSetDimmLevel(deviceId, 100);
} else {
innogyBridgeHandler.commandSetDimmLevel(deviceId, 0);
}
}
// ROLLERSHUTTER
} else if (CHANNEL_ROLLERSHUTTER.equals(channelUID.getId())) {
if (command instanceof DecimalType) {
final DecimalType rollerShutterLevel = (DecimalType) command;
innogyBridgeHandler.commandSetRollerShutterLevel(deviceId,
invertValueIfConfigured(CHANNEL_ROLLERSHUTTER, rollerShutterLevel.intValue()));
} else if (command instanceof OnOffType) {
if (OnOffType.ON.equals(command)) {
innogyBridgeHandler.commandSetRollerShutterStop(deviceId, ShutterAction.ShutterActions.DOWN);
} else {
innogyBridgeHandler.commandSetRollerShutterStop(deviceId, ShutterAction.ShutterActions.UP);
}
} else if (command instanceof UpDownType) {
if (UpDownType.DOWN.equals(command)) {
innogyBridgeHandler.commandSetRollerShutterStop(deviceId, ShutterAction.ShutterActions.DOWN);
} else {
innogyBridgeHandler.commandSetRollerShutterStop(deviceId, ShutterAction.ShutterActions.UP);
}
} else if (command instanceof StopMoveType) {
if (StopMoveType.STOP.equals(command)) {
innogyBridgeHandler.commandSetRollerShutterStop(deviceId, ShutterAction.ShutterActions.STOP);
}
}
// SET_TEMPERATURE
} else if (CHANNEL_SET_TEMPERATURE.equals(channelUID.getId())) {
if (command instanceof DecimalType) {
final DecimalType pointTemperature = (DecimalType) command;
innogyBridgeHandler.commandUpdatePointTemperature(deviceId, pointTemperature.doubleValue());
}
// OPERATION_MODE
} else if (CHANNEL_OPERATION_MODE.equals(channelUID.getId())) {
if (command instanceof StringType) {
final String autoModeCommand = command.toString();
if (CapabilityState.STATE_VALUE_OPERATION_MODE_AUTO.equals(autoModeCommand)) {
innogyBridgeHandler.commandSetOperationMode(deviceId, true);
} else if (CapabilityState.STATE_VALUE_OPERATION_MODE_MANUAL.equals(autoModeCommand)) {
innogyBridgeHandler.commandSetOperationMode(deviceId, false);
} else {
logger.warn("Could not set operationmode. Invalid value '{}'! Only '{}' or '{}' allowed.",
autoModeCommand, CapabilityState.STATE_VALUE_OPERATION_MODE_AUTO,
CapabilityState.STATE_VALUE_OPERATION_MODE_MANUAL);
}
}
// ALARM
} else if (CHANNEL_ALARM.equals(channelUID.getId())) {
if (command instanceof OnOffType) {
innogyBridgeHandler.commandSwitchAlarm(deviceId, OnOffType.ON.equals(command));
}
} else {
logger.debug("UNSUPPORTED channel {} for device {}.", channelUID.getId(), deviceId);
}
}
@Override
public void initialize() {
logger.debug("Initializing innogy SmartHome device handler.");
initializeThing(getBridge() == null ? null : getBridge().getStatus());
}
@Override
public void dispose() {
if (bridgeHandler != null) {
bridgeHandler.unregisterDeviceStatusListener(this);
}
}
@Override
public void bridgeStatusChanged(final ThingStatusInfo bridgeStatusInfo) {
logger.debug("bridgeStatusChanged {}", bridgeStatusInfo);
initializeThing(bridgeStatusInfo.getStatus());
}
/**
* Initializes the {@link Thing} corresponding to the given status of the bridge.
*
* @param bridgeStatus
*/
private void initializeThing(@Nullable final ThingStatus bridgeStatus) {
logger.debug("initializeThing thing {} bridge status {}", getThing().getUID(), bridgeStatus);
final String configDeviceId = (String) getConfig().get(PROPERTY_ID);
if (configDeviceId != null) {
deviceId = configDeviceId;
// note: this call implicitly registers our handler as a listener on
// the bridge
if (getInnogyBridgeHandler() != null) {
if (bridgeStatus == ThingStatus.ONLINE) {
if (initializeProperties()) {
updateStatus(ThingStatus.ONLINE);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.GONE,
"Device not found in innogy config. Was it removed?");
}
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
}
} else {
updateStatus(ThingStatus.OFFLINE);
}
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "device id unknown");
}
}
/**
* Initializes all properties of the {@link Device}, like vendor, serialnumber etc.
*/
private boolean initializeProperties() {
synchronized (this.lock) {
@Nullable
final Device device = getDevice();
if (device != null) {
final Map<String, String> properties = editProperties();
properties.put(PROPERTY_ID, device.getId());
properties.put(PROPERTY_PROTOCOL_ID, device.getConfig().getProtocolId());
if (device.hasSerialNumber()) {
properties.put(Thing.PROPERTY_SERIAL_NUMBER, device.getSerialnumber());
}
properties.put(Thing.PROPERTY_VENDOR, device.getManufacturer());
properties.put(PROPERTY_VERSION, device.getVersion());
if (device.hasLocation()) {
properties.put(PROPERTY_LOCATION, device.getLocation().getName());
}
if (device.isBatteryPowered()) {
properties.put(PROPERTY_BATTERY_POWERED, "yes");
} else {
properties.put(PROPERTY_BATTERY_POWERED, "no");
}
if (device.isController()) {
properties.put(PROPERTY_DEVICE_TYPE, "Controller");
} else if (device.isVirtualDevice()) {
properties.put(PROPERTY_DEVICE_TYPE, "Virtual");
} else if (device.isRadioDevice()) {
properties.put(PROPERTY_DEVICE_TYPE, "Radio");
}
// Thermostat
if (DEVICE_RST.equals(device.getType()) || DEVICE_RST2.equals(device.getType())
|| DEVICE_WRT.equals(device.getType())) {
properties.put(PROPERTY_DISPLAY_CURRENT_TEMPERATURE,
device.getConfig().getDisplayCurrentTemperature());
}
// Meter
if (DEVICE_ANALOG_METER.equals(device.getType()) || DEVICE_GENERATION_METER.equals(device.getType())
|| DEVICE_SMART_METER.equals(device.getType())
|| DEVICE_TWO_WAY_METER.equals(device.getType())) {
properties.put(PROPERTY_METER_ID, device.getConfig().getMeterId());
properties.put(PROPERTY_METER_FIRMWARE_VERSION, device.getConfig().getMeterFirmwareVersion());
}
if (device.getConfig().getTimeOfAcceptance() != null) {
properties.put(PROPERTY_TIME_OF_ACCEPTANCE, device.getConfig().getTimeOfAcceptance()
.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)));
}
if (device.getConfig().getTimeOfDiscovery() != null) {
properties.put(PROPERTY_TIME_OF_DISCOVERY, device.getConfig().getTimeOfDiscovery()
.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)));
}
updateProperties(properties);
onDeviceStateChanged(device);
return true;
} else {
logger.warn("initializeProperties: The device with id {} isn't found", deviceId);
return false;
}
}
}
/**
* Returns the {@link Device} associated with this {@link InnogyDeviceHandler} (referenced by the
* {@link InnogyDeviceHandler#deviceId}).
*
* @return the {@link Device} or null, if not found or no {@link InnogyBridgeHandler} is available
*/
private @Nullable Device getDevice() {
if (getInnogyBridgeHandler() != null) {
return getInnogyBridgeHandler().getDeviceById(deviceId);
}
return null;
}
/**
* Returns the innogy bridge handler.
*
* @return the {@link InnogyBridgeHandler} or null
*/
private @Nullable InnogyBridgeHandler getInnogyBridgeHandler() {
synchronized (this.lock) {
if (this.bridgeHandler == null) {
@Nullable
final Bridge bridge = getBridge();
if (bridge == null) {
return null;
}
@Nullable
final ThingHandler handler = bridge.getHandler();
if (handler instanceof InnogyBridgeHandler) {
this.bridgeHandler = (InnogyBridgeHandler) handler;
this.bridgeHandler.registerDeviceStatusListener(this);
} else {
return null;
}
}
return this.bridgeHandler;
}
}
@Override
public void onDeviceStateChanged(final Device device) {
synchronized (this.lock) {
if (!deviceId.equals(device.getId())) {
logger.trace("DeviceId {} not relevant for this handler (responsible for id {})", device.getId(),
deviceId);
return;
}
logger.debug("onDeviceStateChanged called with device {}/{}", device.getConfig().getName(), device.getId());
// DEVICE STATES
if (device.hasDeviceState()) {
@Nullable
Boolean reachable = null;
if (device.getDeviceState().hasIsReachableState()) {
reachable = device.getDeviceState().isReachable();
}
if (reachable != null && !reachable) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Device not reachable.");
return;
} else if ((reachable != null && reachable) || DEVICE_VARIABLE_ACTUATOR.equals(device.getType())) {
if (device.getDeviceState().deviceIsIncluded()) {
updateStatus(ThingStatus.ONLINE);
} else {
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.CONFIGURATION_PENDING,
"State is " + device.getDeviceState().getDeviceInclusionState());
}
}
}
if (device.isBatteryPowered()) {
if (device.hasLowBattery()) {
updateState(CHANNEL_BATTERY_LOW, OnOffType.ON);
} else {
updateState(CHANNEL_BATTERY_LOW, OnOffType.OFF);
}
}
// CAPABILITY STATES
for (final Entry<String, Capability> entry : device.getCapabilityMap().entrySet()) {
final Capability c = entry.getValue();
logger.debug("->capability:{} ({}/{})", c.getId(), c.getType(), c.getName());
if (c.getCapabilityState() == null) {
logger.debug("Capability not available for device {} ({})", device.getConfig().getName(),
device.getType());
continue;
}
switch (c.getType()) {
case Capability.TYPE_VARIABLEACTUATOR:
final Boolean variableActuatorState = c.getCapabilityState().getVariableActuatorState();
if (variableActuatorState != null) {
updateState(CHANNEL_SWITCH, variableActuatorState ? OnOffType.ON : OnOffType.OFF);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_SWITCHACTUATOR:
final Boolean switchActuatorState = c.getCapabilityState().getSwitchActuatorState();
if (switchActuatorState != null) {
updateState(CHANNEL_SWITCH, switchActuatorState ? OnOffType.ON : OnOffType.OFF);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_DIMMERACTUATOR:
final Integer dimLevel = c.getCapabilityState().getDimmerActuatorState();
if (dimLevel != null) {
logger.debug("Dimlevel state {}", dimLevel);
updateState(CHANNEL_DIMMER, new PercentType(dimLevel));
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_ROLLERSHUTTERACTUATOR:
Integer rollerShutterLevel = c.getCapabilityState().getRollerShutterActuatorState();
if (rollerShutterLevel != null) {
rollerShutterLevel = invertValueIfConfigured(CHANNEL_ROLLERSHUTTER, rollerShutterLevel);
logger.debug("RollerShutterlevel state {}", rollerShutterLevel);
updateState(CHANNEL_ROLLERSHUTTER, new PercentType(rollerShutterLevel));
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_TEMPERATURESENSOR:
// temperature
final Double temperatureSensorState = c.getCapabilityState()
.getTemperatureSensorTemperatureState();
if (temperatureSensorState != null) {
logger.debug("-> Temperature sensor state: {}", temperatureSensorState);
updateState(CHANNEL_TEMPERATURE, new DecimalType(temperatureSensorState));
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
// frost warning
final Boolean temperatureSensorFrostWarningState = c.getCapabilityState()
.getTemperatureSensorFrostWarningState();
if (temperatureSensorFrostWarningState != null) {
updateState(CHANNEL_FROST_WARNING,
temperatureSensorFrostWarningState ? OnOffType.ON : OnOffType.OFF);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_THERMOSTATACTUATOR:
// point temperature
final Double thermostatActuatorPointTemperatureState = c.getCapabilityState()
.getThermostatActuatorPointTemperatureState();
if (thermostatActuatorPointTemperatureState != null) {
final DecimalType pointTemp = new DecimalType(thermostatActuatorPointTemperatureState);
logger.debug(
"Update CHANNEL_SET_TEMPERATURE: state:{}->decType:{} (DeviceName {}, Capab-ID:{})",
thermostatActuatorPointTemperatureState, pointTemp, device.getConfig().getName(),
c.getId());
updateState(CHANNEL_SET_TEMPERATURE, pointTemp);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
// operation mode
final String thermostatActuatorOperationModeState = c.getCapabilityState()
.getThermostatActuatorOperationModeState();
if (thermostatActuatorOperationModeState != null) {
final StringType operationMode = new StringType(thermostatActuatorOperationModeState);
updateState(CHANNEL_OPERATION_MODE, operationMode);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
// window reduction active
final Boolean thermostatActuatorWindowReductionActiveState = c.getCapabilityState()
.getThermostatActuatorWindowReductionActiveState();
if (thermostatActuatorWindowReductionActiveState != null) {
updateState(CHANNEL_WINDOW_REDUCTION_ACTIVE,
thermostatActuatorWindowReductionActiveState ? OnOffType.ON : OnOffType.OFF);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_HUMIDITYSENSOR:
// humidity
final Double humidityState = c.getCapabilityState().getHumiditySensorHumidityState();
if (humidityState != null) {
final DecimalType humidity = new DecimalType(humidityState);
updateState(CHANNEL_HUMIDITY, humidity);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
// mold warning
final Boolean humiditySensorMoldWarningState = c.getCapabilityState()
.getHumiditySensorMoldWarningState();
if (humiditySensorMoldWarningState != null) {
updateState(CHANNEL_MOLD_WARNING,
humiditySensorMoldWarningState ? OnOffType.ON : OnOffType.OFF);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_WINDOWDOORSENSOR:
final Boolean contactState = c.getCapabilityState().getWindowDoorSensorState();
if (contactState != null) {
updateState(CHANNEL_CONTACT, contactState ? OpenClosedType.OPEN : OpenClosedType.CLOSED);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_SMOKEDETECTORSENSOR:
final Boolean smokeState = c.getCapabilityState().getSmokeDetectorSensorState();
if (smokeState != null) {
updateState(CHANNEL_SMOKE, smokeState ? OnOffType.ON : OnOffType.OFF);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_ALARMACTUATOR:
final Boolean alarmState = c.getCapabilityState().getAlarmActuatorState();
if (alarmState != null) {
updateState(CHANNEL_ALARM, alarmState ? OnOffType.ON : OnOffType.OFF);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_MOTIONDETECTIONSENSOR:
final Integer motionState = c.getCapabilityState().getMotionDetectionSensorState();
if (motionState != null) {
final DecimalType motionCount = new DecimalType(motionState);
logger.debug("Motion state {} -> count {}", motionState, motionCount);
updateState(CHANNEL_MOTION_COUNT, motionCount);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_LUMINANCESENSOR:
final Double luminanceState = c.getCapabilityState().getLuminanceSensorState();
if (luminanceState != null) {
final DecimalType luminance = new DecimalType(luminanceState);
updateState(CHANNEL_LUMINANCE, luminance);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_PUSHBUTTONSENSOR:
final Integer pushCountState = c.getCapabilityState().getPushButtonSensorCounterState();
final Integer buttonIndexState = c.getCapabilityState().getPushButtonSensorButtonIndexState();
logger.debug("Pushbutton index {} count {}", buttonIndexState, pushCountState);
if (pushCountState != null) {
final DecimalType pushCount = new DecimalType(pushCountState);
// prevent error when buttonIndexState is null
if (buttonIndexState != null) {
if (buttonIndexState >= 0 && buttonIndexState <= 7) {
final int channelIndex = buttonIndexState + 1;
final String type = c.getCapabilityState().getPushButtonSensorButtonIndexType();
final String triggerEvent = SHORT_PRESS.equals(type)
? CommonTriggerEvents.SHORT_PRESSED
: (LONG_PRESS.equals(type) ? CommonTriggerEvents.LONG_PRESSED
: CommonTriggerEvents.PRESSED);
triggerChannel(CHANNEL_BUTTON + channelIndex, triggerEvent);
updateState(String.format(CHANNEL_BUTTON_COUNT, channelIndex), pushCount);
} else {
logger.debug("Button index {} not supported.", buttonIndexState);
}
// Button handled so remove state to avoid re-trigger.
c.getCapabilityState().setPushButtonSensorButtonIndexState(null);
c.getCapabilityState().setPushButtonSensorButtonIndexType(null);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", c.getType(),
c.getCapabilityState().getId(), c.getId());
}
break;
case Capability.TYPE_ENERGYCONSUMPTIONSENSOR:
updateStateForEnergyChannel(CHANNEL_ENERGY_CONSUMPTION_MONTH_KWH,
c.getCapabilityState().getEnergyConsumptionSensorEnergyConsumptionMonthKWhState(), c);
updateStateForEnergyChannel(CHANNEL_ABOLUTE_ENERGY_CONSUMPTION,
c.getCapabilityState().getEnergyConsumptionSensorAbsoluteEnergyConsumptionState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_CONSUMPTION_MONTH_EURO,
c.getCapabilityState().getEnergyConsumptionSensorEnergyConsumptionMonthEuroState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_CONSUMPTION_DAY_EURO,
c.getCapabilityState().getEnergyConsumptionSensorEnergyConsumptionDayEuroState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_CONSUMPTION_DAY_KWH,
c.getCapabilityState().getEnergyConsumptionSensorEnergyConsumptionDayKWhState(), c);
break;
case Capability.TYPE_POWERCONSUMPTIONSENSOR:
updateStateForEnergyChannel(CHANNEL_POWER_CONSUMPTION_WATT,
c.getCapabilityState().getPowerConsumptionSensorPowerConsumptionWattState(), c);
break;
case Capability.TYPE_GENERATIONMETERENERGYSENSOR:
updateStateForEnergyChannel(CHANNEL_ENERGY_GENERATION_MONTH_KWH,
c.getCapabilityState().getGenerationMeterEnergySensorEnergyPerMonthInKWhState(), c);
updateStateForEnergyChannel(CHANNEL_TOTAL_ENERGY_GENERATION,
c.getCapabilityState().getGenerationMeterEnergySensorTotalEnergyState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_GENERATION_MONTH_EURO,
c.getCapabilityState().getGenerationMeterEnergySensorEnergyPerMonthInEuroState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_GENERATION_DAY_EURO,
c.getCapabilityState().getGenerationMeterEnergySensorEnergyPerDayInEuroState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_GENERATION_DAY_KWH,
c.getCapabilityState().getGenerationMeterEnergySensorEnergyPerDayInKWhState(), c);
break;
case Capability.TYPE_GENERATIONMETERPOWERCONSUMPTIONSENSOR:
updateStateForEnergyChannel(CHANNEL_POWER_GENERATION_WATT,
c.getCapabilityState().getGenerationMeterPowerConsumptionSensorPowerInWattState(), c);
break;
case Capability.TYPE_TWOWAYMETERENERGYCONSUMPTIONSENSOR:
updateStateForEnergyChannel(CHANNEL_ENERGY_MONTH_KWH,
c.getCapabilityState().getTwoWayMeterEnergyConsumptionSensorEnergyPerMonthInKWhState(),
c);
updateStateForEnergyChannel(CHANNEL_TOTAL_ENERGY,
c.getCapabilityState().getTwoWayMeterEnergyConsumptionSensorTotalEnergyState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_MONTH_EURO,
c.getCapabilityState().getTwoWayMeterEnergyConsumptionSensorEnergyPerMonthInEuroState(),
c);
updateStateForEnergyChannel(CHANNEL_ENERGY_DAY_EURO,
c.getCapabilityState().getTwoWayMeterEnergyConsumptionSensorEnergyPerDayInEuroState(),
c);
updateStateForEnergyChannel(CHANNEL_ENERGY_DAY_KWH,
c.getCapabilityState().getTwoWayMeterEnergyConsumptionSensorEnergyPerDayInKWhState(),
c);
break;
case Capability.TYPE_TWOWAYMETERENERGYFEEDSENSOR:
updateStateForEnergyChannel(CHANNEL_ENERGY_FEED_MONTH_KWH,
c.getCapabilityState().getTwoWayMeterEnergyFeedSensorEnergyPerMonthInKWhState(), c);
updateStateForEnergyChannel(CHANNEL_TOTAL_ENERGY_FED,
c.getCapabilityState().getTwoWayMeterEnergyFeedSensorTotalEnergyState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_FEED_MONTH_EURO,
c.getCapabilityState().getTwoWayMeterEnergyFeedSensorEnergyPerMonthInEuroState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_FEED_DAY_EURO,
c.getCapabilityState().getTwoWayMeterEnergyFeedSensorEnergyPerDayInEuroState(), c);
updateStateForEnergyChannel(CHANNEL_ENERGY_FEED_DAY_KWH,
c.getCapabilityState().getTwoWayMeterEnergyFeedSensorEnergyPerDayInKWhState(), c);
break;
case Capability.TYPE_TWOWAYMETERPOWERCONSUMPTIONSENSOR:
updateStateForEnergyChannel(CHANNEL_POWER_WATT,
c.getCapabilityState().getTwoWayMeterPowerConsumptionSensorPowerInWattState(), c);
break;
default:
logger.debug("Unsupported capability type {}.", c.getType());
break;
}
}
}
}
/**
* Updates the state for the {@link Channel} of an energy {@link Device}.
*
* @param channelId
* @param state
* @param capability
*/
private void updateStateForEnergyChannel(final String channelId, @Nullable final Double state,
final Capability capability) {
if (state != null) {
final DecimalType newValue = new DecimalType(state);
updateState(channelId, newValue);
} else {
logger.debug("State for {} is STILL NULL!! cstate-id: {}, c-id: {}", capability.getType(),
capability.getCapabilityState().getId(), capability.getId());
}
}
@Override
public void onDeviceStateChanged(final Device changedDevice, final Event event) {
synchronized (this.lock) {
Device device = changedDevice;
if (!deviceId.equals(device.getId())) {
return;
}
logger.trace("DeviceId {} relevant for this handler.", device.getId());
if (event.isLinkedtoCapability()) {
boolean deviceChanged = false;
final String linkedCapabilityId = event.getSourceId();
Map<String, Capability> capabilityMap = device.getCapabilityMap();
Capability capability = capabilityMap.get(linkedCapabilityId);
logger.trace("Loaded Capability {}, {} with id {}, device {} from device id {}", capability.getType(),
capability.getName(), capability.getId(), capability.getDeviceLink(), device.getId());
CapabilityState capabilityState;
if (capability.hasState()) {
capabilityState = capability.getCapabilityState();
// VariableActuator
if (capability.isTypeVariableActuator()) {
capabilityState.setVariableActuatorState(event.getProperties().getValue());
deviceChanged = true;
// SwitchActuator
} else if (capability.isTypeSwitchActuator()) {
capabilityState.setSwitchActuatorState(event.getProperties().getOnState());
deviceChanged = true;
// DimmerActuator
} else if (capability.isTypeDimmerActuator()) {
capabilityState.setDimmerActuatorState(event.getProperties().getDimLevel());
deviceChanged = true;
// RollerShutterActuator
} else if (capability.isTypeRollerShutterActuator()) {
capabilityState.setRollerShutterActuatorState(event.getProperties().getShutterLevel());
deviceChanged = true;
// TemperatureSensor
} else if (capability.isTypeTemperatureSensor()) {
// when values are changed, they come with separate events
// values should only updated when they are not null
final Double tmpTemperatureState = event.getProperties().getTemperature();
final Boolean tmpFrostWarningState = event.getProperties().getFrostWarning();
if (tmpTemperatureState != null) {
capabilityState.setTemperatureSensorTemperatureState(tmpTemperatureState);
}
if (tmpFrostWarningState != null) {
capabilityState.setTemperatureSensorFrostWarningState(tmpFrostWarningState);
}
deviceChanged = true;
// ThermostatActuator
} else if (capability.isTypeThermostatActuator()) {
// when values are changed, they come with separate events
// values should only updated when they are not null
final Double tmpPointTemperatureState = event.getProperties().getPointTemperature();
final String tmpOperationModeState = event.getProperties().getOperationMode();
final Boolean tmpWindowReductionActiveState = event.getProperties().getWindowReductionActive();
if (tmpPointTemperatureState != null) {
capabilityState.setThermostatActuatorPointTemperatureState(tmpPointTemperatureState);
}
if (tmpOperationModeState != null) {
capabilityState.setThermostatActuatorOperationModeState(tmpOperationModeState);
}
if (tmpWindowReductionActiveState != null) {
capabilityState
.setThermostatActuatorWindowReductionActiveState(tmpWindowReductionActiveState);
}
deviceChanged = true;
// HumiditySensor
} else if (capability.isTypeHumiditySensor()) {
// when values are changed, they come with separate events
// values should only updated when they are not null
final Double tmpHumidityState = event.getProperties().getHumidity();
final Boolean tmpMoldWarningState = event.getProperties().getMoldWarning();
if (tmpHumidityState != null) {
capabilityState.setHumiditySensorHumidityState(tmpHumidityState);
}
if (tmpMoldWarningState != null) {
capabilityState.setHumiditySensorMoldWarningState(tmpMoldWarningState);
}
deviceChanged = true;
// WindowDoorSensor
} else if (capability.isTypeWindowDoorSensor()) {
capabilityState.setWindowDoorSensorState(event.getProperties().getIsOpen());
deviceChanged = true;
// SmokeDetectorSensor
} else if (capability.isTypeSmokeDetectorSensor()) {
capabilityState.setSmokeDetectorSensorState(event.getProperties().getIsSmokeAlarm());
deviceChanged = true;
// AlarmActuator
} else if (capability.isTypeAlarmActuator()) {
capabilityState.setAlarmActuatorState(event.getProperties().getOnState());
deviceChanged = true;
// MotionDetectionSensor
} else if (capability.isTypeMotionDetectionSensor()) {
capabilityState.setMotionDetectionSensorState(event.getProperties().getMotionDetectedCount());
deviceChanged = true;
// LuminanceSensor
} else if (capability.isTypeLuminanceSensor()) {
capabilityState.setLuminanceSensorState(event.getProperties().getLuminance());
deviceChanged = true;
// PushButtonSensor
} else if (capability.isTypePushButtonSensor()) {
// Some devices send both StateChanged and ButtonPressed. But only one should be handled.
// If ButtonPressed is send lastPressedButtonIndex is not set in StateChanged so ignore
// StateChanged.
// type is also not always present if null will be interpreted as a normal key press.
final Integer tmpButtonIndex = event.getProperties().getLastPressedButtonIndex();
if (tmpButtonIndex != null) {
capabilityState.setPushButtonSensorButtonIndexState(tmpButtonIndex);
capabilityState
.setPushButtonSensorButtonIndexType(event.getProperties().getLastKeyPressType());
final Integer tmpLastKeyPressCounter = event.getProperties().getLastKeyPressCounter();
if (tmpLastKeyPressCounter != null) {
capabilityState.setPushButtonSensorCounterState(tmpLastKeyPressCounter);
}
deviceChanged = true;
}
// EnergyConsumptionSensor
} else if (capability.isTypeEnergyConsumptionSensor()) {
capabilityState.setEnergyConsumptionSensorEnergyConsumptionMonthKWhState(
event.getProperties().getEnergyConsumptionMonthKWh());
capabilityState.setEnergyConsumptionSensorAbsoluteEnergyConsumptionState(
event.getProperties().getAbsoluteEnergyConsumption());
capabilityState.setEnergyConsumptionSensorEnergyConsumptionMonthEuroState(
event.getProperties().getEnergyConsumptionMonthEuro());
capabilityState.setEnergyConsumptionSensorEnergyConsumptionDayEuroState(
event.getProperties().getEnergyConsumptionDayEuro());
capabilityState.setEnergyConsumptionSensorEnergyConsumptionDayKWhState(
event.getProperties().getEnergyConsumptionDayKWh());
deviceChanged = true;
// PowerConsumptionSensor
} else if (capability.isTypePowerConsumptionSensor()) {
capabilityState.setPowerConsumptionSensorPowerConsumptionWattState(
event.getProperties().getPowerConsumptionWatt());
deviceChanged = true;
// GenerationMeterEnergySensor
} else if (capability.isTypeGenerationMeterEnergySensor()) {
capabilityState.setGenerationMeterEnergySensorEnergyPerMonthInKWhState(
event.getProperties().getEnergyPerMonthInKWh());
capabilityState
.setGenerationMeterEnergySensorTotalEnergyState(event.getProperties().getTotalEnergy());
capabilityState.setGenerationMeterEnergySensorEnergyPerMonthInEuroState(
event.getProperties().getEnergyPerMonthInEuro());
capabilityState.setGenerationMeterEnergySensorEnergyPerDayInEuroState(
event.getProperties().getEnergyPerDayInEuro());
capabilityState.setGenerationMeterEnergySensorEnergyPerDayInKWhState(
event.getProperties().getEnergyPerDayInKWh());
deviceChanged = true;
// GenerationMeterPowerConsumptionSensor
} else if (capability.isTypeGenerationMeterPowerConsumptionSensor()) {
capabilityState.setGenerationMeterPowerConsumptionSensorPowerInWattState(
event.getProperties().getPowerInWatt());
deviceChanged = true;
// TwoWayMeterEnergyConsumptionSensor
} else if (capability.isTypeTwoWayMeterEnergyConsumptionSensor()) {
capabilityState.setTwoWayMeterEnergyConsumptionSensorEnergyPerMonthInKWhState(
event.getProperties().getEnergyPerMonthInKWh());
capabilityState.setTwoWayMeterEnergyConsumptionSensorTotalEnergyState(
event.getProperties().getTotalEnergy());
capabilityState.setTwoWayMeterEnergyConsumptionSensorEnergyPerMonthInEuroState(
event.getProperties().getEnergyPerMonthInEuro());
capabilityState.setTwoWayMeterEnergyConsumptionSensorEnergyPerDayInEuroState(
event.getProperties().getEnergyPerDayInEuro());
capabilityState.setTwoWayMeterEnergyConsumptionSensorEnergyPerDayInKWhState(
event.getProperties().getEnergyPerDayInKWh());
deviceChanged = true;
// TwoWayMeterEnergyFeedSensor
} else if (capability.isTypeTwoWayMeterEnergyFeedSensor()) {
capabilityState.setTwoWayMeterEnergyFeedSensorEnergyPerMonthInKWhState(
event.getProperties().getEnergyPerMonthInKWh());
capabilityState
.setTwoWayMeterEnergyFeedSensorTotalEnergyState(event.getProperties().getTotalEnergy());
capabilityState.setTwoWayMeterEnergyFeedSensorEnergyPerMonthInEuroState(
event.getProperties().getEnergyPerMonthInEuro());
capabilityState.setTwoWayMeterEnergyFeedSensorEnergyPerDayInEuroState(
event.getProperties().getEnergyPerDayInEuro());
capabilityState.setTwoWayMeterEnergyFeedSensorEnergyPerDayInKWhState(
event.getProperties().getEnergyPerDayInKWh());
deviceChanged = true;
// TwoWayMeterPowerConsumptionSensor
} else if (capability.isTypeTwoWayMeterPowerConsumptionSensor()) {
capabilityState.setTwoWayMeterPowerConsumptionSensorPowerInWattState(
event.getProperties().getPowerInWatt());
deviceChanged = true;
} else {
logger.debug("Unsupported capability type {}.", capability.getType());
}
} else {
logger.debug("Capability {} has no state (yet?) - refreshing device.", capability.getName());
@Nullable
final InnogyBridgeHandler innogyBridgeHandler = getInnogyBridgeHandler();
if (innogyBridgeHandler != null) {
device = innogyBridgeHandler.refreshDevice(deviceId);
}
if (device != null) {
capabilityMap = device.getCapabilityMap();
capability = capabilityMap.get(linkedCapabilityId);
if (capability.hasState()) {
deviceChanged = true;
}
}
}
if (deviceChanged && device != null) {
onDeviceStateChanged(device);
}
} else if (event.isLinkedtoDevice()) {
if (device.hasDeviceState()) {
onDeviceStateChanged(device);
} else {
logger.debug("Device {}/{} has no state.", device.getConfig().getName(), device.getId());
}
}
}
}
/**
* Returns the inverted value. Currently only rollershutter channels are supported.
*
* @param value
* @return the value or the inverted value
*/
private int invertValueIfConfigured(final String channelId, final int value) {
if (!CHANNEL_ROLLERSHUTTER.equals(channelId)) {
logger.debug("Channel {} cannot be inverted.", channelId);
return value;
}
@Nullable
final Channel channel = getThing().getChannel(channelId);
if (channel == null) {
logger.debug("Channel {} was null! Value not inverted.", channelId);
return value;
}
final Boolean invert = (Boolean) channel.getConfiguration().get("invert");
return invert != null && invert ? value : (100 - value);
}
}

View File

@ -1,43 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.listener;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.event.Event;
/**
* The {@link DeviceStatusListener} is called, when {@link Device}s are added, removed or changed.
*
* @author Oliver Kuhl - Initial contribution
*/
@NonNullByDefault
public interface DeviceStatusListener {
/**
* This method is called whenever the state of the given {@link Device} has changed.
*
* @param device
* The device which received the state update.
*/
public void onDeviceStateChanged(Device device);
/**
* This method is called whenever the state of a {@link Device} is changed by the given {@link Event}.
*
* @param device
* @param event
*
*/
public void onDeviceStateChanged(Device device, Event event);
}

View File

@ -1,45 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.listener;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.innogysmarthome.internal.InnogyWebSocket;
/**
* The {@link EventListener} is called by the {@link InnogyWebSocket} on new Events and if the {@link InnogyWebSocket}
* closed the connection.
*
* @author Oliver Kuhl - Initial contribution
*/
@NonNullByDefault
public interface EventListener {
/**
* This method is called, whenever a new event comes from the innogy service (like a device change for example).
*
* @param msg
*/
void onEvent(String msg);
/**
* This method is called when the innogy websocket services throws an onError.
*
* @param cause
*/
void onError(Throwable cause);
/**
* This method is called, when the evenRunner stops abnormally (statuscode <> 1000).
*/
void connectionClosed();
}

View File

@ -1,235 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.manager;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants;
import org.openhab.binding.innogysmarthome.internal.client.InnogyClient;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
import org.openhab.binding.innogysmarthome.internal.client.exception.ApiException;
import org.openhab.binding.innogysmarthome.internal.client.exception.AuthenticationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Manages the structure of the {@link Device}s and the calls to the {@link InnogyClient} to load the {@link Device}
* data from the innogy SmartHome web service.
*
* @author Oliver Kuhl - Initial contribution
*
*/
@NonNullByDefault
public class DeviceStructureManager {
private final Logger logger = LoggerFactory.getLogger(DeviceStructureManager.class);
private final FullDeviceManager deviceManager;
private final Map<String, Device> deviceMap;
private final Map<String, Device> capabilityIdToDeviceMap;
private String bridgeDeviceId = "";
/**
* Constructs the {@link DeviceStructureManager}.
*
* @param deviceManager the {@link FullDeviceManager}
*/
public DeviceStructureManager(FullDeviceManager deviceManager) {
this.deviceManager = deviceManager;
deviceMap = Collections.synchronizedMap(new HashMap<>());
capabilityIdToDeviceMap = new ConcurrentHashMap<>();
}
/**
* Returns the {@link #deviceMap}, a map with the device id and the device.
*
* @return
*/
public Map<String, Device> getDeviceMap() {
return deviceMap;
}
/**
* Loads all device data from the bridge and stores the {@link Device}s and their states in the
* {@link DeviceStructureManager}.
*
* @throws IOException
* @throws ApiException
* @throws AuthenticationException
*/
public void refreshDevices() throws IOException, ApiException, AuthenticationException {
deviceMap.clear();
capabilityIdToDeviceMap.clear();
List<Device> devices = deviceManager.getFullDevices();
for (Device d : devices) {
handleRefreshedDevice(d);
}
}
/**
* Refreshs the {@link Device} with the given id and stores it in the {@link DeviceStructureManager}.
*
* @param deviceId
* @throws IOException
* @throws ApiException
* @throws AuthenticationException
*/
public void refreshDevice(String deviceId) throws IOException, ApiException, AuthenticationException {
logger.trace("Refreshing Device with id '{}'", deviceId);
Device d = deviceManager.getFullDeviceById(deviceId);
handleRefreshedDevice(d);
}
/**
* Stores the newly refreshed {@link Device} in the {@link DeviceStructureManager} structure and logs the
* {@link Device}s details and state, if the debug logging is enabled.
*
* @param d the {@link Device}
*/
private void handleRefreshedDevice(Device d) {
if (InnogyBindingConstants.SUPPORTED_DEVICES.contains(d.getType())) {
addDeviceToStructure(d);
} else {
logger.debug("Device {}:'{}' by {} ({}) ignored - UNSUPPORTED.", d.getType(), d.getConfig().getName(),
d.getManufacturer(), d.getId());
logger.debug("====================================");
return;
}
if (d.isController()) {
bridgeDeviceId = d.getId();
}
if (logger.isDebugEnabled()) {
try {
logger.debug("Device {}:'{}@{}' by {} ({}) loaded.", d.getType(), d.getConfig().getName(),
d.getLocation() != null ? d.getLocation().getName() : "<none>", d.getManufacturer(), d.getId());
for (Capability c : d.getCapabilityMap().values()) {
logger.debug("> CAP: {}/{} ({})", c.getType(), c.getName(), c.getId());
if (d.isRadioDevice() && !d.isReachable()) {
logger.debug(">> CAP-State: unknown (device NOT REACHABLE).");
} else {
if (!c.hasState()) {
logger.debug(">> CAP-State: unknown (NULL)");
}
}
}
} catch (RuntimeException e) {
logger.debug("Error during logging: ", e);
}
logger.debug("====================================");
}
}
/**
* Adds the {@link Device} to the structure.
*
* @param device
*/
public void addDeviceToStructure(Device device) {
if (device.getId() != null) {
getDeviceMap().put(device.getId(), device);
}
for (String cl : device.getCapabilities()) {
capabilityIdToDeviceMap.put(Link.getId(cl), device);
}
}
/**
* Returns the {@link Device} with the given id.
*
* @param id
* @return the {@link Device} or null, if it does not exist
*/
public @Nullable Device getDeviceById(String id) {
logger.debug("getDeviceById {}:{}", id, getDeviceMap().containsKey(id));
return getDeviceMap().get(id);
}
/**
* Returns the {@link Device}, that provides the given capability.
*
* @param capabilityId
* @return {@link Device} or null
*/
public @Nullable Device getDeviceByCapabilityId(String capabilityId) {
return capabilityIdToDeviceMap.get(capabilityId);
}
/**
* Returns the bridge {@link Device}.
*
* @return
*/
public @Nullable Device getBridgeDevice() {
return getDeviceMap().get(bridgeDeviceId);
}
/**
* Returns a {@link Collection} of all {@link Device}s handled by the {@link DeviceStructureManager}.
*
* @return
*/
public Collection<Device> getDeviceList() {
return Collections.unmodifiableCollection(getDeviceMap().values());
}
/**
* Returns the {@link Device}, that has the {@link Message} with the given messageId.
*
* @param messageId the id of the {@link Message}
* @return the {@link Device} or null if none found
*/
public @Nullable Device getDeviceWithMessageId(String messageId) {
logger.trace("Getting Device with MessageId '{}'", messageId);
for (Device d : getDeviceMap().values()) {
if (d.hasMessages()) {
for (Message m : d.getMessageList()) {
if (messageId.equals(m.getId())) {
return d;
}
}
}
}
return null;
}
/**
* Returns the id of the {@link Capability} for {@link Device} with the given id and the given capabilityType.
*
* @param deviceId
* @param capabilityType
* @return the id of the found {@link Capability} or null
*/
public @Nullable String getCapabilityId(String deviceId, String capabilityType) {
Device device = getDeviceMap().get(deviceId);
for (Capability c : device.getCapabilityMap().values()) {
if (c.getType().equals(capabilityType)) {
return c.getId();
}
}
return null;
}
}

View File

@ -1,223 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.manager;
import static org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants.BATTERY_POWERED_DEVICES;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.innogysmarthome.internal.client.InnogyClient;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.CapabilityState;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.DeviceState;
import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
import org.openhab.binding.innogysmarthome.internal.client.entity.location.Location;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
import org.openhab.binding.innogysmarthome.internal.client.exception.ApiException;
import org.openhab.binding.innogysmarthome.internal.client.exception.AuthenticationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Sven Strohschein - Initial contribution (but only created by refactoring the InnogyClient class)
*/
@NonNullByDefault
public class FullDeviceManager {
private final Logger logger = LoggerFactory.getLogger(FullDeviceManager.class);
private final InnogyClient client;
public FullDeviceManager(InnogyClient client) {
this.client = client;
}
/**
* Returns a {@link List} of all {@link Device}s with the full configuration details, {@link Capability}s and
* states. Calling this may take a while...
*/
public List<Device> getFullDevices() throws IOException, ApiException, AuthenticationException {
final Map<String, Location> locationMap = createLocationMap(client);
final Map<String, Capability> capabilityMap = createCapabilityMap(client);
final Map<String, DeviceState> deviceStateMap = createDeviceStateMap(client);
final Map<String, List<Message>> messageMap = createMessageMap(client);
final List<Device> deviceList = client.getDevices(deviceStateMap.keySet());
for (final Device device : deviceList) {
final String deviceId = device.getId();
initializeDevice(device, deviceStateMap.get(deviceId), locationMap, capabilityMap,
getMessageList(device, messageMap));
}
return deviceList;
}
/**
* Returns the {@link Device} with the given deviceId with full configuration details, {@link Capability}s and
* states. Calling this may take a little bit longer...
*/
public Device getFullDeviceById(final String deviceId) throws IOException, ApiException, AuthenticationException {
final Map<String, Location> locationMap = createLocationMap(client);
final Map<String, Capability> capabilityMap = createCapabilityMap(deviceId, client);
final List<Message> messageMap = createMessageMap(deviceId, client);
final DeviceState deviceState = new DeviceState();
deviceState.setId(deviceId);
deviceState.setState(client.getDeviceStateByDeviceId(deviceId));
final Device device = client.getDeviceById(deviceId);
initializeDevice(device, deviceState, locationMap, capabilityMap, messageMap);
return device;
}
private void initializeDevice(Device device, @Nullable DeviceState deviceState, Map<String, Location> locationMap,
Map<String, Capability> capabilityMap, List<Message> messageList) {
device.setDeviceState(deviceState);
if (isBatteryPowered(device)) {
device.setIsBatteryPowered(true);
}
device.setLocation(locationMap.get(device.getLocationId()));
device.setCapabilityMap(createDeviceCapabilityMap(device, capabilityMap));
device.setMessageList(messageList);
}
private static boolean isBatteryPowered(Device device) {
return BATTERY_POWERED_DEVICES.contains(device.getType());
}
private List<Message> getMessageList(Device device, Map<String, List<Message>> messageMap) {
return Objects.requireNonNullElse(messageMap.get(device.getId()), Collections.emptyList());
}
private static Map<String, Location> createLocationMap(InnogyClient client)
throws IOException, ApiException, AuthenticationException {
final List<Location> locationList = client.getLocations();
final Map<String, Location> locationMap = new HashMap<>(locationList.size());
for (final Location location : locationList) {
locationMap.put(location.getId(), location);
}
return locationMap;
}
private static Map<String, CapabilityState> createCapabilityStateMap(InnogyClient client)
throws IOException, ApiException, AuthenticationException {
final List<CapabilityState> capabilityStateList = client.getCapabilityStates();
final Map<String, CapabilityState> capabilityStateMap = new HashMap<>(capabilityStateList.size());
for (final CapabilityState capabilityState : capabilityStateList) {
capabilityStateMap.put(capabilityState.getId(), capabilityState);
}
return capabilityStateMap;
}
private static Map<String, Capability> createCapabilityMap(InnogyClient client)
throws IOException, ApiException, AuthenticationException {
final Map<String, CapabilityState> capabilityStateMap = createCapabilityStateMap(client);
final List<Capability> capabilityList = client.getCapabilities();
return initializeCapabilities(capabilityStateMap, capabilityList);
}
private static Map<String, Capability> createCapabilityMap(String deviceId, InnogyClient client)
throws IOException, ApiException, AuthenticationException {
final Map<String, CapabilityState> capabilityStateMap = createCapabilityStateMap(client);
final List<Capability> capabilityList = client.getCapabilitiesForDevice(deviceId);
return initializeCapabilities(capabilityStateMap, capabilityList);
}
private static Map<String, Capability> initializeCapabilities(Map<String, CapabilityState> capabilityStateMap,
List<Capability> capabilityList) {
final Map<String, Capability> capabilityMap = new HashMap<>(capabilityList.size());
for (final Capability capability : capabilityList) {
String capabilityId = capability.getId();
CapabilityState capabilityState = capabilityStateMap.get(capabilityId);
capability.setCapabilityState(capabilityState);
capabilityMap.put(capabilityId, capability);
}
return capabilityMap;
}
private static Map<String, Capability> createDeviceCapabilityMap(Device device,
Map<String, Capability> capabilityMap) {
final HashMap<String, Capability> deviceCapabilityMap = new HashMap<>();
for (final String capabilityValue : device.getCapabilities()) {
final Capability capability = capabilityMap.get(Link.getId(capabilityValue));
final String capabilityId = capability.getId();
deviceCapabilityMap.put(capabilityId, capability);
}
return deviceCapabilityMap;
}
private static Map<String, DeviceState> createDeviceStateMap(InnogyClient client)
throws IOException, ApiException, AuthenticationException {
final List<DeviceState> deviceStateList = client.getDeviceStates();
final Map<String, DeviceState> deviceStateMap = new HashMap<>(deviceStateList.size());
for (final DeviceState deviceState : deviceStateList) {
deviceStateMap.put(deviceState.getId(), deviceState);
}
return deviceStateMap;
}
private List<Message> createMessageMap(String deviceId, InnogyClient client)
throws IOException, ApiException, AuthenticationException {
final List<Message> messages = client.getMessages();
final List<Message> messageList = new ArrayList<>();
final String deviceIdPath = "/device/" + deviceId;
for (final Message message : messages) {
logger.trace("Message Type {} with ID {}", message.getType(), message.getId());
if (message.getDevices() != null && !message.getDevices().isEmpty()) {
for (final String li : message.getDevices()) {
if (deviceIdPath.equals(li)) {
messageList.add(message);
}
}
}
}
return messageList;
}
private static Map<String, List<Message>> createMessageMap(InnogyClient client)
throws IOException, ApiException, AuthenticationException {
final List<Message> messageList = client.getMessages();
final Map<String, List<Message>> deviceMessageMap = new HashMap<>();
for (final Message message : messageList) {
if (message.getDevices() != null && !message.getDevices().isEmpty()) {
final String deviceId = message.getDevices().get(0).replace("/device/", "");
List<Message> ml;
if (deviceMessageMap.containsKey(deviceId)) {
ml = deviceMessageMap.get(deviceId);
} else {
ml = new ArrayList<>();
}
ml.add(message);
deviceMessageMap.put(deviceId, ml);
}
}
return deviceMessageMap;
}
}

View File

@ -1,39 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.util;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* The {@link ExceptionUtils} class defines static Exception related methods
*
* @author Leo Siepel - Initial contribution
*/
@NonNullByDefault
public class ExceptionUtils {
public static Throwable getRootThrowable(Throwable throwable) {
List<Throwable> list = new ArrayList<>();
while (!list.contains(throwable)) {
list.add(throwable);
Throwable throwableLocal = throwable.getCause();
if (throwableLocal != null) {
throwable = throwableLocal;
}
}
return throwable;
}
}

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon:addon id="innogysmarthome" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:addon="https://openhab.org/schemas/addon/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/addon/v1.0.0 https://openhab.org/schemas/addon-1.0.0.xsd">
<type>binding</type>
<name>innogy SmartHome Binding</name>
<description>The innogy SmartHome binding integrates your innogy SmartHome system.</description>
</addon:addon>

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<config-description:config-descriptions
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:config-description="https://openhab.org/schemas/config-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0
https://openhab.org/schemas/config-description-1.0.0.xsd">
<config-description uri="thing-type:innogysmarthome:config">
<parameter name="id" type="text" required="true">
<label>ID</label>
<description>The identifier uniquely identifies this device.</description>
</parameter>
</config-description>
</config-description:config-descriptions>

View File

@ -1,157 +0,0 @@
# add-on
addon.innogysmarthome.name = innogy SmartHome Binding
addon.innogysmarthome.description = The innogy SmartHome binding integrates your innogy SmartHome system.
# thing types
thing-type.innogysmarthome.AnalogMeter.label = Analog Meter
thing-type.innogysmarthome.AnalogMeter.description = The Analog Meter from the innogy EnergyControl product.
thing-type.innogysmarthome.BRC8.label = Basic Remote Controller (BRC8)
thing-type.innogysmarthome.BRC8.description = A battery powered remote controller with eight push buttons.
thing-type.innogysmarthome.BT-PSS.label = Bluetooth Pluggable Smart Switch (BT-PSS)
thing-type.innogysmarthome.BT-PSS.description = A pluggable switch that can be switched on and off and which can measure the current energy consumption.
thing-type.innogysmarthome.GenerationMeter.label = Generation Meter
thing-type.innogysmarthome.GenerationMeter.description = The Generation Meter from the innogy PowerControlSolar product, that measures the generated energy.
thing-type.innogysmarthome.ISC2.label = In Wall Smart Controller (ISC2)
thing-type.innogysmarthome.ISC2.description = A smart controller with two push buttons.
thing-type.innogysmarthome.ISD2.label = In Wall Smart Dimmer (ISD2)
thing-type.innogysmarthome.ISD2.description = An in wall dimmer with push buttons.
thing-type.innogysmarthome.ISR2.label = In Wall Smart Roller Shutter (ISR2)
thing-type.innogysmarthome.ISR2.description = An in wall rollershutter with two push buttons.
thing-type.innogysmarthome.ISS2.label = In Wall Smart Switch (ISS2)
thing-type.innogysmarthome.ISS2.description = An in wall switch with push buttons that can be switched on and off.
thing-type.innogysmarthome.PSD.label = Pluggable Smart Dimmer (PSD)
thing-type.innogysmarthome.PSD.description = A pluggable dimmer.
thing-type.innogysmarthome.PSS.label = Pluggable Smart Switch (PSS)
thing-type.innogysmarthome.PSS.description = A pluggable switch that can be switched on and off.
thing-type.innogysmarthome.PSSO.label = Pluggable Smart Switch Outdoor (PSSO)
thing-type.innogysmarthome.PSSO.description = A pluggable outdoor switch that can be switched on and off.
thing-type.innogysmarthome.RST.label = Radiator Mounted Smart Thermostat (RST)
thing-type.innogysmarthome.RST.description = A thermostat, that supports setting the temperature and measuring the current temperature and humidity.
thing-type.innogysmarthome.RST2.label = Radiator Mounted Smart Thermostat (RST2)
thing-type.innogysmarthome.RST2.description = A thermostat, that supports setting the temperature and measuring the current temperature and humidity (2 battery version since 2018)
thing-type.innogysmarthome.SmartMeter.label = Smart Meter
thing-type.innogysmarthome.SmartMeter.description = The Smart Meter from the innogy PowerControl product.
thing-type.innogysmarthome.TwoWayMeter.label = Two-Way-Meter
thing-type.innogysmarthome.TwoWayMeter.description = The Two-Way-Meter from the innogy PowerControlSolar product.
thing-type.innogysmarthome.VariableActuator.label = Variable Actuator
thing-type.innogysmarthome.VariableActuator.description = A variable from the innogy SmartHome System that can be switched on and off.
thing-type.innogysmarthome.WDS.label = Wall Mounted Door/Window Sensor (WDS)
thing-type.innogysmarthome.WDS.description = A window/door sensor, that provides the open/close state.
thing-type.innogysmarthome.WMD.label = Wall Mounted Motion Detector Indoor (WMD)
thing-type.innogysmarthome.WMD.description = A battery powered motion detector, that also measures luminance.
thing-type.innogysmarthome.WMDO.label = Wall Mounted Motion Detector Outdoor (WMDO)
thing-type.innogysmarthome.WMDO.description = A battery powered motion detector for outdoors, that also measures luminance.
thing-type.innogysmarthome.WRT.label = Wall Mounted Room Thermostat (WRT)
thing-type.innogysmarthome.WRT.description = A wall thermostat, that supports setting the temperature and measuring the current temperature and humidity.
thing-type.innogysmarthome.WSC2.label = Wall Mounted Smart Controller (WSC2)
thing-type.innogysmarthome.WSC2.description = A battery powered smart controller with two push buttons.
thing-type.innogysmarthome.WSD.label = Wall Mounted Smoke Detector (WSD)
thing-type.innogysmarthome.WSD.description = A battery powered smoke detector sensor with integrated alarm (first version).
thing-type.innogysmarthome.WSD2.label = Wall Mounted Smoke Detector (WSD2)
thing-type.innogysmarthome.WSD2.description = A battery powered smoke detector sensor with integrated alarm (2nd version with long-life battery).
thing-type.innogysmarthome.bridge.label = innogy SmartHome Controller
thing-type.innogysmarthome.bridge.description = The innogy SmartHome Controller (SHC) is the bridge for the innogy SmartHome System.
# thing types config
thing-type.config.innogysmarthome.bridge.authcode.label = Authorization Code
thing-type.config.innogysmarthome.bridge.authcode.description = The auth-code is a one-time code needed to retrieve the necessary access-codes from innogy SmartHome Service. <b>Please go - depending on your brand - to...</b> <ul> <li><b>innogy SmartHome Portal</b>: https://auth.services-smarthome.de/AUTH/authorize?response_type=code&client_id=24635748&redirect_uri=https%3A%2F%2Fwww.openhab.org%2Foauth%2Finnogy%2Finnogy-smarthome.html&scope&lang=de-DE</li> </ul> <b>... to generate an auth-code and paste it here</b>. After initial authorization, this code is not needed anymore.
thing-type.config.innogysmarthome.bridge.brand.label = Brand
thing-type.config.innogysmarthome.bridge.brand.description = Choose the brand of your innogy SmartHome based solution.
thing-type.config.innogysmarthome.bridge.brand.option.innogy_smarthome = innogy SmartHome
thing-type.config.innogysmarthome.bridge.group.advanced.label = Advanced Configuration
thing-type.config.innogysmarthome.bridge.group.advanced.description = Advanced parameters, for special tweaking only.
thing-type.config.innogysmarthome.bridge.group.connection.label = Connection
thing-type.config.innogysmarthome.bridge.group.connection.description = Parameters for connecting to innogy SmartHome Controller (SHC)
thing-type.config.innogysmarthome.bridge.websocketidletimeout.label = WebSocket Idle Timeout in Seconds
thing-type.config.innogysmarthome.bridge.websocketidletimeout.description = The WebSocket is the connection to the innogy service that listens to status updates. If no data is received over the websocket connection for the given time, the websocket will reconnect. 0 will disable the idle timeout. Default is 900 seconds (15 minutes).
thing-type.config.innogysmarthome.config.id.label = ID
thing-type.config.innogysmarthome.config.id.description = The identifier uniquely identifies this device.
# channel types
channel-type.innogysmarthome.AbsoluteEnergyConsumption.label = Total Consumption
channel-type.innogysmarthome.AbsoluteEnergyConsumption.description = The absolute Energy consumption
channel-type.innogysmarthome.AlarmActuator.label = Alarm
channel-type.innogysmarthome.AlarmActuator.description = Switches the alarm on/off
channel-type.innogysmarthome.BooleanStateActuator.label = Switch
channel-type.innogysmarthome.BooleanStateActuator.description = Switches the state on/off
channel-type.innogysmarthome.CPUUsage.label = CPU Usage
channel-type.innogysmarthome.CPUUsage.description = The CPU usage of SHC-A, updated every 5 minutes
channel-type.innogysmarthome.DimmerActuator.label = Dimmer
channel-type.innogysmarthome.DimmerActuator.description = Dimms the connected light
channel-type.innogysmarthome.DiskUsage.label = Disk Usage
channel-type.innogysmarthome.DiskUsage.description = The disk usage of SHC-A, updated every 5 minutes
channel-type.innogysmarthome.EnergyConsumptionDayEuro.label = Consumption Costs (day)
channel-type.innogysmarthome.EnergyConsumptionDayEuro.description = The energy consumption per day in Euro
channel-type.innogysmarthome.EnergyConsumptionDayKWh.label = Consumption (day)
channel-type.innogysmarthome.EnergyConsumptionDayKWh.description = The energy consumption per day in kWh
channel-type.innogysmarthome.EnergyConsumptionMonthEuro.label = Consumption Costs (month)
channel-type.innogysmarthome.EnergyConsumptionMonthEuro.description = The energy consumption per month in Euro
channel-type.innogysmarthome.EnergyConsumptionMonthKWh.label = Consumption (month)
channel-type.innogysmarthome.EnergyConsumptionMonthKWh.description = The energy consumption per month in kWh
channel-type.innogysmarthome.EnergyFeedDayEuro.label = Feed Income (day)
channel-type.innogysmarthome.EnergyFeedDayEuro.description = The energy feed per day in Euro
channel-type.innogysmarthome.EnergyFeedDayKWh.label = Feed (day)
channel-type.innogysmarthome.EnergyFeedDayKWh.description = The energy feed per day in kWh
channel-type.innogysmarthome.EnergyFeedMonthEuro.label = Feed Income (month)
channel-type.innogysmarthome.EnergyFeedMonthEuro.description = The energy feed per month in Euro
channel-type.innogysmarthome.EnergyFeedMonthKWh.label = Feed (month)
channel-type.innogysmarthome.EnergyFeedMonthKWh.description = The energy feed per month in kWh
channel-type.innogysmarthome.EnergyGenerationDayEuro.label = Generation Value (day)
channel-type.innogysmarthome.EnergyGenerationDayEuro.description = The energy generation per day in Euro
channel-type.innogysmarthome.EnergyGenerationDayKWh.label = Generation (day)
channel-type.innogysmarthome.EnergyGenerationDayKWh.description = The energy generation per day in kWh
channel-type.innogysmarthome.EnergyGenerationMonthEuro.label = Generation Value (month)
channel-type.innogysmarthome.EnergyGenerationMonthEuro.description = The energy generation per month in Euro
channel-type.innogysmarthome.EnergyGenerationMonthKWh.label = Generation (month)
channel-type.innogysmarthome.EnergyGenerationMonthKWh.description = The energy generation per month in kWh
channel-type.innogysmarthome.HumiditySensor_Humidity.label = Actual Humidity
channel-type.innogysmarthome.HumiditySensor_Humidity.description = Actual measured room humidity
channel-type.innogysmarthome.HumiditySensor_MoldWarning.label = Mold Warning
channel-type.innogysmarthome.HumiditySensor_MoldWarning.description = Active, if humidity is over a threshold (configured in innogy app)
channel-type.innogysmarthome.LuminanceSensor.label = Luminance
channel-type.innogysmarthome.LuminanceSensor.description = Shows the detected luminance in percent
channel-type.innogysmarthome.MemoryUsage.label = Memory Usage
channel-type.innogysmarthome.MemoryUsage.description = The memory usage of SHC-A, updated every 5 minutes
channel-type.innogysmarthome.MotionDetectionSensor.label = Motion Count
channel-type.innogysmarthome.MotionDetectionSensor.description = The count of detected motions
channel-type.innogysmarthome.PowerConsumptionWatt.label = Current Power Consumption
channel-type.innogysmarthome.PowerConsumptionWatt.description = The current power consumption in Watt
channel-type.innogysmarthome.PowerGenerationWatt.label = Current Power Generation
channel-type.innogysmarthome.PowerGenerationWatt.description = The current power generation in Watt
channel-type.innogysmarthome.PushButtonCounter.label = Button Pushed Count
channel-type.innogysmarthome.PushButtonCounter.description = The count of button pushes.
channel-type.innogysmarthome.RollerShutterActuator.label = Blinds Position
channel-type.innogysmarthome.RollerShutterActuator.description = Controls the blinds
channel-type.innogysmarthome.SmokeDetectorSensor.label = Smoke
channel-type.innogysmarthome.SmokeDetectorSensor.description = Shows if smoke was detected
channel-type.innogysmarthome.SwitchActuator.label = Switch
channel-type.innogysmarthome.SwitchActuator.description = Switches the current on/off
channel-type.innogysmarthome.TemperatureSensor_FrostWarning.label = Frost Warning
channel-type.innogysmarthome.TemperatureSensor_FrostWarning.description = Warns, if temperature drop below a threshold (configured in innogy app)
channel-type.innogysmarthome.TemperatureSensor_Temperature.label = Actual Temperature
channel-type.innogysmarthome.TemperatureSensor_Temperature.description = Actual measured room temperature
channel-type.innogysmarthome.ThermostatActuator_OperationMode.label = Operation Mode
channel-type.innogysmarthome.ThermostatActuator_OperationMode.description = Thermostat operation mode (manual/auto)
channel-type.innogysmarthome.ThermostatActuator_OperationMode.state.option.Auto = auto
channel-type.innogysmarthome.ThermostatActuator_OperationMode.state.option.Manu = manual
channel-type.innogysmarthome.ThermostatActuator_PointTemperature.label = Target Temperature
channel-type.innogysmarthome.ThermostatActuator_PointTemperature.description = Thermostat target temperature
channel-type.innogysmarthome.ThermostatActuator_WindowReductionActive.label = Window Reduction Active
channel-type.innogysmarthome.ThermostatActuator_WindowReductionActive.description = Thermostat temperature reduced, if window is open.
channel-type.innogysmarthome.TotalEnergyConsumption.label = Total Consumption
channel-type.innogysmarthome.TotalEnergyConsumption.description = The total Energy consumption
channel-type.innogysmarthome.TotalEnergyFed.label = Total Fed
channel-type.innogysmarthome.TotalEnergyFed.description = The total Energy fed
channel-type.innogysmarthome.TotalEnergyGeneration.label = Total Generation
channel-type.innogysmarthome.TotalEnergyGeneration.description = The total Energy generation
channel-type.innogysmarthome.WindowDoorSensor.label = Contact
channel-type.innogysmarthome.WindowDoorSensor.description = Shows the open/close state
# channel types config
channel-type.config.innogysmarthome.RollerShutterActuator.invert.label = Invert Position
channel-type.config.innogysmarthome.RollerShutterActuator.invert.description = When invert is true than 0 on innogy is UP and 100 is DOWN

View File

@ -1,106 +0,0 @@
# add-on
addon.innogysmarthome.name = innogy SmartHome Binding
addon.innogysmarthome.description = Das innogy SmartHome Binding verbindet Dein innogy SmartHome System mit openHAB.
# thing types
thing-type.innogysmarthome.bridge.label = innogy SmartHome Zentrale
thing-type.innogysmarthome.bridge.description = Der innogy SmartHome Controller (SHC) ist die Zentrale für das innogy SmartHome System.
thing-type.config.innogysmarthome.bridge.connection.label = Verbindung
thing-type.config.innogysmarthome.bridge.connection.description = Parameter zur Verbindung mit dem innogy SmartHome Controller (SHC)
thing-type.config.innogysmarthome.bridge.brand.label = Marke
thing-type.config.innogysmarthome.bridge.brand.description = Wähle die Marke Deiner innogy SmartHome Lösung.
thing-type.config.innogysmarthome.bridge.authcode.label = Autorisierungscode
thing-type.config.innogysmarthome.bridge.authcode.description = Der Autorisierungscode ist ein einmaliger Code, um die notwendigen Zugangscodes vom innogy SmartHome Dienst zu erhalten. <b> Bitte gehe je nach Marke zum...</b><ul> <li><b>innogy SmartHome Portal</b>: https://auth.services-smarthome.de/AUTH/authorize?response_type=code&client_id=24635748&redirect_uri=https%3A%2F%2Fwww.openhab.org%2Foauth%2Finnogy%2Finnogy-smarthome.html&scope&lang=de-DE</li></ul><b>... um einen Autorisierungscode zu erstellen und kopiere ihn hier hinein.</b>. Nach der einmaligen Autorisierung verfällt der Code und wird nicht mehr benötigt.
thing-type.config.innogysmarthome.bridge.websocketidletimeout.label = WebSocket idle timeout in Sekunden
thing-type.config.innogysmarthome.bridge.websocketidletimeout.description = Der WebSocket hält die Verbindung zum innogy Webservice und wartet auf Statusaktualisierungen. Wenn für die angegebene Dauer keine Daten über den WebSocket empfangen werden, wird die Verbindung neu aufgebaut. 0 deaktiviert den idle timeout. Standard ist 900 Sekunden (15 Minuten).
thing-type.config.innogysmarthome.bridge.refreshtoken.label = Refresh-Token
thing-type.config.innogysmarthome.bridge.refreshtoken.description = Über den Refresh-Token wird ein gültiger Access-Token generiert. Der Refresh-Token wird automatisch mittels des Autorisierungscodes einmalig vom innogy Backend abgeholt.
thing-type.config.innogysmarthome.bridge.accesstoken.label = Access-Token
thing-type.config.innogysmarthome.bridge.accesstoken.description = Der Access-Token wird genutzt, um auf das innogy SmartHome Backend zuzugreifen. Er wird automatisch vom innogy Backend abgeholt.
thing-type.innogysmarthome.BRC8.label = Funkfernbedienung (BRC8)
thing-type.innogysmarthome.BRC8.description = Eine batteriebetriebene Fernbedienung mit 8 Tasten.
thing-type.innogysmarthome.ISC2.label = Unterputzsender (ISC2)
thing-type.innogysmarthome.ISC2.description = Ein Unterputzsender mit zwei Tasten.
thing-type.innogysmarthome.ISD2.label = Unterputzdimmer (ISD2)
thing-type.innogysmarthome.ISD2.description = Ein Unterputzdimmer mit zwei Tasten.
thing-type.innogysmarthome.ISR2.label = Unterputz Rolladensteuerung (ISR2)
thing-type.innogysmarthome.ISR2.description = Eine Unterputz Rolladensteuerung mit zwei Tasten.
thing-type.config.innogysmarthome.ISR2.label = Werte invertieren
thing-type.config.innogysmarthome.ISR2.description = Invertiert die Werteanzeige und Steuerung.
thing-type.innogysmarthome.ISS2.label = Unterputz Lichtschalter (ISS2)
thing-type.innogysmarthome.ISS2.description = Ein Unterputz Lichtschalter mit zwei Tasten.
thing-type.innogysmarthome.PSD.label = Zwischenstecker dimmbar (PSD)
thing-type.innogysmarthome.PSD.description = Ein dimmbarer Zwischenstecker.
thing-type.innogysmarthome.PSS.label = Zwischenstecker innen (PSS)
thing-type.innogysmarthome.PSS.description = Ein Zwischenstecker für innen, der ein- und ausgeschaltet werden kann.
thing-type.innogysmarthome.PSSO.label = Zwischenstecker außen (PSSO)
thing-type.innogysmarthome.PSSO.description = Ein Zwischenstecker für den Außenbereich, der ein- und ausgeschaltet werden kann.
thing-type.innogysmarthome.RST.label = Heizkörperthermostat (RST)
thing-type.innogysmarthome.RST.description = Das Thermostat unterstützt das Einstellen der Temperatur sowie das Messen der aktuellen Temperatur und Luftfeuchtigkeit.
thing-type.innogysmarthome.RST2.label = Heizkörperthermostat (RST2)
thing-type.innogysmarthome.RST2.description = Das Thermostat unterstützt das Einstellen der Temperatur sowie das Messen der aktuellen Temperatur und Luftfeuchtigkeit (Version mit 2 Batterien seit 2018).
thing-type.innogysmarthome.VariableActuator.label = Zustandsvariable
thing-type.innogysmarthome.VariableActuator.description = Eine Zustandsvariable des innogy SmartHome Systems, die ein- oder ausgeschaltet werden kann.
thing-type.innogysmarthome.WDS.label = Fenster-/Türkontakt (WDS)
thing-type.innogysmarthome.WDS.description = Ein Fenster-/Türkontakt, der offen oder geschlossen anzeigt.
thing-type.innogysmarthome.WMD.label = Bewegungsmelder (WMD)
thing-type.innogysmarthome.WMD.description = Ein batteriebetriebener Bewegungsmelder, der zusätzlich die Helligkeit misst.
thing-type.innogysmarthome.WMDO.label = Bewegungsmelder außen (WMDO)
thing-type.innogysmarthome.WMDO.description = Ein batteriebetriebener Bewegungsmelder für den Außenbereich, der zusätzlich die Helligkeit misst.
thing-type.innogysmarthome.WRT.label = Raumthermostat (WRT)
thing-type.innogysmarthome.WRT.description = Ein Raumthermostat zur Wandbefestigung, das das Einstellen der Temperatur sowie das Messen der aktuellen Temperatur und Luftfeuchtigkeit unterstützt.
thing-type.innogysmarthome.WSC2.label = Wandsender (WSC2)
thing-type.innogysmarthome.WSC2.description = Ein batteriebetriebener Wandsender mit zwei Tasten.
thing-type.innogysmarthome.WSD.label = Rauchmelder (WSD)
thing-type.innogysmarthome.WSD.description = Ein batteriebetriebener Rauchmelder mit integriertem Alarm (erste Version).
thing-type.innogysmarthome.WSD2.label = Rauchmelder (WSD2)
thing-type.innogysmarthome.WSD2.description = Ein batteriebetriebener Rauchmelder mit integriertem Alarm (zweite Version mit long-life Batterie).
# channel types
channel-type.innogysmarthome.SwitchActuator.label = Schalter
channel-type.innogysmarthome.SwitchActuator.description = Schaltet den Strom an/aus
channel-type.innogysmarthome.DimmerActuator.label = Dimmer
channel-type.innogysmarthome.DimmerActuator.description = Dimmt das verbundene Licht
channel-type.innogysmarthome.RollerShutterActuator.label = Rolladenposition
channel-type.innogysmarthome.RollerShutterActuator.description = Steuert die Rolladen
channel-type.innogysmarthome.BooleanStateActuator.label = Schalter
channel-type.innogysmarthome.BooleanStateActuator.description = Schaltet den Status an/aus
channel-type.innogysmarthome.ThermostatActuator_PointTemperature.label = Solltemperatur
channel-type.innogysmarthome.ThermostatActuator_PointTemperature.description = Temperaturvorgabe für das Thermostat
channel-type.innogysmarthome.ThermostatActuator_OperationMode.label = Betriebsmodus
channel-type.innogysmarthome.ThermostatActuator_OperationMode.description = Betriebsmodus des Thermostats (manuell/automatisch)
channel-type.innogysmarthome.ThermostatActuator_WindowReductionActive.label = Fensterabsenkung aktiv
channel-type.innogysmarthome.ThermostatActuator_WindowReductionActive.description = Absenkung der Solltemperatur bei offenem Fenster
channel-type.innogysmarthome.TemperatureSensor_Temperature.label = Aktuelle Temperatur
channel-type.innogysmarthome.TemperatureSensor_Temperature.description = Aktuell gemessene Raumtemperatur
channel-type.innogysmarthome.TemperatureSensor_FrostWarning.label = Frostwarnung
channel-type.innogysmarthome.TemperatureSensor_FrostWarning.description = Warnt beim Unterschreiten einer Mindesttemperatur (wie in innogy App konfiguriert)
channel-type.innogysmarthome.HumiditySensor_Humidity.label = Luftfeuchtigkeit
channel-type.innogysmarthome.HumiditySensor_Humidity.description = Aktuell gemessene Luftfeuchtigkeit
channel-type.innogysmarthome.HumiditySensor_MoldWarning.label = Schimmelwarnung
channel-type.innogysmarthome.HumiditySensor_MoldWarning.description = Warnt bei überschreiten einer maximalen Feuchtigkeit (wie in innogy App konfiguriert)
channel-type.innogysmarthome.WindowDoorSensor.label = Tür/Fensterstatus
channel-type.innogysmarthome.WindowDoorSensor.description = Zeigt den offen/geschlossen Status
channel-type.innogysmarthome.SmokeDetectorSensor.label = Rauchalarm
channel-type.innogysmarthome.SmokeDetectorSensor.description = Meldet bei Raucherkennung
channel-type.innogysmarthome.AlarmActuator.label = Alarmton
channel-type.innogysmarthome.AlarmActuator.description = Schaltet den Alarmton an/aus
channel-type.innogysmarthome.MotionDetectionSensor.label = Bewegungserkennung (Anzahl)
channel-type.innogysmarthome.MotionDetectionSensor.description = Anzahl der erkannten Bewegungen
channel-type.innogysmarthome.LuminanceSensor.label = Helligkeit
channel-type.innogysmarthome.LuminanceSensor.description = Gemessene Helligkeit in Prozent
channel-type.innogysmarthome.PushButtonSensor.label = Schaltanzahl
channel-type.innogysmarthome.PushButtonSensor.description = Anzahl der Schalterbetätigungen

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="AnalogMeter">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Analog Meter</label>
<description>The Analog Meter from the innogy EnergyControl product.</description>
<channels>
<channel id="energy_consumption_month_kwh" typeId="EnergyConsumptionMonthKWh"/>
<channel id="absolute_energy_consumption" typeId="AbsoluteEnergyConsumption"/>
<channel id="energy_consumption_month_euro" typeId="EnergyConsumptionMonthEuro"/>
<channel id="energy_consumption_day_euro" typeId="EnergyConsumptionDayEuro"/>
<channel id="energy_consumption_day_kwh" typeId="EnergyConsumptionDayKWh"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="BRC8">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Basic Remote Controller (BRC8)</label>
<description>A battery powered remote controller with eight push buttons.</description>
<channels>
<channel id="button1" typeId="system.button"/>
<channel id="button2" typeId="system.button"/>
<channel id="button3" typeId="system.button"/>
<channel id="button4" typeId="system.button"/>
<channel id="button5" typeId="system.button"/>
<channel id="button6" typeId="system.button"/>
<channel id="button7" typeId="system.button"/>
<channel id="button8" typeId="system.button"/>
<channel id="button1_count" typeId="PushButtonCounter"/>
<channel id="button2_count" typeId="PushButtonCounter"/>
<channel id="button3_count" typeId="PushButtonCounter"/>
<channel id="button4_count" typeId="PushButtonCounter"/>
<channel id="button5_count" typeId="PushButtonCounter"/>
<channel id="button6_count" typeId="PushButtonCounter"/>
<channel id="button7_count" typeId="PushButtonCounter"/>
<channel id="button8_count" typeId="PushButtonCounter"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="BT-PSS">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Bluetooth Pluggable Smart Switch (BT-PSS)</label>
<description>A pluggable switch that can be switched on and off and which can measure the current energy consumption.</description>
<channels>
<channel id="switch" typeId="SwitchActuator"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="GenerationMeter">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Generation Meter</label>
<description>The Generation Meter from the innogy PowerControlSolar product, that measures the generated energy.</description>
<channels>
<channel id="energy_generation_month_kwh" typeId="EnergyGenerationMonthKWh"/>
<channel id="total_energy_generation" typeId="TotalEnergyGeneration"/>
<channel id="energy_generation_month_euro" typeId="EnergyGenerationMonthEuro"/>
<channel id="energy_generation_day_euro" typeId="EnergyGenerationDayEuro"/>
<channel id="energy_generation_day_kwh" typeId="EnergyGenerationDayKWh"/>
<channel id="power_generation_watt" typeId="PowerGenerationWatt"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="ISC2">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>In Wall Smart Controller (ISC2)</label>
<description>A smart controller with two push buttons.</description>
<channels>
<channel id="button1" typeId="system.button"/>
<channel id="button2" typeId="system.button"/>
<channel id="button1_count" typeId="PushButtonCounter"/>
<channel id="button2_count" typeId="PushButtonCounter"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="ISD2">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>In Wall Smart Dimmer (ISD2)</label>
<description>An in wall dimmer with push buttons.</description>
<channels>
<channel id="dimmer" typeId="DimmerActuator"/>
<channel id="button1" typeId="system.button"/>
<channel id="button2" typeId="system.button"/>
<channel id="button1_count" typeId="PushButtonCounter"/>
<channel id="button2_count" typeId="PushButtonCounter"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="ISR2">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>In Wall Smart Roller Shutter (ISR2)</label>
<description>An in wall rollershutter with two push buttons.</description>
<channels>
<channel id="rollershutter" typeId="RollerShutterActuator"/>
<channel id="button1" typeId="system.button"/>
<channel id="button2" typeId="system.button"/>
<channel id="button1_count" typeId="PushButtonCounter"/>
<channel id="button2_count" typeId="PushButtonCounter"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="ISS2">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>In Wall Smart Switch (ISS2)</label>
<description>An in wall switch with push buttons that can be switched on and off.</description>
<channels>
<channel id="switch" typeId="SwitchActuator"/>
<channel id="button1" typeId="system.button"/>
<channel id="button2" typeId="system.button"/>
<channel id="button1_count" typeId="PushButtonCounter"/>
<channel id="button2_count" typeId="PushButtonCounter"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="PSD">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Pluggable Smart Dimmer (PSD)</label>
<description>A pluggable dimmer.</description>
<channels>
<channel id="dimmer" typeId="DimmerActuator"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="PSS">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Pluggable Smart Switch (PSS)</label>
<description>A pluggable switch that can be switched on and off.</description>
<channels>
<channel id="switch" typeId="SwitchActuator"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="PSSO">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Pluggable Smart Switch Outdoor (PSSO)</label>
<description>A pluggable outdoor switch that can be switched on and off.</description>
<channels>
<channel id="switch" typeId="SwitchActuator"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="RST">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Radiator Mounted Smart Thermostat (RST)</label>
<description>A thermostat, that supports setting the temperature and measuring the current temperature and humidity.</description>
<channels>
<channel id="set_temperature" typeId="ThermostatActuator_PointTemperature"/>
<channel id="temperature" typeId="TemperatureSensor_Temperature"/>
<channel id="frost_warning" typeId="TemperatureSensor_FrostWarning"/>
<channel id="humidity" typeId="HumiditySensor_Humidity"/>
<channel id="mold_warning" typeId="HumiditySensor_MoldWarning"/>
<channel id="operation_mode" typeId="ThermostatActuator_OperationMode"/>
<channel id="window_reduction_active" typeId="ThermostatActuator_WindowReductionActive"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="RST2">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Radiator Mounted Smart Thermostat (RST2)</label>
<description>A thermostat, that supports setting the temperature and measuring the current temperature and humidity (2
battery version since 2018)</description>
<channels>
<channel id="set_temperature" typeId="ThermostatActuator_PointTemperature"/>
<channel id="temperature" typeId="TemperatureSensor_Temperature"/>
<channel id="frost_warning" typeId="TemperatureSensor_FrostWarning"/>
<channel id="humidity" typeId="HumiditySensor_Humidity"/>
<channel id="mold_warning" typeId="HumiditySensor_MoldWarning"/>
<channel id="operation_mode" typeId="ThermostatActuator_OperationMode"/>
<channel id="window_reduction_active" typeId="ThermostatActuator_WindowReductionActive"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="SmartMeter">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Smart Meter</label>
<description>The Smart Meter from the innogy PowerControl product.</description>
<channels>
<channel id="energy_consumption_month_kwh" typeId="EnergyConsumptionMonthKWh"/>
<channel id="absolute_energy_consumption" typeId="AbsoluteEnergyConsumption"/>
<channel id="energy_consumption_month_euro" typeId="EnergyConsumptionMonthEuro"/>
<channel id="energy_consumption_day_euro" typeId="EnergyConsumptionDayEuro"/>
<channel id="energy_consumption_day_kwh" typeId="EnergyConsumptionDayKWh"/>
<channel id="power_consumption_watt" typeId="PowerConsumptionWatt"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="TwoWayMeter">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Two-Way-Meter</label>
<description>The Two-Way-Meter from the innogy PowerControlSolar product.</description>
<channels>
<channel id="energy_month_kwh" typeId="EnergyConsumptionMonthKWh"/>
<channel id="total_energy" typeId="TotalEnergyConsumption"/>
<channel id="energy_month_euro" typeId="EnergyConsumptionMonthEuro"/>
<channel id="energy_day_euro" typeId="EnergyConsumptionDayEuro"/>
<channel id="energy_day_kwh" typeId="EnergyConsumptionDayKWh"/>
<channel id="energy_feed_month_kwh" typeId="EnergyFeedMonthKWh"/>
<channel id="total_energy_fed" typeId="TotalEnergyFed"/>
<channel id="energy_feed_month_euro" typeId="EnergyFeedMonthEuro"/>
<channel id="energy_feed_day_euro" typeId="EnergyFeedDayEuro"/>
<channel id="energy_feed_day_kwh" typeId="EnergyFeedDayKWh"/>
<channel id="power_watt" typeId="PowerConsumptionWatt"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="VariableActuator">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Variable Actuator</label>
<description>A variable from the innogy SmartHome System that can be switched on and off.</description>
<channels>
<channel id="switch" typeId="BooleanStateActuator"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="WDS">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Wall Mounted Door/Window Sensor (WDS)</label>
<description>A window/door sensor, that provides the open/close state.</description>
<channels>
<channel id="contact" typeId="WindowDoorSensor"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="WMD">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Wall Mounted Motion Detector Indoor (WMD)</label>
<description>A battery powered motion detector, that also measures luminance.</description>
<channels>
<channel id="motion_count" typeId="MotionDetectionSensor"/>
<channel id="luminance" typeId="LuminanceSensor"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="WMDO">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Wall Mounted Motion Detector Outdoor (WMDO)</label>
<description>A battery powered motion detector for outdoors, that also measures luminance.</description>
<channels>
<channel id="motion_count" typeId="MotionDetectionSensor"/>
<channel id="luminance" typeId="LuminanceSensor"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="WRT">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Wall Mounted Room Thermostat (WRT)</label>
<description>A wall thermostat, that supports setting the temperature and measuring the current temperature and
humidity.</description>
<channels>
<channel id="set_temperature" typeId="ThermostatActuator_PointTemperature"/>
<channel id="temperature" typeId="TemperatureSensor_Temperature"/>
<channel id="frost_warning" typeId="TemperatureSensor_FrostWarning"/>
<channel id="humidity" typeId="HumiditySensor_Humidity"/>
<channel id="mold_warning" typeId="HumiditySensor_MoldWarning"/>
<channel id="operation_mode" typeId="ThermostatActuator_OperationMode"/>
<channel id="window_reduction_active" typeId="ThermostatActuator_WindowReductionActive"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="WSC2">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Wall Mounted Smart Controller (WSC2)</label>
<description>A battery powered smart controller with two push buttons.</description>
<channels>
<channel id="button1" typeId="system.button"/>
<channel id="button2" typeId="system.button"/>
<channel id="button1_count" typeId="PushButtonCounter"/>
<channel id="button2_count" typeId="PushButtonCounter"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="WSD">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Wall Mounted Smoke Detector (WSD)</label>
<description>A battery powered smoke detector sensor with integrated alarm (first version).</description>
<channels>
<channel id="smoke" typeId="SmokeDetectorSensor"/>
<channel id="alarm" typeId="AlarmActuator"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="WSD2">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Wall Mounted Smoke Detector (WSD2)</label>
<description>A battery powered smoke detector sensor with integrated alarm (2nd version with long-life battery).</description>
<channels>
<channel id="smoke" typeId="SmokeDetectorSensor"/>
<channel id="alarm" typeId="AlarmActuator"/>
<channel id="battery_low" typeId="system.low-battery"/>
</channels>
<config-description-ref uri="thing-type:innogysmarthome:config"/>
</thing-type>
</thing:thing-descriptions>

View File

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<bridge-type id="bridge">
<label>innogy SmartHome Controller</label>
<description>The innogy SmartHome Controller (SHC) is the bridge for the innogy SmartHome System.</description>
<channels>
<channel id="cpu" typeId="CPUUsage"/>
<channel id="disk" typeId="DiskUsage"/>
<channel id="memory" typeId="MemoryUsage"/>
</channels>
<config-description>
<parameter-group name="connection">
<label>Connection</label>
<description>Parameters for connecting to innogy SmartHome Controller (SHC)</description>
</parameter-group>
<parameter-group name="advanced">
<label>Advanced Configuration</label>
<description>Advanced parameters, for special tweaking only.</description>
<advanced>true</advanced>
</parameter-group>
<parameter name="brand" type="text" required="true" groupName="connection">
<label>Brand</label>
<description>Choose the brand of your innogy SmartHome based solution.</description>
<default>innogy_smarthome</default>
<options>
<option value="innogy_smarthome">innogy SmartHome</option>
</options>
</parameter>
<parameter name="authcode" type="text" groupName="connection">
<label>Authorization Code</label>
<description><![CDATA[ The auth-code is a one-time code needed to retrieve the
necessary access-codes from innogy SmartHome Service. <b>Please go - depending on your brand - to...</b>
<ul>
<li><b>innogy SmartHome Portal</b>: https://auth.services-smarthome.de/AUTH/authorize?response_type=code&client_id=24635748&redirect_uri=https%3A%2F%2Fwww.openhab.org%2Foauth%2Finnogy%2Finnogy-smarthome.html&scope&lang=de-DE</li>
</ul>
<b>... to generate an auth-code and paste it here</b>. After initial authorization, this code is not needed anymore.]]></description>
</parameter>
<parameter name="websocketidletimeout" type="integer" min="0" max="3600" unit="s" groupName="advanced">
<unitLabel>seconds</unitLabel>
<label>WebSocket Idle Timeout in Seconds</label>
<description>The WebSocket is the connection to the innogy service that listens to status updates. If no data is
received over the websocket connection for the given time, the websocket will reconnect. 0 will disable the idle
timeout. Default is 900 seconds (15 minutes).</description>
<default>900</default>
<advanced>true</advanced>
</parameter>
</config-description>
</bridge-type>
</thing:thing-descriptions>

View File

@ -1,350 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="innogysmarthome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<!-- Switch Channel -->
<channel-type id="SwitchActuator">
<item-type>Switch</item-type>
<label>Switch</label>
<description>Switches the current on/off</description>
<category>Switch</category>
</channel-type>
<!-- Dimmer Channel -->
<channel-type id="DimmerActuator">
<item-type>Dimmer</item-type>
<label>Dimmer</label>
<description>Dimms the connected light</description>
<category>Light</category>
</channel-type>
<!-- RollerShutter Channel -->
<channel-type id="RollerShutterActuator">
<item-type>Rollershutter</item-type>
<label>Blinds Position</label>
<description>Controls the blinds</description>
<category>Blinds</category>
<config-description>
<parameter name="invert" type="boolean">
<label>Invert Position</label>
<description>When invert is true than 0 on innogy is UP and 100 is DOWN</description>
</parameter>
</config-description>
</channel-type>
<!-- BooleanSwitch Channel -->
<channel-type id="BooleanStateActuator">
<item-type>Switch</item-type>
<label>Switch</label>
<description>Switches the state on/off</description>
<category>Switch</category>
</channel-type>
<!-- ThermostatActuator -->
<channel-type id="ThermostatActuator_PointTemperature">
<item-type>Number</item-type>
<label>Target Temperature</label>
<description>Thermostat target temperature</description>
<category>Temperature</category>
<state min="6" max="30" step="0.5" pattern="%.1f °C" readOnly="false">
</state>
</channel-type>
<channel-type id="ThermostatActuator_OperationMode" advanced="true">
<item-type>String</item-type>
<label>Operation Mode</label>
<description>Thermostat operation mode (manual/auto)</description>
<category>Mode</category>
<state>
<options>
<option value="Auto">auto</option>
<option value="Manu">manual</option>
</options>
</state>
</channel-type>
<channel-type id="ThermostatActuator_WindowReductionActive" advanced="true">
<item-type>Switch</item-type>
<label>Window Reduction Active</label>
<description>Thermostat temperature reduced, if window is open.</description>
<category>Temperature</category>
<state readOnly="true"/>
</channel-type>
<!-- TemperatureSensor -->
<channel-type id="TemperatureSensor_Temperature">
<item-type>Number</item-type>
<label>Actual Temperature</label>
<description>Actual measured room temperature</description>
<category>Temperature</category>
<state pattern="%.1f °C" readOnly="true">
</state>
</channel-type>
<channel-type id="TemperatureSensor_FrostWarning" advanced="true">
<item-type>Switch</item-type>
<label>Frost Warning</label>
<description>Warns, if temperature drop below a threshold (configured in innogy app)</description>
<category>Temperature</category>
<state readOnly="true"/>
</channel-type>
<!-- HumiditySensor -->
<channel-type id="HumiditySensor_Humidity">
<item-type>Number</item-type>
<label>Actual Humidity</label>
<description>Actual measured room humidity</description>
<category>Humidity</category>
<state pattern="%.1f%%" readOnly="true">
</state>
</channel-type>
<channel-type id="HumiditySensor_MoldWarning" advanced="true">
<item-type>Switch</item-type>
<label>Mold Warning</label>
<description>Active, if humidity is over a threshold (configured in innogy app)</description>
<category>Humidity</category>
<state readOnly="true"/>
</channel-type>
<!-- WindowDoorSensor Channel -->
<channel-type id="WindowDoorSensor">
<item-type>Contact</item-type>
<label>Contact</label>
<description>Shows the open/close state</description>
<category>Contact</category>
<state readOnly="true"></state>
</channel-type>
<!-- SmokeDetectorSensor Channel -->
<channel-type id="SmokeDetectorSensor">
<item-type>Switch</item-type>
<label>Smoke</label>
<description>Shows if smoke was detected</description>
<category>Smoke</category>
<state readOnly="true"></state>
</channel-type>
<!-- AlarmActuator Channel -->
<channel-type id="AlarmActuator">
<item-type>Switch</item-type>
<label>Alarm</label>
<description>Switches the alarm on/off</description>
<category>Alarm</category>
</channel-type>
<!-- MotionDetectionSensor Channel -->
<channel-type id="MotionDetectionSensor">
<item-type>Number</item-type>
<label>Motion Count</label>
<description>The count of detected motions</description>
<category>Count</category>
<state readOnly="true"></state>
</channel-type>
<!-- LuminanceSensor Channel -->
<channel-type id="LuminanceSensor">
<item-type>Number</item-type>
<label>Luminance</label>
<description>Shows the detected luminance in percent</description>
<category>Light</category>
<state pattern="%d%%" readOnly="true"></state>
</channel-type>
<!-- PushButtonCounter Channel -->
<channel-type id="PushButtonCounter" advanced="true">
<item-type>Number</item-type>
<label>Button Pushed Count</label>
<description>The count of button pushes.</description>
<category>Count</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyConsumptionMonthKWh -->
<channel-type id="EnergyConsumptionMonthKWh">
<item-type>Number</item-type>
<label>Consumption (month)</label>
<description>The energy consumption per month in kWh</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- AbsoluteEnergyConsumption -->
<channel-type id="AbsoluteEnergyConsumption">
<item-type>Number</item-type>
<label>Total Consumption</label>
<description>The absolute Energy consumption</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyConsumptionMonthEuro -->
<channel-type id="EnergyConsumptionMonthEuro" advanced="true">
<item-type>Number</item-type>
<label>Consumption Costs (month)</label>
<description>The energy consumption per month in Euro</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyConsumptionDayEuro -->
<channel-type id="EnergyConsumptionDayEuro" advanced="true">
<item-type>Number</item-type>
<label>Consumption Costs (day)</label>
<description>The energy consumption per day in Euro</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyConsumptionDayKWh -->
<channel-type id="EnergyConsumptionDayKWh">
<item-type>Number</item-type>
<label>Consumption (day)</label>
<description>The energy consumption per day in kWh</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- PowerConsumptionWatt -->
<channel-type id="PowerConsumptionWatt">
<item-type>Number</item-type>
<label>Current Power Consumption</label>
<description>The current power consumption in Watt</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyGenerationMonthKWh -->
<channel-type id="EnergyGenerationMonthKWh">
<item-type>Number</item-type>
<label>Generation (month)</label>
<description>The energy generation per month in kWh</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- TotalEnergyGeneration -->
<channel-type id="TotalEnergyGeneration">
<item-type>Number</item-type>
<label>Total Generation</label>
<description>The total Energy generation</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyGenerationMonthEuro -->
<channel-type id="EnergyGenerationMonthEuro" advanced="true">
<item-type>Number</item-type>
<label>Generation Value (month)</label>
<description>The energy generation per month in Euro</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyGenerationDayEuro -->
<channel-type id="EnergyGenerationDayEuro" advanced="true">
<item-type>Number</item-type>
<label>Generation Value (day)</label>
<description>The energy generation per day in Euro</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyGenerationDayKWh -->
<channel-type id="EnergyGenerationDayKWh">
<item-type>Number</item-type>
<label>Generation (day)</label>
<description>The energy generation per day in kWh</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- PowerGenerationWatt -->
<channel-type id="PowerGenerationWatt">
<item-type>Number</item-type>
<label>Current Power Generation</label>
<description>The current power generation in Watt</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- TotalEnergyConsumption -->
<channel-type id="TotalEnergyConsumption">
<item-type>Number</item-type>
<label>Total Consumption</label>
<description>The total Energy consumption</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyFeedMonthKWh -->
<channel-type id="EnergyFeedMonthKWh">
<item-type>Number</item-type>
<label>Feed (month)</label>
<description>The energy feed per month in kWh</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- TotalEnergyFeed -->
<channel-type id="TotalEnergyFed">
<item-type>Number</item-type>
<label>Total Fed</label>
<description>The total Energy fed</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyFeedMonthEuro -->
<channel-type id="EnergyFeedMonthEuro" advanced="true">
<item-type>Number</item-type>
<label>Feed Income (month)</label>
<description>The energy feed per month in Euro</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyFeedDayEuro -->
<channel-type id="EnergyFeedDayEuro" advanced="true">
<item-type>Number</item-type>
<label>Feed Income (day)</label>
<description>The energy feed per day in Euro</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- EnergyFeedDayKWh -->
<channel-type id="EnergyFeedDayKWh">
<item-type>Number</item-type>
<label>Feed (day)</label>
<description>The energy feed per day in kWh</description>
<category>Energy</category>
<state readOnly="true"></state>
</channel-type>
<!-- CPUUsage -->
<channel-type id="CPUUsage">
<item-type>Number</item-type>
<label>CPU Usage</label>
<description>The CPU usage of SHC-A, updated every 5 minutes</description>
<category>System</category>
<state readOnly="true"></state>
</channel-type>
<!-- DiskUsage -->
<channel-type id="DiskUsage">
<item-type>Number</item-type>
<label>Disk Usage</label>
<description>The disk usage of SHC-A, updated every 5 minutes</description>
<category>System</category>
<state readOnly="true"></state>
</channel-type>
<!-- MemoryUsage -->
<channel-type id="MemoryUsage">
<item-type>Number</item-type>
<label>Memory Usage</label>
<description>The memory usage of SHC-A, updated every 5 minutes</description>
<category>System</category>
<state readOnly="true"></state>
</channel-type>
</thing:thing-descriptions>

View File

@ -1,244 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import java.net.URI;
import java.util.concurrent.Future;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.innogysmarthome.internal.listener.EventListener;
/**
* @author Sven Strohschein - Initial contribution
*/
public class InnogyWebSocketTest {
private InnogyWebSocketAccessible webSocket;
private EventListenerDummy eventListener;
private WebSocketClient webSocketClientMock;
private Session sessionMock;
@BeforeEach
public void before() throws Exception {
sessionMock = mock(Session.class);
Future<Session> futureMock = mock(Future.class);
when(futureMock.get()).thenReturn(sessionMock);
webSocketClientMock = mock(WebSocketClient.class);
when(webSocketClientMock.connect(any(), any())).thenReturn(futureMock);
eventListener = new EventListenerDummy();
webSocket = new InnogyWebSocketAccessible(eventListener, new URI(""), 1000);
}
@Test
public void testStart() throws Exception {
startWebSocket();
assertTrue(webSocket.isRunning());
}
@Test
public void testStop() throws Exception {
startWebSocket();
webSocket.stop();
assertFalse(webSocket.isRunning());
}
@Test
public void testOnCloseAfterStop() throws Exception {
startWebSocket();
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
webSocket.stop();
webSocket.onClose(StatusCode.ABNORMAL, "Test");
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
// stop() itself causes a (abnormal) close event, that shouldn't get noticed
// (otherwise it would cause a reconnect event which would lead to an infinite loop ...)
assertFalse(eventListener.isConnectionClosedCalled());
}
@Test
public void testOnCloseAfterRestart() throws Exception {
startWebSocket();
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
webSocket.stop();
webSocket.onClose(StatusCode.ABNORMAL, "Test");
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
// stop() itself causes a (abnormal) close event, that shouldn't get noticed
// (otherwise it would cause a reconnect event which would lead to an infinite loop ...)
assertFalse(eventListener.isConnectionClosedCalled());
startWebSocket();
webSocket.onClose(StatusCode.ABNORMAL, "Test");
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
// A close event after a restart of the web socket should get recognized again
assertTrue(eventListener.isConnectionClosedCalled());
}
@Test
public void testOnCloseAbnormal() throws Exception {
startWebSocket();
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
webSocket.onClose(StatusCode.ABNORMAL, "Test");
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertTrue(eventListener.isConnectionClosedCalled());
}
@Test
public void testOnCloseNormal() throws Exception {
startWebSocket();
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
webSocket.onClose(StatusCode.NORMAL, "Test");
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
// Nothing should get noticed when a normal close is executed (for example by stopping OpenHAB)
assertFalse(eventListener.isConnectionClosedCalled());
}
@Test
public void testOnMessage() throws Exception {
startWebSocket();
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
webSocket.onMessage("Test-Message");
assertTrue(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
}
@Test
public void testOnMessageAfterStop() throws Exception {
startWebSocket();
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
webSocket.stop();
webSocket.onClose(StatusCode.ABNORMAL, "Test");
webSocket.onMessage("Test-Message");
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
}
@Test
public void testOnError() throws Exception {
startWebSocket();
assertFalse(eventListener.isOnEventCalled());
assertFalse(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
webSocket.onError(new RuntimeException("Test-Exception"));
assertFalse(eventListener.isOnEventCalled());
assertTrue(eventListener.isOnErrorCalled());
assertFalse(eventListener.isConnectionClosedCalled());
}
private void startWebSocket() throws Exception {
webSocket.start();
when(sessionMock.isOpen()).thenReturn(true);
webSocket.onConnect(sessionMock);
}
private class InnogyWebSocketAccessible extends InnogyWebSocket {
private InnogyWebSocketAccessible(EventListener eventListener, URI webSocketURI, int maxIdleTimeout) {
super(eventListener, webSocketURI, maxIdleTimeout);
}
@Override
WebSocketClient startWebSocketClient() {
return webSocketClientMock;
}
}
private class EventListenerDummy implements EventListener {
private boolean isOnEventCalled;
private boolean isOnErrorCalled;
private boolean isConnectionClosedCalled;
@Override
public void onEvent(String msg) {
isOnEventCalled = true;
}
@Override
public void onError(Throwable cause) {
isOnErrorCalled = true;
}
@Override
public void connectionClosed() {
isConnectionClosedCalled = true;
}
public boolean isOnEventCalled() {
return isOnEventCalled;
}
public boolean isOnErrorCalled() {
return isOnErrorCalled;
}
public boolean isConnectionClosedCalled() {
return isConnectionClosedCalled;
}
}
}

View File

@ -1,101 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collections;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.core.auth.client.oauth2.AccessTokenResponse;
import org.openhab.core.auth.client.oauth2.OAuthClientService;
/**
* @author Sven Strohschein - Initial contribution
*/
@ExtendWith(MockitoExtension.class)
public class InnogyClientTest {
private static final String DEVICES_URL = "https://api.services-smarthome.de/API/1.1/device";
private InnogyClient client;
@Mock
private OAuthClientService oAuthClient;
@Mock
private HttpClient httpClient;
@BeforeEach
public void before() throws Exception {
AccessTokenResponse accessTokenResponse = new AccessTokenResponse();
accessTokenResponse.setAccessToken("accessToken");
when(oAuthClient.getAccessTokenResponse()).thenReturn(accessTokenResponse);
client = new InnogyClient(oAuthClient, httpClient);
}
@Test
public void testGetDevices() throws Exception {
mockRequest(DEVICES_URL, "[ { id: 123 }, { id: 789, type: 'VariableActuator' } ]");
assertEquals(2, client.getDevices(Arrays.asList("123", "456")).size());
}
@Test
public void testGetDevicesNoDeviceIds() throws Exception {
mockRequest(DEVICES_URL, "[ { id: 123 } ]");
assertEquals(0, client.getDevices(Collections.emptyList()).size());
}
@Test
public void testGetDevicesFalseDeviceIds() throws Exception {
mockRequest(DEVICES_URL, "[ { id: 789 }]");
assertEquals(0, client.getDevices(Arrays.asList("123", "456")).size());
}
@Test
public void testGetDevicesNoDevicesNoDeviceIds() throws Exception {
mockRequest(DEVICES_URL, "[]");
assertEquals(0, client.getDevices(Collections.emptyList()).size());
}
@Test
public void testGetDevicesNoDevicesDeviceIds() throws Exception {
mockRequest(DEVICES_URL, "[]");
assertEquals(0, client.getDevices(Arrays.asList("123", "456")).size());
}
private void mockRequest(String url, String responseContent) throws Exception {
ContentResponse response = mock(ContentResponse.class);
when(response.getStatus()).thenReturn(HttpStatus.OK_200);
when(response.getContentAsString()).thenReturn(responseContent);
Request requestMock = mock(Request.class);
when(httpClient.newRequest(url)).thenReturn(requestMock);
when(requestMock.method(any(HttpMethod.class))).thenReturn(requestMock);
when(requestMock.header(any(HttpHeader.class), any())).thenReturn(requestMock);
when(requestMock.idleTimeout(anyLong(), any())).thenReturn(requestMock);
when(requestMock.timeout(anyLong(), any())).thenReturn(requestMock);
when(requestMock.send()).thenReturn(response);
}
}

View File

@ -1,194 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.client.entity.device;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
import org.openhab.binding.innogysmarthome.internal.client.entity.state.BooleanState;
/**
* @author Sven Strohschein - Initial contribution
*/
public class DeviceTest {
@Test
public void testSetMessageListLowBatteryMessage() {
Device device = createDevice();
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
device.setMessageList(Collections.singletonList(createMessage(Message.TYPE_DEVICE_LOW_BATTERY)));
assertTrue(device.isReachable());
assertTrue(device.hasLowBattery());
}
@Test
public void testSetMessageListUnreachableMessage() {
Device device = createDevice();
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
device.setMessageList(Collections.singletonList(createMessage(Message.TYPE_DEVICE_UNREACHABLE)));
assertFalse(device.isReachable());
assertFalse(device.hasLowBattery());
}
@Test
public void testSetMessageListResetByEmpty() {
Device device = createDevice();
assertNull(device.getMessageList());
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
List<Message> messages = Arrays.asList(createMessage(Message.TYPE_DEVICE_LOW_BATTERY),
createMessage(Message.TYPE_DEVICE_UNREACHABLE));
device.setMessageList(messages);
assertEquals(messages, device.getMessageList());
assertFalse(device.isReachable());
assertTrue(device.hasLowBattery());
device.setMessageList(Collections.emptyList());
// Nothing should get changed.
// New messages are only set in real-life when the device is refreshed with new data of the API.
// Therefore the data of the API should be kept / not overwritten when no corresponding messages are available.
assertEquals(Collections.emptyList(), device.getMessageList());
assertFalse(device.isReachable());
assertTrue(device.hasLowBattery());
}
@Test
public void testSetMessageListResetByNULL() {
Device device = createDevice();
assertNull(device.getMessageList());
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
List<Message> messages = Arrays.asList(createMessage(Message.TYPE_DEVICE_LOW_BATTERY),
createMessage(Message.TYPE_DEVICE_UNREACHABLE));
device.setMessageList(messages);
assertEquals(messages, device.getMessageList());
assertFalse(device.isReachable());
assertTrue(device.hasLowBattery());
device.setMessageList(null);
// Nothing should get changed.
// New messages are only set in real-life when the device is refreshed with new data of the API.
// Therefore the data of the API should be kept / not overwritten when no corresponding messages are available.
assertNull(device.getMessageList());
assertFalse(device.isReachable());
assertTrue(device.hasLowBattery());
}
@Test
public void testSetMessageListResetByUnimportantMessage() {
Device device = createDevice();
assertNull(device.getMessageList());
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
List<Message> messages = Arrays.asList(createMessage(Message.TYPE_DEVICE_LOW_BATTERY),
createMessage(Message.TYPE_DEVICE_UNREACHABLE));
device.setMessageList(messages);
assertEquals(messages, device.getMessageList());
assertFalse(device.isReachable());
assertTrue(device.hasLowBattery());
messages = Collections.singletonList(createMessage("UNKNOWN"));
device.setMessageList(messages);
// Nothing should get changed.
// New messages are only set in real-life when the device is refreshed with new data of the API.
// Therefore the data of the API should be kept / not overwritten when no corresponding messages are available.
assertEquals(messages, device.getMessageList());
assertFalse(device.isReachable());
assertTrue(device.hasLowBattery());
}
@Test
public void testSetMessageListUnimportantMessage() {
Device device = createDevice();
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
device.setMessageList(Collections.singletonList(createMessage("UNKNOWN")));
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
}
private Message createMessage(String messageType) {
Message message = new Message();
message.setType(messageType);
return message;
}
@Test
public void testSetMessageListNULL() {
Device device = createDevice();
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
device.setMessageList(null);
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
}
@Test
public void testSetMessageListEmpty() {
Device device = createDevice();
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
device.setMessageList(Collections.emptyList());
assertTrue(device.isReachable());
assertFalse(device.hasLowBattery());
}
private static Device createDevice() {
BooleanState isReachableState = new BooleanState();
isReachableState.setValue(true);
State state = new State();
state.setIsReachable(isReachableState);
DeviceState deviceState = new DeviceState();
deviceState.setState(state);
Device device = new Device();
device.setDeviceState(deviceState);
return device;
}
}

View File

@ -1,259 +0,0 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.innogysmarthome.internal.handler;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.net.ConnectException;
import java.util.Collections;
import java.util.HashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jetty.client.HttpClient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants;
import org.openhab.binding.innogysmarthome.internal.InnogyWebSocket;
import org.openhab.binding.innogysmarthome.internal.client.InnogyClient;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.DeviceConfig;
import org.openhab.binding.innogysmarthome.internal.manager.FullDeviceManager;
import org.openhab.core.auth.client.oauth2.OAuthClientService;
import org.openhab.core.auth.client.oauth2.OAuthFactory;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
/**
* @author Sven Strohschein - Initial contribution
*/
public class InnogyBridgeHandlerTest {
private static final int MAXIMUM_RETRY_EXECUTIONS = 10;
private InnogyBridgeHandlerAccessible bridgeHandler;
private Bridge bridgeMock;
private InnogyWebSocket webSocketMock;
@BeforeEach
public void before() throws Exception {
final Logger loggerBridge = (Logger) LoggerFactory.getLogger(InnogyBridgeHandler.class);
loggerBridge.setLevel(Level.OFF);
final Logger logerBaseHandler = (Logger) LoggerFactory.getLogger(BaseThingHandler.class);
logerBaseHandler.setLevel(Level.OFF);
bridgeMock = mock(Bridge.class);
when(bridgeMock.getUID()).thenReturn(new ThingUID("innogysmarthome", "bridge"));
webSocketMock = mock(InnogyWebSocket.class);
OAuthClientService oAuthService = mock(OAuthClientService.class);
OAuthFactory oAuthFactoryMock = mock(OAuthFactory.class);
when(oAuthFactoryMock.createOAuthClientService(any(), any(), any(), any(), any(), any(), any()))
.thenReturn(oAuthService);
HttpClient httpClientMock = mock(HttpClient.class);
bridgeHandler = new InnogyBridgeHandlerAccessible(bridgeMock, oAuthFactoryMock, httpClientMock);
}
@Test
public void testInitializeBridgeNotAvailable() throws Exception {
Configuration bridgeConfig = new Configuration();
HashMap<String, Object> map = new HashMap<>();
map.put("brand", "XY");
bridgeConfig.setProperties(map);
when(bridgeMock.getConfiguration()).thenReturn(bridgeConfig);
bridgeHandler.initialize();
verify(webSocketMock, never()).start();
assertEquals(0, bridgeHandler.getDirectExecutionCount());
}
@Test
public void testInitialize() throws Exception {
Configuration bridgeConfig = new Configuration();
when(bridgeMock.getConfiguration()).thenReturn(bridgeConfig);
bridgeHandler.initialize();
verify(webSocketMock).start();
assertEquals(1, bridgeHandler.getDirectExecutionCount());
}
@Test
public void testInitializeErrorOnStartingWebSocket() throws Exception {
Configuration bridgeConfig = new Configuration();
when(bridgeMock.getConfiguration()).thenReturn(bridgeConfig);
doThrow(new RuntimeException("Test-Exception")).when(webSocketMock).start();
bridgeHandler.initialize();
verify(webSocketMock, times(MAXIMUM_RETRY_EXECUTIONS)).start();
assertEquals(1, bridgeHandler.getDirectExecutionCount()); // only the first execution should be without a delay
}
@Test
public void testConnectionClosed() throws Exception {
Configuration bridgeConfig = new Configuration();
when(bridgeMock.getConfiguration()).thenReturn(bridgeConfig);
bridgeHandler.initialize();
verify(webSocketMock).start();
assertEquals(1, bridgeHandler.getDirectExecutionCount());
bridgeHandler.connectionClosed();
verify(webSocketMock, times(2)).start(); // automatically restarted (with a delay)
assertEquals(1, bridgeHandler.getDirectExecutionCount());
bridgeHandler.connectionClosed();
verify(webSocketMock, times(3)).start(); // automatically restarted (with a delay)
assertEquals(1, bridgeHandler.getDirectExecutionCount());
}
@Test
public void testConnectionClosedReconnectNotPossible() throws Exception {
Configuration bridgeConfig = new Configuration();
when(bridgeMock.getConfiguration()).thenReturn(bridgeConfig);
bridgeHandler.initialize();
verify(webSocketMock).start();
assertEquals(1, bridgeHandler.getDirectExecutionCount());
doThrow(new ConnectException("Connection refused")).when(webSocketMock).start();
bridgeHandler.connectionClosed();
verify(webSocketMock, times(10)).start(); // automatic reconnect attempts (with a delay)
assertEquals(1, bridgeHandler.getDirectExecutionCount());
}
@Test
public void testOnEventDisconnect() throws Exception {
final String disconnectEventJSON = "{ type: \"Disconnect\" }";
Configuration bridgeConfig = new Configuration();
when(bridgeMock.getConfiguration()).thenReturn(bridgeConfig);
bridgeHandler.initialize();
verify(webSocketMock).start();
assertEquals(1, bridgeHandler.getDirectExecutionCount());
bridgeHandler.onEvent(disconnectEventJSON);
verify(webSocketMock, times(2)).start(); // automatically restarted (with a delay)
assertEquals(1, bridgeHandler.getDirectExecutionCount());
bridgeHandler.onEvent(disconnectEventJSON);
verify(webSocketMock, times(3)).start(); // automatically restarted (with a delay)
assertEquals(1, bridgeHandler.getDirectExecutionCount());
}
private class InnogyBridgeHandlerAccessible extends InnogyBridgeHandler {
private final InnogyClient innogyClientMock;
private final FullDeviceManager fullDeviceManagerMock;
private final ScheduledExecutorService schedulerMock;
private int executionCount;
private int directExecutionCount;
private InnogyBridgeHandlerAccessible(Bridge bridge, OAuthFactory oAuthFactory, HttpClient httpClient)
throws Exception {
super(bridge, oAuthFactory, httpClient);
Device bridgeDevice = new Device();
bridgeDevice.setId("bridgeId");
bridgeDevice.setType(InnogyBindingConstants.DEVICE_SHC);
bridgeDevice.setConfig(new DeviceConfig());
innogyClientMock = mock(InnogyClient.class);
fullDeviceManagerMock = mock(FullDeviceManager.class);
when(fullDeviceManagerMock.getFullDevices()).thenReturn(Collections.singletonList(bridgeDevice));
schedulerMock = mock(ScheduledExecutorService.class);
doAnswer(invocationOnMock -> {
if (executionCount <= MAXIMUM_RETRY_EXECUTIONS) {
executionCount++;
invocationOnMock.getArgument(0, Runnable.class).run();
}
return null;
}).when(schedulerMock).execute(any());
doAnswer(invocationOnMock -> {
if (executionCount <= MAXIMUM_RETRY_EXECUTIONS) {
executionCount++;
long seconds = invocationOnMock.getArgument(1);
if (seconds <= 0) {
directExecutionCount++;
}
invocationOnMock.getArgument(0, Runnable.class).run();
}
return mock(ScheduledFuture.class);
}).when(schedulerMock).schedule(any(Runnable.class), anyLong(), any());
}
public int getDirectExecutionCount() {
return directExecutionCount;
}
@Override
@NonNull
FullDeviceManager createFullDeviceManager(@NonNull InnogyClient client) {
return fullDeviceManagerMock;
}
@Override
@NonNull
InnogyClient createInnogyClient(@NonNull OAuthClientService oAuthService, @NonNull HttpClient httpClient) {
return innogyClientMock;
}
@Override
@NonNull
InnogyWebSocket createWebSocket() {
return webSocketMock;
}
@Override
@NonNull
ScheduledExecutorService getScheduler() {
return schedulerMock;
}
}
}

Some files were not shown because too many files have changed in this diff Show More