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.digitalstrom.internal.lib.manager;
15 import java.util.List;
17 import org.openhab.binding.digitalstrom.internal.lib.event.EventHandler;
18 import org.openhab.binding.digitalstrom.internal.lib.listener.ManagerStatusListener;
19 import org.openhab.binding.digitalstrom.internal.lib.listener.SceneStatusListener;
20 import org.openhab.binding.digitalstrom.internal.lib.listener.stateenums.ManagerStates;
21 import org.openhab.binding.digitalstrom.internal.lib.listener.stateenums.ManagerTypes;
22 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device;
23 import org.openhab.binding.digitalstrom.internal.lib.structure.scene.InternalScene;
26 * The {@link SceneManager} manages all functions concerning scenes without sending the commands itself.
29 * So it manages a list of all {@link InternalScene} they called in the past or was generated by calling
30 * {@link #generateScenes()}.<br>
31 * Through this class you can also register {@link SceneStatusListener}'s to the {@link InternalScene}'s or register a
32 * scene discovery. With {@link #addEcho(String)} or {@link #addEcho(String, short)} scene calls form the library can be
33 * ignored. To update the state of an {@link InternalScene} or {@link Device} the methods
34 * {@link #callInternalScene(InternalScene)}, {@link #callInternalScene(String)},
35 * {@link #callDeviceScene(Device, Short)}
36 * , {@link #callDeviceScene(String, Short)} etc. can be used.
39 * If you call the {@link #start()} method an {@link org.openhab.binding.digitalstrom.internal.lib.event.EventListener}
40 * will be started to handle scene calls and undos from the outside.
42 * @author Michael Ochel - Initial contribution
43 * @author Matthias Siegele - Initial contribution
46 public interface SceneManager extends EventHandler {
49 * Activates the given {@link InternalScene}, if it exists. Otherwise it will be added to the scene list and
50 * activated, if it is a callable scene.
52 * @param scene to call
54 void callInternalScene(InternalScene scene);
57 * Activates an {@link InternalScene} with the given id, if it exists. Otherwise a new
58 * {@link InternalScene} will be created and activated, if it is a callable scene.
60 * @param sceneID of the scene to call
62 void callInternalScene(String sceneID);
65 * Call the given sceneID on the {@link Device} with the given dSID, if the {@link Device} exists.
67 * @param dSID of the {@link Device} to call
68 * @param sceneID of the scene to call
70 void callDeviceScene(String dSID, Short sceneID);
73 * Call the given sceneID on the given {@link Device}, if the {@link Device} exists.
75 * @param device to call
76 * @param sceneID to call
78 void callDeviceScene(Device device, Short sceneID);
81 * Deactivates the given {@link InternalScene}, if it exists. Otherwise it will added to the scene list and
82 * deactivated, if it is a callable scene.
84 * @param scene to undo
86 void undoInternalScene(InternalScene scene);
89 * Deactivates an {@link InternalScene} with the given sceneID, if it exists. Otherwise a new
90 * {@link InternalScene} will be created and deactivated, if it is a callable scene.
92 * @param sceneID of the scene to undo
94 void undoInternalScene(String sceneID);
97 * Undo the last scene on the {@link Device} with the given dSID, if the {@link Device} exists.
99 * @param dSID of the {@link Device} to undo
101 void undoDeviceScene(String dSID);
104 * Undo the last scene on the {@link Device}, if the {@link Device} exists.
106 * @param device the {@link Device} to undo
108 void undoDeviceScene(Device device);
111 * Registers the given {@link SceneStatusListener} to the {@link InternalScene}, if it exists or registers it as a
112 * Scene-Discovery if the id of the {@link SceneStatusListener} is {@link SceneStatusListener#SCENE_DISCOVERY}.
114 * @param sceneListener to register
116 void registerSceneListener(SceneStatusListener sceneListener);
119 * Unregisters the given {@link SceneStatusListener} from the {@link InternalScene}, if it exists or unregisters the
120 * Scene-Discovery, if the id of the {@link SceneStatusListener} is {@link SceneStatusListener#SCENE_DISCOVERY}.
122 * @param sceneListener to register
124 void unregisterSceneListener(SceneStatusListener sceneListener);
127 * Adds the given {@link InternalScene} to the scene list, if it is a callable scene.
129 * @param intScene to add
131 void addInternalScene(InternalScene intScene);
134 * Adds the scene call with the given dSID and sceneId as an echo to ignore them by detecting the
135 * {@link org.openhab.binding.digitalstrom.internal.lib.event.types.EventItem}.
137 * @param dSID of the {@link Device} that will be ignored
138 * @param sceneId of the scene that will be ignored
140 void addEcho(String dSID, short sceneId);
143 * Adds the scene call with the given internal scene id as an echo to ignore them by detecting the
144 * {@link org.openhab.binding.digitalstrom.internal.lib.event.types.EventItem}
147 * @param internalSceneID to ignore
149 void addEcho(String internalSceneID);
152 * Returns the list of all {@link InternalScene}.
154 * @return list of all scenes
156 List<InternalScene> getScenes();
159 * Returns true, if all reachable scenes are already generated, otherwise false.
161 * @return true = reachable scenes generated, otherwise false
163 boolean scenesGenerated();
166 * Generates all reachable scenes.
169 void generateScenes();
172 * Will be called from the {@link org.openhab.binding.digitalstrom.internal.lib.structure.scene.SceneDiscovery},
173 * if a scene type is generated or is fail.<br>
174 * For that the scenesGenerated char array has four chars. Each char represents one scene type in the following
177 * <li><b>first:</b> named scenes</li>
178 * <li><b>second:</b> apartment scenes</li>
179 * <li><b>third:</b> zone scenes</li>
180 * <li><b>fourth</b>: group scenes, if they can call by push buttons</li>
182 * If a scene type is not generated the char is "0". If a scene type is generated the char is "1" and, if it is fail
185 * @param scenesGenerated array
187 void scenesGenerated(char[] scenesGenerated);
190 * Returns true, if a discovery is registered, otherwise false.
192 * @return true discovery is registered, otherwise false
194 boolean isDiscoveryRegistrated();
197 * Starts the {@link org.openhab.binding.digitalstrom.internal.lib.event.EventListener}.
202 * Stops the {@link org.openhab.binding.digitalstrom.internal.lib.event.EventListener}.
207 * Removes the {@link InternalScene} with the given sceneID.
209 * @param sceneID of the {@link InternalScene} to remove
211 void removeInternalScene(String sceneID);
214 * Returns the {@link InternalScene} with the given sceneID.
216 * @param sceneID of the {@link InternalScene}
217 * @return internal scenes
219 InternalScene getInternalScene(String sceneID);
222 * Registers the given {@link ManagerStatusListener} to this class.
224 * @param statusListener to register
226 void registerStatusListener(ManagerStatusListener statusListener);
229 * Unregisters the {@link ManagerStatusListener} from this class.
231 void unregisterStatusListener();
234 * Returns the {@link ManagerTypes} of this class.
236 * @return these {@link ManagerTypes}
238 ManagerTypes getManagerType();
241 * Returns the current {@link ManagerStates}.
243 * @return current {@link ManagerStates}
245 ManagerStates getManagerState();
248 * Calls a scene without inform the scene discovery about the conceivably new {@link InternalScene}.
250 * @param zoneID to call
251 * @param groupID to call
252 * @param sceneID to call
254 void callInternalSceneWithoutDiscovery(Integer zoneID, Short groupID, Short sceneID);