]> git.basschouten.com Git - openhab-addons.git/blob
8dd9ccd976502195932063b300d9a868cda60731
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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     BASIC_FAN("BasicFan"),
43     FAN("Fan"),
44     LOCK("Lock"),
45     SECURITY_SYSTEM("SecuritySystem"),
46     OUTLET("Outlet"),
47     SPEAKER("Speaker"),
48     SMART_SPEAKER("SmartSpeaker"),
49     GARAGE_DOOR_OPENER("GarageDoorOpener"),
50     HEATER_COOLER("HeaterCooler"),
51     LIGHT_SENSOR("LightSensor"),
52     AIR_QUALITY_SENSOR("AirQualitySensor"),
53     BATTERY("Battery"),
54     FILTER_MAINTENANCE("Filter"),
55     FAUCET("Faucet"),
56     MICROPHONE("Microphone"),
57     SLAT("Slat"),
58     TELEVISION("Television"),
59     INPUT_SOURCE("InputSource"),
60     TELEVISION_SPEAKER("TelevisionSpeaker"),
61     ACCESSORY_GROUP("AccessoryGroup"),
62     IRRIGATION_SYSTEM("IrrigationSystem"),
63     DUMMY("Dummy");
64
65     private static final Map<String, HomekitAccessoryType> TAG_MAP = new HashMap<>();
66
67     static {
68         for (HomekitAccessoryType type : HomekitAccessoryType.values()) {
69             TAG_MAP.put(type.tag, type);
70         }
71     }
72
73     private final String tag;
74
75     private HomekitAccessoryType(String tag) {
76         this.tag = tag;
77     }
78
79     public String getTag() {
80         return tag;
81     }
82
83     /**
84      * get accessoryType from String
85      *
86      * @param tag the tag string
87      * @return accessoryType or Optional.empty if no accessory type for the tag was found
88      */
89     public static Optional<HomekitAccessoryType> valueOfTag(String tag) {
90         return Optional.ofNullable(TAG_MAP.get(tag));
91     }
92 }