2 * Copyright (c) 2010-2024 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;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * @author Connor Petty - Initial contribution
29 public enum GoveeModel {
30 H5051(THING_TYPE_HYGROMETER, "Govee Wi-Fi Temperature Humidity Monitor", false),
31 H5052(THING_TYPE_HYGROMETER_MONITOR, "Govee Temperature Humidity Monitor", true),
32 H5071(THING_TYPE_HYGROMETER, "Govee Temperature Humidity Monitor", false),
33 H5072(THING_TYPE_HYGROMETER_MONITOR, "Govee Temperature Humidity Monitor", true),
34 H5074(THING_TYPE_HYGROMETER_MONITOR, "Govee Mini Temperature Humidity Monitor", true),
35 H5075(THING_TYPE_HYGROMETER_MONITOR, "Govee Temperature Humidity Monitor", true),
36 H5101(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
37 H5102(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
38 H5177(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
39 H5179(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
40 B5175(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true),
41 B5178(THING_TYPE_HYGROMETER_MONITOR, "Govee Smart Thermo-Hygrometer", true);
43 private final ThingTypeUID thingTypeUID;
44 private final String label;
45 private final boolean supportsWarningBroadcast;
47 private static final Logger logger = LoggerFactory.getLogger(GoveeModel.class);
49 private GoveeModel(ThingTypeUID thingTypeUID, String label, boolean supportsWarningBroadcast) {
50 this.thingTypeUID = thingTypeUID;
52 this.supportsWarningBroadcast = supportsWarningBroadcast;
55 public ThingTypeUID getThingTypeUID() {
59 public String getLabel() {
63 public boolean supportsWarningBroadcast() {
64 return supportsWarningBroadcast;
67 public static @Nullable GoveeModel getGoveeModel(BluetoothDiscoveryDevice device) {
68 String name = device.getName();
70 if ((name.startsWith("Govee") && name.length() >= 11) || name.startsWith("GVH")) {
71 String uname = name.toUpperCase();
72 for (GoveeModel model : GoveeModel.values()) {
73 if (uname.contains(model.name())) {
74 logger.debug("detected model {}", model);
80 logger.debug("Device {} is no Govee", name);