]> git.basschouten.com Git - openhab-addons.git/blob
c401e5ce263c9654fe703497a4c9959164ef4d3a
[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.mihome.internal;
14
15 import static org.openhab.binding.mihome.internal.XiaomiGatewayBindingConstants.*;
16
17 import java.util.HashMap;
18 import java.util.Map;
19
20 import org.openhab.core.thing.ThingTypeUID;
21
22 /**
23  * Maps the model (provided from Xiaomi) to thing.
24  *
25  * @author Patrick Boos - Initial contribution
26  * @author Kuba Wolanin - Renamed labels
27  * @author Dieter Schmidt - Refactor
28  * @author Daniel Walters - Add Xiaomi Aqara Temperature, Humidity & Pressure sensor and Xiaomi Aqara Door/Window
29  *         sensor
30  */
31 public class ModelMapper {
32
33     private static final Map<String, ThingTypeUID> THING_MAP = new HashMap<>();
34     private static final Map<String, String> LABEL_MAP = new HashMap<>();
35     static {
36         // Alphabetical order
37         THING_MAP.put("curtain", THING_TYPE_ACTOR_CURTAIN);
38         THING_MAP.put("gateway", THING_TYPE_GATEWAY);
39         THING_MAP.put("plug", THING_TYPE_ACTOR_PLUG);
40         THING_MAP.put("ctrl_86plug.aq1", THING_TYPE_ACTOR_PLUG);
41         THING_MAP.put("ctrl_neutral1", THING_TYPE_ACTOR_AQARA1);
42         THING_MAP.put("ctrl_neutral2", THING_TYPE_ACTOR_AQARA2);
43         THING_MAP.put("ctrl_ln1", THING_TYPE_ACTOR_AQARA_ZERO1);
44         THING_MAP.put("ctrl_ln1.aq1", THING_TYPE_ACTOR_AQARA_ZERO1);
45         THING_MAP.put("ctrl_ln2", THING_TYPE_ACTOR_AQARA_ZERO2);
46         THING_MAP.put("ctrl_ln2.aq1", THING_TYPE_ACTOR_AQARA_ZERO2);
47         THING_MAP.put("86sw1", THING_TYPE_SENSOR_AQARA1);
48         THING_MAP.put("86sw2", THING_TYPE_SENSOR_AQARA2);
49         THING_MAP.put("cube", THING_TYPE_SENSOR_CUBE);
50         THING_MAP.put("sensor_cube.aqgl01", THING_TYPE_SENSOR_CUBE);
51         THING_MAP.put("sensor_ht", THING_TYPE_SENSOR_HT);
52         THING_MAP.put("lock.aq1", THING_TYPE_SENSOR_AQARA_LOCK);
53         THING_MAP.put("magnet", THING_TYPE_SENSOR_MAGNET);
54         THING_MAP.put("motion", THING_TYPE_SENSOR_MOTION);
55         THING_MAP.put("natgas", THING_TYPE_SENSOR_GAS);
56         THING_MAP.put("sensor_magnet.aq2", THING_TYPE_SENSOR_AQARA_MAGNET);
57         THING_MAP.put("sensor_motion.aq2", THING_TYPE_SENSOR_AQARA_MOTION);
58         THING_MAP.put("sensor_wleak.aq1", THING_TYPE_SENSOR_WATER);
59         THING_MAP.put("sensor_switch.aq2", THING_TYPE_SENSOR_AQARA_SWITCH);
60         THING_MAP.put("sensor_switch.aq3", THING_TYPE_SENSOR_AQARA_SWITCH);
61         THING_MAP.put("remote.b1acn01", THING_TYPE_SENSOR_AQARA_SWITCH);
62         THING_MAP.put("remote.b186acn01", THING_TYPE_SENSOR_AQARA1);
63         THING_MAP.put("remote.b286acn01", THING_TYPE_SENSOR_AQARA2);
64         THING_MAP.put("smoke", THING_TYPE_SENSOR_SMOKE);
65         THING_MAP.put("switch", THING_TYPE_SENSOR_SWITCH);
66         THING_MAP.put("vibration", THING_TYPE_SENSOR_AQARA_VIBRATION);
67         THING_MAP.put("weather.v1", THING_TYPE_SENSOR_AQARA_WEATHER_V1);
68
69         LABEL_MAP.put("curtain", "Xiaomi Aqara Intelligent Curtain Motor");
70         LABEL_MAP.put("gateway", "Xiaomi Mi Smart Home Gateway");
71         LABEL_MAP.put("plug", "Xiaomi Mi Smart Socket Plug");
72         LABEL_MAP.put("ctrl_86plug.aq1", "Xiaomi Aqara Smart Socket Plug");
73         LABEL_MAP.put("ctrl_neutral1", "Xiaomi Aqara Wall Switch 1 Button");
74         LABEL_MAP.put("ctrl_neutral2", "Xiaomi Aqara Wall Switch 2 Button");
75         LABEL_MAP.put("ctrl_ln1", "Xiaomi \"zero-fire\" 1 Channel Wall Switch");
76         LABEL_MAP.put("ctrl_ln1.aq1", "Xiaomi Aqara \"zero-fire\" 1 Channel Wall Switch");
77         LABEL_MAP.put("ctrl_ln2", "Xiaomi \"zero-fire\" 2 Channel Wall Switch");
78         LABEL_MAP.put("ctrl_ln2.aq1", "Xiaomi \"zero-fire\" 2 Channel Wall Switch");
79         LABEL_MAP.put("86sw1", "Xiaomi Aqara Smart Switch 1 Button");
80         LABEL_MAP.put("86sw2", "Xiaomi Aqara Smart Switch 2 Button");
81         LABEL_MAP.put("cube", "Xiaomi Mi Smart Cube");
82         LABEL_MAP.put("sensor_cube.aqgl01", "Xiaomi Mi Smart Cube");
83         LABEL_MAP.put("sensor_ht", "Xiaomi Mi Temperature & Humidity Sensor");
84         LABEL_MAP.put("lock.aq1", "Xiaomi Aqara Fingerprint Door Lock");
85         LABEL_MAP.put("magnet", "Xiaomi Door/Window Sensor");
86         LABEL_MAP.put("motion", "Xiaomi Mi Motion Sensor");
87         LABEL_MAP.put("natgas", "Xiaomi Mijia Honeywell Gas Alarm Detector");
88         LABEL_MAP.put("sensor_magnet.aq2", "Xiaomi Aqara Door/Window Sensor");
89         LABEL_MAP.put("sensor_motion.aq2", "Xiaomi Aqara Motion Sensor");
90         LABEL_MAP.put("sensor_wleak.aq1", "Xiaomi Aqara Water Leak Sensor");
91         LABEL_MAP.put("sensor_switch.aq2", "Xiaomi Aqara Wireless Switch");
92         LABEL_MAP.put("sensor_switch.aq3", "Xiaomi Aqara Wireless Switch with Accelerometer");
93         LABEL_MAP.put("remote.b1acn01", "Xiaomi Aqara Wireless Switch");
94         LABEL_MAP.put("remote.b186acn01", "Xiaomi Aqara Smart Switch 1 Button");
95         LABEL_MAP.put("remote.b286acn01", "Xiaomi Aqara Smart Switch 2 Button");
96         LABEL_MAP.put("smoke", "Xiaomi Mijia Honeywell Fire Alarm Detector");
97         LABEL_MAP.put("switch", "Xiaomi Mi Wireless Switch");
98         LABEL_MAP.put("vibration", "Xiaomi Aqara Smart Motion Sensor");
99         LABEL_MAP.put("weather.v1", "Xiaomi Aqara Temperature, Humidity & Pressure Sensor");
100     }
101
102     public static ThingTypeUID getThingTypeForModel(String model) {
103         return THING_MAP.get(model);
104     }
105
106     public static String getLabelForModel(String model) {
107         return LABEL_MAP.get(model);
108     }
109 }