]> git.basschouten.com Git - openhab-addons.git/blob
3f93372a0670766e2953b26563cf6fd244137b39
[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.client;
14
15 import java.util.function.BiConsumer;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.webthing.internal.client.dto.WebThingDescription;
19
20 /**
21  * A WebThing represents the client-side proxy of a remote devices implementing the Web Thing API according to
22  * https://iot.mozilla.org/wot/
23  * The API design is oriented on https://www.w3.org/TR/wot-scripting-api/#the-consumedthing-interface
24  *
25  * @author Gregor Roth - Initial contribution
26  */
27 @NonNullByDefault
28 public interface ConsumedThing {
29
30     /**
31      * @return the description (meta data) of the WebThing
32      */
33     WebThingDescription getThingDescription();
34
35     /**
36      * Makes a request for Property value change notifications
37      *
38      * @param propertyName the property to be observed
39      * @param listener the listener to call on changes
40      */
41     void observeProperty(String propertyName, BiConsumer<String, Object> listener);
42
43     /**
44      * Writes a single Property.
45      *
46      * @param propertyName the propertyName
47      * @return the current propertyValue
48      * @throws PropertyAccessException if the property can not be read
49      */
50     Object readProperty(String propertyName) throws PropertyAccessException;
51
52     /**
53      * Writes a single Property.
54      *
55      * @param propertyName the propertyName
56      * @param newValue the new propertyValue
57      * @throws PropertyAccessException if the property can not be written
58      */
59     void writeProperty(String propertyName, Object newValue) throws PropertyAccessException;
60
61     /**
62      * @return true, if connection is alive
63      */
64     boolean isAlive();
65
66     /**
67      * closes the connection
68      */
69     void close();
70 }