]> git.basschouten.com Git - openhab-addons.git/blob
a2bdde8337cf80bab8d727a945570abdb4f408e7
[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.silvercrestwifisocket.internal.enums;
14
15 /**
16  * This enum represents the available Wifi Socket vendors.
17  *
18  * @author Christian Heimerl - Initial contribution
19  *
20  */
21 public enum SilvercrestWifiSocketVendor {
22     LIDL_SILVERCREST("C1", "7150"),
23     ALDI_EASYHOME("C2", "92DD");
24
25     private final String companyCode;
26     private String authenticationCode;
27
28     SilvercrestWifiSocketVendor(String companyCode, String authenticationCode) {
29         this.companyCode = companyCode;
30         this.authenticationCode = authenticationCode;
31     }
32
33     /**
34      * Gets the hexadecimal company code included in a request message.
35      *
36      * @return the hexadecimal company code
37      */
38     public String getCompanyCode() {
39         return this.companyCode;
40     }
41
42     /**
43      * Gets the hexadecimal authentication code included in a request message
44      *
45      * @return the hexadecimal authentication code
46      */
47     public String getAuthenticationCode() {
48         return this.authenticationCode;
49     }
50
51     /**
52      * Returns the SilvercrestWifiSocketVendor matching the given two digit company code.
53      *
54      * @param companyCode The two digit company code that should be searched for, e.g. C1
55      * @return A SilvercrestWifiSocketVendor or null if no vendor matches the company code.
56      */
57     public static SilvercrestWifiSocketVendor fromCode(String companyCode) {
58         for (SilvercrestWifiSocketVendor v : SilvercrestWifiSocketVendor.values()) {
59             if (v.getCompanyCode().equals(companyCode)) {
60                 return v;
61             }
62         }
63         return null;
64     }
65 }