]> git.basschouten.com Git - openhab-addons.git/blob
b70cc5c370f1da399f0e3a754bc901973226c7d5
[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.LcnException;
23 import org.openhab.binding.lcn.internal.common.PckGenerator;
24 import org.openhab.binding.lcn.internal.connection.ModInfo;
25 import org.openhab.core.library.types.StringType;
26
27 /**
28  * Handles the heating/cooling mode of a regulator.
29  *
30  * @author Fabian Wolter - Initial contribution
31  */
32 @NonNullByDefault
33 public class LcnModuleRvarModeSubHandler extends AbstractLcnModuleVariableSubHandler {
34     public LcnModuleRvarModeSubHandler(LcnModuleHandler handler, ModInfo info) {
35         super(handler, info);
36     }
37
38     @Override
39     public void handleStatusMessage(Matcher matcher) throws LcnException {
40         // nothing
41     }
42
43     @Override
44     public void handleCommandString(StringType command, int number) throws LcnException {
45         boolean cooling;
46         switch (command.toString()) {
47             case "HEATING":
48                 cooling = false;
49                 break;
50             case "COOLING":
51                 cooling = true;
52                 break;
53             default:
54                 throw new LcnException();
55         }
56
57         handler.sendPck(PckGenerator.setRVarMode(number, cooling));
58     }
59
60     @Override
61     public Collection<Pattern> getPckStatusMessagePatterns() {
62         return Collections.emptyList();
63     }
64 }