]> git.basschouten.com Git - openhab-addons.git/blob
3945c4472a288e9aa2c30a20d3f05c540e33cde2
[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.binding.shelly.internal.discovery;
14
15 import static org.openhab.binding.shelly.internal.ShellyBindingConstants.BINDING_ID;
16 import static org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.*;
17 import static org.openhab.binding.shelly.internal.util.ShellyUtils.*;
18
19 import java.util.LinkedHashMap;
20 import java.util.Map;
21
22 import org.eclipse.jdt.annotation.NonNullByDefault;
23 import org.openhab.core.thing.ThingTypeUID;
24 import org.openhab.core.thing.ThingUID;
25
26 /**
27  * The {@link ShellyThingCreator} maps the device id into the thing type id
28  *
29  * @author Markus Michels - Initial contribution
30  */
31 @NonNullByDefault
32 public class ShellyThingCreator {
33     // Device Types
34     public static final String SHELLYDT_1 = "SHSW-1";
35     public static final String SHELLYDT_1PM = "SHSW-PM";
36     public static final String SHELLYDT_1L = "SHSW-L";
37     public static final String SHELLYDT_SHPLG = "SHPLG-1";
38     public static final String SHELLYDT_SHPLG_S = "SHPLG-S";
39     public static final String SHELLYDT_SHPLG_U1 = "SHPLG-U1";
40     public static final String SHELLYDT_SHELLY2 = "SHSW-21";
41     public static final String SHELLYDT_SHELLY25 = "SHSW-25";
42     public static final String SHELLYDT_SHPRO = "SHSW-44";
43     public static final String SHELLYDT_4PRO = "SHPSW04P";
44     public static final String SHELLYDT_EM = "SHEM";
45     public static final String SHELLYDT_3EM = "SHEM-3";
46     public static final String SHELLYDT_HT = "SHHT-1";
47     public static final String SHELLYDT_DW = "SHDW-1";
48     public static final String SHELLYDT_DW2 = "SHDW-2";
49     public static final String SHELLYDT_SENSE = "SHSEN-1";
50     public static final String SHELLYDT_MOTION = "SHMOS-01";
51     public static final String SHELLYDT_MOTION2 = "SHMOS-02";
52     public static final String SHELLYDT_GAS = "SHGS-1";
53     public static final String SHELLYDT_DIMMER = "SHDM-1";
54     public static final String SHELLYDT_DIMMER2 = "SHDM-2";
55     public static final String SHELLYDT_IX3 = "SHIX3-1";
56     public static final String SHELLYDT_BULB = "SHBLB-1";
57     public static final String SHELLYDT_DUO = "SHBDUO-1";
58     public static final String SHELLYDT_DUORGBW = "SHCB-1";
59     public static final String SHELLYDT_VINTAGE = "SHVIN-1";
60     public static final String SHELLYDT_RGBW2 = "SHRGBW2";
61     public static final String SHELLYDT_BUTTON1 = "SHBTN-1";
62     public static final String SHELLYDT_BUTTON2 = "SHBTN-2";
63     public static final String SHELLYDT_UNI = "SHUNI-1";
64     public static final String SHELLYDT_TRV = "SHTRV-01";
65
66     // Shelly Plus Series
67     public static final String SHELLYDT_PLUS1 = "SNSW-001X16EU";
68     public static final String SHELLYDT_PLUS1PM = "SNSW-001P16EU";
69     public static final String SHELLYDT_PLUS1UL = "SNSW-001X15UL";
70     public static final String SHELLYDT_PLUS1PMUL = "SNSW-001P15UL";
71     public static final String SHELLYDT_PLUS2PM_RELAY = "SNSW-002P16EU-relay";
72     public static final String SHELLYDT_PLUS2PM_ROLLER = "SNSW-002P16EU-roller";
73     public static final String SHELLYDT_PLUS2PM_RELAY_2 = "SNSW-102P16EU-relay";
74     public static final String SHELLYDT_PLUS2PM_ROLLER_2 = "SNSW-102P16EU-roller";
75     public static final String SHELLYDT_PLUSPLUGS = "SNPL-00112EU";
76     public static final String SHELLYDT_PLUSPLUGIT = "SNPL-00110IT";
77     public static final String SHELLYDT_PLUSPLUGUK = "SNPL-00112UK";
78     public static final String SHELLYDT_PLUSPLUGUS = "SNPL-00116US";
79     public static final String SHELLYDT_PLUSI4 = "SNSN-0024X";
80     public static final String SHELLYDT_PLUSI4DC = "SNSN-0D24X";
81     public static final String SHELLYDT_PLUSHT = "SNSN-0013A";
82     public static final String SHELLYDT_PLUSSMOKE = "SNSN-0031Z";
83     public static final String SHELLYDT_PLUSUNI = "SNSN-0043X";
84     public static final String SHELLYDT_PLUSDIMMERUS = "SNDM-0013US";
85     public static final String SHELLYDT_PLUSDIMMER10V = "SNGW-0A11WW010";
86     public static final String SHELLYDT_PLUSWALLDISPLAY = "SAWD-0A1XX10EU1";
87
88     // Shelly Pro Series
89     public static final String SHELLYDT_PRO1 = "SPSW-001XE16EU";
90     public static final String SHELLYDT_PRO1_2 = "SPSW-101XE16EU";
91     public static final String SHELLYDT_PRO1_3 = "SPSW-201XE16EU";
92     public static final String SHELLYDT_PRO1PM = "SPSW-001PE16EU";
93     public static final String SHELLYDT_PRO1PM_2 = "SPSW-101PE16EU";
94     public static final String SHELLYDT_PRO1PM_3 = "SPSW-201PE16EU";
95     public static final String SHELLYDT_PRO2_RELAY = "SPSW-002XE16EU-relay";
96     public static final String SHELLYDT_PRO2_RELAY_2 = "SPSW-102XE16EU-relay";
97     public static final String SHELLYDT_PRO2_RELAY_3 = "SPSW-202XE16EU-relay";
98     public static final String SHELLYDT_PRO2PM_RELAY = "SPSW-002PE16EU-relay";
99     public static final String SHELLYDT_PRO2PM_ROLLER = "SPSW-002PE16EU-roller";
100     public static final String SHELLYDT_PRO2PM_RELAY_2 = "SPSW-102PE16EU-relay";
101     public static final String SHELLYDT_PRO2PM_ROLLER_2 = "SPSW-102PE16EU-roller";
102     public static final String SHELLYDT_PRO2PM_RELAY_3 = "SPSW-202PE16EU-relay";
103     public static final String SHELLYDT_PRO2PM_ROLLER_3 = "SPSW-202PE16EU-roller";
104     public static final String SHELLYDT_PRO3 = "SPSW-003XE16EU";
105     public static final String SHELLYDT_PRO3EM = "SPEM-003CEBEU";
106     public static final String SHELLYDT_PROEM50 = "SPEM-002CEBEU50";
107     public static final String SHELLYDT_PRO4PM = "SPSW-004PE16EU";
108     public static final String SHELLYDT_PRO4PM_2 = "SPSW-104PE16EU";
109
110     // Shelly Plus Mini Series
111     // Mini Generation 2
112     public static final String SHELLYDT_MINI1 = "SNSW-001X8EU";
113     public static final String SHELLYDT_MINIPM = "SNPM-001PCEU16";
114     public static final String SHELLYDT_MINI1PM = "SNSW-001P8EU";
115     // Mini Generation 3
116     public static final String SHELLYDT_MINI1G3_1 = "S3SW-001X8EU";
117     public static final String SHELLYDT_MINIG3_PM = "S3PM-001PCEU16";
118     public static final String SHELLYDT_MINIG3_1PM = "S3SW-001P8EU";
119
120     // Shelly BLU Series
121     public static final String SHELLYDT_BLUBUTTON = "SBBT";
122     public static final String SHELLYDT_BLUDW = "SBDW";
123     public static final String SHELLYDT_BLUMOTION = "SBMO";
124     public static final String SHELLYDT_BLUHT = "SBHT";
125     public static final String SHELLYDT_BLUGW = "SNGW-BT01";
126
127     // Thing names
128     public static final String THING_TYPE_SHELLY1_STR = "shelly1";
129     public static final String THING_TYPE_SHELLY1L_STR = "shelly1l";
130     public static final String THING_TYPE_SHELLY1PM_STR = "shelly1pm";
131     public static final String THING_TYPE_SHELLYEM_STR = "shellyem";
132     public static final String THING_TYPE_SHELLY3EM_STR = "shellyem3"; // bad: misspelled product name, it's 3EM
133     public static final String THING_TYPE_SHELLY2_PREFIX = "shellyswitch";
134     public static final String THING_TYPE_SHELLY2_RELAY_STR = "shelly2-relay";
135     public static final String THING_TYPE_SHELLY2_ROLLER_STR = "shelly2-roller";
136     public static final String THING_TYPE_SHELLY25_PREFIX = "shellyswitch25";
137     public static final String THING_TYPE_SHELLY25_RELAY_STR = "shelly25-relay";
138     public static final String THING_TYPE_SHELLY25_ROLLER_STR = "shelly25-roller";
139     public static final String THING_TYPE_SHELLY4PRO_STR = "shelly4pro";
140     public static final String THING_TYPE_SHELLYPLUG_STR = "shellyplug";
141     public static final String THING_TYPE_SHELLYPLUGS_STR = "shellyplugs";
142     public static final String THING_TYPE_SHELLYPLUGU1_STR = "shellyplugu1"; // Shely Plug US
143     public static final String THING_TYPE_SHELLYDIMMER_STR = "shellydimmer";
144     public static final String THING_TYPE_SHELLYDIMMER2_STR = "shellydimmer2";
145     public static final String THING_TYPE_SHELLYIX3_STR = "shellyix3";
146     public static final String THING_TYPE_SHELLYBULB_STR = "shellybulb";
147     public static final String THING_TYPE_SHELLYDUO_STR = "shellybulbduo";
148     public static final String THING_TYPE_SHELLYVINTAGE_STR = "shellyvintage";
149     public static final String THING_TYPE_SHELLYRGBW2_PREFIX = "shellyrgbw2";
150     public static final String THING_TYPE_SHELLYRGBW2_COLOR_STR = THING_TYPE_SHELLYRGBW2_PREFIX + "-color";
151     public static final String THING_TYPE_SHELLYRGBW2_WHITE_STR = THING_TYPE_SHELLYRGBW2_PREFIX + "-white";
152     public static final String THING_TYPE_SHELLYDUORGBW_STR = "shellycolorbulb";
153     public static final String THING_TYPE_SHELLYHT_STR = "shellyht";
154     public static final String THING_TYPE_SHELLYSMOKE_STR = "shellysmoke";
155     public static final String THING_TYPE_SHELLYGAS_STR = "shellygas";
156     public static final String THING_TYPE_SHELLYFLOOD_STR = "shellyflood";
157     public static final String THING_TYPE_SHELLYDOORWIN_STR = "shellydw";
158     public static final String THING_TYPE_SHELLYDOORWIN2_STR = "shellydw2";
159     public static final String THING_TYPE_SHELLYEYE_STR = "shellyseye";
160     public static final String THING_TYPE_SHELLYSENSE_STR = "shellysense";
161     public static final String THING_TYPE_SHELLYTRV_STR = "shellytrv";
162     public static final String THING_TYPE_SHELLYMOTION_STR = "shellymotion";
163     public static final String THING_TYPE_SHELLYMOTION2_STR = "shellymotion2";
164     public static final String THING_TYPE_SHELLYBUTTON1_STR = "shellybutton1";
165     public static final String THING_TYPE_SHELLYBUTTON2_STR = "shellybutton2";
166     public static final String THING_TYPE_SHELLYUNI_STR = "shellyuni";
167
168     // Shelly Plus Seriens
169     public static final String THING_TYPE_SHELLYPLUS1_STR = "shellyplus1";
170     public static final String THING_TYPE_SHELLYPLUS1PM_STR = "shellyplus1pm";
171     public static final String THING_TYPE_SHELLYPLUS2PM_RELAY_STR = "shellyplus2pm-relay";
172     public static final String THING_TYPE_SHELLYPLUS2PM_ROLLER_STR = "shellyplus2pm-roller";
173     public static final String THING_TYPE_SHELLYPLUSI4_STR = "shellyplusi4";
174     public static final String THING_TYPE_SHELLYPLUSI4DC_STR = "shellyplusi4dc";
175     public static final String THING_TYPE_SHELLYPLUSHT_STR = "shellyplusht";
176     public static final String THING_TYPE_SHELLYPLUSSMOKE_STR = "shellyplussmoke";
177     public static final String THING_TYPE_SHELLYPLUSUNI_STR = "shellyplusuni";
178     public static final String THING_TYPE_SHELLYPLUSPLUGS_STR = "shellyplusplug";
179     public static final String THING_TYPE_SHELLYPLUSPLUGUS_STR = "shellyplusplugus";
180     public static final String THING_TYPE_SHELLYPLUSDIMMERUS_STR = "shellypluswdus";
181     public static final String THING_TYPE_SHELLYPLUSDIMMER10V_STR = "shellyplus10v";
182
183     // Shelly Wall Display
184     public static final String THING_TYPE_SHELLYPLUSWALLDISPLAY_STR = "shellywalldisplay";
185
186     // Shelly Plus Mini Series
187     public static final String THING_TYPE_SHELLYMINI1_STR = "shelly1mini";
188     public static final String THING_TYPE_SHELLYMINIPM_STR = "shellypmmini";
189     public static final String THING_TYPE_SHELLYMINI1PM_STR = "shelly1pmmini";
190
191     // Shelly Pro Series
192     public static final String THING_TYPE_SHELLYPRO1_STR = "shellypro1";
193     public static final String THING_TYPE_SHELLYPRO1PM_STR = "shellypro1pm";
194     public static final String THING_TYPE_SHELLYPRO2_RELAY_STR = "shellypro2-relay";
195     public static final String THING_TYPE_SHELLYPRO2PM_RELAY_STR = "shellypro2pm-relay";
196     public static final String THING_TYPE_SHELLYPRO2PM_ROLLER_STR = "shellypro2pm-roller";
197     public static final String THING_TYPE_SHELLYPRO3_STR = "shellypro3";
198     public static final String THING_TYPE_SHELLYPRO3EM_STR = "shellypro3em";
199     public static final String THING_TYPE_SHELLYPROEM50_STR = "shellyproem50";
200     public static final String THING_TYPE_SHELLYPRO4PM_STR = "shellypro4pm";
201
202     // Shelly BLU Series
203     public static final String THING_TYPE_SHELLYBLU_PREFIX = "shellyblu";
204     public static final String THING_TYPE_SHELLYBLUBUTTON_STR = THING_TYPE_SHELLYBLU_PREFIX + "button";
205     public static final String THING_TYPE_SHELLYBLUDW_STR = THING_TYPE_SHELLYBLU_PREFIX + "dw";
206     public static final String THING_TYPE_SHELLYBLUMOTION_STR = THING_TYPE_SHELLYBLU_PREFIX + "motion";
207     public static final String THING_TYPE_SHELLYBLUHT_STR = THING_TYPE_SHELLYBLU_PREFIX + "ht";
208     public static final String THING_TYPE_SHELLYBLUGW_STR = THING_TYPE_SHELLYBLU_PREFIX + "gw";
209
210     // Password protected or unknown device
211     public static final String THING_TYPE_SHELLYPROTECTED_STR = "shellydevice";
212     public static final String THING_TYPE_SHELLYUNKNOWN_STR = "shellyunknown";
213
214     // List of all Thing Type UIDs
215     public static final ThingTypeUID THING_TYPE_SHELLY1 = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY1_STR);
216     public static final ThingTypeUID THING_TYPE_SHELLY1L = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY1L_STR);
217     public static final ThingTypeUID THING_TYPE_SHELLY1PM = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY1PM_STR);
218     public static final ThingTypeUID THING_TYPE_SHELLYEM = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYEM_STR);
219     public static final ThingTypeUID THING_TYPE_SHELLY3EM = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY3EM_STR);
220     public static final ThingTypeUID THING_TYPE_SHELLY2_RELAY = new ThingTypeUID(BINDING_ID,
221             THING_TYPE_SHELLY2_RELAY_STR);
222     public static final ThingTypeUID THING_TYPE_SHELLY2_ROLLER = new ThingTypeUID(BINDING_ID,
223             THING_TYPE_SHELLY2_ROLLER_STR);
224     public static final ThingTypeUID THING_TYPE_SHELLY25_RELAY = new ThingTypeUID(BINDING_ID,
225             THING_TYPE_SHELLY25_RELAY_STR);
226     public static final ThingTypeUID THING_TYPE_SHELLY25_ROLLER = new ThingTypeUID(BINDING_ID,
227             THING_TYPE_SHELLY25_ROLLER_STR);
228     public static final ThingTypeUID THING_TYPE_SHELLY4PRO = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY4PRO_STR);
229     public static final ThingTypeUID THING_TYPE_SHELLYPLUG = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUG_STR);
230     public static final ThingTypeUID THING_TYPE_SHELLYPLUGS = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUGS_STR);
231     public static final ThingTypeUID THING_TYPE_SHELLYPLUGU1 = new ThingTypeUID(BINDING_ID,
232             THING_TYPE_SHELLYPLUGU1_STR);
233     public static final ThingTypeUID THING_TYPE_SHELLYUNI = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYUNI_STR);
234     public static final ThingTypeUID THING_TYPE_SHELLYDIMMER = new ThingTypeUID(BINDING_ID,
235             THING_TYPE_SHELLYDIMMER_STR);
236     public static final ThingTypeUID THING_TYPE_SHELLYDIMMER2 = new ThingTypeUID(BINDING_ID,
237             THING_TYPE_SHELLYDIMMER2_STR);
238     public static final ThingTypeUID THING_TYPE_SHELLYIX3 = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYIX3_STR);
239     public static final ThingTypeUID THING_TYPE_SHELLYBULB = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBULB_STR);
240     public static final ThingTypeUID THING_TYPE_SHELLYDUO = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYDUO_STR);
241     public static final ThingTypeUID THING_TYPE_SHELLYVINTAGE = new ThingTypeUID(BINDING_ID,
242             THING_TYPE_SHELLYVINTAGE_STR);
243     public static final ThingTypeUID THING_TYPE_SHELLYDUORGBW = new ThingTypeUID(BINDING_ID,
244             THING_TYPE_SHELLYDUORGBW_STR);
245     public static final ThingTypeUID THING_TYPE_SHELLYHT = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYHT_STR);
246     public static final ThingTypeUID THING_TYPE_SHELLYSENSE = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYSENSE_STR);
247     public static final ThingTypeUID THING_TYPE_SHELLYSMOKE = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYSMOKE_STR);
248     public static final ThingTypeUID THING_TYPE_SHELLYGAS = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYGAS_STR);
249     public static final ThingTypeUID THING_TYPE_SHELLYFLOOD = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYFLOOD_STR);
250     public static final ThingTypeUID THING_TYPE_SHELLYDOORWIN = new ThingTypeUID(BINDING_ID,
251             THING_TYPE_SHELLYDOORWIN_STR);
252     public static final ThingTypeUID THING_TYPE_SHELLYDOORWIN2 = new ThingTypeUID(BINDING_ID,
253             THING_TYPE_SHELLYDOORWIN2_STR);
254     public static final ThingTypeUID THING_TYPE_SHELLYTRV = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYTRV_STR);
255     public static final ThingTypeUID THING_TYPE_SHELLYBUTTON1 = new ThingTypeUID(BINDING_ID,
256             THING_TYPE_SHELLYBUTTON1_STR);
257     public static final ThingTypeUID THING_TYPE_SHELLYBUTTON2 = new ThingTypeUID(BINDING_ID,
258             THING_TYPE_SHELLYBUTTON2_STR);
259     public static final ThingTypeUID THING_TYPE_SHELLYEYE = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYEYE_STR);
260     public static final ThingTypeUID THING_TYPE_SHELLMOTION = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYMOTION_STR);
261     public static final ThingTypeUID THING_TYPE_SHELLYRGBW2_COLOR = new ThingTypeUID(BINDING_ID,
262             THING_TYPE_SHELLYRGBW2_COLOR_STR);
263     public static final ThingTypeUID THING_TYPE_SHELLYRGBW2_WHITE = new ThingTypeUID(BINDING_ID,
264             THING_TYPE_SHELLYRGBW2_WHITE_STR);
265     public static final ThingTypeUID THING_TYPE_SHELLYPROTECTED = new ThingTypeUID(BINDING_ID,
266             THING_TYPE_SHELLYPROTECTED_STR);
267     public static final ThingTypeUID THING_TYPE_SHELLYUNKNOWN = new ThingTypeUID(BINDING_ID,
268             THING_TYPE_SHELLYUNKNOWN_STR);
269
270     // Shelly Plus
271     public static final ThingTypeUID THING_TYPE_SHELLYPLUS1 = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUS1_STR);
272     public static final ThingTypeUID THING_TYPE_SHELLYPLUS1PM = new ThingTypeUID(BINDING_ID,
273             THING_TYPE_SHELLYPLUS1PM_STR);
274     public static final ThingTypeUID THING_TYPE_SHELLYPLUS2PM_RELAY = new ThingTypeUID(BINDING_ID,
275             THING_TYPE_SHELLYPLUS2PM_RELAY_STR);
276     public static final ThingTypeUID THING_TYPE_SHELLYPLUS2PM_ROLLER = new ThingTypeUID(BINDING_ID,
277             THING_TYPE_SHELLYPLUS2PM_ROLLER_STR);
278     public static final ThingTypeUID THING_TYPE_SHELLYPLUSI4 = new ThingTypeUID(BINDING_ID,
279             THING_TYPE_SHELLYPLUSI4_STR);
280     public static final ThingTypeUID THING_TYPE_SHELLYPLUSI4DC = new ThingTypeUID(BINDING_ID,
281             THING_TYPE_SHELLYPLUSI4DC_STR);
282     public static final ThingTypeUID THING_TYPE_SHELLYPLUSHT = new ThingTypeUID(BINDING_ID,
283             THING_TYPE_SHELLYPLUSHT_STR);
284     public static final ThingTypeUID THING_TYPE_SHELLYPLUSSMOKE = new ThingTypeUID(BINDING_ID,
285             THING_TYPE_SHELLYPLUSSMOKE_STR);
286     public static final ThingTypeUID THING_TYPE_SHELLYPLUSPLUGS = new ThingTypeUID(BINDING_ID,
287             THING_TYPE_SHELLYPLUSPLUGS_STR);
288     public static final ThingTypeUID THING_TYPE_SHELLYPLUSPLUGUS = new ThingTypeUID(BINDING_ID,
289             THING_TYPE_SHELLYPLUSPLUGUS_STR);
290     public static final ThingTypeUID THING_TYPE_SHELLYPLUSDIMMERUS = new ThingTypeUID(BINDING_ID,
291             THING_TYPE_SHELLYPLUSDIMMERUS_STR);
292     public static final ThingTypeUID THING_TYPE_SHELLYPLUSDIMMER10V = new ThingTypeUID(BINDING_ID,
293             THING_TYPE_SHELLYPLUSDIMMER10V_STR);
294
295     // Shelly Wall Display
296     public static final ThingTypeUID THING_TYPE_SHELLYPLUSWALLDISPLAY = new ThingTypeUID(BINDING_ID,
297             THING_TYPE_SHELLYPLUSWALLDISPLAY_STR);
298
299     // Shelly Plus Mini Series
300     public static final ThingTypeUID THING_TYPE_SHELLYMINI1 = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYMINI1_STR);
301     public static final ThingTypeUID THING_TYPE_SHELLYMINIPM = new ThingTypeUID(BINDING_ID,
302             THING_TYPE_SHELLYMINIPM_STR);
303     public static final ThingTypeUID THING_TYPE_SHELLYMINI1PM = new ThingTypeUID(BINDING_ID,
304             THING_TYPE_SHELLYMINI1PM_STR);
305
306     // Shelly Pro
307     public static final ThingTypeUID THING_TYPE_SHELLYPRO1 = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPRO1_STR);
308     public static final ThingTypeUID THING_TYPE_SHELLYPRO1PM = new ThingTypeUID(BINDING_ID,
309             THING_TYPE_SHELLYPRO1PM_STR);
310     public static final ThingTypeUID THING_TYPE_SHELLYPRO2_RELAY = new ThingTypeUID(BINDING_ID,
311             THING_TYPE_SHELLYPRO2_RELAY_STR);
312     public static final ThingTypeUID THING_TYPE_SHELLYPRO2PM_RELAY = new ThingTypeUID(BINDING_ID,
313             THING_TYPE_SHELLYPRO2PM_RELAY_STR);
314     public static final ThingTypeUID THING_TYPE_SHELLYPRO2PM_ROLLER = new ThingTypeUID(BINDING_ID,
315             THING_TYPE_SHELLYPRO2PM_ROLLER_STR);
316     public static final ThingTypeUID THING_TYPE_SHELLYPRO3 = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPRO3_STR);
317     public static final ThingTypeUID THING_TYPE_SHELLYPRO3EM = new ThingTypeUID(BINDING_ID,
318             THING_TYPE_SHELLYPRO3EM_STR);
319     public static final ThingTypeUID THING_TYPE_SHELLYPROEM50 = new ThingTypeUID(BINDING_ID,
320             THING_TYPE_SHELLYPROEM50_STR);
321     public static final ThingTypeUID THING_TYPE_SHELLYPRO4PM = new ThingTypeUID(BINDING_ID,
322             THING_TYPE_SHELLYPRO4PM_STR);
323
324     // Shelly Blu series
325     public static final ThingTypeUID THING_TYPE_SHELLYBLUBUTTON = new ThingTypeUID(BINDING_ID,
326             THING_TYPE_SHELLYBLUBUTTON_STR);
327     public static final ThingTypeUID THING_TYPE_SHELLYBLUDW = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBLUDW_STR);
328     public static final ThingTypeUID THING_TYPE_SHELLYBLUMOTION = new ThingTypeUID(BINDING_ID,
329             THING_TYPE_SHELLYBLUMOTION_STR);
330     public static final ThingTypeUID THING_TYPE_SHELLYBLUHT = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBLUHT_STR);
331     public static final ThingTypeUID THING_TYPE_SHELLYBLUGW = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBLUGW_STR);
332
333     private static final Map<String, String> THING_TYPE_MAPPING = new LinkedHashMap<>();
334     static {
335         // mapping by device type id
336         THING_TYPE_MAPPING.put(SHELLYDT_1PM, THING_TYPE_SHELLY1PM_STR);
337         THING_TYPE_MAPPING.put(SHELLYDT_1L, THING_TYPE_SHELLY1L_STR);
338         THING_TYPE_MAPPING.put(SHELLYDT_1, THING_TYPE_SHELLY1_STR);
339         THING_TYPE_MAPPING.put(SHELLYDT_SHPRO, THING_TYPE_SHELLY4PRO_STR);
340         THING_TYPE_MAPPING.put(SHELLYDT_4PRO, THING_TYPE_SHELLY4PRO_STR);
341         THING_TYPE_MAPPING.put(SHELLYDT_3EM, THING_TYPE_SHELLY3EM_STR);
342         THING_TYPE_MAPPING.put(SHELLYDT_EM, THING_TYPE_SHELLYEM_STR);
343         THING_TYPE_MAPPING.put(SHELLYDT_SHPLG_S, THING_TYPE_SHELLYPLUGS_STR);
344         THING_TYPE_MAPPING.put(SHELLYDT_SHPLG_U1, THING_TYPE_SHELLYPLUGU1_STR);
345         THING_TYPE_MAPPING.put(SHELLYDT_GAS, THING_TYPE_SHELLYGAS_STR);
346         THING_TYPE_MAPPING.put(SHELLYDT_DW, THING_TYPE_SHELLYDOORWIN_STR);
347         THING_TYPE_MAPPING.put(SHELLYDT_DW2, THING_TYPE_SHELLYDOORWIN2_STR);
348         THING_TYPE_MAPPING.put(SHELLYDT_DUO, THING_TYPE_SHELLYDUO_STR);
349         THING_TYPE_MAPPING.put(SHELLYDT_DUORGBW, THING_TYPE_SHELLYDUORGBW_STR);
350         THING_TYPE_MAPPING.put(SHELLYDT_BULB, THING_TYPE_SHELLYBULB_STR);
351         THING_TYPE_MAPPING.put(SHELLYDT_VINTAGE, THING_TYPE_SHELLYVINTAGE_STR);
352         THING_TYPE_MAPPING.put(SHELLYDT_DIMMER, THING_TYPE_SHELLYDIMMER_STR);
353         THING_TYPE_MAPPING.put(SHELLYDT_DIMMER2, THING_TYPE_SHELLYDIMMER2_STR);
354         THING_TYPE_MAPPING.put(SHELLYDT_IX3, THING_TYPE_SHELLYIX3_STR);
355         THING_TYPE_MAPPING.put(SHELLYDT_BUTTON1, THING_TYPE_SHELLYBUTTON1_STR);
356         THING_TYPE_MAPPING.put(SHELLYDT_BUTTON2, THING_TYPE_SHELLYBUTTON2_STR);
357         THING_TYPE_MAPPING.put(SHELLYDT_UNI, THING_TYPE_SHELLYUNI_STR);
358         THING_TYPE_MAPPING.put(SHELLYDT_HT, THING_TYPE_SHELLYHT_STR);
359         THING_TYPE_MAPPING.put(SHELLYDT_TRV, THING_TYPE_SHELLYTRV_STR);
360         THING_TYPE_MAPPING.put(SHELLYDT_MOTION, THING_TYPE_SHELLYMOTION_STR);
361
362         // Plus Series
363         THING_TYPE_MAPPING.put(SHELLYDT_PLUS1, THING_TYPE_SHELLYPLUS1_STR);
364         THING_TYPE_MAPPING.put(SHELLYDT_PLUS1PM, THING_TYPE_SHELLYPLUS1PM_STR);
365         THING_TYPE_MAPPING.put(SHELLYDT_PLUS1UL, THING_TYPE_SHELLYPLUS1_STR);
366         THING_TYPE_MAPPING.put(SHELLYDT_PLUS1PMUL, THING_TYPE_SHELLYPLUS1PM_STR);
367         THING_TYPE_MAPPING.put(SHELLYDT_PLUS2PM_RELAY, THING_TYPE_SHELLYPLUS2PM_RELAY_STR);
368         THING_TYPE_MAPPING.put(SHELLYDT_PLUS2PM_ROLLER, THING_TYPE_SHELLYPLUS2PM_ROLLER_STR);
369         THING_TYPE_MAPPING.put(SHELLYDT_PLUS2PM_RELAY_2, THING_TYPE_SHELLYPLUS2PM_RELAY_STR);
370         THING_TYPE_MAPPING.put(SHELLYDT_PLUS2PM_ROLLER_2, THING_TYPE_SHELLYPLUS2PM_ROLLER_STR);
371         THING_TYPE_MAPPING.put(SHELLYDT_PLUSPLUGS, THING_TYPE_SHELLYPLUSPLUGS_STR);
372         THING_TYPE_MAPPING.put(SHELLYDT_PLUSPLUGIT, THING_TYPE_SHELLYPLUSPLUGS_STR);
373         THING_TYPE_MAPPING.put(SHELLYDT_PLUSPLUGUK, THING_TYPE_SHELLYPLUSPLUGS_STR);
374         THING_TYPE_MAPPING.put(SHELLYDT_PLUSPLUGUS, THING_TYPE_SHELLYPLUSPLUGUS_STR);
375         THING_TYPE_MAPPING.put(SHELLYDT_PLUSI4DC, THING_TYPE_SHELLYPLUSI4DC_STR);
376         THING_TYPE_MAPPING.put(SHELLYDT_PLUSI4, THING_TYPE_SHELLYPLUSI4_STR);
377         THING_TYPE_MAPPING.put(SHELLYDT_PLUSHT, THING_TYPE_SHELLYPLUSHT_STR);
378         THING_TYPE_MAPPING.put(SHELLYDT_PLUSSMOKE, THING_TYPE_SHELLYPLUSSMOKE_STR);
379         THING_TYPE_MAPPING.put(SHELLYDT_PLUSUNI, THING_TYPE_SHELLYUNI_STR);
380         THING_TYPE_MAPPING.put(SHELLYDT_PLUSDIMMERUS, THING_TYPE_SHELLYPLUSDIMMERUS_STR);
381         THING_TYPE_MAPPING.put(SHELLYDT_PLUSDIMMER10V, THING_TYPE_SHELLYPLUSDIMMER10V_STR);
382
383         // Plus Mini Series
384         THING_TYPE_MAPPING.put(SHELLYDT_MINI1, THING_TYPE_SHELLYMINI1_STR);
385         THING_TYPE_MAPPING.put(SHELLYDT_MINIPM, THING_TYPE_SHELLYMINIPM_STR);
386         THING_TYPE_MAPPING.put(SHELLYDT_MINI1PM, THING_TYPE_SHELLYMINI1PM_STR);
387         THING_TYPE_MAPPING.put(SHELLYDT_MINI1G3_1, THING_TYPE_SHELLYMINI1_STR);
388         THING_TYPE_MAPPING.put(SHELLYDT_MINIG3_PM, THING_TYPE_SHELLYMINIPM_STR);
389         THING_TYPE_MAPPING.put(SHELLYDT_MINIG3_1PM, THING_TYPE_SHELLYMINI1PM_STR);
390
391         // Pro Series
392         THING_TYPE_MAPPING.put(SHELLYDT_PRO1, THING_TYPE_SHELLYPRO1_STR);
393         THING_TYPE_MAPPING.put(SHELLYDT_PRO1_2, THING_TYPE_SHELLYPRO1_STR);
394         THING_TYPE_MAPPING.put(SHELLYDT_PRO1_3, THING_TYPE_SHELLYPRO1_STR);
395         THING_TYPE_MAPPING.put(SHELLYDT_PRO1PM, THING_TYPE_SHELLYPRO1PM_STR);
396         THING_TYPE_MAPPING.put(SHELLYDT_PRO1PM_2, THING_TYPE_SHELLYPRO1PM_STR);
397         THING_TYPE_MAPPING.put(SHELLYDT_PRO1PM_3, THING_TYPE_SHELLYPRO1PM_STR);
398         THING_TYPE_MAPPING.put(SHELLYDT_PRO2_RELAY, THING_TYPE_SHELLYPRO2_RELAY_STR);
399         THING_TYPE_MAPPING.put(SHELLYDT_PRO2_RELAY_2, THING_TYPE_SHELLYPRO2_RELAY_STR);
400         THING_TYPE_MAPPING.put(SHELLYDT_PRO2_RELAY_3, THING_TYPE_SHELLYPRO2_RELAY_STR);
401         THING_TYPE_MAPPING.put(SHELLYDT_PRO2PM_RELAY, THING_TYPE_SHELLYPRO2PM_RELAY_STR);
402         THING_TYPE_MAPPING.put(SHELLYDT_PRO2PM_RELAY_2, THING_TYPE_SHELLYPRO2PM_RELAY_STR);
403         THING_TYPE_MAPPING.put(SHELLYDT_PRO2PM_RELAY_3, THING_TYPE_SHELLYPRO2PM_RELAY_STR);
404         THING_TYPE_MAPPING.put(SHELLYDT_PRO2PM_ROLLER, THING_TYPE_SHELLYPRO2PM_ROLLER_STR);
405         THING_TYPE_MAPPING.put(SHELLYDT_PRO2PM_ROLLER_2, THING_TYPE_SHELLYPRO2PM_ROLLER_STR);
406         THING_TYPE_MAPPING.put(SHELLYDT_PRO2PM_ROLLER_3, THING_TYPE_SHELLYPRO2PM_ROLLER_STR);
407         THING_TYPE_MAPPING.put(SHELLYDT_PRO3, THING_TYPE_SHELLYPRO3_STR);
408         THING_TYPE_MAPPING.put(SHELLYDT_PROEM50, THING_TYPE_SHELLYPROEM50_STR);
409         THING_TYPE_MAPPING.put(SHELLYDT_PRO3EM, THING_TYPE_SHELLYPRO3EM_STR);
410         THING_TYPE_MAPPING.put(SHELLYDT_PRO4PM, THING_TYPE_SHELLYPRO4PM_STR);
411         THING_TYPE_MAPPING.put(SHELLYDT_PRO4PM_2, THING_TYPE_SHELLYPRO4PM_STR);
412
413         // BLU Series
414         THING_TYPE_MAPPING.put(SHELLYDT_BLUBUTTON, THING_TYPE_SHELLYBLUBUTTON_STR);
415         THING_TYPE_MAPPING.put(SHELLYDT_BLUDW, THING_TYPE_SHELLYBLUDW_STR);
416         THING_TYPE_MAPPING.put(SHELLYDT_BLUMOTION, THING_TYPE_SHELLYBLUMOTION_STR);
417         THING_TYPE_MAPPING.put(SHELLYDT_BLUHT, THING_TYPE_SHELLYBLUHT_STR);
418         THING_TYPE_MAPPING.put(SHELLYDT_BLUGW, THING_TYPE_SHELLYBLUGW_STR);
419
420         // Wall displays
421         THING_TYPE_MAPPING.put(SHELLYDT_PLUSWALLDISPLAY, THING_TYPE_SHELLYPLUSWALLDISPLAY_STR);
422
423         // mapping by thing type
424         THING_TYPE_MAPPING.put(THING_TYPE_SHELLY1_STR, THING_TYPE_SHELLY1_STR);
425         THING_TYPE_MAPPING.put(THING_TYPE_SHELLY1PM_STR, THING_TYPE_SHELLY1PM_STR);
426         THING_TYPE_MAPPING.put(THING_TYPE_SHELLY1L_STR, THING_TYPE_SHELLY1L_STR);
427         THING_TYPE_MAPPING.put(THING_TYPE_SHELLY3EM_STR, THING_TYPE_SHELLY3EM_STR);
428         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYEM_STR, THING_TYPE_SHELLYEM_STR);
429         THING_TYPE_MAPPING.put(THING_TYPE_SHELLY4PRO_STR, THING_TYPE_SHELLY4PRO_STR);
430         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYDIMMER2_STR, THING_TYPE_SHELLYDIMMER2_STR);
431         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYDIMMER_STR, THING_TYPE_SHELLYDIMMER_STR);
432         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYIX3_STR, THING_TYPE_SHELLYIX3_STR);
433         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYDUORGBW_STR, THING_TYPE_SHELLYDUORGBW_STR);
434         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYDUO_STR, THING_TYPE_SHELLYDUO_STR);
435         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYVINTAGE_STR, THING_TYPE_SHELLYVINTAGE_STR);
436         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYBULB_STR, THING_TYPE_SHELLYBULB_STR);
437         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYDUO_STR, THING_TYPE_SHELLYDUO_STR);
438         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYHT_STR, THING_TYPE_SHELLYHT_STR);
439         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYSMOKE_STR, THING_TYPE_SHELLYSMOKE_STR);
440         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYGAS_STR, THING_TYPE_SHELLYGAS_STR);
441         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYFLOOD_STR, THING_TYPE_SHELLYFLOOD_STR);
442         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYTRV_STR, THING_TYPE_SHELLYTRV_STR);
443         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYDOORWIN_STR, THING_TYPE_SHELLYDOORWIN_STR);
444         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYDOORWIN2_STR, THING_TYPE_SHELLYDOORWIN2_STR);
445         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYSENSE_STR, THING_TYPE_SHELLYSENSE_STR);
446         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYEYE_STR, THING_TYPE_SHELLYEYE_STR);
447         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYBUTTON1_STR, THING_TYPE_SHELLYBUTTON1_STR);
448         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYBUTTON2_STR, THING_TYPE_SHELLYBUTTON2_STR);
449         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYUNI_STR, THING_TYPE_SHELLYUNI_STR);
450         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYMOTION2_STR, THING_TYPE_SHELLYMOTION_STR);
451
452         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUS1PM_STR, THING_TYPE_SHELLYPLUS1PM_STR);
453         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUS1_STR, THING_TYPE_SHELLYPLUS1_STR);
454         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUS1PM_STR, THING_TYPE_SHELLYPLUS1PM_STR);
455         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUS2PM_RELAY_STR, THING_TYPE_SHELLYPLUS2PM_RELAY_STR);
456         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUS2PM_ROLLER_STR, THING_TYPE_SHELLYPLUS2PM_ROLLER_STR);
457         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUS2PM_RELAY_STR, THING_TYPE_SHELLYPLUS2PM_RELAY_STR);
458         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUS2PM_ROLLER_STR, THING_TYPE_SHELLYPLUS2PM_ROLLER_STR);
459         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSPLUGS_STR, THING_TYPE_SHELLYPLUSPLUGS_STR);
460         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSPLUGUS_STR, THING_TYPE_SHELLYPLUSPLUGUS_STR);
461         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSI4DC_STR, THING_TYPE_SHELLYPLUSI4DC_STR);
462         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSI4_STR, THING_TYPE_SHELLYPLUSI4_STR);
463         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSHT_STR, THING_TYPE_SHELLYPLUSHT_STR);
464         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSSMOKE_STR, THING_TYPE_SHELLYPLUSSMOKE_STR);
465         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSUNI_STR, THING_TYPE_SHELLYUNI_STR);
466         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSDIMMERUS_STR, THING_TYPE_SHELLYPLUSDIMMERUS_STR);
467         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSDIMMER10V_STR, THING_TYPE_SHELLYPLUSDIMMER10V_STR);
468
469         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPLUSWALLDISPLAY_STR, THING_TYPE_SHELLYPLUSWALLDISPLAY_STR);
470
471         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYMINI1_STR, THING_TYPE_SHELLYMINI1_STR);
472         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYMINIPM_STR, THING_TYPE_SHELLYMINIPM_STR);
473         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYMINI1PM_STR, THING_TYPE_SHELLYMINI1PM_STR);
474
475         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPRO1_STR, THING_TYPE_SHELLYPRO1_STR);
476         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPRO1PM_STR, THING_TYPE_SHELLYPRO1PM_STR);
477         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPRO2PM_RELAY_STR, THING_TYPE_SHELLYPRO2PM_RELAY_STR);
478         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPRO2PM_ROLLER_STR, THING_TYPE_SHELLYPRO2PM_ROLLER_STR);
479         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPRO2_RELAY_STR, THING_TYPE_SHELLYPRO2_RELAY_STR);
480         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPROEM50_STR, THING_TYPE_SHELLYPROEM50_STR);
481         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPRO3EM_STR, THING_TYPE_SHELLYPRO3EM_STR);
482         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPRO3_STR, THING_TYPE_SHELLYPRO3_STR);
483         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPRO4PM_STR, THING_TYPE_SHELLYPRO4PM_STR);
484
485         THING_TYPE_MAPPING.put(THING_TYPE_SHELLYPROTECTED_STR, THING_TYPE_SHELLYPROTECTED_STR);
486     }
487
488     public static ThingUID getThingUID(String serviceName, String deviceType, String mode, boolean unknown) {
489         String devid = substringAfterLast(serviceName, "-");
490         if (devid.isEmpty()) {
491             throw new IllegalArgumentException("serviceName has improper format: " + serviceName);
492         }
493         return new ThingUID(!unknown ? getThingTypeUID(serviceName, deviceType, mode)
494                 : getThingTypeUID(THING_TYPE_SHELLYPROTECTED_STR + "-" + devid, deviceType, mode), devid);
495     }
496
497     public static ThingTypeUID getThingTypeUID(String serviceName, String deviceType, String mode) {
498         return new ThingTypeUID(BINDING_ID, getThingType(serviceName, deviceType, mode));
499     }
500
501     public static ThingTypeUID getUnknownTTUID() {
502         return new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPROTECTED_STR);
503     }
504
505     public static String getThingType(String hostname, String deviceType, String mode) {
506         if (THING_TYPE_SHELLYPROTECTED_STR.equals(hostname)) {
507             return THING_TYPE_SHELLYPROTECTED_STR;
508         }
509         String name = hostname.toLowerCase();
510         String type = substringBefore(name, "-").toLowerCase();
511         String devid = substringAfterLast(name, "-");
512         if (devid.isEmpty() || type.isEmpty()) {
513             throw new IllegalArgumentException("Invalid device name format: " + hostname);
514         }
515
516         // First check for special handling
517         if (name.startsWith(THING_TYPE_SHELLY25_PREFIX)) { // Shelly v2.5
518             return mode.equals(SHELLY_MODE_RELAY) ? THING_TYPE_SHELLY25_RELAY_STR : THING_TYPE_SHELLY25_ROLLER_STR;
519         }
520         if (name.startsWith(THING_TYPE_SHELLY2_PREFIX)) { // Shelly v2
521             return mode.equals(SHELLY_MODE_RELAY) ? THING_TYPE_SHELLY2_RELAY_STR : THING_TYPE_SHELLY2_ROLLER_STR;
522         }
523         if (name.startsWith(THING_TYPE_SHELLYPLUG_STR)) {
524             // shellyplug-s needs to be mapped to shellyplugs to follow the schema
525             // for the thing types: <thing type>-<mode>
526             if (name.startsWith(THING_TYPE_SHELLYPLUGS_STR) || name.contains("-s")) {
527                 return THING_TYPE_SHELLYPLUGS_STR;
528             }
529             if (name.startsWith(THING_TYPE_SHELLYPLUGU1_STR)) {
530                 return THING_TYPE_SHELLYPLUGU1_STR;
531             }
532             return THING_TYPE_SHELLYPLUG_STR;
533         }
534         if (name.startsWith(THING_TYPE_SHELLYRGBW2_PREFIX)) {
535             return mode.equals(SHELLY_MODE_COLOR) ? THING_TYPE_SHELLYRGBW2_COLOR_STR : THING_TYPE_SHELLYRGBW2_WHITE_STR;
536         }
537         if (name.startsWith(THING_TYPE_SHELLYMOTION_STR)) {
538             // depending on firmware release the Motion advertises under shellymotion-xxx or shellymotionsensor-xxxx
539             return THING_TYPE_SHELLYMOTION_STR;
540         }
541
542         // Check general mapping
543         if (!deviceType.isEmpty()) {
544             String res = THING_TYPE_MAPPING.get(deviceType); // by device type
545             if (res != null) {
546                 return res;
547             }
548
549             String dt = mode.equals(SHELLY_MODE_RELAY) || mode.equals(SHELLY_MODE_ROLLER) ? deviceType + "-" + mode
550                     : deviceType;
551             res = THING_TYPE_MAPPING.get(dt); // <DT>-relay / <DT>-roller
552             if (res != null) {
553                 return res;
554             }
555         }
556
557         String res = THING_TYPE_MAPPING.get(type);
558         if (res != null) {
559             return res;
560         }
561         return THING_TYPE_SHELLYUNKNOWN_STR;
562     }
563 }