2 * Copyright (c) 2010-2021 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.bluetooth.govee.internal;
15 import static org.openhab.binding.bluetooth.govee.internal.GoveeBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.bluetooth.discovery.BluetoothDiscoveryDevice;
20 import org.openhab.core.thing.ThingTypeUID;
23 * @author Connor Petty - Initial contribution
27 public enum GoveeModel {
28 H5051(THING_TYPE_HYGROMETER, "Govee Wi-Fi Temperature Humidity Monitor", false),
29 H5052(THING_TYPE_HYGROMETER_MONITOR, "Govee Temperature Humidity Monitor", true),
30 H5071(THING_TYPE_HYGROMETER, "Govee Temperature Humidity Monitor", false),
31 H5072(THING_TYPE_HYGROMETER_MONITOR, "Govee Temperature Humidity Monitor", true),
32 H5074(THING_TYPE_HYGROMETER_MONITOR, "Govee Mini Temperature Humidity Monitor", true),
33 H5075(THING_TYPE_HYGROMETER_MONITOR, "Govee Temperature Humidity Monitor", true),
34 H5101(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
35 H5102(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
36 H5177(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
37 H5179(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
38 B5175(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
39 B5178(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true);
41 private final ThingTypeUID thingTypeUID;
42 private final String label;
43 private final boolean supportsWarningBroadcast;
45 private GoveeModel(ThingTypeUID thingTypeUID, String label, boolean supportsWarningBroadcast) {
46 this.thingTypeUID = thingTypeUID;
48 this.supportsWarningBroadcast = supportsWarningBroadcast;
51 public ThingTypeUID getThingTypeUID() {
55 public String getLabel() {
59 public boolean supportsWarningBroadcast() {
60 return supportsWarningBroadcast;
63 public static @Nullable GoveeModel getGoveeModel(BluetoothDiscoveryDevice device) {
64 String name = device.getName();
66 if (name.startsWith("Govee") && name.length() >= 11) {
67 String uname = name.toUpperCase();
68 for (GoveeModel model : GoveeModel.values()) {
69 if (uname.contains(model.name())) {