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.loxone.internal.types;
15 import org.openhab.binding.loxone.internal.controls.LxControl;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 * A state of a Loxone control ({@link LxControl})
22 * Each control object may have a number of states defined, that describe the overall condition of the control.
23 * List of states is read from LoxApp3.json configuration file.
25 * Each state is identified by its own UUID and a name of the state. Names are proprietary to a particular type of the
26 * control and as such are defined in {@link LxControl} child classes implementation.
27 * Objects of this class are used to bind state updates received from the Miniserver to a control object.
29 * @author Pawel Pieczul - initial contribution
32 public class LxState {
33 private final LxUuid uuid;
34 private final String name;
35 private final LxControl control;
36 private final Logger logger = LoggerFactory.getLogger(LxState.class);
37 private Object stateValue;
40 * Create a control state object.
42 * @param uuid UUID of the state
43 * @param name name of the state
44 * @param control control to which this state belongs
46 public LxState(LxUuid uuid, String name, LxControl control) {
49 this.control = control;
53 * Gets UUID of the state
55 * @return state's UUID
57 public LxUuid getUuid() {
62 * Sets current value of the control's state
64 * @param value current state's value to set
66 public void setStateValue(Object value) {
67 logger.debug("State set ({},{}) control ({},{}) value={}", uuid, name, control.getUuid(), control.getName(),
69 if (value != null && !value.equals(this.stateValue)) {
70 this.stateValue = value;
71 control.onStateChange(this);
76 * Gets current value of the control's state
78 * @return current state's value
80 public Object getStateValue() {
87 * State's name is proprietary per control type.
89 * @return state's name
91 public String getName() {