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.innogysmarthome.internal.client.entity.device;
15 import java.util.HashMap;
17 import org.openhab.binding.innogysmarthome.internal.client.entity.Property;
20 * Defines the {@link DeviceState}, e.g. if the device is reachable.
22 * @author Oliver Kuhl - Initial contribution
24 public class DeviceState {
26 protected static final String DEVICE_INCLUSION_STATE_INCLUDED = "Included";
27 protected static final String DEVICE_INCLUSION_STATE_PENDING = "InclusionPending";
28 protected static final String DEVICE_UPDATE_STATE_UPTODATE = "UpToDate";
30 protected static final String PROTOCOL_ID_WMBUS = "wMBus";
31 protected static final String PROTOCOL_ID_VIRTUAL = "Virtual";
32 protected static final String PROTOCOL_ID_COSIP = "Cosip";
38 private HashMap<String, Property> stateMap;
43 public String getId() {
48 * @param id the id to set
50 public void setId(String id) {
57 public State getState() {
62 * @param state the state to set
64 public void setState(State state) {
69 * Returns true if the device is reachable, false otherwise.
71 * @return true or false for "reachable" {@link Device}s, else null.
73 public Boolean isReachable() {
74 return getState().getIsReachable().getValue();
78 * Returns if the {@link State} "isReachable" is available for the current {@link Device}.
82 public Boolean hasIsReachableState() {
83 return getState().getIsReachable() != null;
87 * Sets if the {@link Device} is reachable.
91 public void setReachable(boolean isReachable) {
92 getState().getIsReachable().setValue(isReachable);
96 * Returns the configuration state of the device.
98 * @return the configuration state
100 public String getDeviceConfigurationState() {
101 return getState().getDeviceConfigurationState().getValue();
105 * Returns the device inclusion state.
107 * @return the device inclusion state
109 public String getDeviceInclusionState() {
110 return getState().getDeviceInclusionState().getValue();
114 * Returns true, if the device is included.
116 * @return true, if the {@link Device} is "Included"
118 public boolean deviceIsIncluded() {
119 return DEVICE_INCLUSION_STATE_INCLUDED.equals(getState().getDeviceInclusionState().getValue());
123 * @return the stateMap
125 public HashMap<String, Property> getStateMap() {
130 * @param stateMap the stateMap to set
132 public void setStateMap(HashMap<String, Property> stateMap) {
133 this.stateMap = stateMap;
137 * Returns true, if the device inclusion state is "InclusionPending".
139 * @return true, if the inclusion state is "InclusionPending"
141 public Boolean deviceInclusionIsPending() {
142 return DEVICE_INCLUSION_STATE_PENDING.equals(getDeviceInclusionState());
146 * Return the update state of the {@link Device}.
148 * @return the update state
150 public String getDeviceUpdateState() {
151 return getState().getUpdateState().getValue();
155 * Returns true if the {@link Device} is up to date.
157 * @return true, if the deviceUpdateState is "UpToDate"
159 public Boolean deviceIsUpToDate() {
160 return DEVICE_UPDATE_STATE_UPTODATE.equals(getDeviceUpdateState());
164 * Returns the firmware version of the {@link Device}.
166 * @return the firmware version
168 public String getFirmwareVersion() {
169 return getState().getFirmwareVersion().getValue();