Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add start stop channel for Aeotec swipe #1135

Merged
merged 1 commit into from
Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ESH-INF/thing/aeon/zw130_0_0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,44 @@ WallMote Quad<br /><h1>Overview</h1><p>Aeotec WallMote Quad is an intelligent Z-
<property name="binding:*:PercentType">COMMAND_CLASS_BATTERY</property>
</properties>
</channel>
<channel id="switch_startstop1" typeId="switch_startstop">
<label>Swipe Switch 1</label>
<properties>
</properties>
</channel>
<channel id="scene_number1" typeId="scene_number">
<label>Scene Number 1</label>
<properties>
<property name="binding:*:DecimalType">COMMAND_CLASS_CENTRAL_SCENE:1</property>
</properties>
</channel>
<channel id="switch_startstop2" typeId="switch_startstop">
<label>Swipe Switch 2</label>
<properties>
</properties>
</channel>
<channel id="scene_number2" typeId="scene_number">
<label>Scene Number 2</label>
<properties>
<property name="binding:*:DecimalType">COMMAND_CLASS_CENTRAL_SCENE:2</property>
</properties>
</channel>
<channel id="switch_startstop3" typeId="switch_startstop">
<label>Swipe Switch 3</label>
<properties>
</properties>
</channel>
<channel id="scene_number3" typeId="scene_number">
<label>Scene Number 3</label>
<properties>
<property name="binding:*:DecimalType">COMMAND_CLASS_CENTRAL_SCENE:3</property>
</properties>
</channel>
<channel id="switch_startstop4" typeId="switch_startstop">
<label>Swipe Switch 4</label>
<properties>
</properties>
</channel>
<channel id="scene_number4" typeId="scene_number">
<label>Scene Number 4</label>
<properties>
Expand Down
8 changes: 8 additions & 0 deletions ESH-INF/thing/channels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,14 @@
<category>Switch</category>
</channel-type>

<!-- Switch Start/Stop Channel -->
<channel-type id="switch_startstop">
<item-type>String</item-type>
<label>StartStop Switch</label>
<description>Switch indicating direction</description>
<category>Switch</category>
</channel-type>

<!-- Brightness (Dimmer) Channel -->
<channel-type id="switch_dimmer">
<item-type>Dimmer</item-type>
Expand Down
35 changes: 26 additions & 9 deletions doc/aeon/zw130_0_0.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ The following table summarises the channels available for the ZW130 -:
| Channel | Channel Id | Category | Item Type |
|---------|------------|----------|-----------|
| Scene Number | scene_number | | Number |
| Alarm (power) | alarm_power | Door | Switch |
| Alarm (power) | alarm_power | Energy | Switch |
| Battery Level | battery-level | Battery | Number |
| Swipe Switch 1 | switch_startstop1 | Switch | String |
| Scene Number 1 | scene_number1 | | Number |
| Swipe Switch 2 | switch_startstop2 | Switch | String |
| Scene Number 2 | scene_number2 | | Number |
| Swipe Switch 3 | switch_startstop3 | Switch | String |
| Scene Number 3 | scene_number3 | | Number |
| Swipe Switch 4 | switch_startstop4 | Switch | String |
| Scene Number 4 | scene_number4 | | Number |

### Scene Number

Triggers when a scene button is pressed.

The ```scene_number``` channel supports the ```Number``` item.
Expand All @@ -84,10 +87,9 @@ This channel provides the scene, and the event as a decimal value in the form ``
| 6 | 5 x keypress |

### Alarm (power)

Indicates if a power alarm is triggered.

The ```alarm_power``` channel supports the ```Switch``` item and is in the ```Door``` category. This is a read only channel so will only be updated following state changes from the device.
The ```alarm_power``` channel supports the ```Switch``` item and is in the ```Energy``` category. This is a read only channel so will only be updated following state changes from the device.

The following state translation is provided for this channel to the ```Switch``` item type -:

Expand All @@ -97,13 +99,16 @@ The following state translation is provided for this channel to the ```Switch```
| ON | Alarm |

### Battery Level

Represents the battery level as a percentage (0-100%). Bindings for things supporting battery level in a different format (e.g. 4 levels) should convert to a percentage to provide a consistent battery level reading.

The ```battery-level``` channel supports the ```Number``` item and is in the ```Battery``` category.

### Scene Number 1
### Swipe Switch 1
Switch indicating direction.

The ```switch_startstop1``` channel supports the ```String``` item and is in the ```Switch``` category.
This channel provides the start/stop state of a switch as a JSON string. It is designed for use in rules and will indicate the direction of travel of the switch as INCREASE, DECREASE, STOP.
### Scene Number 1
Triggers when a scene button is pressed.

