]> git.basschouten.com Git - openhab-addons.git/blob
2beb97ecb2ddc53b33e7256d5546ad61c08f7bf9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.iaqualink.internal.handler;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.iaqualink.internal.IAqualinkBindingConstants;
18 import org.openhab.core.thing.type.ChannelTypeUID;
19
20 /**
21  * AuxiliaryType maps iAquaLink Auxiliary Devices to binding channel types
22  *
23  * @author Dan Cunningham - Initial contribution
24  *
25  */
26 @NonNullByDefault
27 public enum AuxiliaryType {
28     SWITCH("0", "0", IAqualinkBindingConstants.CHANNEL_TYPE_UID_AUX_SWITCH),
29     DIMMER("1", "NA", IAqualinkBindingConstants.CHANNEL_TYPE_UID_AUX_DIMMER),
30     JANDYCOLOR("2", "1", IAqualinkBindingConstants.CHANNEL_TYPE_UID_AUX_JANDYCOLOR),
31     PENTAIRSAM("2", "2", IAqualinkBindingConstants.CHANNEL_TYPE_UID_AUX_PENTAIRSAM),
32     JANDYLED("2", "4", IAqualinkBindingConstants.CHANNEL_TYPE_UID_AUX_JANDYLED),
33     PENTAIRIB("2", "5", IAqualinkBindingConstants.CHANNEL_TYPE_UID_AUX_PENTAIRIB),
34     HAYWARD("2", "6", IAqualinkBindingConstants.CHANNEL_TYPE_UID_AUX_HAYWARD);
35
36     private String type;
37     private String subType;
38     private ChannelTypeUID channelTypeUID;
39
40     AuxiliaryType(String type, String subType, ChannelTypeUID channelTypeUID) {
41         this.type = type;
42         this.subType = subType;
43         this.channelTypeUID = channelTypeUID;
44     }
45
46     public String getSubType() {
47         return subType;
48     }
49
50     public String getType() {
51         return type;
52     }
53
54     public ChannelTypeUID getChannelTypeUID() {
55         return channelTypeUID;
56     }
57
58     public static AuxiliaryType fromSubType(String subType) {
59         for (AuxiliaryType at : AuxiliaryType.values()) {
60             if (at.subType.equals(subType)) {
61                 return at;
62             }
63         }
64         return AuxiliaryType.SWITCH;
65     }
66
67     public static AuxiliaryType fromChannelTypeUID(@Nullable ChannelTypeUID channelTypeUID) {
68         for (AuxiliaryType at : AuxiliaryType.values()) {
69             if (at.channelTypeUID.equals(channelTypeUID)) {
70                 return at;
71             }
72         }
73         return AuxiliaryType.SWITCH;
74     }
75 }