]> git.basschouten.com Git - openhab-addons.git/blob
109e3ffa154a08bd82b24ab3121fc6793bb753f8
[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.io.homekit.internal;
14
15 import java.util.HashMap;
16 import java.util.Map;
17 import java.util.Optional;
18
19 /**
20  * Enum of the possible device types. The defined tag string can be used
21  * as a tag on an item to enable it for Homekit.
22  *
23  * @author Andy Lintner - Initial contribution
24  */
25 public enum HomekitAccessoryType {
26     HUMIDITY_SENSOR("HumiditySensor"),
27     LIGHTBULB("Lighting"),
28     SWITCH("Switchable"),
29     TEMPERATURE_SENSOR("TemperatureSensor"),
30     THERMOSTAT("Thermostat"),
31     CONTACT_SENSOR("ContactSensor"),
32     VALVE("Valve"),
33     LEAK_SENSOR("LeakSensor"),
34     MOTION_SENSOR("MotionSensor"),
35     OCCUPANCY_SENSOR("OccupancySensor"),
36     WINDOW_COVERING("WindowCovering"),
37     DOOR("Door"),
38     WINDOW("Window"),
39     SMOKE_SENSOR("SmokeSensor"),
40     CARBON_MONOXIDE_SENSOR("CarbonMonoxideSensor"),
41     CARBON_DIOXIDE_SENSOR("CarbonDioxideSensor"),
42     FAN("Fan"),
43     LOCK("Lock"),
44     SECURITY_SYSTEM("SecuritySystem"),
45     OUTLET("Outlet"),
46     SPEAKER("Speaker"),
47     GARAGE_DOOR_OPENER("GarageDoorOpener"),
48     HEATER_COOLER("HeaterCooler"),
49     LIGHT_SENSOR("LightSensor"),
50     AIR_QUALITY_SENSOR("AirQualitySensor"),
51     DUMMY("Dummy"),
52     @Deprecated()
53     BLINDS("Blinds"),
54     @Deprecated()
55     OLD_DIMMABLE_LIGHTBULB("DimmableLighting"),
56     @Deprecated()
57     OLD_HUMIDITY_SENSOR("CurrentHumidity"),
58     @Deprecated()
59     OLD_COLORFUL_LIGHTBULB("ColorfulLighting");
60
61     private static final Map<String, HomekitAccessoryType> TAG_MAP = new HashMap<>();
62
63     static {
64         for (HomekitAccessoryType type : HomekitAccessoryType.values()) {
65             TAG_MAP.put(type.tag, type);
66         }
67     }
68
69     private final String tag;
70
71     private HomekitAccessoryType(String tag) {
72         this.tag = tag;
73     }
74
75     public String getTag() {
76         return tag;
77     }
78
79     /**
80      * get accessoryType from String
81      *
82      * @param tag the tag string
83      * @return accessoryType or Optional.empty if no accessory type for the tag was found
84      */
85     public static Optional<HomekitAccessoryType> valueOfTag(String tag) {
86         return Optional.ofNullable(TAG_MAP.get(tag));
87     }
88 }