The ```scene_number1``` channel supports the ```Number``` item.
Expand All @@ -119,8 +124,12 @@ This channel provides the scene, and the event as a decimal value in the form ``
| 5 | 4 x keypress |
| 6 | 5 x keypress |

### Scene Number 2
### Swipe Switch 2
Switch indicating direction.

The ```switch_startstop2``` channel supports the ```String``` item and is in the ```Switch``` category.
This channel provides the start/stop state of a switch as a JSON string. It is designed for use in rules and will indicate the direction of travel of the switch as INCREASE, DECREASE, STOP.
### Scene Number 2
Triggers when a scene button is pressed.

The ```scene_number2``` channel supports the ```Number``` item.
Expand All @@ -136,8 +145,12 @@ This channel provides the scene, and the event as a decimal value in the form ``
| 5 | 4 x keypress |
| 6 | 5 x keypress |

### Scene Number 3
### Swipe Switch 3
Switch indicating direction.

The ```switch_startstop3``` channel supports the ```String``` item and is in the ```Switch``` category.
This channel provides the start/stop state of a switch as a JSON string. It is designed for use in rules and will indicate the direction of travel of the switch as INCREASE, DECREASE, STOP.
### Scene Number 3
Triggers when a scene button is pressed.

The ```scene_number3``` channel supports the ```Number``` item.
Expand All @@ -153,8 +166,12 @@ This channel provides the scene, and the event as a decimal value in the form ``
| 5 | 4 x keypress |
| 6 | 5 x keypress |

### Scene Number 4
### Swipe Switch 4
Switch indicating direction.

The ```switch_startstop4``` channel supports the ```String``` item and is in the ```Switch``` category.
This channel provides the start/stop state of a switch as a JSON string. It is designed for use in rules and will indicate the direction of travel of the switch as INCREASE, DECREASE, STOP.
### Scene Number 4
Triggers when a scene button is pressed.

