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.velux.internal.things;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.velux.internal.VeluxBindingConstants;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * <B>Velux</B> scene representation.
23 * Combined set of information with references towards multiple Velux product states.
25 * Methods in handle this type of information:
27 * <LI>{@link #VeluxScene(String, int, boolean, VeluxProductState[])} to create a new scene.</LI>
28 * <LI>{@link #VeluxScene(VeluxScene)} to duplicate a scene.</LI>
29 * <LI>{@link #getName} to retrieve the name of this scene.</LI>
30 * <LI>{@link #getBridgeSceneIndex()} to retrieve the index of this scene.</LI>
31 * <LI>{@link #toString()} to retrieve a human-readable description of this scene.</LI>
34 * @see VeluxProductState
36 * @author Guenther Schreiner - initial contribution.
39 public class VeluxScene {
40 private final Logger logger = LoggerFactory.getLogger(VeluxScene.class);
44 public static final VeluxScene UNKNOWN = new VeluxScene();
48 public static class SceneName {
50 private static final SceneName UNKNOWN = new SceneName(VeluxBindingConstants.UNKNOWN);
55 public String toString() {
59 public SceneName(String name) {
63 public boolean equals(SceneName anotherName) {
64 return this.name.equals(anotherName.toString());
68 public static class SceneBridgeIndex {
70 private static final SceneBridgeIndex UNKNOWN = new SceneBridgeIndex(0);
75 public String toString() {
76 return String.valueOf(id);
83 private SceneBridgeIndex(int id) {
90 private SceneName name;
91 private SceneBridgeIndex bridgeSceneIndex;
92 private boolean silent;
93 private VeluxProductState[] productStates;
100 * just for the dummy VeluxProduct.
102 private VeluxScene() {
103 logger.trace("VeluxScene() created.");
104 this.name = SceneName.UNKNOWN;
105 this.bridgeSceneIndex = SceneBridgeIndex.UNKNOWN;
107 this.productStates = new VeluxProductState[0];
110 public VeluxScene(String name, int sceneBridgeIndex, boolean silentOperation, VeluxProductState[] actions) {
111 this.name = new SceneName(name);
112 this.bridgeSceneIndex = new SceneBridgeIndex(sceneBridgeIndex);
113 this.silent = silentOperation;
114 this.productStates = actions;
117 public VeluxScene(VeluxScene scene) {
118 this.name = new SceneName(scene.name.toString());
119 this.bridgeSceneIndex = new SceneBridgeIndex(scene.bridgeSceneIndex.toInt());
120 this.silent = scene.silent;
121 this.productStates = scene.productStates;
123 // Class access methods
125 public SceneName getName() {
129 public SceneBridgeIndex getBridgeSceneIndex() {
130 return this.bridgeSceneIndex;
134 public String toString() {
135 return String.format("Scene \"%s\" (index %d) with %ssilent mode and %d actions", this.name,
136 this.bridgeSceneIndex.toInt(), this.silent ? "" : "non-", this.productStates.length);