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.lutron.internal.protocol;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import com.google.gson.annotations.SerializedName;
20 * Defines Lutron fan controller speed settings
22 * @author Bob Adair - Initial contribution
25 public enum FanSpeedType {
26 @SerializedName("High")
28 @SerializedName("MediumHigh")
29 MEDIUMHIGH(75, "MediumHigh"),
30 @SerializedName("Medium")
32 @SerializedName("Low")
34 @SerializedName("Off")
37 /** Fan speed expressed as a percentage **/
38 private final int speed;
40 /** Fan speed expressed as a String (used by LEAP) **/
41 private final String leapValue;
43 FanSpeedType(int speed, String leapValue) {
45 this.leapValue = leapValue;
52 public String leapValue() {
57 public String toString() {
61 public static FanSpeedType toFanSpeedType(int percentage) {
62 if (percentage == OFF.speed) {
63 return FanSpeedType.OFF;
64 } else if (percentage > OFF.speed && percentage <= LOW.speed) {
65 return FanSpeedType.LOW;
66 } else if (percentage > LOW.speed && percentage <= MEDIUM.speed) {
67 return FanSpeedType.MEDIUM;
68 } else if (percentage > MEDIUM.speed && percentage <= MEDIUMHIGH.speed) {
69 return FanSpeedType.MEDIUMHIGH;
71 return FanSpeedType.HIGH;
75 public static FanSpeedType toFanSpeedType(String speedString) {
76 for (FanSpeedType enumValue : FanSpeedType.values()) {
77 if (enumValue.leapValue.equalsIgnoreCase(speedString)) {