The ```scene_number4``` channel supports the ```Number``` item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
package org.openhab.binding.zwave.internal.converter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.PercentType;
import org.eclipse.smarthome.core.library.types.StopMoveType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.library.types.UpDownType;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.State;
Expand All @@ -22,6 +25,7 @@
import org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveBatteryCommandClass;
import org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveCommandClass;
import org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveMultiLevelSwitchCommandClass;
import org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveMultiLevelSwitchCommandClass.ZWaveStartStopEvent;
import org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent;
import org.openhab.binding.zwave.internal.protocol.transaction.ZWaveCommandClassTransactionPayload;
import org.slf4j.Logger;
Expand Down Expand Up @@ -68,6 +72,9 @@ public State handleEvent(ZWaveThingChannel channel, ZWaveCommandClassValueEvent
boolean configInvertControl = "true".equalsIgnoreCase(channel.getArguments().get("config_invert_control"));
boolean configInvertPercent = "true".equalsIgnoreCase(channel.getArguments().get("config_invert_percent"));

if (event instanceof ZWaveStartStopEvent) {
return handleStartStopEvent(channel, (ZWaveStartStopEvent) event);
}
int value = (int) event.getValue();

// A value of 254 means the device doesn't know it's current position
Expand Down Expand Up @@ -122,6 +129,17 @@ public State handleEvent(ZWaveThingChannel channel, ZWaveCommandClassValueEvent
return state;
}

private State handleStartStopEvent(ZWaveThingChannel channel, ZWaveStartStopEvent event) {
if (channel.getUID().getId().equals("switch_startstop")) {
Map<String, Object> object = new HashMap<String, Object>();
object.put("direction", event.direction);

return new StringType(propertiesToJson(object));
}

return null;
}

@Override
public List<ZWaveCommandClassTransactionPayload> receiveCommand(ZWaveThingChannel channel, ZWaveNode node,
Command command) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ZWaveInclusionController implements ZWaveEventListener {
/**
* Create the inclusion controller
*
* @param controller the {@link ZWaveController} to include a device into
* @param controller the {@link ZWaveController} to include a device into
* @param networkSecurityKey the network security key
*/
public ZWaveInclusionController(ZWaveController controller, String networkSecurityKey) {
Expand All @@ -63,7 +63,7 @@ public ZWaveInclusionController(ZWaveController controller, String networkSecuri
/**
* Starts a network inclusion process.
*
* @param highPower use high power inclusion
* @param highPower use high power inclusion
* @param networkWide use network wide inclusion
*/
public void startInclusion(boolean highPower, boolean networkWide) {
Expand Down Expand Up @@ -367,6 +367,7 @@ private synchronized void startTimer(int period) {
private void stopTimer() {
if (timerTask != null) {
timerTask.cancel();
timerTask = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public class ZWaveMultiLevelSwitchCommandClass extends ZWaveCommandClass
private static final int SWITCH_MULTILEVEL_SUPPORTED_GET = 0x06;
private static final int SWITCH_MULTILEVEL_SUPPORTED_REPORT = 0x07;

private static final int START_LEVEL_INCREASE = 0;
private static final int START_LEVEL_DECREASE = 0x40;
private static final int START_LEVEL_IGNORE_LEVEL = 0x20;

private SwitchType switchTypePrimary = null;
private SwitchType switchTypeSecondary = null;

Expand All @@ -66,9 +70,9 @@ public class ZWaveMultiLevelSwitchCommandClass extends ZWaveCommandClass
/**
* Creates a new instance of the ZWaveMultiLevelSwitchCommandClass class.
*
* @param node the node this command class belongs to
* @param node the node this command class belongs to
* @param controller the controller to use
* @param endpoint the endpoint this Command class belongs to
* @param endpoint the endpoint this Command class belongs to
*/
public ZWaveMultiLevelSwitchCommandClass(ZWaveNode node, ZWaveController controller, ZWaveEndpoint endpoint) {
super(node, controller, endpoint);
Expand Down Expand Up @@ -102,6 +106,33 @@ public void handleSwitchMultilevelReport(ZWaveCommandClassPayload payload, int e
dynamicDone = true;
}

@ZWaveResponseHandler(id = SWITCH_MULTILEVEL_START_LEVEL_CHANGE, name = "SWITCH_MULTILEVEL_START_LEVEL_CHANGE")
public void handleSwitchMultilevelStartLevelChanel(ZWaveCommandClassPayload payload, int endpoint) {
StartStopDirection direction = ((payload.getPayloadByte(2) & START_LEVEL_DECREASE) != 0)
? StartStopDirection.DECREASE
: StartStopDirection.INCREASE;

logger.debug("NODE {}: Switch Multi Level start level change, direction = {}", getNode().getNodeId(),
direction);
ZWaveCommandClassValueEvent zEvent = new ZWaveStartStopEvent(getNode().getNodeId(), endpoint, getCommandClass(),
direction);

getController().notifyEventListeners(zEvent);

dynamicDone = true;
}

@ZWaveResponseHandler(id = SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE, name = "SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE")
public void handleSwitchMultilevelStopLevelChanel(ZWaveCommandClassPayload payload, int endpoint) {
logger.debug("NODE {}: Switch Multi Level stop level change", getNode().getNodeId());
ZWaveCommandClassValueEvent zEvent = new ZWaveStartStopEvent(getNode().getNodeId(), endpoint, getCommandClass(),
StartStopDirection.STOP);

getController().notifyEventListeners(zEvent);

dynamicDone = true;
}

@ZWaveResponseHandler(id = SWITCH_MULTILEVEL_SUPPORTED_REPORT, name = "SWITCH_MULTILEVEL_SUPPORTED_REPORT")
public void handleSwitchMultilevelSupportedReport(ZWaveCommandClassPayload payload, int endpoint) {
int primary = payload.getPayloadByte(2) & 0x1f;
Expand Down Expand Up @@ -179,10 +210,12 @@ public ZWaveCommandClassTransactionPayload startLevelChangeMessage(boolean incre
getNode().getNodeId());
byte[] newPayload = { 0, 0, 0 };
if (increase) {
newPayload[0] = 32;
newPayload[0] = START_LEVEL_INCREASE;
} else {
newPayload[0] = 96;
newPayload[0] = START_LEVEL_DECREASE;
}
newPayload[0] |= START_LEVEL_IGNORE_LEVEL;

newPayload[1] = 0; // Start level - ignored (for now!)
newPayload[2] = (byte) duration;

Expand Down Expand Up @@ -287,4 +320,25 @@ public int getValue() {
return value;
}
}

public enum StartStopDirection {
INCREASE,
DECREASE,
STOP
}

/**
* Z-Wave Alarm Event class. Indicates that an alarm value changed.
*/
public static class ZWaveStartStopEvent extends ZWaveCommandClassValueEvent {
public StartStopDirection direction;

public ZWaveStartStopEvent(int nodeId, int endpoint, CommandClass commandClass, StartStopDirection direction) {
super(nodeId, endpoint, commandClass, direction);

this.direction = direction;
}

}

}
Loading