Skip to content

Commit

Permalink
Z-Way: Update Z-Way library and add new device types (#2211)
Browse files Browse the repository at this point in the history
* Update Z-Way library.
* Add SensorDiscrete, ToggleButton, SwitchToggle.

Signed-off-by: Patrick Hecker <[email protected]> (github: pathec)
  • Loading branch information
pathec authored and kaikreuzer committed Apr 26, 2017
1 parent 713ccc7 commit 32de188
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion addons/binding/org.openhab.binding.zway/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="lib" path="lib/zway-lib-0.1.7-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/zway-lib-0.2.7-SNAPSHOT.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ channel-type.zway.switchColor.label = Switch color
channel-type.zway.switchColor.description = This channel represents the RGBW switch device type from Z-Way.
channel-type.zway.switchControl.label = Switch control
channel-type.zway.switchControl.description = This channel represents a universal channel if no further device information is available.
channel-type.zway.sensorDiscrete.label = Sensor discrete
channel-type.zway.sensorDiscrete.description = This channel represents a two-digit value. The first digit is the button/scene number and the second digit points to action/keyAttribute (have a look at http://z-wave.sigmadesigns.com/wp-content/uploads/2016/08/SDS12657-12-Z-Wave-Command-Class-Specification-A-M.pdf, p. 153).
channel-type.zway.thermostatMode.label = Thermostat mode
channel-type.zway.thermostatMode.description = The channel allows the control or display of a thermostat (mode). A thermostat can have up to three states (modes): off, heating and cooling. The state of heating and cooling is alternately set at the state on.
channel-type.zway.thermostatSetPoint.label = Thermostat set point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ channel-type.zway.switchColor.label = RGB-Schalter
channel-type.zway.switchColor.description = Dieser Channel repräsentiert einen RGB-Schalter von Z-Way.
channel-type.zway.switchControl.label = Binärschalter
channel-type.zway.switchControl.description = Dieser Channel ist allgemeingültig für verschiedene Geräte des gleichen Gerätetyps, wenn keine weiteren Informationen zur Verfügung stehen.
channel-type.zway.sensorDiscrete.label = Diskreter Sensor
channel-type.zway.sensorDiscrete.description = Dieser Channel repräsentiert einen zweistelligen Wert. Die erste Zahl ist der Button/Szene und der zweite Wert beschreibt die Aktion/KeyAttribute (siehe auch http://z-wave.sigmadesigns.com/wp-content/uploads/2016/08/SDS12657-12-Z-Wave-Command-Class-Specification-A-M.pdf, S. 153).
channel-type.zway.thermostatMode.label = Thermostat Modus
channel-type.zway.thermostatMode.description = Dieser Channel erlaubt die Steuerung und Anzeige eines Thermostats (Modus). Ein Thermostat kann einer der drei Zustände einnehmen (Modi): "Aus", "Heizen" oder "Kühlen". Der Zustand "Heizen" und "Kühlen" wird wechselweise im Zustand "An" gesetzt.
channel-type.zway.thermostatSetPoint.label = Thermostat Sollwert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@
<description>This channel represents the rgbw switch device type from Z-Way.</description>
<category>ColorLight</category>
</channel-type>

<!-- TODO: SwitchToggle ? -->

<channel-type id="thermostatMode">
<item-type>Switch</item-type>
Expand All @@ -207,7 +205,12 @@
<state readOnly="false" />
</channel-type>

<!-- TODO: ToggleButton -->
<channel-type id="sensorDiscrete">
<item-type>Number</item-type>
<label>Sensor discrete</label>
<description>This channel represents a two-digit value. The first digit is the button/scene number and the second digit points to action/keyAttribute (have a look at http://z-wave.sigmadesigns.com/wp-content/uploads/2016/08/SDS12657-12-Z-Wave-Command-Class-Specification-A-M.pdf, p. 153).</description>
<state readOnly="true" />
</channel-type>

<channel-type id="thermostatModeCC">
<item-type>Number</item-type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bundle-Version: 2.1.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .,
lib/commons-lang3-3.4.jar,
lib/zway-lib-0.1.7-SNAPSHOT.jar
lib/zway-lib-0.2.7-SNAPSHOT.jar
Import-Package: com.google.common.collect,
com.google.gson,
com.google.gson.annotations,
Expand Down
7 changes: 4 additions & 3 deletions addons/binding/org.openhab.binding.zway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ The following channels represent universial channels if no further device inform
| switchBinary | Switch | Switch | SwitchBinary |
| switchMultilevel | Dimmer | - | SwitchMultilevel |
| switchColor | Color | ColorLight | SwitchRGBW |
| switchControl | Switch | Switch | SwitchControl |
| switchControl | Switch | Switch | SwitchControl, ToggleButton, SwitchToggle |
| thermostat | Number | Temperature | Thermostat |
| sensorDiscrete | Number | - | SensorDiscrete |

Currently unsupported Z-Way device types: SwitchToggle, ToggleButton.
Unsupported Z-Way device types: Camera, SensorMultiline, Text. The integration of these types isn't planned.

### Channels for the Z-Way Server (Bridge)

Expand Down Expand Up @@ -171,7 +172,7 @@ Because textual configuration isn't useful, follow the instructions in the [Gett
### Restrictions

- Z-Way device types (especially the probe types) supported by openHAB channels with detailed information (scale types and so on) are not complete.
- Configuration of the Z-Wave network by the binding is currently not possible (device inclusion or physical device configuration)
- Configuration of the Z-Wave network by the binding is currently not possible (physical device configuration)
- Z-Way App "openHAB Connector" is required. Further versions will contain other mechanisms under usage of the WebSocket implementation of Z-Way or MQTT.

<br>
Expand Down
2 changes: 1 addition & 1 deletion addons/binding/org.openhab.binding.zway/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h3>Third Party Content</h3>
</em></p>

<p><em>
<strong>Z-Way Library for Java 0.1.7</strong><br/><br/>
<strong>Z-Way Library for Java 0.2.7</strong><br/><br/>
<br><a href="http://www.eclipse.org/legal/epl-v10.html">Eclipse Public License - v 1.0</a>.
<br><a href="https://github.com/pathec/ZWay-library-for-Java">Github</a>.
</em></p>
Expand Down
2 changes: 1 addition & 1 deletion addons/binding/org.openhab.binding.zway/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ bin.includes = META-INF/,\
OSGI-INF/,\
ESH-INF/,\
lib/commons-lang3-3.4.jar,\
lib/zway-lib-0.1.7-SNAPSHOT.jar,\
lib/zway-lib-0.2.7-SNAPSHOT.jar,\
about.html

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class ZWayBindingConstants {
public static final String DOORLOCK_CHANNEL = "doorlock";
public static final String SENSOR_BINARY_CHANNEL = "sensorBinary";
public static final String SENSOR_MULTILEVEL_CHANNEL = "sensorMultilevel";
public static final String SENSOR_DISCRETE_CHANNEL = "sensorDiscrete";
public static final String SWITCH_BINARY_CHANNEL = "switchBinary";
public static final String SWITCH_CONTROL_CHANNEL = "switchControl";
public static final String SWITCH_MULTILEVEL_CHANNEL = "switchMultilevel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void initialize() {
logger.debug("Configuration complete: {}", mConfig);

mZWayApi = new ZWayApiHttp(mConfig.getZWayIpAddress(), mConfig.getZWayPort(), mConfig.getZWayProtocol(),
mConfig.getZWayUsername(), mConfig.getZWayPassword(), this);
mConfig.getZWayUsername(), mConfig.getZWayPassword(), -1, false, this);

// Start an extra thread, because it takes sometimes more
// than 5000 milliseconds and the handler will suspend (ThingStatus.UNINITIALIZED).
Expand Down Expand Up @@ -621,7 +621,7 @@ public void getDevicesResponse(DeviceList deviceList) {
}

@Override
public void postDeviceResponse(Device device) {
public void putDeviceResponse(Device device) {
}

@Override
Expand Down Expand Up @@ -720,6 +720,10 @@ public void responseFormatError(String message, boolean invalidateApiState) {
}
}

@Override
public void message(int code, String message) {
}

@Override
public void getZWaveDeviceResponse(ZWaveDevice zwaveDevice) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import de.fh_zwickau.informatik.sensor.model.devices.types.Battery;
import de.fh_zwickau.informatik.sensor.model.devices.types.Doorlock;
import de.fh_zwickau.informatik.sensor.model.devices.types.SensorBinary;
import de.fh_zwickau.informatik.sensor.model.devices.types.SensorDiscrete;
import de.fh_zwickau.informatik.sensor.model.devices.types.SensorMultilevel;
import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchBinary;
import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchControl;
Expand Down Expand Up @@ -582,8 +583,6 @@ public void handleCommand(ChannelUID channelUID, final Command command) {
device.off();
}
}
} else if (device instanceof SwitchToggle) {
// possible commands: ?
} else if (device instanceof Thermostat) {
if (command instanceof DecimalType) {
logger.debug("Handle command: DecimalType");
Expand All @@ -603,10 +602,16 @@ public void handleCommand(ChannelUID channelUID, final Command command) {
device.off();
}
}
} else if (device instanceof ToggleButton) {
} else if (device instanceof ToggleButton || device instanceof SwitchToggle) {
// possible commands: on(), off(), exact(level), upstart(), upstop(), downstart(),
// downstop()
// TODO
if (command instanceof OnOffType) {
logger.debug("Handle command: OnOffType");

if (command.equals(OnOffType.ON)) {
device.on();
} // no else - only ON command is sent to Z-Way
}
}
}
} catch (UnsupportedOperationException e) {
Expand Down Expand Up @@ -670,8 +675,6 @@ protected synchronized void addDeviceAsChannel(Device device) {
} else if (device instanceof SwitchMultilevel) {
id = SWITCH_MULTILEVEL_CHANNEL;
acceptedItemType = "Dimmer";
} else if (device instanceof SwitchToggle) {
// ?
} else if (device instanceof SwitchRGBW) {
id = SWITCH_COLOR_CHANNEL;
acceptedItemType = "Color";
Expand All @@ -681,8 +684,12 @@ protected synchronized void addDeviceAsChannel(Device device) {
} else if (device instanceof SwitchControl) {
id = SWITCH_CONTROL_CHANNEL;
acceptedItemType = "Switch";
} else if (device instanceof ToggleButton) {
// TODO
} else if (device instanceof ToggleButton || device instanceof SwitchToggle) {
id = SWITCH_CONTROL_CHANNEL;
acceptedItemType = "Switch";
} else if (device instanceof SensorDiscrete) {
id = SENSOR_DISCRETE_CHANNEL;
acceptedItemType = "Number";
}

// 2. Check if device information includes further information about sensor type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import de.fh_zwickau.informatik.sensor.model.devices.types.Battery;
import de.fh_zwickau.informatik.sensor.model.devices.types.Doorlock;
import de.fh_zwickau.informatik.sensor.model.devices.types.SensorBinary;
import de.fh_zwickau.informatik.sensor.model.devices.types.SensorDiscrete;
import de.fh_zwickau.informatik.sensor.model.devices.types.SensorMultilevel;
import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchBinary;
import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchControl;
Expand Down Expand Up @@ -65,14 +66,14 @@ public static State toState(Device device, Channel channel) {
}
} else if (device instanceof SwitchRGBW) {
return getColorState(device.getMetrics().getColor());
} else if (device instanceof SwitchToggle) {
// ?
} else if (device instanceof Thermostat) {
return getMultilevelState(level);
} else if (device instanceof SwitchControl) {
return getBinaryState(level.toLowerCase());
} else if (device instanceof ToggleButton) {
// TODO
} else if (device instanceof ToggleButton || device instanceof SwitchToggle) {
return getBinaryState(level.toLowerCase());
} else if (device instanceof SensorDiscrete) {
return getMultilevelState(level);
}

return UnDefType.UNDEF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

import de.fh_zwickau.informatik.sensor.model.devices.Device;
import de.fh_zwickau.informatik.sensor.model.devices.DeviceList;
import de.fh_zwickau.informatik.sensor.model.devices.types.Camera;
import de.fh_zwickau.informatik.sensor.model.devices.types.SensorMultiline;
import de.fh_zwickau.informatik.sensor.model.devices.types.Text;
import de.fh_zwickau.informatik.sensor.model.locations.LocationList;
import de.fh_zwickau.informatik.sensor.model.zwaveapi.devices.ZWaveDevice;

Expand Down Expand Up @@ -155,6 +158,12 @@ private void scan() {
continue;
}

if (device instanceof SensorMultiline || device instanceof Camera || device instanceof Text) {
logger.debug("Skip device because the device type is not supported: {}",
device.getMetrics().getTitle());
continue;
}

ThingUID bridgeUID = mBridgeHandler.getThing().getUID();

String location = "";
Expand Down

0 comments on commit 32de188

Please sign in to comment.