]> git.basschouten.com Git - openhab-addons.git/blob
29df81c3db1d8cdaa1914e652577fb4cc3f47d6c
[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.webthing.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.thing.ChannelUID;
17 import org.openhab.core.types.Command;
18 import org.openhab.core.types.State;
19
20 /**
21  * The {@link ChannelHandler} class is a simplified abstraction of an openHAB Channel implementing
22  * methods to observe a channel as well to update an Item associated to a channel
23  *
24  * @author Gregor Roth - Initial contribution
25  */
26 @NonNullByDefault
27 public interface ChannelHandler {
28
29     /**
30      * register a listener to observer the channel regarding item change events
31      *
32      * @param channelUID the channel identifier
33      * @param listener the listener to be notified
34      */
35     void observeChannel(ChannelUID channelUID, ItemChangedListener listener);
36
37     /**
38      * updates an Item state of a dedicated channel
39      *
40      * @param channelUID the channel identifier
41      * @param command the state update command
42      */
43     void updateItemState(ChannelUID channelUID, Command command);
44
45     /**
46      * Listener that will be notified, if an Item state is changed
47      */
48     interface ItemChangedListener {
49
50         /**
51          * item change callback method
52          * 
53          * @param channelUID the channel identifier
54          * @param stateCommand the item change command
55          */
56         void onItemStateChanged(ChannelUID channelUID, State stateCommand);
57     }
58 }