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 EventListener} will be started to handle scene calls and undos from
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 {@link EventItem}.
136 * @param dSID of the {@link Device} that will be ignored
137 * @param sceneId of the scene that will be ignored
139 void addEcho(String dSID, short sceneId);
142 * Adds the scene call with the given internal scene id as an echo to ignore them by detecting the {@link EventItem}
145 * @param internalSceneID to ignore
147 void addEcho(String internalSceneID);
150 * Returns the list of all {@link InternalScene}.
152 * @return list of all scenes
154 List<InternalScene> getScenes();
157 * Returns true, if all reachable scenes are already generated, otherwise false.
159 * @return true = reachable scenes generated, otherwise false
161 boolean scenesGenerated();
164 * Generates all reachable scenes.
167 void generateScenes();
170 * Will be called from the {@link SceneDiscovery}, if a scene type is generated or is fail.<br>
171 * For that the scenesGenerated char array has four chars. Each char represents one scene type in the following
174 * <li><b>first:</b> named scenes</li>
175 * <li><b>second:</b> apartment scenes</li>
176 * <li><b>third:</b> zone scenes</li>
177 * <li><b>fourth</b>: group scenes, if they can call by push buttons</li>
179 * 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
182 * @param scenesGenerated array
184 void scenesGenerated(char[] scenesGenerated);
187 * Returns true, if a discovery is registered, otherwise false.
189 * @return true discovery is registered, otherwise false
191 boolean isDiscoveryRegistrated();
194 * Starts the {@link EventListener}.
199 * Stops the {@link EventListener}.
204 * Removes the {@link InternalScene} with the given sceneID.
206 * @param sceneID of the {@link InternalScene} to remove
208 void removeInternalScene(String sceneID);
211 * Returns the {@link InternalScene} with the given sceneID.
213 * @param sceneID of the {@link InternalScene}
214 * @return internal scenes
216 InternalScene getInternalScene(String sceneID);
219 * Registers the given {@link ManagerStatusListener} to this class.
221 * @param statusListener to register
223 void registerStatusListener(ManagerStatusListener statusListener);
226 * Unregisters the {@link ManagerStatusListener} from this class.
228 void unregisterStatusListener();
231 * Returns the {@link ManagerTypes} of this class.
233 * @return these {@link ManagerTypes}
235 ManagerTypes getManagerType();
238 * Returns the current {@link ManagerStates}.
240 * @return current {@link ManagerStates}
242 ManagerStates getManagerState();
245 * Calls a scene without inform the scene discovery about the conceivably new {@link InternalScene}.
247 * @param zoneID to call
248 * @param groupID to call
249 * @param sceneID to call
251 void callInternalSceneWithoutDiscovery(Integer zoneID, Short groupID, Short sceneID);