]> git.basschouten.com Git - openhab-addons.git/blob
41b0983fdbfa0ac1fca4e0eb380418b67b8727fc
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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             case "2BRL":
46             case "3B":
47             case "4B":
48                 buttonList = kp.getComponents(mod, ComponentType.BUTTON);
49                 break;
50             default:
51                 logger.warn("No valid keypad model defined ({}). Assuming model 3BRL.", mod);
52                 // fall through
53             case "Generic":
54             case "3BRL":
55                 buttonList = kp.getComponents("3BRL", ComponentType.BUTTON);
56                 break;
57         }
58     }
59 }