Skip to content

Commit

Permalink
openhab#10 Support stop for roller shutter
Browse files Browse the repository at this point in the history
  • Loading branch information
magx2 committed Apr 9, 2019
1 parent 27fb3ed commit f2f6dad
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,33 @@ private void handleOneZeroCommand(final int channelId,
// channelsApi.executeAction(new ChannelExecuteActionRequest().action(action), channelId);
}

@SuppressWarnings("SwitchStatementWithTooFewBranches")
@Override
protected void handleStopMoveTypeCommand(final @NonNull ChannelUID channelUID, final @NonNull StopMoveType command) throws Exception {
logger.warn("Not handling `{}` ({}) on channel `{}`", command, command.getClass().getSimpleName(), channelUID);
protected void handleStopMoveTypeCommand(final @NonNull ChannelUID channelUID, final @NonNull StopMoveType command) throws ApiException {
final int channelId = parseInt(channelUID.getId());
final pl.grzeslowski.jsupla.api.generated.model.Channel channel = queryForChannel(channelId);
switch (channel.getFunction().getName()) {
case CONTROLLINGTHEROLLERSHUTTER:
handleStopMoveTypeCommandOnRollerShutter(channelUID, channel, command);
return;
default:
logger.warn("Not handling `{}` ({}) on channel `{}`", command, command.getClass().getSimpleName(), channelUID);
}
}

private void handleStopMoveTypeCommandOnRollerShutter(
final ChannelUID channelUID,
final pl.grzeslowski.jsupla.api.generated.model.Channel channel,
final StopMoveType command) throws ApiException {
switch (command) {
case MOVE:
logger.trace("Do not know how to handle command `{}` on roller shutter with id `{}`", command, channelUID);
return;
case STOP:
final ChannelFunctionActionEnum action = ChannelFunctionActionEnum.STOP;
logger.trace("Sending stop action `{}` to channel with UUID `{}`", action, channelUID);
channelsApi.executeAction(new ChannelExecuteActionRequest().action(action), channel.getId());
}
}

private Optional<State> findState(pl.grzeslowski.jsupla.api.generated.model.Channel channel) {
Expand Down

0 comments on commit f2f6dad

Please sign in to comment.