2 * Copyright (c) 2010-2024 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.Map.Entry;
16 import java.util.stream.Collectors;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.lutron.internal.discovery.project.ComponentType;
21 import org.openhab.binding.lutron.internal.keypadconfig.KeypadConfigPico;
22 import org.openhab.core.thing.Thing;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * Handler responsible for communicating with Lutron Pico keypads
29 * @author Bob Adair - Initial contribution
32 public class PicoKeypadHandler extends BaseKeypadHandler {
34 private final Logger logger = LoggerFactory.getLogger(PicoKeypadHandler.class);
36 public PicoKeypadHandler(Thing thing) {
38 kp = new KeypadConfigPico();
42 protected void configureComponents(@Nullable String model) {
43 String mod = model == null ? "Generic" : model;
44 logger.debug("Configuring components for keypad model {}", mod);
48 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
49 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_2B;
52 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
53 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_2BRL;
56 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
57 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_3B;
60 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
61 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_4B;
64 logger.warn("No valid keypad model defined ({}). Assuming model 3BRL.", mod);
68 buttonList = kp.getComponents("3BRL", ComponentType.BUTTON);
69 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_3BRL;
72 leapButtonInverseMap = leapButtonMap.entrySet().stream()
73 .collect(Collectors.toMap(Entry::getValue, Entry::getKey));