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.lutron.internal.handler;
15 import java.util.Arrays;
16 import java.util.List;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.lutron.internal.KeypadComponent;
21 import org.openhab.binding.lutron.internal.discovery.project.ComponentType;
22 import org.openhab.core.thing.Thing;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * Handler responsible for communicating with Lutron VCRX visor control receiver
29 * @author Bob Adair - Initial contribution
32 public class VcrxHandler extends BaseKeypadHandler {
34 private enum Component implements KeypadComponent {
35 BUTTON1(1, "button1", "Button 1", ComponentType.BUTTON),
36 BUTTON2(2, "button2", "Button 2", ComponentType.BUTTON),
37 BUTTON3(3, "button3", "Button 3", ComponentType.BUTTON),
38 BUTTON4(4, "button4", "Button 4", ComponentType.BUTTON),
39 BUTTON5(5, "button5", "Button 5", ComponentType.BUTTON),
40 BUTTON6(6, "button6", "Button 6", ComponentType.BUTTON),
42 CCI1(30, "cci1", "CCI 1", ComponentType.CCI),
43 CCI2(31, "cci2", "CCI 2", ComponentType.CCI),
44 CCI3(32, "cci3", "CCI 3", ComponentType.CCI),
45 CCI4(33, "cci4", "CCI 4", ComponentType.CCI),
47 LED1(81, "led1", "LED 1", ComponentType.LED),
48 LED2(82, "led2", "LED 2", ComponentType.LED),
49 LED3(83, "led3", "LED 3", ComponentType.LED),
50 LED4(84, "led4", "LED 4", ComponentType.LED),
51 LED5(85, "led5", "LED 5", ComponentType.LED),
52 LED6(86, "led6", "LED 6", ComponentType.LED);
55 private final String channel;
56 private final String description;
57 private final ComponentType type;
59 Component(int id, String channel, String description, ComponentType type) {
61 this.channel = channel;
62 this.description = description;
72 public String channel() {
77 public String description() {
78 return this.description;
82 public ComponentType type() {
87 private static final List<Component> BUTTON_GROUP = Arrays.asList(Component.BUTTON1, Component.BUTTON2,
88 Component.BUTTON3, Component.BUTTON4, Component.BUTTON5, Component.BUTTON6);
90 private static final List<Component> LED_GROUP = Arrays.asList(Component.LED1, Component.LED2, Component.LED3,
91 Component.LED4, Component.LED5, Component.LED6);
93 private static final List<Component> CCI_GROUP = Arrays.asList(Component.CCI1, Component.CCI2, Component.CCI3,
96 private final Logger logger = LoggerFactory.getLogger(VcrxHandler.class);
99 protected boolean isLed(int id) {
100 return (id >= 81 && id <= 86);
104 protected boolean isButton(int id) {
105 return (id >= 1 && id <= 6);
109 protected boolean isCCI(int id) {
110 return (id >= 30 && id <= 33);
114 protected void configureComponents(@Nullable String model) {
115 logger.debug("Configuring components for VCRX");
117 buttonList.addAll(BUTTON_GROUP);
118 ledList.addAll(LED_GROUP);
119 cciList.addAll(CCI_GROUP);
122 public VcrxHandler(Thing thing) {