]> git.basschouten.com Git - openhab-addons.git/blob
97e7a40ac30e57d7b4d8020085d4596f81982355
[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.lutron.internal.handler;
14
15 import java.util.Arrays;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.lutron.internal.KeypadComponent;
20 import org.openhab.binding.lutron.internal.discovery.project.ComponentType;
21 import org.openhab.core.thing.Thing;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * Handler responsible for communicating with Lutron QS IO Interfaces
27  *
28  * @author Bob Adair - Initial contribution
29  */
30 @NonNullByDefault
31 public class QSIOHandler extends BaseKeypadHandler {
32
33     private enum Component implements KeypadComponent {
34         CCI1(1, "cci1", "CCI 1", ComponentType.CCI),
35         CCI2(2, "cci2", "CCI 2", ComponentType.CCI),
36         CCI3(3, "cci3", "CCI 3", ComponentType.CCI),
37         CCI4(4, "cci4", "CCI 4", ComponentType.CCI),
38         CCI5(5, "cci5", "CCI 5", ComponentType.CCI);
39
40         private final int id;
41         private final String channel;
42         private final String description;
43         private final ComponentType type;
44
45         Component(int id, String channel, String description, ComponentType type) {
46             this.id = id;
47             this.channel = channel;
48             this.description = description;
49             this.type = type;
50         }
51
52         @Override
53         public int id() {
54             return this.id;
55         }
56
57         @Override
58         public String channel() {
59             return this.channel;
60         }
61
62         @Override
63         public String description() {
64             return this.description;
65         }
66
67         @Override
68         public ComponentType type() {
69             return type;
70         }
71     }
72
73     private final Logger logger = LoggerFactory.getLogger(QSIOHandler.class);
74
75     @Override
76     protected boolean isLed(int id) {
77         return false;
78     }
79
80     @Override
81     protected boolean isButton(int id) {
82         return false;
83     }
84
85     @Override
86     protected boolean isCCI(int id) {
87         return (id >= 1 && id <= 5);
88     }
89
90     @Override
91     protected void configureComponents(@Nullable String model) {
92         logger.debug("Configuring components for VCRX");
93
94         cciList.addAll(Arrays.asList(Component.CCI1, Component.CCI2, Component.CCI3, Component.CCI4, Component.CCI5));
95     }
96
97     public QSIOHandler(Thing thing) {
98         super(thing);
99     }
100 }