]> git.basschouten.com Git - openhab-addons.git/blob
b2ad68175d89217eb023adc9f17052345d283141
[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.keypadconfig;
14
15 import java.util.Arrays;
16 import java.util.Map;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.lutron.internal.KeypadComponent;
20 import org.openhab.binding.lutron.internal.discovery.project.ComponentType;
21
22 /**
23  * Keypad configuration definition for Pico models
24  *
25  * @author Bob Adair - Initial contribution
26  */
27 @NonNullByDefault
28 public final class KeypadConfigPico extends KeypadConfig {
29
30     // Button mappings for LEAP protocol
31     public static final Map<Integer, Integer> LEAPBUTTONS_2B = Map.of(2, 1, 4, 2);
32     public static final Map<Integer, Integer> LEAPBUTTONS_2BRL = Map.of(2, 1, 4, 2, 5, 3, 6, 4);
33     public static final Map<Integer, Integer> LEAPBUTTONS_3B = Map.of(2, 1, 3, 2, 4, 3);
34     public static final Map<Integer, Integer> LEAPBUTTONS_4B = Map.of(8, 1, 9, 2, 10, 3, 11, 4);
35     public static final Map<Integer, Integer> LEAPBUTTONS_3BRL = Map.of(2, 1, 3, 2, 4, 3, 5, 4, 6, 5);
36
37     private static enum Component implements KeypadComponent {
38         // Buttons for 2B, 2BRL, 3B, and 3BRL models
39         BUTTON1(2, "button1", "Button 1", ComponentType.BUTTON),
40         BUTTON2(3, "button2", "Button 2", ComponentType.BUTTON),
41         BUTTON3(4, "button3", "Button 3", ComponentType.BUTTON),
42
43         RAISE(5, "buttonraise", "Raise Button", ComponentType.BUTTON),
44         LOWER(6, "buttonlower", "Lower Button", ComponentType.BUTTON),
45
46         // Buttons for PJ2-4B model
47         BUTTON1_4B(8, "button01", "Button 1", ComponentType.BUTTON),
48         BUTTON2_4B(9, "button02", "Button 2", ComponentType.BUTTON),
49         BUTTON3_4B(10, "button03", "Button 3", ComponentType.BUTTON),
50         BUTTON4_4B(11, "button04", "Button 4", ComponentType.BUTTON);
51
52         private final int id;
53         private final String channel;
54         private final String description;
55         private final ComponentType type;
56
57         Component(int id, String channel, String description, ComponentType type) {
58             this.id = id;
59             this.channel = channel;
60             this.description = description;
61             this.type = type;
62         }
63
64         @Override
65         public int id() {
66             return id;
67         }
68
69         @Override
70         public String channel() {
71             return channel;
72         }
73
74         @Override
75         public String description() {
76             return description;
77         }
78
79         @Override
80         public ComponentType type() {
81             return type;
82         }
83     }
84
85     @Override
86     public boolean isLed(int id) {
87         return false;
88     }
89
90     @Override
91     public boolean isButton(int id) {
92         return (id >= 2 && id <= 11);
93     }
94
95     @Override
96     public boolean isCCI(int id) {
97         return false;
98     }
99
100     public KeypadConfigPico() {
101         modelData.put("2B", Arrays.asList(Component.BUTTON1, Component.BUTTON3));
102         modelData.put("2BRL", Arrays.asList(Component.BUTTON1, Component.BUTTON3, Component.RAISE, Component.LOWER));
103         modelData.put("3B", Arrays.asList(Component.BUTTON1, Component.BUTTON2, Component.BUTTON3));
104         modelData.put("3BRL", Arrays.asList(Component.BUTTON1, Component.BUTTON2, Component.BUTTON3, Component.RAISE,
105                 Component.LOWER));
106         modelData.put("4B",
107                 Arrays.asList(Component.BUTTON1_4B, Component.BUTTON2_4B, Component.BUTTON3_4B, Component.BUTTON4_4B));
108     }
109 }