diff --git a/CODEOWNERS b/CODEOWNERS index cf2250b77..ab7d0b668 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -200,6 +200,7 @@ /bundles/org.openhab.binding.pushbullet/ @hakan42 /bundles/org.openhab.binding.radiothermostat/ @mlobstein /bundles/org.openhab.binding.regoheatpump/ @crnjan +/bundles/org.openhab.binding.remoteopenhab/ @lolodomo /bundles/org.openhab.binding.rfxcom/ @martinvw @paulianttila /bundles/org.openhab.binding.rme/ @kgoderis /bundles/org.openhab.binding.robonect/ @reyem diff --git a/bom/openhab-addons/pom.xml b/bom/openhab-addons/pom.xml index a6321b9c6..169663f18 100644 --- a/bom/openhab-addons/pom.xml +++ b/bom/openhab-addons/pom.xml @@ -991,6 +991,11 @@ org.openhab.binding.regoheatpump ${project.version} + + org.openhab.addons.bundles + org.openhab.binding.remoteopenhab + ${project.version} + org.openhab.addons.bundles org.openhab.binding.rfxcom diff --git a/bundles/org.openhab.binding.remoteopenhab/NOTICE b/bundles/org.openhab.binding.remoteopenhab/NOTICE new file mode 100644 index 000000000..38d625e34 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/NOTICE @@ -0,0 +1,13 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-addons diff --git a/bundles/org.openhab.binding.remoteopenhab/README.md b/bundles/org.openhab.binding.remoteopenhab/README.md new file mode 100644 index 000000000..0947b3f9c --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/README.md @@ -0,0 +1,66 @@ +# Remote openHAB Binding + +The Remote openHAB binding allows to communicate with remote openHAB servers. +The communication is bidirectional. +The binding on the local server listens to any item state updates on the remote server and updates accordingly the linked channel on the local server. +It also transfers any item command from the local server to the remote server. + +One first usage is the distribution of your home automation system on a set of openHAB servers. + +A second usage is for users having old openHAB v1 bindings running that were not migrated to openHAB v2 or openHAB v3. +They can keep an openHAB v2 server to run their old openHAB v1 bindings and setup a new openHAB v3 server for everything else. +The Remote openHAB binding installed on the openHAB v3 server will then allow to use the openHAB v1 bindings through communication with the openHAB v2 server. + +A third usage is for users that would like to keep unchanged an existing openHAB v2 server but would like to use the new UI from openHAB v3; they can simply setup a new openHAB v3 server with the Remote openHAB binding linked to their openHAB v2 server. + +## Supported Things + +There is one unique supported thing : the `server` bridge thing + +## Discovery + +All openHAB servers in the local network are automatically discovered (through mDNS) by the binding. +You will find in the inbox one discovery thing per remote server interface. +So if your remote server has one IPv4 address and one IPv6 address, you will discover two things in the inbox. +Just choose one of the two things. + +## Binding Configuration + +The binding has no configuration options, all configuration is done at Thing level. + +## Thing Configuration + +The thing has the following configuration parameters: + +| Parameter | Required | Description | +|-----------|-------------------------------------------------------------------------------------------------------------------| +| host | yes | The host name or IP address of the remote openHAB server. | +| port | yes | The HTTP port to be used to communicate with the remote openHAB server. Default is 8080. | +| restPath | yes | The subpath of the REST API on the remote openHAB server. Default is /rest | +| token | no | The token to use when the remote openHAB server is setup to require authorization to run its REST API. | + +## Channels + +The channels are built dynamically and automatically by the binding. +One channel is created for each item from the remote server. +Only basic groups (with no state) are ignored. +The channel id of the built channel corresponds to the name of the item on the remote server. + +## Limitations + +* The binding will not try to communicate with an openHAB v1 server. +* The binding only uses the HTTP protocol for the communications with the remote server (not HTTPS). + +## Example + +### demo.things: + +``` +Bridge remoteopenhab:server:oh2 "OH2 server" [ host="192.168.0.100" ] +``` + +### demo.items: + +``` +DateTime MyDate "Date [%1$tA %1$td %1$tR]" { channel="remoteopenhab:server:oh2:MyDate" } +``` diff --git a/bundles/org.openhab.binding.remoteopenhab/pom.xml b/bundles/org.openhab.binding.remoteopenhab/pom.xml new file mode 100644 index 000000000..d67a216a4 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/pom.xml @@ -0,0 +1,17 @@ + + + + 4.0.0 + + + org.openhab.addons.bundles + org.openhab.addons.reactor.bundles + 3.0.0-SNAPSHOT + + + org.openhab.binding.remoteopenhab + + openHAB Add-ons :: Bundles :: Remote openHAB Binding + + diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/feature/feature.xml b/bundles/org.openhab.binding.remoteopenhab/src/main/feature/feature.xml new file mode 100644 index 000000000..61bb75b03 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/feature/feature.xml @@ -0,0 +1,11 @@ + + + mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features + + + + openhab-runtime-base + mvn:org.openhab.addons.bundles/org.openhab.binding.remoteopenhab/${project.version} + + + diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabBindingConstants.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabBindingConstants.java new file mode 100644 index 000000000..20407c7a6 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabBindingConstants.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal; + +import java.util.Collections; +import java.util.Set; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.thing.ThingTypeUID; + +/** + * The {@link RemoteopenhabBindingConstants} class defines common constants, which are + * used across the whole binding. + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class RemoteopenhabBindingConstants { + + public static final String BINDING_ID = "remoteopenhab"; + + // List of all Thing Type UIDs + public static final ThingTypeUID BRIDGE_TYPE_SERVER = new ThingTypeUID(BINDING_ID, "server"); + + public static final Set SUPPORTED_THING_TYPES_UIDS = Collections.singleton(BRIDGE_TYPE_SERVER); +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabChannelTypeProvider.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabChannelTypeProvider.java new file mode 100644 index 000000000..9119da496 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabChannelTypeProvider.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal; + +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.thing.type.ChannelType; +import org.openhab.core.thing.type.ChannelTypeProvider; +import org.openhab.core.thing.type.ChannelTypeUID; +import org.osgi.service.component.annotations.Component; + +/** + * Channel type provider used for all the channel types built by the binding when building dynamically the channels. + * One different channel type is built for each different item type found on the remote openHAB server. + * + * @author Laurent Garnier - Initial contribution + */ +@Component(service = { ChannelTypeProvider.class, RemoteopenhabChannelTypeProvider.class }) +@NonNullByDefault +public class RemoteopenhabChannelTypeProvider implements ChannelTypeProvider { + private final List channelTypes = new CopyOnWriteArrayList<>(); + + @Override + public Collection getChannelTypes(@Nullable Locale locale) { + return channelTypes; + } + + @Override + public @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID, @Nullable Locale locale) { + for (ChannelType channelType : channelTypes) { + if (channelType.getUID().equals(channelTypeUID)) { + return channelType; + } + } + return null; + } + + public void addChannelType(ChannelType type) { + channelTypes.add(type); + } + + public void removeChannelType(ChannelType type) { + channelTypes.remove(type); + } +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabHandlerFactory.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabHandlerFactory.java new file mode 100644 index 000000000..cd57ccab1 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabHandlerFactory.java @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal; + +import static org.openhab.binding.remoteopenhab.internal.RemoteopenhabBindingConstants.*; + +import javax.ws.rs.client.ClientBuilder; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.remoteopenhab.internal.handler.RemoteopenhabBridgeHandler; +import org.openhab.core.thing.Bridge; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingTypeUID; +import org.openhab.core.thing.binding.BaseThingHandlerFactory; +import org.openhab.core.thing.binding.ThingHandler; +import org.openhab.core.thing.binding.ThingHandlerFactory; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.jaxrs.client.SseEventSourceFactory; + +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * The {@link RemoteopenhabHandlerFactory} is responsible for creating things and thing + * handlers. + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +@Component(service = ThingHandlerFactory.class, configurationPid = "binding.remoteopenhab") +public class RemoteopenhabHandlerFactory extends BaseThingHandlerFactory { + + private final ClientBuilder clientBuilder; + private final SseEventSourceFactory eventSourceFactory; + private final RemoteopenhabChannelTypeProvider channelTypeProvider; + private final RemoteopenhabStateDescriptionOptionProvider stateDescriptionProvider; + private final Gson jsonParser; + + @Activate + public RemoteopenhabHandlerFactory(final @Reference ClientBuilder clientBuilder, + final @Reference SseEventSourceFactory eventSourceFactory, + final @Reference RemoteopenhabChannelTypeProvider channelTypeProvider, + final @Reference RemoteopenhabStateDescriptionOptionProvider stateDescriptionProvider) { + this.clientBuilder = clientBuilder; + this.eventSourceFactory = eventSourceFactory; + this.channelTypeProvider = channelTypeProvider; + this.stateDescriptionProvider = stateDescriptionProvider; + jsonParser = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create(); + } + + /** + * The things this factory supports creating. + */ + @Override + public boolean supportsThingType(ThingTypeUID thingTypeUID) { + return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); + } + + /** + * Creates a handler for the specific thing. + */ + @Override + protected @Nullable ThingHandler createHandler(Thing thing) { + ThingTypeUID thingTypeUID = thing.getThingTypeUID(); + + return BRIDGE_TYPE_SERVER.equals(thingTypeUID) + ? new RemoteopenhabBridgeHandler((Bridge) thing, clientBuilder, eventSourceFactory, channelTypeProvider, + stateDescriptionProvider, jsonParser) + : null; + } +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabStateDescriptionOptionProvider.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabStateDescriptionOptionProvider.java new file mode 100644 index 000000000..57a0a3721 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/RemoteopenhabStateDescriptionOptionProvider.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal; + +import java.util.List; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.binding.BaseDynamicStateDescriptionProvider; +import org.openhab.core.thing.i18n.ChannelTypeI18nLocalizationService; +import org.openhab.core.thing.type.DynamicStateDescriptionProvider; +import org.openhab.core.types.StateOption; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +/** + * Dynamic provider of state options while leaving other state description fields as original. + * + * @author Laurent Garnier - Initial contribution + */ +@Component(service = { DynamicStateDescriptionProvider.class, RemoteopenhabStateDescriptionOptionProvider.class }) +@NonNullByDefault +public class RemoteopenhabStateDescriptionOptionProvider extends BaseDynamicStateDescriptionProvider { + + public @Nullable List getStateOptions(ChannelUID channelUID) { + return channelOptionsMap.get(channelUID); + } + + @Reference + protected void setChannelTypeI18nLocalizationService( + final ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService) { + this.channelTypeI18nLocalizationService = channelTypeI18nLocalizationService; + } + + protected void unsetChannelTypeI18nLocalizationService( + final ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService) { + this.channelTypeI18nLocalizationService = null; + } +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/config/RemoteopenhabInstanceConfiguration.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/config/RemoteopenhabInstanceConfiguration.java new file mode 100644 index 000000000..4b2093060 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/config/RemoteopenhabInstanceConfiguration.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.config; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * The {@link RemoteopenhabInstanceConfiguration} is responsible for holding + * configuration informations associated to a remote openHAB server + * thing type + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class RemoteopenhabInstanceConfiguration { + public static final String HOST = "host"; + public static final String PORT = "port"; + public static final String REST_PATH = "restPath"; + + public String host = ""; + public int port = 8080; + public String restPath = "/rest"; + public String token = ""; +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Event.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Event.java new file mode 100644 index 000000000..e37cbf411 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Event.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.data; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Event received through the SSE connection. + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class Event { + + public String type = ""; + public String topic = ""; + public String payload = ""; +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/EventPayload.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/EventPayload.java new file mode 100644 index 000000000..2fceb9d19 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/EventPayload.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.data; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Payload from ItemStateEvent / GroupItemStateChangedEvent events received through the SSE connection. + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class EventPayload { + + public String type = ""; + public String value = ""; +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Item.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Item.java new file mode 100644 index 000000000..6c0cab673 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Item.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.data; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + +/** + * Response to the API GET /rest/items + * Also payload from ItemAddedEvent / ItemRemovedEvent / ItemUpdatedEvent events received through the SSE connection. + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class Item { + + public String name = ""; + public String type = ""; + public String state = ""; + public String groupType = ""; + public @Nullable StateDescription stateDescription; +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Option.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Option.java new file mode 100644 index 000000000..670eccfb8 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/Option.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.data; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Part of {@link StateDescription} containing one state option + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class Option { + + public String value = ""; + public String label = ""; +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RestApi.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RestApi.java new file mode 100644 index 000000000..0ac3e1c80 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RestApi.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.data; + +import org.eclipse.jdt.annotation.Nullable; + +/** + * Response to the API GET /rest + * + * @author Laurent Garnier - Initial contribution + */ +public class RestApi { + + public String version; + public RestApiEndpoint[] links; + public @Nullable RuntimeInfo runtimeInfo; +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RestApiEndpoint.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RestApiEndpoint.java new file mode 100644 index 000000000..eda714e32 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RestApiEndpoint.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.data; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Subpart of the response to the API GET /rest + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class RestApiEndpoint { + + public String type = ""; + public String url = ""; +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RuntimeInfo.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RuntimeInfo.java new file mode 100644 index 000000000..e17675d0a --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/RuntimeInfo.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.data; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Subpart of the response to the API GET /rest containing the runtime information + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class RuntimeInfo { + + public String version = ""; + public String buildString = ""; +} diff --git a/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/StateDescription.java b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/StateDescription.java new file mode 100644 index 000000000..b2b7a4860 --- /dev/null +++ b/bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/data/StateDescription.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.remoteopenhab.internal.data; + +import java.util.List; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + +/** + * Part of {@link Item} containing the state description + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public class StateDescription { + + public String pattern = ""; + public boolean readOnly; + public @Nullable List