2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.mihome.internal;
15 import static org.openhab.binding.mihome.internal.XiaomiGatewayBindingConstants.*;
17 import java.util.HashMap;
20 import org.openhab.core.thing.ThingTypeUID;
23 * Maps the model (provided from Xiaomi) to thing.
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 sensor
30 public class ModelMapper {
32 private static final Map<String, ThingTypeUID> THING_MAP = new HashMap<>();
33 private static final Map<String, String> LABEL_MAP = new HashMap<>();
36 THING_MAP.put("curtain", THING_TYPE_ACTOR_CURTAIN);
37 THING_MAP.put("gateway", THING_TYPE_GATEWAY);
38 THING_MAP.put("plug", THING_TYPE_ACTOR_PLUG);
39 THING_MAP.put("ctrl_86plug.aq1", THING_TYPE_ACTOR_PLUG);
40 THING_MAP.put("ctrl_neutral1", THING_TYPE_ACTOR_AQARA1);
41 THING_MAP.put("ctrl_neutral2", THING_TYPE_ACTOR_AQARA2);
42 THING_MAP.put("ctrl_ln1", THING_TYPE_ACTOR_AQARA_ZERO1);
43 THING_MAP.put("ctrl_ln1.aq1", THING_TYPE_ACTOR_AQARA_ZERO1);
44 THING_MAP.put("ctrl_ln2", THING_TYPE_ACTOR_AQARA_ZERO2);
45 THING_MAP.put("ctrl_ln2.aq1", THING_TYPE_ACTOR_AQARA_ZERO2);
46 THING_MAP.put("86sw1", THING_TYPE_SENSOR_AQARA1);
47 THING_MAP.put("86sw2", THING_TYPE_SENSOR_AQARA2);
48 THING_MAP.put("cube", THING_TYPE_SENSOR_CUBE);
49 THING_MAP.put("sensor_cube.aqgl01", THING_TYPE_SENSOR_CUBE);
50 THING_MAP.put("sensor_ht", THING_TYPE_SENSOR_HT);
51 THING_MAP.put("lock.aq1", THING_TYPE_SENSOR_AQARA_LOCK);
52 THING_MAP.put("magnet", THING_TYPE_SENSOR_MAGNET);
53 THING_MAP.put("motion", THING_TYPE_SENSOR_MOTION);
54 THING_MAP.put("natgas", THING_TYPE_SENSOR_GAS);
55 THING_MAP.put("sensor_magnet.aq2", THING_TYPE_SENSOR_AQARA_MAGNET);
56 THING_MAP.put("sensor_motion.aq2", THING_TYPE_SENSOR_AQARA_MOTION);
57 THING_MAP.put("sensor_wleak.aq1", THING_TYPE_SENSOR_WATER);
58 THING_MAP.put("sensor_switch.aq2", THING_TYPE_SENSOR_AQARA_SWITCH);
59 THING_MAP.put("sensor_switch.aq3", THING_TYPE_SENSOR_AQARA_SWITCH);
60 THING_MAP.put("remote.b1acn01", THING_TYPE_SENSOR_AQARA_SWITCH);
61 THING_MAP.put("remote.b186acn01", THING_TYPE_SENSOR_AQARA1);
62 THING_MAP.put("remote.b286acn01", THING_TYPE_SENSOR_AQARA2);
63 THING_MAP.put("smoke", THING_TYPE_SENSOR_SMOKE);
64 THING_MAP.put("switch", THING_TYPE_SENSOR_SWITCH);
65 THING_MAP.put("vibration", THING_TYPE_SENSOR_AQARA_VIBRATION);
66 THING_MAP.put("weather.v1", THING_TYPE_SENSOR_AQARA_WEATHER_V1);
68 LABEL_MAP.put("curtain", "Xiaomi Aqara Intelligent Curtain Motor");
69 LABEL_MAP.put("gateway", "Xiaomi Mi Smart Home Gateway");
70 LABEL_MAP.put("plug", "Xiaomi Mi Smart Socket Plug");
71 LABEL_MAP.put("ctrl_86plug.aq1", "Xiaomi Aqara Smart Socket Plug");
72 LABEL_MAP.put("ctrl_neutral1", "Xiaomi Aqara Wall Switch 1 Button");
73 LABEL_MAP.put("ctrl_neutral2", "Xiaomi Aqara Wall Switch 2 Button");
74 LABEL_MAP.put("ctrl_ln1", "Xiaomi \"zero-fire\" 1 Channel Wall Switch");
75 LABEL_MAP.put("ctrl_ln1.aq1", "Xiaomi Aqara \"zero-fire\" 1 Channel Wall Switch");
76 LABEL_MAP.put("ctrl_ln2", "Xiaomi \"zero-fire\" 2 Channel Wall Switch");
77 LABEL_MAP.put("ctrl_ln2.aq1", "Xiaomi \"zero-fire\" 2 Channel Wall Switch");
78 LABEL_MAP.put("86sw1", "Xiaomi Aqara Smart Switch 1 Button");
79 LABEL_MAP.put("86sw2", "Xiaomi Aqara Smart Switch 2 Button");
80 LABEL_MAP.put("cube", "Xiaomi Mi Smart Cube");
81 LABEL_MAP.put("sensor_cube.aqgl01", "Xiaomi Mi Smart Cube");
82 LABEL_MAP.put("sensor_ht", "Xiaomi Mi Temperature & Humidity Sensor");
83 LABEL_MAP.put("lock.aq1", "Xiaomi Aqara Fingerprint Door Lock");
84 LABEL_MAP.put("magnet", "Xiaomi Door/Window Sensor");
85 LABEL_MAP.put("motion", "Xiaomi Mi Motion Sensor");
86 LABEL_MAP.put("natgas", "Xiaomi Mijia Honeywell Gas Alarm Detector");
87 LABEL_MAP.put("sensor_magnet.aq2", "Xiaomi Aqara Door/Window Sensor");
88 LABEL_MAP.put("sensor_motion.aq2", "Xiaomi Aqara Motion Sensor");
89 LABEL_MAP.put("sensor_wleak.aq1", "Xiaomi Aqara Water Leak Sensor");
90 LABEL_MAP.put("sensor_switch.aq2", "Xiaomi Aqara Wireless Switch");
91 LABEL_MAP.put("sensor_switch.aq3", "Xiaomi Aqara Wireless Switch with Accelerometer");
92 LABEL_MAP.put("remote.b1acn01", "Xiaomi Aqara Wireless Switch");
93 LABEL_MAP.put("remote.b186acn01", "Xiaomi Aqara Smart Switch 1 Button");
94 LABEL_MAP.put("remote.b286acn01", "Xiaomi Aqara Smart Switch 2 Button");
95 LABEL_MAP.put("smoke", "Xiaomi Mijia Honeywell Fire Alarm Detector");
96 LABEL_MAP.put("switch", "Xiaomi Mi Wireless Switch");
97 LABEL_MAP.put("vibration", "Xiaomi Aqara Smart Motion Sensor");
98 LABEL_MAP.put("weather.v1", "Xiaomi Aqara Temperature, Humidity & Pressure Sensor");
101 public static ThingTypeUID getThingTypeForModel(String model) {
102 return THING_MAP.get(model);
105 public static String getLabelForModel(String model) {
106 return LABEL_MAP.get(model);