]> git.basschouten.com Git - openhab-addons.git/blob
0c0c4e2336ec51beb310af0e77476425b994c8cf
[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.deconz.internal.types;
14
15 import java.util.Arrays;
16 import java.util.Map;
17 import java.util.stream.Collectors;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24  * Type of a light as reported by the REST API for usage in
25  * {@link org.openhab.binding.deconz.internal.dto.LightMessage}
26  *
27  * @author Jan N. Klug - Initial contribution
28  */
29 @NonNullByDefault
30 public enum LightType {
31     ON_OFF_LIGHT("On/Off light"),
32     ON_OFF_PLUGIN_UNIT("On/Off plug-in unit"),
33     SMART_PLUG("Smart plug"),
34     EXTENDED_COLOR_LIGHT("Extended color light"),
35     COLOR_LIGHT("Color light"),
36     COLOR_DIMMABLE_LIGHT("Color dimmable light"),
37     COLOR_TEMPERATURE_LIGHT("Color temperature light"),
38     DIMMABLE_LIGHT("Dimmable light"),
39     DIMMABLE_PLUGIN_UNIT("Dimmable plug-in unit"),
40     WINDOW_COVERING_DEVICE("Window covering device"),
41     WINDOW_COVERING_CONTROLLER("Window covering controller"),
42     CONFIGURATION_TOOL("Configuration tool"),
43     WARNING_DEVICE("Warning device"),
44     DOORLOCK("Door Lock"),
45     UNKNOWN("");
46
47     private static final Map<String, LightType> MAPPING = Arrays.stream(LightType.values())
48             .collect(Collectors.toMap(v -> v.type, v -> v));
49     private static final Logger LOGGER = LoggerFactory.getLogger(LightType.class);
50
51     private final String type;
52
53     LightType(String type) {
54         this.type = type;
55     }
56
57     public static LightType fromString(String s) {
58         LightType lightType = MAPPING.getOrDefault(s, UNKNOWN);
59         if (lightType == UNKNOWN) {
60             LOGGER.debug("Unknown light type '{}' found. This should be reported.", s);
61         }
62         return lightType;
63     }
64 }