]> git.basschouten.com Git - openhab-addons.git/blob
43d233bbabb1b8a0b44487bd07651e39b6417aa8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lcn.internal.subhandler;
14
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.regex.Matcher;
18 import java.util.regex.Pattern;
19
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.OnOffType;
28 import org.openhab.core.library.types.StringType;
29
30 /**
31  * Handles Commands and State changes of LEDs of an LCN module.
32  *
33  * @author Fabian Wolter - Initial contribution
34  */
35 @NonNullByDefault
36 public class LcnModuleLedSubHandler extends AbstractLcnModuleSubHandler {
37     public LcnModuleLedSubHandler(LcnModuleHandler handler, ModInfo info) {
38         super(handler, info);
39     }
40
41     @Override
42     public void handleRefresh(LcnChannelGroup channelGroup, int number) {
43         info.refreshLedsAndLogic();
44     }
45
46     @Override
47     public void handleCommandOnOff(OnOffType command, LcnChannelGroup channelGroup, int number) throws LcnException {
48         handleCommandString(new StringType(command.toString()), number);
49     }
50
51     @Override
52     public void handleCommandString(StringType command, int number) throws LcnException {
53         handler.sendPck(PckGenerator.controlLed(number, LcnDefs.LedStatus.valueOf(command.toString())));
54         info.refreshStatusLedsAnLogicAfterChange();
55     }
56
57     @Override
58     public void handleStatusMessage(Matcher matcher) {
59         /** Status messages are handled in {@link LcnModuleLogicSubHandler}. */
60     }
61
62     @Override
63     public Collection<Pattern> getPckStatusMessagePatterns() {
64         return Collections.emptyList();
65     }
66 }