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 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.binding.lutron.internal.protocol.lip.TargetType;
20 import org.openhab.core.thing.Thing;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * Handler responsible for communicating with the virtual buttons on the RadioRA2 main repeater
27 * @author Bob Adair - Initial contribution
30 public class VirtualKeypadHandler extends BaseKeypadHandler {
32 private static final String MODEL_OPTION_CASETA = "Caseta";
33 private static final String MODEL_OPTION_OTHER = "Other";
35 private class Component implements KeypadComponent {
37 private final String channel;
38 private final String description;
39 private final ComponentType type;
41 Component(int id, String channel, String description, ComponentType type) {
43 this.channel = channel;
44 this.description = description;
54 public String channel() {
59 public String description() {
64 public ComponentType type() {
69 private final Logger logger = LoggerFactory.getLogger(VirtualKeypadHandler.class);
72 protected boolean isLed(int id) {
73 return (id >= 101 && id <= 200);
77 protected boolean isButton(int id) {
78 return (id >= 1 && id <= 100);
82 protected boolean isCCI(int id) {
87 protected void configureComponents(@Nullable String model) {
88 String mod = model == null ? MODEL_OPTION_OTHER : model;
89 logger.debug("Configuring components for virtual keypad for model {}", mod);
90 boolean caseta = mod.equalsIgnoreCase(MODEL_OPTION_CASETA);
92 for (int x = 1; x <= 100; x++) {
93 buttonList.add(new Component(x, String.format("button%d", x), "Virtual Button", ComponentType.BUTTON));
94 if (!caseta) { // Caseta scene buttons have no virtual LEDs
95 ledList.add(new Component(x + 100, String.format("led%d", x), "Virtual LED", ComponentType.LED));
100 public VirtualKeypadHandler(Thing thing) {
102 // Mark all channels "Advanced" since most are unlikely to be used in any particular config
103 advancedChannels = true;
104 commandTargetType = TargetType.VIRTUALKEYPAD; // For the LEAP bridge