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.sleepiq.internal.api.enums;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * The {@link FoundationPreset} represents preset bed positions for a bed side.
20 * @author Mark Hilbush - Initial contribution
23 public enum FoundationPreset {
32 private final int preset;
34 FoundationPreset(final int preset) {
42 public static FoundationPreset forValue(int value) {
43 for (FoundationPreset s : FoundationPreset.values()) {
44 if (s.preset == value) {
48 throw new IllegalArgumentException("Invalid preset: " + value);
51 public static FoundationPreset convertFromStatus(String currentPositionPreset) {
52 FoundationPreset preset;
53 switch (currentPositionPreset.toLowerCase()) {
55 preset = FoundationPreset.NOT_AT_PRESET;
58 preset = FoundationPreset.FAVORITE;
61 preset = FoundationPreset.READ;
64 preset = FoundationPreset.WATCH_TV;
67 preset = FoundationPreset.FLAT;
70 preset = FoundationPreset.ZERO_G;
73 preset = FoundationPreset.SNORE;
76 throw new IllegalArgumentException("Unknown preset value: " + currentPositionPreset);
82 public String toString() {
83 return String.valueOf(preset);