From 9d4acd32df0ccaa150724a78d80a8c88638be6c5 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sun, 1 Jan 2023 22:49:06 +0100 Subject: [PATCH 01/11] Add actions for device joining and scenes Backported from SmartHome/J Also-by: Jan N. Klug Signed-off-by: Jacob Laursen --- bundles/org.openhab.binding.deconz/README.md | 26 +++ .../deconz/internal/action/BridgeActions.java | 86 ++++++++++ .../deconz/internal/action/GroupActions.java | 154 ++++++++++++++++++ .../deconz/internal/dto/NewSceneResponse.java | 29 ++++ .../handler/DeconzBaseThingHandler.java | 29 +++- .../internal/handler/DeconzBridgeHandler.java | 20 ++- .../internal/handler/GroupThingHandler.java | 8 + .../internal/netutils/AsyncHttpClient.java | 2 +- 8 files changed, 348 insertions(+), 6 deletions(-) create mode 100644 bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java create mode 100644 bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java create mode 100644 bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index 13723a4571b85..25bea04d10372 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -211,6 +211,24 @@ Both will be added during runtime if supported by the switch. | GESTURE_ROTATE_CLOCKWISE | 7 | | GESTURE_ROTATE_COUNTER_CLOCKWISE | 8 | +## Thing Actions + +Thing actions can be used to manage the network and its content. + +The `deconz` thing supports a thing action to allow new devices to join the network: + +| Action name | Input Value | Return Value | Description | +|------------------------|----------------------|--------------|----------------------------------------------------------------------------------------------------------------| +| `permitJoin(duration)` | `duration` (Integer) | - | allows new devices to join for `duration` seconds. Allowed values are 1-240, default is 120 if no value given. | + +The `lightgroup` thing supports thing actions for managing scenes: + +| Action name | Input Value | Return Value | Description | +|---------------------|-----------------|--------------|-------------------------------------------------------------------------------------------| +| `createScene(name)` | `name` (String) | `newSceneId` | Creates a new scene with the name `name` and returns the new scene's id (if successfull). | +| `deleteScene(id)` | `id` (Integer) | - | Deletes the scene with the given id. | +| `storeScene(id)` | `id` (Integer) | - | Store the current group's state as scene with the given id. | + ## Full Example ### Things file @@ -260,6 +278,14 @@ then end ``` +### Thing Actions + +```js +deconzActions = actions.get("deconz", "deconz:lightgroup:00212E040ED9:5"); +retVal = deconzActions.createScene("TestScene"); +deconzActions.storeScene(retVal["newSceneId"]); +``` + ### Troubleshooting By default state updates are ignored for 250ms after a command. diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java new file mode 100644 index 0000000000000..32ca2d3367200 --- /dev/null +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2010-2022 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.deconz.internal.action; + +import java.util.Map; +import java.util.Objects; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.http.HttpMethod; +import org.openhab.binding.deconz.internal.Util; +import org.openhab.binding.deconz.internal.handler.DeconzBridgeHandler; +import org.openhab.core.automation.annotation.ActionInput; +import org.openhab.core.automation.annotation.RuleAction; +import org.openhab.core.thing.binding.ThingActions; +import org.openhab.core.thing.binding.ThingActionsScope; +import org.openhab.core.thing.binding.ThingHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The {@link BridgeActions} provides actions for managing scenes in groups + * + * @author Jan N. Klug - Initial contribution + */ +@ThingActionsScope(name = "deconz") +@NonNullByDefault +public class BridgeActions implements ThingActions { + private final Logger logger = LoggerFactory.getLogger(BridgeActions.class); + + private @Nullable DeconzBridgeHandler handler; + + @RuleAction(label = "permit join ZigBee network", description = "Permits ew devices to join the zigbee network for a given duration (default 120s).") + public void permitJoin(@ActionInput(name = "duration") @Nullable Integer duration) { + DeconzBridgeHandler handler = this.handler; + + if (handler == null) { + logger.warn("Deconz BridgeActions service ThingHandler is null!"); + return; + } + + int searchDuration = Util.constrainToRange(Objects.requireNonNullElse(duration, 120), 1, 240); + + Object object = Map.of("permitjoin", searchDuration); + handler.sendObject("config", object, HttpMethod.PUT).thenAccept(v -> { + if (v.getResponseCode() != java.net.HttpURLConnection.HTTP_OK) { + logger.warn("Sending {} via PUT to config failed: {} - {}", object, v.getResponseCode(), v.getBody()); + } else { + logger.trace("Result code={}, body={}", v.getResponseCode(), v.getBody()); + logger.info("Enabled device searching for {} seconds on bridge {}.", searchDuration, + handler.getThing().getUID()); + } + }).exceptionally(e -> { + logger.warn("Sending {} via PUT to config failed: {} - {}", object, e.getClass(), e.getMessage()); + return null; + }); + } + + public static void permitJoin(ThingActions actions, @Nullable Integer duration) { + if (actions instanceof BridgeActions) { + ((BridgeActions) actions).permitJoin(duration); + } + } + + @Override + public void setThingHandler(@Nullable ThingHandler handler) { + if (handler instanceof DeconzBridgeHandler) { + this.handler = (DeconzBridgeHandler) handler; + } + } + + @Override + public @Nullable ThingHandler getThingHandler() { + return handler; + } +} diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java new file mode 100644 index 0000000000000..c8f3e70179231 --- /dev/null +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java @@ -0,0 +1,154 @@ +/** + * Copyright (c) 2010-2022 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.deconz.internal.action; + +import java.lang.reflect.Type; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.http.HttpMethod; +import org.openhab.binding.deconz.internal.dto.NewSceneResponse; +import org.openhab.binding.deconz.internal.handler.GroupThingHandler; +import org.openhab.core.automation.annotation.ActionInput; +import org.openhab.core.automation.annotation.ActionOutput; +import org.openhab.core.automation.annotation.RuleAction; +import org.openhab.core.thing.binding.ThingActions; +import org.openhab.core.thing.binding.ThingActionsScope; +import org.openhab.core.thing.binding.ThingHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; +import com.google.gson.JsonParseException; +import com.google.gson.reflect.TypeToken; + +/** + * The {@link GroupActions} provides actions for managing scenes in groups + * + * @author Jan N. Klug - Initial contribution + */ +@ThingActionsScope(name = "deconz") +@NonNullByDefault +public class GroupActions implements ThingActions { + private static final String NEW_SCENE_ID_OUTPUT = "newSceneId"; + private static final Type NEW_SCENE_RESPONSE_TYPE = new TypeToken>() { + }.getType(); + + private final Logger logger = LoggerFactory.getLogger(GroupActions.class); + private final Gson gson = new Gson(); + + private @Nullable GroupThingHandler handler; + + @RuleAction(label = "create a scene", description = "Creates a new scene and returns the new scene's id") + public @ActionOutput(name = NEW_SCENE_ID_OUTPUT, type = "java.lang.Integer") Map createScene( + @ActionInput(name = "name") @Nullable String name) { + GroupThingHandler handler = this.handler; + + if (handler == null) { + logger.warn("Deconz GroupActions service ThingHandler is null!"); + return Map.of(); + } + + if (name == null) { + logger.debug("Skipping scene creation due to missing scene name"); + return Map.of(); + } + + CompletableFuture newSceneId = new CompletableFuture<>(); + handler.doNetwork(Map.of("name", name), "scenes", HttpMethod.POST, newSceneId::complete); + + try { + String returnedJson = newSceneId.get(2000, TimeUnit.MILLISECONDS); + List newSceneResponses = gson.fromJson(returnedJson, NEW_SCENE_RESPONSE_TYPE); + if (newSceneResponses != null && !newSceneResponses.isEmpty()) { + return Map.of(NEW_SCENE_ID_OUTPUT, newSceneResponses.get(0).success.id); + } + throw new IllegalStateException("response is empty"); + } catch (InterruptedException | ExecutionException | TimeoutException | JsonParseException + | IllegalStateException e) { + logger.warn("Couldn't get newSceneId", e); + return Map.of(); + } + } + + public static Map createScene(ThingActions actions, @Nullable String name) { + if (actions instanceof GroupActions) { + return ((GroupActions) actions).createScene(name); + } + return Map.of(); + } + + @RuleAction(label = "delete a scene", description = "Deletes a scene") + public void deleteScene(@ActionInput(name = "sceneId") @Nullable Integer sceneId) { + GroupThingHandler handler = this.handler; + + if (handler == null) { + logger.warn("Deconz GroupActions service ThingHandler is null!"); + return; + } + + if (sceneId == null) { + logger.debug("Skipping scene deletion due to missing scene id"); + return; + } + + handler.doNetwork(null, "scenes/" + sceneId, HttpMethod.DELETE, null); + } + + public static void deleteScene(ThingActions actions, @Nullable Integer sceneId) { + if (actions instanceof GroupActions) { + ((GroupActions) actions).deleteScene(sceneId); + } + } + + @RuleAction(label = "store as scene", description = "Stores the current light state as scene") + public void storeScene(@ActionInput(name = "sceneId") @Nullable Integer sceneId) { + GroupThingHandler handler = this.handler; + + if (handler == null) { + logger.warn("Deconz GroupActions service ThingHandler is null!"); + return; + } + + if (sceneId == null) { + logger.debug("Skipping scene storage due to missing scene id"); + return; + } + + handler.doNetwork(null, "scenes/" + sceneId + "/store", HttpMethod.PUT, null); + } + + public static void storeScene(ThingActions actions, @Nullable Integer sceneId) { + if (actions instanceof GroupActions) { + ((GroupActions) actions).storeScene(sceneId); + } + } + + @Override + public void setThingHandler(@Nullable ThingHandler handler) { + if (handler instanceof GroupThingHandler) { + this.handler = (GroupThingHandler) handler; + } + } + + @Override + public @Nullable ThingHandler getThingHandler() { + return handler; + } +} diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java new file mode 100644 index 0000000000000..4cfb031f733b0 --- /dev/null +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2010-2022 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.deconz.internal.dto; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * The {@link NewSceneResponse} is the response after a successfull scene creation + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +public class NewSceneResponse { + public Success success = new Success(); + + public class Success { + public int id = 0; + } +} diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBaseThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBaseThingHandler.java index 8717620c745dd..969462ed375f0 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBaseThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBaseThingHandler.java @@ -22,6 +22,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.http.HttpMethod; import org.openhab.binding.deconz.internal.dto.DeconzBaseMessage; import org.openhab.binding.deconz.internal.netutils.WebSocketConnection; import org.openhab.binding.deconz.internal.netutils.WebSocketMessageListener; @@ -195,7 +196,7 @@ protected void sendCommand(@Nullable Object object, Command originalCommand, Cha String endpoint = Stream.of(resourceType.getIdentifier(), config.id, commandUrl) .collect(Collectors.joining("/")); - bridgeHandler.sendObject(endpoint, object).thenAccept(v -> { + bridgeHandler.sendObject(endpoint, object, HttpMethod.PUT).thenAccept(v -> { if (acceptProcessing != null) { acceptProcessing.run(); } @@ -212,6 +213,32 @@ protected void sendCommand(@Nullable Object object, Command originalCommand, Cha }); } + public void doNetwork(@Nullable Object object, String commandUrl, HttpMethod httpMethod, + @Nullable Consumer acceptProcessing) { + DeconzBridgeHandler bridgeHandler = getBridgeHandler(); + if (bridgeHandler == null) { + return; + } + String endpoint = Stream.of(resourceType.getIdentifier(), config.id, commandUrl) + .collect(Collectors.joining("/")); + + bridgeHandler.sendObject(endpoint, object, httpMethod).thenAccept(v -> { + if (v.getResponseCode() != java.net.HttpURLConnection.HTTP_OK) { + logger.warn("Sending {} via {} to {} failed: {} - {}", object, httpMethod, commandUrl, + v.getResponseCode(), v.getBody()); + } else { + logger.trace("Result code={}, body={}", v.getResponseCode(), v.getBody()); + if (acceptProcessing != null) { + acceptProcessing.accept(v.getBody()); + } + } + }).exceptionally(e -> { + logger.warn("Sending {} via {} to {} failed: {} - {}", object, httpMethod, commandUrl, e.getClass(), + e.getMessage()); + return null; + }); + } + @Override public void dispose() { stopInitializationJob(); diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBridgeHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBridgeHandler.java index 79f956be936e2..2c4381385154e 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBridgeHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBridgeHandler.java @@ -30,6 +30,8 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.http.HttpMethod; +import org.openhab.binding.deconz.internal.action.BridgeActions; import org.openhab.binding.deconz.internal.discovery.ThingDiscoveryService; import org.openhab.binding.deconz.internal.dto.ApiKeyMessage; import org.openhab.binding.deconz.internal.dto.BridgeFullState; @@ -97,7 +99,7 @@ public DeconzBridgeHandler(Bridge thing, WebSocketFactory webSocketFactory, Asyn @Override public Collection> getServices() { - return Set.of(ThingDiscoveryService.class); + return Set.of(ThingDiscoveryService.class, BridgeActions.class); } @Override @@ -326,13 +328,23 @@ public WebSocketConnection getWebsocketConnection() { * * @param endPoint the endpoint (e.g. "lights/2/state") * @param object the object (or null if no object) + * @param httpMethod the HTTP Method * @return CompletableFuture of the result */ - public CompletableFuture sendObject(String endPoint, @Nullable Object object) { + public CompletableFuture sendObject(String endPoint, @Nullable Object object, + HttpMethod httpMethod) { String json = object == null ? null : gson.toJson(object); String url = buildUrl(config.host, config.httpPort, config.apikey, endPoint); - logger.trace("Sending {} via {}", json, url); + logger.trace("Sending {} via {} to {}", json, httpMethod, url); - return http.put(url, json, config.timeout); + if (httpMethod == HttpMethod.PUT) { + return http.put(url, json, config.timeout); + } else if (httpMethod == HttpMethod.POST) { + return http.post(url, json, config.timeout); + } else if (httpMethod == HttpMethod.DELETE) { + return http.delete(url, config.timeout); + } + + return CompletableFuture.failedFuture(new IllegalArgumentException("Unknown HTTP Method")); } } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java index 02db57957c99b..2729b1b503866 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java @@ -14,6 +14,7 @@ import static org.openhab.binding.deconz.internal.BindingConstants.*; +import java.util.Collection; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -21,6 +22,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.deconz.internal.DeconzDynamicCommandDescriptionProvider; import org.openhab.binding.deconz.internal.Util; +import org.openhab.binding.deconz.internal.action.GroupActions; import org.openhab.binding.deconz.internal.dto.DeconzBaseMessage; import org.openhab.binding.deconz.internal.dto.GroupAction; import org.openhab.binding.deconz.internal.dto.GroupMessage; @@ -36,6 +38,7 @@ import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; import org.openhab.core.thing.ThingTypeUID; +import org.openhab.core.thing.binding.ThingHandlerService; import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; import org.slf4j.Logger; @@ -199,4 +202,9 @@ public void messageReceived(String sensorID, DeconzBaseMessage message) { } } } + + @Override + public Collection> getServices() { + return Set.of(GroupActions.class); + } } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/AsyncHttpClient.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/AsyncHttpClient.java index 5ca7c68e6afbe..c989e5037fbce 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/AsyncHttpClient.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/AsyncHttpClient.java @@ -48,7 +48,7 @@ public AsyncHttpClient(HttpClient client) { * @param timeout A timeout * @return The result */ - public CompletableFuture post(String address, String jsonString, int timeout) { + public CompletableFuture post(String address, @Nullable String jsonString, int timeout) { return doNetwork(HttpMethod.POST, address, jsonString, timeout); } From 246ffdda5967500625f79ed8c696b96a2fde0a35 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sun, 1 Jan 2023 22:51:40 +0100 Subject: [PATCH 02/11] Fix typos Signed-off-by: Jacob Laursen --- bundles/org.openhab.binding.deconz/README.md | 10 +++++----- .../binding/deconz/internal/action/BridgeActions.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index 25bea04d10372..675a53812e30e 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -223,11 +223,11 @@ The `deconz` thing supports a thing action to allow new devices to join the netw The `lightgroup` thing supports thing actions for managing scenes: -| Action name | Input Value | Return Value | Description | -|---------------------|-----------------|--------------|-------------------------------------------------------------------------------------------| -| `createScene(name)` | `name` (String) | `newSceneId` | Creates a new scene with the name `name` and returns the new scene's id (if successfull). | -| `deleteScene(id)` | `id` (Integer) | - | Deletes the scene with the given id. | -| `storeScene(id)` | `id` (Integer) | - | Store the current group's state as scene with the given id. | +| Action name | Input Value | Return Value | Description | +|---------------------|-----------------|--------------|------------------------------------------------------------------------------------------| +| `createScene(name)` | `name` (String) | `newSceneId` | Creates a new scene with the name `name` and returns the new scene's id (if successful). | +| `deleteScene(id)` | `id` (Integer) | - | Deletes the scene with the given id. | +| `storeScene(id)` | `id` (Integer) | - | Store the current group's state as scene with the given id. | ## Full Example diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java index 32ca2d3367200..8418678ea79eb 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java @@ -40,7 +40,7 @@ public class BridgeActions implements ThingActions { private @Nullable DeconzBridgeHandler handler; - @RuleAction(label = "permit join ZigBee network", description = "Permits ew devices to join the zigbee network for a given duration (default 120s).") + @RuleAction(label = "permit join Zigbee network", description = "Permits new devices to join the Zigbee network for a given duration (default 120s).") public void permitJoin(@ActionInput(name = "duration") @Nullable Integer duration) { DeconzBridgeHandler handler = this.handler; From 4bf75b55f10b7214767ebf2f1da3da47a2f56f7a Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Mon, 2 Jan 2023 02:04:47 +0100 Subject: [PATCH 03/11] Add SmartHome/J copyright headers Signed-off-by: Jacob Laursen --- .../deconz/internal/action/BridgeActions.java | 13 +++++++++++++ .../deconz/internal/action/GroupActions.java | 13 +++++++++++++ .../deconz/internal/dto/NewSceneResponse.java | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java index 8418678ea79eb..4e9974667cc0e 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java @@ -10,6 +10,19 @@ * * SPDX-License-Identifier: EPL-2.0 */ + +/** + * Copyright (c) 2021-2022 Contributors to the SmartHome/J 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.deconz.internal.action; import java.util.Map; diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java index c8f3e70179231..e507dc640ff82 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java @@ -10,6 +10,19 @@ * * SPDX-License-Identifier: EPL-2.0 */ + +/** + * Copyright (c) 2021-2022 Contributors to the SmartHome/J 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.deconz.internal.action; import java.lang.reflect.Type; diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java index 4cfb031f733b0..5c49552852348 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java @@ -10,6 +10,19 @@ * * SPDX-License-Identifier: EPL-2.0 */ + +/** + * Copyright (c) 2021-2022 Contributors to the SmartHome/J 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.deconz.internal.dto; import org.eclipse.jdt.annotation.NonNullByDefault; From cbcaab964e92ec1aae061e36be2bb916ebbfc813 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Wed, 4 Jan 2023 23:31:22 +0100 Subject: [PATCH 04/11] Add I18N texts Signed-off-by: Jacob Laursen --- .../deconz/internal/action/BridgeActions.java | 2 +- .../deconz/internal/action/GroupActions.java | 6 ++--- .../resources/OH-INF/i18n/deconz.properties | 23 ++++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java index 4e9974667cc0e..232ccb754dc15 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java @@ -53,7 +53,7 @@ public class BridgeActions implements ThingActions { private @Nullable DeconzBridgeHandler handler; - @RuleAction(label = "permit join Zigbee network", description = "Permits new devices to join the Zigbee network for a given duration (default 120s).") + @RuleAction(label = "@text/action.permit-join-network.label", description = "@text/action.permit-join-network.description") public void permitJoin(@ActionInput(name = "duration") @Nullable Integer duration) { DeconzBridgeHandler handler = this.handler; diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java index e507dc640ff82..cd83681c4af77 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java @@ -68,7 +68,7 @@ public class GroupActions implements ThingActions { private @Nullable GroupThingHandler handler; - @RuleAction(label = "create a scene", description = "Creates a new scene and returns the new scene's id") + @RuleAction(label = "@text/action.create-scene.label", description = "@text/action.create-scene.description") public @ActionOutput(name = NEW_SCENE_ID_OUTPUT, type = "java.lang.Integer") Map createScene( @ActionInput(name = "name") @Nullable String name) { GroupThingHandler handler = this.handler; @@ -107,7 +107,7 @@ public static Map createScene(ThingActions actions, @Nullable St return Map.of(); } - @RuleAction(label = "delete a scene", description = "Deletes a scene") + @RuleAction(label = "@text/action.delete-scene.label", description = "@text/action.delete-scene.description") public void deleteScene(@ActionInput(name = "sceneId") @Nullable Integer sceneId) { GroupThingHandler handler = this.handler; @@ -130,7 +130,7 @@ public static void deleteScene(ThingActions actions, @Nullable Integer sceneId) } } - @RuleAction(label = "store as scene", description = "Stores the current light state as scene") + @RuleAction(label = "@text/action.store-as-scene.label", description = "@text/action.store-as-scene.description") public void storeScene(@ActionInput(name = "sceneId") @Nullable Integer sceneId) { GroupThingHandler handler = this.handler; diff --git a/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/i18n/deconz.properties b/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/i18n/deconz.properties index 8f9e71c2dba30..de8503f2f188c 100644 --- a/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/i18n/deconz.properties +++ b/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/i18n/deconz.properties @@ -5,13 +5,13 @@ binding.deconz.description = Allows to use the real-time channel of the deCONZ s # thing types +thing-type.deconz.airqualitysensor.label = Air quality Sensor +thing-type.deconz.airqualitysensor.description = An air quality sensor thing-type.deconz.alarmsensor.label = Alarm Sensor thing-type.deconz.alarmsensor.description = An alarm sensor thing-type.deconz.batterysensor.label = Battery Sensor thing-type.deconz.batterysensor.description = A battery sensor thing-type.deconz.carbonmonoxidesensor.label = Carbon-monoxide Sensor -thing-type.deconz.airqualitysensor.label = Air quality Sensor -thing-type.deconz.airqualitysensor.description = An air quality sensor thing-type.deconz.colorcontrol.label = Color Controller thing-type.deconz.colorlight.label = Color Light thing-type.deconz.colorlight.description = A dimmable light with adjustable color. @@ -98,6 +98,10 @@ thing-type.config.deconz.sensor.lastSeenPolling.description = Interval to poll t # channel types +channel-type.deconz.airquality.label = Air quality level +channel-type.deconz.airquality.description = Current air quality level based on volatile organic compounds (VOCs) measurement. Example: good or poor, ... +channel-type.deconz.airqualityppb.label = Air quality in ppb +channel-type.deconz.airqualityppb.description = Current air quality based on measurements of volatile organic compounds (VOCs). The measured value is specified in ppb (parts per billion). channel-type.deconz.alarm.label = Alarm channel-type.deconz.alarm.description = Alarm was triggered. channel-type.deconz.alert.label = Alert @@ -114,10 +118,6 @@ channel-type.deconz.buttonevent.label = Button Trigger channel-type.deconz.buttonevent.description = This channel is triggered on a button event. The trigger payload consists of the button event number. channel-type.deconz.carbonmonoxide.label = Carbon-monoxide channel-type.deconz.carbonmonoxide.description = Carbon-monoxide was detected. -channel-type.deconz.airquality.label = Air quality level -channel-type.deconz.airquality.description = Current air quality level based on volatile organic compounds (VOCs) measurement. Example: good or poor, ... -channel-type.deconz.airqualityppb.label = Air quality in ppb -channel-type.deconz.airqualityppb.description = Current air quality based on measurements of volatile organic compounds (VOCs). The measured value is specified in ppb (parts per billion). channel-type.deconz.consumption.label = Consumption channel-type.deconz.consumption.description = Current consumption channel-type.deconz.ct.label = Color Temperature @@ -201,3 +201,14 @@ channel-type.deconz.waterleakage.description = Water leakage detected offline.light-not-reachable = Not reachable offline.sensor-not-reachable = Not reachable + +# actions + +action.permit-join-network.label = permit join Zigbee network +action.permit-join-network.description = Permits new devices to join the Zigbee network for a given duration (default 120s). +action.create-scene.label = create a scene +action.create-scene.description = Creates a new scene and returns the new scene's id +action.delete-scene.label = delete a scene +action.delete-scene.description = Deletes a scene +action.store-as-scene.label = store as scene +action.store-as-scene.description = Stores the current light state as scene From 29d719841b2090b89b414b20457a62cc596e8664 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Wed, 4 Jan 2023 23:35:24 +0100 Subject: [PATCH 05/11] Log level warning for missing action parameters Signed-off-by: Jacob Laursen --- .../binding/deconz/internal/action/GroupActions.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java index cd83681c4af77..869ffcec3290c 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java @@ -79,7 +79,7 @@ public class GroupActions implements ThingActions { } if (name == null) { - logger.debug("Skipping scene creation due to missing scene name"); + logger.warn("Skipping scene creation due to missing scene name"); return Map.of(); } @@ -117,7 +117,7 @@ public void deleteScene(@ActionInput(name = "sceneId") @Nullable Integer sceneId } if (sceneId == null) { - logger.debug("Skipping scene deletion due to missing scene id"); + logger.warn("Skipping scene deletion due to missing scene id"); return; } @@ -140,7 +140,7 @@ public void storeScene(@ActionInput(name = "sceneId") @Nullable Integer sceneId) } if (sceneId == null) { - logger.debug("Skipping scene storage due to missing scene id"); + logger.warn("Skipping scene storage due to missing scene id"); return; } From 702e0871d1b24f5b169fb96ac3f986e0fdfda014 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Fri, 6 Jan 2023 21:34:41 +0100 Subject: [PATCH 06/11] Update copyright year Signed-off-by: Jacob Laursen --- .../openhab/binding/deconz/internal/action/BridgeActions.java | 2 +- .../openhab/binding/deconz/internal/action/GroupActions.java | 2 +- .../openhab/binding/deconz/internal/dto/NewSceneResponse.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java index 232ccb754dc15..36b9a94e71d79 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2022 Contributors to the openHAB project + * Copyright (c) 2010-2023 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java index 869ffcec3290c..315cb69eba084 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2022 Contributors to the openHAB project + * Copyright (c) 2010-2023 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java index 5c49552852348..6edcede72ed78 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/NewSceneResponse.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2022 Contributors to the openHAB project + * Copyright (c) 2010-2023 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. From 7ad152486b01ba69e4a1f550926a5cede51bf6f0 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Fri, 6 Jan 2023 22:15:07 +0100 Subject: [PATCH 07/11] Emphasize the return value concept Signed-off-by: Jacob Laursen --- bundles/org.openhab.binding.deconz/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index 675a53812e30e..7523b8726f8f3 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -219,7 +219,7 @@ The `deconz` thing supports a thing action to allow new devices to join the netw | Action name | Input Value | Return Value | Description | |------------------------|----------------------|--------------|----------------------------------------------------------------------------------------------------------------| -| `permitJoin(duration)` | `duration` (Integer) | - | allows new devices to join for `duration` seconds. Allowed values are 1-240, default is 120 if no value given. | +| `permitJoin(duration)` | `duration` (Integer) | - | Allows new devices to join for `duration` seconds. Allowed values are 1-240, default is 120 if no value given. | The `lightgroup` thing supports thing actions for managing scenes: @@ -229,6 +229,8 @@ The `lightgroup` thing supports thing actions for managing scenes: | `deleteScene(id)` | `id` (Integer) | - | Deletes the scene with the given id. | | `storeScene(id)` | `id` (Integer) | - | Store the current group's state as scene with the given id. | +The return value refers to a key of the given name within the returned Map. See [example](#thing-actions). + ## Full Example ### Things file From a01482ec625c3e632446ec031402d5013700befa Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Fri, 6 Jan 2023 22:25:10 +0100 Subject: [PATCH 08/11] Fix duplicate header Signed-off-by: Jacob Laursen --- bundles/org.openhab.binding.deconz/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index 7523b8726f8f3..061d43bfeac15 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -229,7 +229,7 @@ The `lightgroup` thing supports thing actions for managing scenes: | `deleteScene(id)` | `id` (Integer) | - | Deletes the scene with the given id. | | `storeScene(id)` | `id` (Integer) | - | Store the current group's state as scene with the given id. | -The return value refers to a key of the given name within the returned Map. See [example](#thing-actions). +The return value refers to a key of the given name within the returned Map. See [example](#thing-actions-example). ## Full Example @@ -280,7 +280,7 @@ then end ``` -### Thing Actions +### Thing Actions Example ```js deconzActions = actions.get("deconz", "deconz:lightgroup:00212E040ED9:5"); From 5022dd1332d03034f49d27a4206ae07c7ca8602b Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Fri, 6 Jan 2023 22:42:09 +0100 Subject: [PATCH 09/11] Provide example as DSL rule also Signed-off-by: Jacob Laursen --- bundles/org.openhab.binding.deconz/README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index 061d43bfeac15..578ac8f20de5c 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -282,12 +282,30 @@ end ### Thing Actions Example -```js +:::: tabs + +::: tab JavaScript + +```javascript deconzActions = actions.get("deconz", "deconz:lightgroup:00212E040ED9:5"); retVal = deconzActions.createScene("TestScene"); deconzActions.storeScene(retVal["newSceneId"]); ``` +::: + +::: tab DSL + +```java +val deconzActions = getActions("deconz", "deconz:lightgroup:00212E040ED9:5"); +var retVal = deconzActions.createScene("TestScene"); +deconzActions.storeScene(retVal.get("newSceneId")); +``` + +::: + +:::: + ### Troubleshooting By default state updates are ignored for 250ms after a command. From 90c4d097d344112cd5aabe13b0b204010e965c92 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 7 Jan 2023 17:36:38 +0100 Subject: [PATCH 10/11] Add parameter labels and descriptions Signed-off-by: Jacob Laursen --- bundles/org.openhab.binding.deconz/README.md | 10 +++++----- .../deconz/internal/action/BridgeActions.java | 3 ++- .../binding/deconz/internal/action/GroupActions.java | 8 +++++--- .../src/main/resources/OH-INF/i18n/deconz.properties | 12 ++++++++++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index 578ac8f20de5c..61993a26e8b15 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -223,11 +223,11 @@ The `deconz` thing supports a thing action to allow new devices to join the netw The `lightgroup` thing supports thing actions for managing scenes: -| Action name | Input Value | Return Value | Description | -|---------------------|-----------------|--------------|------------------------------------------------------------------------------------------| -| `createScene(name)` | `name` (String) | `newSceneId` | Creates a new scene with the name `name` and returns the new scene's id (if successful). | -| `deleteScene(id)` | `id` (Integer) | - | Deletes the scene with the given id. | -| `storeScene(id)` | `id` (Integer) | - | Store the current group's state as scene with the given id. | +| Action name | Input Value | Return Value | Description | +|---------------------|----------------------|--------------|------------------------------------------------------------------------------------------| +| `createScene(name)` | `name` (String) | `newSceneId` | Creates a new scene with the name `name` and returns the new scene's id (if successful). | +| `deleteScene(id)` | `sceneId` (Integer) | - | Deletes the scene with the given id. | +| `storeScene(id)` | `sceneId` (Integer) | - | Store the current group's state as scene with the given id. | The return value refers to a key of the given name within the returned Map. See [example](#thing-actions-example). diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java index 36b9a94e71d79..3b17342acc2e7 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java @@ -54,7 +54,8 @@ public class BridgeActions implements ThingActions { private @Nullable DeconzBridgeHandler handler; @RuleAction(label = "@text/action.permit-join-network.label", description = "@text/action.permit-join-network.description") - public void permitJoin(@ActionInput(name = "duration") @Nullable Integer duration) { + public void permitJoin( + @ActionInput(name = "duration", label = "@text/action.permit-join-network.duration.label", description = "@text/action.permit-join-network.duration.description") @Nullable Integer duration) { DeconzBridgeHandler handler = this.handler; if (handler == null) { diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java index 315cb69eba084..75f5205015f42 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java @@ -70,7 +70,7 @@ public class GroupActions implements ThingActions { @RuleAction(label = "@text/action.create-scene.label", description = "@text/action.create-scene.description") public @ActionOutput(name = NEW_SCENE_ID_OUTPUT, type = "java.lang.Integer") Map createScene( - @ActionInput(name = "name") @Nullable String name) { + @ActionInput(name = "name", label = "@text/action.create-scene.name.label", description = "@text/action.create-scene.name.description") @Nullable String name) { GroupThingHandler handler = this.handler; if (handler == null) { @@ -108,7 +108,8 @@ public static Map createScene(ThingActions actions, @Nullable St } @RuleAction(label = "@text/action.delete-scene.label", description = "@text/action.delete-scene.description") - public void deleteScene(@ActionInput(name = "sceneId") @Nullable Integer sceneId) { + public void deleteScene( + @ActionInput(name = "sceneId", label = "@text/action.delete-scene.sceneId.label", description = "@text/action.delete-scene.sceneId.description") @Nullable Integer sceneId) { GroupThingHandler handler = this.handler; if (handler == null) { @@ -131,7 +132,8 @@ public static void deleteScene(ThingActions actions, @Nullable Integer sceneId) } @RuleAction(label = "@text/action.store-as-scene.label", description = "@text/action.store-as-scene.description") - public void storeScene(@ActionInput(name = "sceneId") @Nullable Integer sceneId) { + public void storeScene( + @ActionInput(name = "sceneId", label = "@text/action.store-as-scene.sceneId.label", description = "@text/action.store-as-scene.sceneId.description") @Nullable Integer sceneId) { GroupThingHandler handler = this.handler; if (handler == null) { diff --git a/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/i18n/deconz.properties b/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/i18n/deconz.properties index de8503f2f188c..2d5f72e225765 100644 --- a/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/i18n/deconz.properties +++ b/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/i18n/deconz.properties @@ -204,11 +204,19 @@ offline.sensor-not-reachable = Not reachable # actions +action.permit-join-network.duration.label = Duration +action.permit-join-network.duration.description = Number of seconds to allow new devices to join. action.permit-join-network.label = permit join Zigbee network action.permit-join-network.description = Permits new devices to join the Zigbee network for a given duration (default 120s). action.create-scene.label = create a scene -action.create-scene.description = Creates a new scene and returns the new scene's id +action.create-scene.description = Creates a new scene and returns the new scene's id. +action.create-scene.name.label = Name +action.create-scene.name.description = Name of the scene to create. action.delete-scene.label = delete a scene -action.delete-scene.description = Deletes a scene +action.delete-scene.description = Deletes a scene. +action.delete-scene.sceneId.label = Scene id +action.delete-scene.sceneId.description = Id of the scene to delete. action.store-as-scene.label = store as scene action.store-as-scene.description = Stores the current light state as scene +action.store-as-scene.sceneId.label = Scene id +action.store-as-scene.sceneId.description = Id of the scene to store current group's state as. From 0d43f303cda6418f80a571de009be9ba83635fe4 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Wed, 1 Feb 2023 21:48:02 +0100 Subject: [PATCH 11/11] Remove SmartHome/J headers Signed-off-by: Jacob Laursen --- .../deconz/internal/action/BridgeActions.java | 13 ------------- .../deconz/internal/action/GroupActions.java | 13 ------------- 2 files changed, 26 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java index 3b17342acc2e7..818ee69385680 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java @@ -10,19 +10,6 @@ * * SPDX-License-Identifier: EPL-2.0 */ - -/** - * Copyright (c) 2021-2022 Contributors to the SmartHome/J 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.deconz.internal.action; import java.util.Map; diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java index 75f5205015f42..60b894ecad8e4 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java @@ -10,19 +10,6 @@ * * SPDX-License-Identifier: EPL-2.0 */ - -/** - * Copyright (c) 2021-2022 Contributors to the SmartHome/J 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.deconz.internal.action; import java.lang.reflect.Type;