2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lcn.internal.subhandler;
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.regex.Matcher;
18 import java.util.regex.Pattern;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.lcn.internal.LcnModuleHandler;
22 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
23 import org.openhab.binding.lcn.internal.common.LcnDefs;
24 import org.openhab.binding.lcn.internal.common.LcnException;
25 import org.openhab.binding.lcn.internal.common.PckGenerator;
26 import org.openhab.binding.lcn.internal.connection.ModInfo;
27 import org.openhab.core.library.types.StopMoveType;
28 import org.openhab.core.library.types.UpDownType;
31 * Handles Commands and State changes of roller shutters connected to dimmer outputs of an LCN module.
33 * @author Fabian Wolter - Initial contribution
36 public class LcnModuleRollershutterOutputSubHandler extends AbstractLcnModuleSubHandler {
37 public LcnModuleRollershutterOutputSubHandler(LcnModuleHandler handler, ModInfo info) {
42 public void handleRefresh(LcnChannelGroup channelGroup, int number) {
43 info.refreshOutput(number);
47 public void handleCommandUpDown(UpDownType command, LcnChannelGroup channelGroup, int number, boolean invertUpDown)
49 // When configured as shutter in LCN-PRO, an output gets switched off, when the other is
50 // switched on and vice versa.
51 if (command == UpDownType.UP ^ invertUpDown) {
53 handler.sendPck(PckGenerator.dimOutput(0, 100, LcnDefs.ROLLER_SHUTTER_RAMP_MS));
55 // second output: 100%
56 handler.sendPck(PckGenerator.dimOutput(1, 100, LcnDefs.ROLLER_SHUTTER_RAMP_MS));
61 public void handleCommandStopMove(StopMoveType command, LcnChannelGroup channelGroup, int number)
63 if (command == StopMoveType.STOP) {
65 handler.sendPck(PckGenerator.dimOutput(0, 0, 0));
66 handler.sendPck(PckGenerator.dimOutput(1, 0, 0));
68 // roller shutters on outputs are stateless, assume always down when MOVE is sent
69 // second output: 100%
70 handler.sendPck(PckGenerator.dimOutput(1, 100, LcnDefs.ROLLER_SHUTTER_RAMP_MS));
75 public void handleStatusMessage(Matcher matcher) {
76 // status messages of roller shutters on dimmer outputs are handled in the dimmer output sub handler
80 public Collection<Pattern> getPckStatusMessagePatterns() {
81 return Collections.emptyList();