Skip to content

Commit

Permalink
[somfytahoma] improvements for the MY position setting
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Pecta <[email protected]>
  • Loading branch information
octa22 committed Jan 1, 2020
1 parent 464fcb7 commit 344e744
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 28 deletions.
9 changes: 9 additions & 0 deletions bundles/org.openhab.binding.somfytahoma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ When a roller shutter-like thing receives STOP command, there are two possible b
- when the roller shutter is idle then MY command is interpreted (the roller shutter/exterior screen/awning goes to your favourite position)
- when the roller shutter is moving then STOP command is interpreted (the roller shutter/exterior screen/awning stops)

If you want to set the MY position of a roller shutter and you don't care the possible movement, try sending the MOVE command (OH2 does not know MY, so it stands for "move to MY position")

```
sendCommand(ROLLERSHUTTER_THING, MOVE)
```
or
```
ROLLERSHUTTER_THING.sendCommand(MOVE)
```

## Full Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,9 @@ public class SomfyTahomaBindingConstants {
public static final String THING_REMOTE_CONTROLLER = "RemoteController";
public static final String THING_NETWORK_COMPONENT = "NetworkComponent";

// cache timeout
public static final int CACHE_EXPIRY = 10000;
// Event states
public static final String FAILED_EVENT = "FAILED";
public static final String COMPLETED_EVENT = "COMPLETED";

// supported thing types for discovery
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>(Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ public void handleCommand(ChannelUID channelUID, Command command) {
} else {
String cmd = getTahomaCommand(command.toString());
if (COMMAND_MY.equals(cmd)) {
sendCommand(COMMAND_MY);
} else if (COMMAND_STOP.equals(cmd)) {
String executionId = getCurrentExecutions();
if (executionId != null) {
//Check if the awning is moving and MY is sent => STOP it
//Check if the awning is moving and STOP is sent => STOP it
cancelExecution(executionId);
} else {
sendCommand(COMMAND_MY);
Expand All @@ -68,8 +70,11 @@ private String getTahomaCommand(String command) {
case "ON":
case "UP":
return COMMAND_UP;
case "STOP":
case "MOVE":
case "MY":
return COMMAND_MY;
case "STOP":
return COMMAND_STOP;
default:
return COMMAND_SET_DEPLOYMENT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private void processExecutionRegisteredEvent(SomfyTahomaEvent event) {
}

private void processExecutionChangedEvent(SomfyTahomaEvent event) {
if ("FAILED".equals(event.getNewState()) || "COMPLETED".equals(event.getNewState())) {
if (FAILED_EVENT.equals(event.getNewState()) || COMPLETED_EVENT.equals(event.getNewState())) {
logger.debug("Removing execution id: {}", event.getExecId());
unregisterExecution(event.getExecId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ protected String getTahomaCommand(String command) {
case "UP":
case "OPEN":
return COMMAND_OPEN;
case "MOVE":
case "MY":
case "STOP":
return COMMAND_MY;
case "STOP":
return COMMAND_STOP;
default:
return COMMAND_SET_CLOSURE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}

if (RefreshType.REFRESH.equals(command)) {
return;
return;
} else {
String cmd = getTahomaCommand(command.toString());
if (COMMAND_MY.equals(cmd)) {
sendCommand(COMMAND_MY);
} else if (COMMAND_STOP.equals(cmd)) {
String executionId = getCurrentExecutions();
if (executionId != null) {
//Check if the roller shutter is moving and MY is sent => STOP it
//Check if the roller shutter is moving and STOP is sent => STOP it
cancelExecution(executionId);
} else {
sendCommand(COMMAND_MY);
Expand All @@ -71,9 +73,11 @@ protected String getTahomaCommand(String command) {
case "UP":
case "OPEN":
return COMMAND_UP;
case "MOVE":
case "MY":
case "STOP":
return COMMAND_MY;
case "STOP":
return COMMAND_STOP;
default:
return COMMAND_SET_CLOSURE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @author Ondrej Pecta - Initial contribution
*/
@NonNullByDefault
public class SomfyTahomaSilentRollerShutterHandler extends SomfyTahomaBaseThingHandler {
public class SomfyTahomaSilentRollerShutterHandler extends SomfyTahomaRollerShutterHandler {

public SomfyTahomaSilentRollerShutterHandler(Thing thing) {
super(thing);
Expand All @@ -47,9 +47,11 @@ public void handleCommand(ChannelUID channelUID, Command command) {
} else {
String cmd = getTahomaCommand(command.toString());
if (COMMAND_MY.equals(cmd)) {
sendCommand(COMMAND_MY);
} else if (COMMAND_STOP.equals(cmd)) {
String executionId = getCurrentExecutions();
if (executionId != null) {
//Check if the roller shutter is moving and MY is sent => STOP it
//Check if the roller shutter is moving and STOP is sent => STOP it
cancelExecution(executionId);
} else {
sendCommand(COMMAND_MY);
Expand All @@ -66,19 +68,4 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
}
}

private String getTahomaCommand(String command) {
switch (command) {
case "OFF":
case "DOWN":
return COMMAND_DOWN;
case "ON":
case "UP":
return COMMAND_UP;
case "STOP":
return COMMAND_MY;
default:
return COMMAND_SET_CLOSURE;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public void handleCommand(ChannelUID channelUID, Command command) {
} else {
String cmd = getTahomaCommand(command.toString(), channelUID.getId());
if (COMMAND_MY.equals(cmd)) {
sendCommand(COMMAND_MY);
} else if (COMMAND_STOP.equals(cmd)) {
String executionId = getCurrentExecutions();
if (executionId != null) {
//Check if the venetian blind is moving and MY is sent => STOP it
//Check if the venetian blind is moving and STOP is sent => STOP it
cancelExecution(executionId);
} else {
sendCommand(COMMAND_MY);
Expand All @@ -66,12 +68,17 @@ private String getTahomaCommand(String command, String channelId) {
switch (command) {
case "OFF":
case "DOWN":
case "CLOSE":
return COMMAND_DOWN;
case "ON":
case "UP":
case "OPEN":
return COMMAND_UP;
case "STOP":
case "MOVE":
case "MY":
return COMMAND_MY;
case "STOP":
return COMMAND_STOP;
default:
if (CONTROL.equals(channelId)) {
return COMMAND_SET_CLOSURE;
Expand Down

0 comments on commit 344e744

Please sign in to comment.