diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/ButtongridRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/ButtongridRenderer.java index d6e3f28b88..93a8325081 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/ButtongridRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/ButtongridRenderer.java @@ -186,6 +186,7 @@ private String buildButton(String item, @Nullable String lab, String cmd, @Nulla button = button.replace("%item%", item); button = button.replace("%cmd%", escapeHtml(cmd)); + button = button.replace("%release_cmd%", ""); String buttonClass = "buttongrid-button"; button = button.replace("%label%", escapeHtml(label)); diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java index 1a9140199e..a3409b0963 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java @@ -378,6 +378,7 @@ public CharSequence renderSettings() throws RenderException { private void buildButton(String label, String cmd, StringBuilder buttons) throws RenderException { buttons.append(getSnippet("button") // .replace("%cmd%", escapeHtml(cmd)) // + .replace("%release_cmd%", "") // .replace("%label%", escapeHtml(label)) // .replace("%textclass%", "mdl-button-text") // .replace("%icon_snippet%", "") // diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/SwitchRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/SwitchRenderer.java index 69d04c253a..e619fe50be 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/SwitchRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/SwitchRenderer.java @@ -134,13 +134,14 @@ public EList renderWidget(Widget w, StringBuilder sb, String sitemap) th if (commandDescription != null) { for (CommandOption option : commandDescription.getCommandOptions()) { // Truncate the button label to MAX_LABEL_SIZE characters - buildButton(s, option.getLabel(), option.getCommand(), null, MAX_LABEL_SIZE, item, state, + buildButton(s, option.getLabel(), option.getCommand(), null, null, MAX_LABEL_SIZE, item, state, buttons); } } } else { for (Mapping mapping : s.getMappings()) { - buildButton(s, mapping.getLabel(), mapping.getCmd(), mapping.getIcon(), -1, item, state, buttons); + buildButton(s, mapping.getLabel(), mapping.getCmd(), mapping.getReleaseCmd(), mapping.getIcon(), -1, + item, state, buttons); } } snippet = snippet.replace("%buttons%", buttons.toString()); @@ -153,17 +154,22 @@ public EList renderWidget(Widget w, StringBuilder sb, String sitemap) th return ECollections.emptyEList(); } - private void buildButton(Switch w, @Nullable String lab, String cmd, @Nullable String icon, int maxLabelSize, - @Nullable Item item, @Nullable State state, StringBuilder buttons) throws RenderException { + private void buildButton(Switch w, @Nullable String lab, String cmd, @Nullable String releaseCmd, + @Nullable String icon, int maxLabelSize, @Nullable Item item, @Nullable State state, StringBuilder buttons) + throws RenderException { String button = getSnippet("button"); String command = cmd; + String releaseCommand = releaseCmd; String label = lab == null ? cmd : lab; if (item instanceof NumberItem && ((NumberItem) item).getDimension() != null) { String unit = getUnitForWidget(w); if (unit != null) { command = command.replace(UnitUtils.UNIT_PLACEHOLDER, unit); + if (releaseCommand != null) { + releaseCommand = releaseCommand.replace(UnitUtils.UNIT_PLACEHOLDER, unit); + } label = label.replace(UnitUtils.UNIT_PLACEHOLDER, unit); } } @@ -173,6 +179,7 @@ private void buildButton(Switch w, @Nullable String lab, String cmd, @Nullable S } button = button.replace("%cmd%", escapeHtml(command)); + button = button.replace("%release_cmd%", releaseCommand == null ? "" : escapeHtml(releaseCommand)); String buttonClass = ""; button = button.replace("%label%", escapeHtml(label)); if (icon == null) { diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/button.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/button.html index 018f7121ce..15ef395b92 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/button.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/button.html @@ -1,5 +1,6 @@