]> git.basschouten.com Git - openhab-addons.git/blob
44f674976e3aca38728f20ef7ac39b2daf1a67bf
[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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.lutron.internal.discovery.project.ComponentType;
18 import org.openhab.binding.lutron.internal.keypadconfig.KeypadConfigPico;
19 import org.openhab.core.thing.Thing;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24  * Handler responsible for communicating with Lutron Pico keypads
25  *
26  * @author Bob Adair - Initial contribution
27  */
28 @NonNullByDefault
29 public class PicoKeypadHandler extends BaseKeypadHandler {
30
31     private final Logger logger = LoggerFactory.getLogger(PicoKeypadHandler.class);
32
33     public PicoKeypadHandler(Thing thing) {
34         super(thing);
35         kp = new KeypadConfigPico();
36     }
37
38     @Override
39     protected void configureComponents(@Nullable String model) {
40         String mod = model == null ? "Generic" : model;
41         logger.debug("Configuring components for keypad model {}", mod);
42
43         switch (mod) {
44             case "2B":
45                 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
46                 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_2B;
47                 break;
48             case "2BRL":
49                 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
50                 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_2BRL;
51                 break;
52             case "3B":
53                 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
54                 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_3B;
55                 break;
56             case "4B":
57                 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
58                 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_4B;
59                 break;
60             default:
61                 logger.warn("No valid keypad model defined ({}). Assuming model 3BRL.", mod);
62                 // fall through
63             case "Generic":
64             case "3BRL":
65                 buttonList = kp.getComponents("3BRL", ComponentType.BUTTON);
66                 leapButtonMap = KeypadConfigPico.LEAPBUTTONS_3BRL;
67                 break;
68         }
69     }
70 }