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.livisismarthome.internal.client.api.entity.device;
15 import java.util.HashMap;
17 import org.openhab.binding.livisismarthome.internal.client.api.entity.PropertyDTO;
20 * Defines the {@link DeviceStateDTO}, e.g. if the device is reachable.
22 * @author Oliver Kuhl - Initial contribution
24 public class DeviceStateDTO {
26 private static final String DEVICE_UPDATE_STATE_UPTODATE = "UpToDate";
29 private StateDTO state;
30 private HashMap<String, PropertyDTO> stateMap;
32 public DeviceStateDTO() {
33 state = new StateDTO();
34 stateMap = new HashMap<>();
40 public String getId() {
45 * @param id the id to set
47 public void setId(String id) {
54 public StateDTO getState() {
59 * @param state the state to set
61 public void setState(StateDTO state) {
66 * Returns true if the device is reachable, false otherwise.
68 * @return true or false for "reachable" {@link DeviceDTO}s, else null.
70 public Boolean isReachable() {
71 return getState().getIsReachable().getValue();
75 * Returns if the {@link StateDTO} "isReachable" is available for the current {@link DeviceDTO}.
77 * @return true if the reachable state is available, otherwise false
79 public Boolean hasIsReachableState() {
80 return getState().getIsReachable() != null;
84 * Sets if the {@link DeviceDTO} is reachable.
86 * @param isReachable reachable (boolean)
88 public void setReachable(boolean isReachable) {
89 getState().getIsReachable().setValue(isReachable);
93 * Returns the configuration state of the device.
95 * @return the configuration state
97 public String getDeviceConfigurationState() {
98 return getState().getDeviceConfigurationState().getValue();
102 * Returns the device inclusion state.
104 * @return the device inclusion state
106 public String getDeviceInclusionState() {
107 return getState().getDeviceInclusionState().getValue();
111 * @return the stateMap
113 public HashMap<String, PropertyDTO> getStateMap() {
118 * @param stateMap the stateMap to set
120 public void setStateMap(HashMap<String, PropertyDTO> stateMap) {
121 this.stateMap = stateMap;
125 * Return the update state of the {@link DeviceDTO}.
127 * @return the update state
129 public String getDeviceUpdateState() {
130 return getState().getUpdateState().getValue();
134 * Returns true if the {@link DeviceDTO} is up to date.
136 * @return true, if the deviceUpdateState is "UpToDate"
138 public Boolean deviceIsUpToDate() {
139 return DEVICE_UPDATE_STATE_UPTODATE.equals(getDeviceUpdateState());
143 * Returns the firmware version of the {@link DeviceDTO}.
145 * @return the firmware version
147 public String getFirmwareVersion() {
148 return getState().getFirmwareVersion().getValue();