]> git.basschouten.com Git - openhab-addons.git/blob
f0b8aa49403f9e7af2ab0c0df5f6962a4a61e1e2
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.digitalstrom.internal.lib.listener;
14
15 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.GeneralDeviceInformation;
16 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.DeviceStateUpdate;
17 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.ChangeableDeviceConfigEnum;
18
19 /**
20  * The {@link DeviceStatusListener} is notified, if a {@link Device} status or configuration has changed, if a scene
21  * configuration is added to a {@link Device} or if a device has been added or removed. The {@link DeviceStatusListener}
22  * can be also registered by a {@link Circuit} to get informed by configuration or status changes.
23  * <p>
24  * By implementation with the id {@link #DEVICE_DISCOVERY} this listener can be used as a device discovery to get
25  * informed, if a new {@link Device} or {@link Circuit} is added or removed from the digitalSTROM-System.<br>
26  * For that the {@link DeviceStatusListener} has to be registered on the
27  * {@link DeviceStatusManager#registerDeviceListener(DeviceStatusListener)}. Then the {@link DeviceStatusListener} gets
28  * informed by the methods {@link #onDeviceAdded(Object)} and {@link #onDeviceRemoved(Object)}.
29  * </p>
30  *
31  * @author Michael Ochel - Initial contribution
32  * @author Matthias Siegele - Initial contribution
33  *
34  */
35 public interface DeviceStatusListener {
36
37     /**
38      * ID of the device discovery listener.
39      */
40     static final String DEVICE_DISCOVERY = "DeviceDiscovery";
41
42     /**
43      * This method is called whenever the state of the {@link Device} has changed and passes the new device state as an
44      * {@link DeviceStateUpdate} object.
45      *
46      * @param deviceStateUpdate new device status
47      */
48     void onDeviceStateChanged(DeviceStateUpdate deviceStateUpdate);
49
50     /**
51      * This method is called whenever a device is removed.
52      *
53      * @param device which is removed
54      */
55     void onDeviceRemoved(GeneralDeviceInformation device);
56
57     /**
58      * This method is called whenever a device is added.
59      *
60      * @param device which is added
61      */
62     void onDeviceAdded(GeneralDeviceInformation device);
63
64     /**
65      * This method is called whenever a configuration of a device has changed. What configuration has changed
66      * can be see by the given parameter whatConfig to handle the change.<br>
67      * Please have a look at {@link ChangeableDeviceConfigEnum} to see what configuration are changeable.
68      *
69      * @param whatConfig has changed
70      */
71     void onDeviceConfigChanged(ChangeableDeviceConfigEnum whatConfig);
72
73     /**
74      * This method is called whenever a scene configuration is added to a device.
75      *
76      * @param sceneID of a read scene configuration
77      */
78     void onSceneConfigAdded(short sceneID);
79
80     /**
81      * Returns the id of this {@link DeviceStatusListener}.
82      *
83      * @return the device listener id
84      */
85     String getDeviceStatusListenerID();
86 }