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.somneo.internal.model;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.library.types.DecimalType;
18 import org.openhab.core.library.types.OnOffType;
19 import org.openhab.core.library.types.PercentType;
20 import org.openhab.core.types.State;
21 import org.openhab.core.types.UnDefType;
23 import com.google.gson.annotations.SerializedName;
26 * This class represents the relax program state from the API.
28 * @author Michael Myrcik - Initial contribution
31 public class RelaxData {
33 @SerializedName("onoff")
34 private @Nullable Boolean state;
36 @SerializedName("progr")
37 private @Nullable Integer breathingRate;
39 @SerializedName("durat")
40 private @Nullable Integer durationInMin;
42 @SerializedName("rtype")
43 private @Nullable Integer guidanceType;
46 * Brightness range from 0 to 25.
48 @SerializedName("intny")
49 private @Nullable Integer lightIntensity;
52 * Volume range from 0 to 25.
54 @SerializedName("sndlv")
55 private @Nullable Integer soundVolume;
57 public State getSwitchState() {
58 final Boolean state = this.state;
60 return UnDefType.NULL;
62 return OnOffType.from(state);
65 public void setState(boolean state) {
69 public State getBreathingRate() {
70 final Integer breathingRate = this.breathingRate;
71 if (breathingRate == null) {
72 return UnDefType.NULL;
74 return new DecimalType(breathingRate);
77 public void setBreathingRate(int breathingRate) {
78 this.breathingRate = breathingRate;
81 public State getDurationInMin() {
82 final Integer durationInMin = this.durationInMin;
83 if (durationInMin == null) {
84 return UnDefType.NULL;
86 return new DecimalType(durationInMin);
89 public void setDurationInMin(int durationInMin) {
90 this.durationInMin = durationInMin;
93 public State getGuidanceType() {
94 final Integer guidanceType = this.guidanceType;
95 if (guidanceType == null) {
96 return UnDefType.NULL;
98 return new DecimalType(guidanceType);
101 public void setGuidanceType(int guidanceType) {
102 this.guidanceType = guidanceType;
105 public State getLightIntensity() {
106 final Integer lightIntensity = this.lightIntensity;
107 if (lightIntensity == null) {
108 return UnDefType.NULL;
110 return new PercentType(lightIntensity * 4);
113 public void setLightIntensity(int percent) {
114 this.lightIntensity = percent / 4;
117 public State getSoundVolume() {
118 final Integer soundVolume = this.soundVolume;
119 if (soundVolume == null) {
120 return UnDefType.NULL;
122 return new PercentType(soundVolume * 4);
125 public void setSoundVolume(int percent) {
126 this.soundVolume = percent / 4;