2 * Copyright (c) 2010-2020 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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.lutron.internal.KeypadComponent;
18 import org.openhab.binding.lutron.internal.discovery.project.ComponentType;
19 import org.openhab.core.thing.Thing;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * Handler responsible for communicating with the virtual buttons on the RadioRA2 main repeater
26 * @author Bob Adair - Initial contribution
29 public class VirtualKeypadHandler extends BaseKeypadHandler {
31 private static final String MODEL_OPTION_CASETA = "Caseta";
32 private static final String MODEL_OPTION_OTHER = "Other";
34 private class Component implements KeypadComponent {
36 private final String channel;
37 private final String description;
38 private final ComponentType type;
40 Component(int id, String channel, String description, ComponentType type) {
42 this.channel = channel;
43 this.description = description;
53 public String channel() {
58 public String description() {
63 public ComponentType type() {
68 private final Logger logger = LoggerFactory.getLogger(VirtualKeypadHandler.class);
71 protected boolean isLed(int id) {
72 return (id >= 101 && id <= 200);
76 protected boolean isButton(int id) {
77 return (id >= 1 && id <= 100);
81 protected boolean isCCI(int id) {
86 protected void configureComponents(@Nullable String model) {
87 String mod = model == null ? MODEL_OPTION_OTHER : model;
88 logger.debug("Configuring components for virtual keypad for model {}", mod);
89 boolean caseta = mod.equalsIgnoreCase(MODEL_OPTION_CASETA);
91 for (int x = 1; x <= 100; x++) {
92 buttonList.add(new Component(x, String.format("button%d", x), "Virtual Button", ComponentType.BUTTON));
93 if (!caseta) { // Caseta scene buttons have no virtual LEDs
94 ledList.add(new Component(x + 100, String.format("led%d", x), "Virtual LED", ComponentType.LED));
99 public VirtualKeypadHandler(Thing thing) {
101 // Mark all channels "Advanced" since most are unlikely to be used in any particular config
102 advancedChannels = true;