From eaae6a8682d8b56ab006914fa805a9fe43c91549 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sun, 30 Jun 2024 15:04:45 +0200 Subject: [PATCH 01/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../internal/LivisiBindingConstants.java | 1 + .../internal/client/LivisiClient.java | 14 ++++++--- .../api/entity/action/RestartActionDTO.java | 30 +++++++++++++++++++ .../internal/handler/LivisiBridgeHandler.java | 15 ++++++++++ .../internal/handler/LivisiDeviceHandler.java | 8 +++++ .../OH-INF/i18n/livisismarthome.properties | 2 ++ .../main/resources/OH-INF/thing/bridge.xml | 1 + .../main/resources/OH-INF/thing/channels.xml | 8 +++++ 8 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/LivisiBindingConstants.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/LivisiBindingConstants.java index ad83eef22ddce..0ccd27883ed54 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/LivisiBindingConstants.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/LivisiBindingConstants.java @@ -184,6 +184,7 @@ public class LivisiBindingConstants { public static final String CHANNEL_DISK = "disk"; public static final String CHANNEL_MEMORY = "memory"; public static final String CHANNEL_OPERATION_STATUS = "status"; + public static final String CHANNEL_RESTART = "restart"; // List of channel parameters public static final String INVERT_CHANNEL_PARAMETER = "invert"; diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/LivisiClient.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/LivisiClient.java index a2275dec13c3a..a8dc591413881 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/LivisiClient.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/LivisiClient.java @@ -32,10 +32,7 @@ import org.eclipse.jetty.http.HttpStatus; import org.openhab.binding.livisismarthome.internal.LivisiBindingConstants; import org.openhab.binding.livisismarthome.internal.client.api.entity.StatusResponseDTO; -import org.openhab.binding.livisismarthome.internal.client.api.entity.action.ActionDTO; -import org.openhab.binding.livisismarthome.internal.client.api.entity.action.ShutterActionDTO; -import org.openhab.binding.livisismarthome.internal.client.api.entity.action.ShutterActionType; -import org.openhab.binding.livisismarthome.internal.client.api.entity.action.StateActionSetterDTO; +import org.openhab.binding.livisismarthome.internal.client.api.entity.action.*; import org.openhab.binding.livisismarthome.internal.client.api.entity.capability.CapabilityDTO; import org.openhab.binding.livisismarthome.internal.client.api.entity.capability.CapabilityStateDTO; import org.openhab.binding.livisismarthome.internal.client.api.entity.device.DeviceDTO; @@ -265,6 +262,15 @@ public void setRollerShutterAction(final String capabilityId, final ShutterActio executePost(createActionURL(), new ShutterActionDTO(capabilityId, rollerShutterAction)); } + /** + * Restarts the SHC (bridge) device + */ + public void setRestartAction(@Nullable final String bridgeDeviceId) throws IOException { + if (bridgeDeviceId != null) { + executePost(createActionURL(), new RestartActionDTO(bridgeDeviceId)); + } + } + /** * Sets a new state of a VariableActuator. */ diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java new file mode 100644 index 0000000000000..ce631ad893a25 --- /dev/null +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2010-2024 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.livisismarthome.internal.client.api.entity.action; + +import org.openhab.binding.livisismarthome.internal.client.api.entity.link.LinkDTO; + +/** + * Special {@link ActionDTO} to execute a restart. + * + * @author Sven Strohschein + */ +public class RestartActionDTO extends ActionDTO { + + private static final String ACTION_TYPE_RESTART = "Restart"; + + public RestartActionDTO(String deviceId) { + setType(ACTION_TYPE_RESTART); + setTarget(LinkDTO.LINK_TYPE_DEVICE + deviceId); + } +} diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java index 3df6053788ac7..3a459fbfc2d31 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java @@ -67,6 +67,7 @@ import org.openhab.core.auth.client.oauth2.OAuthException; import org.openhab.core.auth.client.oauth2.OAuthFactory; import org.openhab.core.auth.client.oauth2.OAuthResponseException; +import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; import org.openhab.core.library.unit.Units; @@ -497,6 +498,9 @@ public void onDeviceStateChanged(final DeviceDTO bridgeDevice) { logger.debug("-> Operation status: {}", operationStatus); updateState(CHANNEL_OPERATION_STATUS, new StringType(operationStatus.toUpperCase())); } + + // Update the restart channel to OFF to enable a (new) restart command. + updateState(CHANNEL_RESTART, OnOffType.OFF); } } } @@ -821,6 +825,17 @@ public void commandSetRollerShutterStop(final String deviceId, final ShutterActi (capabilityId) -> client.setRollerShutterAction(capabilityId, action)); } + /** + * Restarts the SHC (bridge) device + */ + public void commandRestart() { + try { + client.setRestartAction(bridgeId); + } catch (IOException e) { + handleClientException(e); + } + } + private void executeCommand(final String deviceId, final String capabilityType, final CommandExecutor commandExecutor) { try { diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java index bac5a2693c5ec..d10992f3e58a0 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java @@ -130,6 +130,8 @@ private void executeCommand(ChannelUID channelUID, Command command, LivisiBridge commandSwitchSiren(command, SIREN_NOTIFICATION, bridgeHandler); } else if (CHANNEL_SIREN_FEEDBACK.equals(channelUID.getId())) { commandSwitchSiren(command, SIREN_FEEDBACK, bridgeHandler); + } else if (CHANNEL_RESTART.equals(channelUID.getId())) { + commandRestart(command, bridgeHandler); } else { logger.debug("UNSUPPORTED channel {} for device {}.", channelUID.getId(), deviceId); } @@ -232,6 +234,12 @@ private void commandSwitchSiren(Command command, String notificationSound, Livis } } + private void commandRestart(Command command, LivisiBridgeHandler bridgeHandler) { + if (command instanceof OnOffType && OnOffType.ON.equals(command)) { + bridgeHandler.commandRestart(); + } + } + @Override public void initialize() { logger.debug("Initializing LIVISI SmartHome device handler."); diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/i18n/livisismarthome.properties b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/i18n/livisismarthome.properties index 71618fd703310..ac55affa22040 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/i18n/livisismarthome.properties +++ b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/i18n/livisismarthome.properties @@ -128,6 +128,8 @@ channel-type.livisismarthome.powerGenerationWatt.label = Current Power Generatio channel-type.livisismarthome.powerGenerationWatt.description = The current power generation (Watt) channel-type.livisismarthome.pushButtonCounter.label = Button Pushed Count channel-type.livisismarthome.pushButtonCounter.description = The count of button pushes. +channel-type.livisismarthome.restartAction.label = Restart +channel-type.livisismarthome.restartAction.description = Restarts the device channel-type.livisismarthome.rollerShutterActuator.label = Blinds Position channel-type.livisismarthome.rollerShutterActuator.description = Controls the blinds (percent) channel-type.livisismarthome.smokeDetectorSensor.label = Smoke diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/bridge.xml b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/bridge.xml index 27f5281d1845b..09f3424f1a839 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/bridge.xml +++ b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/bridge.xml @@ -13,6 +13,7 @@ + id diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml index be98f1f701cf3..7512cba8f7062 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml @@ -389,4 +389,12 @@ + + + Switch + + Restarts the device + Switch + + From 73583f6176c4e08a025a523d3d8abcc9949b5cf4 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sun, 30 Jun 2024 15:57:02 +0200 Subject: [PATCH 02/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../internal/handler/LivisiBridgeHandler.java | 18 ++++++++++++------ .../internal/handler/LivisiDeviceHandler.java | 8 -------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java index 3a459fbfc2d31..f6056ef725733 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java @@ -19,11 +19,7 @@ import java.net.URI; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; -import java.util.Collection; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ScheduledExecutorService; @@ -133,7 +129,17 @@ public LivisiBridgeHandler(final Bridge bridge, final OAuthFactory oAuthFactory, @Override public void handleCommand(final ChannelUID channelUID, final Command command) { - // not needed + if (CHANNEL_RESTART.equals(channelUID.getId())) { + commandRestart(command); + } else { + logger.debug("UNSUPPORTED channel {} for bridge {}.", channelUID.getId(), bridgeId); + } + } + + private void commandRestart(Command command) { + if (command instanceof OnOffType && OnOffType.ON.equals(command)) { + commandRestart(); + } } @Override diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java index d10992f3e58a0..bac5a2693c5ec 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java @@ -130,8 +130,6 @@ private void executeCommand(ChannelUID channelUID, Command command, LivisiBridge commandSwitchSiren(command, SIREN_NOTIFICATION, bridgeHandler); } else if (CHANNEL_SIREN_FEEDBACK.equals(channelUID.getId())) { commandSwitchSiren(command, SIREN_FEEDBACK, bridgeHandler); - } else if (CHANNEL_RESTART.equals(channelUID.getId())) { - commandRestart(command, bridgeHandler); } else { logger.debug("UNSUPPORTED channel {} for device {}.", channelUID.getId(), deviceId); } @@ -234,12 +232,6 @@ private void commandSwitchSiren(Command command, String notificationSound, Livis } } - private void commandRestart(Command command, LivisiBridgeHandler bridgeHandler) { - if (command instanceof OnOffType && OnOffType.ON.equals(command)) { - bridgeHandler.commandRestart(); - } - } - @Override public void initialize() { logger.debug("Initializing LIVISI SmartHome device handler."); From 7b77b012ff48d35069b489c91a242e446508004d Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sun, 30 Jun 2024 16:06:52 +0200 Subject: [PATCH 03/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../client/api/entity/action/ActionParamsDTO.java | 15 +++++++++++++++ .../api/entity/action/RestartActionDTO.java | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/ActionParamsDTO.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/ActionParamsDTO.java index cd6d40cd76aeb..186993a985598 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/ActionParamsDTO.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/ActionParamsDTO.java @@ -29,6 +29,7 @@ public class ActionParamsDTO { private StringActionParamDTO operationMode; private StringActionParamDTO rampDirection; private StringActionParamDTO activeChannel; + private StringActionParamDTO reason; /** * @return the onState @@ -141,4 +142,18 @@ public StringActionParamDTO getActiveChannel() { public void setActiveChannel(StringActionParamDTO activeChannel) { this.activeChannel = activeChannel; } + + /** + * @return the reason (for example the reason to restart the controller) + */ + public StringActionParamDTO getReason() { + return reason; + } + + /** + * @param reason the reason (for example the reason to restart the controller) + */ + public void setReason(StringActionParamDTO reason) { + this.reason = reason; + } } diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java index ce631ad893a25..4cfb862e6ba73 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java @@ -22,9 +22,15 @@ public class RestartActionDTO extends ActionDTO { private static final String ACTION_TYPE_RESTART = "Restart"; + private static final String CONSTANT = "Constant"; + private static final String DEFAULT_RESTART_REASON = "The OpenHAB binding requested to restart the smart home controller."; public RestartActionDTO(String deviceId) { setType(ACTION_TYPE_RESTART); setTarget(LinkDTO.LINK_TYPE_DEVICE + deviceId); + + final ActionParamsDTO params = new ActionParamsDTO(); + params.setReason(new StringActionParamDTO(CONSTANT, DEFAULT_RESTART_REASON)); + setParams(params); } } From 87c57fb080a3b61482ad2cec47c4a67b5bbeebff Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sun, 30 Jun 2024 16:25:29 +0200 Subject: [PATCH 04/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../internal/handler/LivisiBridgeHandler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java index f6056ef725733..ca532896dbe1b 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java @@ -455,6 +455,9 @@ private void refreshBridgeState() { deviceState.setId(bridgeDevice.getId()); deviceState.setState(client.getDeviceStateByDeviceId(bridgeDevice.getId(), isSHCClassic())); bridgeDevice.setDeviceState(deviceState); + + // Update the restart channel to OFF to enable a (new) restart command. + updateState(CHANNEL_RESTART, OnOffType.OFF); } catch (IOException e) { logger.debug("Exception occurred on reloading bridge", e); } @@ -504,9 +507,6 @@ public void onDeviceStateChanged(final DeviceDTO bridgeDevice) { logger.debug("-> Operation status: {}", operationStatus); updateState(CHANNEL_OPERATION_STATUS, new StringType(operationStatus.toUpperCase())); } - - // Update the restart channel to OFF to enable a (new) restart command. - updateState(CHANNEL_RESTART, OnOffType.OFF); } } } @@ -837,6 +837,8 @@ public void commandSetRollerShutterStop(final String deviceId, final ShutterActi public void commandRestart() { try { client.setRestartAction(bridgeId); + + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Restarting ..."); } catch (IOException e) { handleClientException(e); } From abe45072d84f349b46d4f663e01f8a2d7074efb2 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sun, 30 Jun 2024 16:35:26 +0200 Subject: [PATCH 05/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../internal/handler/LivisiBridgeHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java index ca532896dbe1b..875d9680e84e2 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java @@ -199,6 +199,9 @@ private void startClient() { scheduleBridgeRefreshJob(bridgeDevice); startWebSocket(bridgeDevice); + + // Update the restart channel to OFF to enable a (new) restart command. + updateState(CHANNEL_RESTART, OnOffType.OFF); } else { logger.debug("Failed to get bridge device, re-scheduling startClient."); scheduleRestartClient(true); @@ -455,9 +458,6 @@ private void refreshBridgeState() { deviceState.setId(bridgeDevice.getId()); deviceState.setState(client.getDeviceStateByDeviceId(bridgeDevice.getId(), isSHCClassic())); bridgeDevice.setDeviceState(deviceState); - - // Update the restart channel to OFF to enable a (new) restart command. - updateState(CHANNEL_RESTART, OnOffType.OFF); } catch (IOException e) { logger.debug("Exception occurred on reloading bridge", e); } From 8f24dddc976c485b3b83502b7ac38ae8eac0e2b5 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Wed, 3 Jul 2024 21:03:25 +0200 Subject: [PATCH 06/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../internal/client/api/entity/action/RestartActionDTO.java | 2 +- .../livisismarthome/internal/handler/LivisiBridgeHandler.java | 4 ++-- .../livisismarthome/internal/handler/LivisiDeviceHandler.java | 2 +- .../src/main/resources/OH-INF/thing/channels.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java index 4cfb862e6ba73..fe9ea91c5dfa0 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java @@ -23,7 +23,7 @@ public class RestartActionDTO extends ActionDTO { private static final String ACTION_TYPE_RESTART = "Restart"; private static final String CONSTANT = "Constant"; - private static final String DEFAULT_RESTART_REASON = "The OpenHAB binding requested to restart the smart home controller."; + private static final String DEFAULT_RESTART_REASON = "The openHAB binding requested to restart the smart home controller."; public RestartActionDTO(String deviceId) { setType(ACTION_TYPE_RESTART); diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java index 875d9680e84e2..6cbd6b657f558 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java @@ -137,7 +137,7 @@ public void handleCommand(final ChannelUID channelUID, final Command command) { } private void commandRestart(Command command) { - if (command instanceof OnOffType && OnOffType.ON.equals(command)) { + if (OnOffType.ON.equals(command)) { commandRestart(); } } @@ -838,7 +838,7 @@ public void commandRestart() { try { client.setRestartAction(bridgeId); - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "Restarting ..."); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "Restarting..."); } catch (IOException e) { handleClientException(e); } diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java index bac5a2693c5ec..4412e6b285d57 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiDeviceHandler.java @@ -225,7 +225,7 @@ private void commandSwitchAlarm(Command command, LivisiBridgeHandler bridgeHandl } private void commandSwitchSiren(Command command, String notificationSound, LivisiBridgeHandler bridgeHandler) { - if (command instanceof OnOffType && OnOffType.ON.equals(command)) { + if (OnOffType.ON.equals(command)) { bridgeHandler.commandSwitchSiren(deviceId, notificationSound); } else { bridgeHandler.commandSwitchSiren(deviceId, SIREN_NONE); diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml index 7512cba8f7062..6bd5f458c93b7 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml @@ -390,7 +390,7 @@ - + Switch Restarts the device From 9345d8b471e987a3adc3dde4e8211ae671202d0a Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Wed, 3 Jul 2024 21:13:29 +0200 Subject: [PATCH 07/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- bundles/org.openhab.binding.livisismarthome/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/bundles/org.openhab.binding.livisismarthome/README.md b/bundles/org.openhab.binding.livisismarthome/README.md index 26030a9c03f33..e0fa1736415cb 100644 --- a/bundles/org.openhab.binding.livisismarthome/README.md +++ b/bundles/org.openhab.binding.livisismarthome/README.md @@ -93,6 +93,7 @@ However, only devices will appear that are added in the LIVISI SmartHome app bef | moldWarning | Switch | Active, if the measured humidity is too low (ON/OFF) | RST, RST2, WRT | | motionCount | Number | Number of detected motions, increases with each detected motion | WMD, WMDO | | operationMode | String | The mode of a thermostat (auto/manual) | RST, RST2, WRT | +| restart | Switch | Restarts the device | SHC (bridge) | | rollershutter | Rollershutter | Controls a roller shutter | ISR2 | | targetTemperature | Number | Sets the target temperature in °C (min 6 °C, max 30 °C) | RST, RST2, WRT | | siren | Switch | Switches the siren (ON/OFF) | SIR | From f9e16fae7a4335e588d21f68e99c49f9d47cdb5f Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sat, 6 Jul 2024 20:16:08 +0200 Subject: [PATCH 08/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../livisismarthome/internal/client/LivisiClient.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/LivisiClient.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/LivisiClient.java index a8dc591413881..4cd049a189ae4 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/LivisiClient.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/LivisiClient.java @@ -32,7 +32,11 @@ import org.eclipse.jetty.http.HttpStatus; import org.openhab.binding.livisismarthome.internal.LivisiBindingConstants; import org.openhab.binding.livisismarthome.internal.client.api.entity.StatusResponseDTO; -import org.openhab.binding.livisismarthome.internal.client.api.entity.action.*; +import org.openhab.binding.livisismarthome.internal.client.api.entity.action.ActionDTO; +import org.openhab.binding.livisismarthome.internal.client.api.entity.action.RestartActionDTO; +import org.openhab.binding.livisismarthome.internal.client.api.entity.action.ShutterActionDTO; +import org.openhab.binding.livisismarthome.internal.client.api.entity.action.ShutterActionType; +import org.openhab.binding.livisismarthome.internal.client.api.entity.action.StateActionSetterDTO; import org.openhab.binding.livisismarthome.internal.client.api.entity.capability.CapabilityDTO; import org.openhab.binding.livisismarthome.internal.client.api.entity.capability.CapabilityStateDTO; import org.openhab.binding.livisismarthome.internal.client.api.entity.device.DeviceDTO; From 1362af6346f11aace10cf56f1a6ddc1dc802b6a8 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sat, 6 Jul 2024 20:16:38 +0200 Subject: [PATCH 09/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../internal/client/api/entity/action/RestartActionDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java index fe9ea91c5dfa0..f086ffb7a5b0e 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/client/api/entity/action/RestartActionDTO.java @@ -17,7 +17,7 @@ /** * Special {@link ActionDTO} to execute a restart. * - * @author Sven Strohschein + * @author Sven Strohschein - Initial contribution */ public class RestartActionDTO extends ActionDTO { From f601e5f58f3d5c98bef53e1fed64aee04eeb5670 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sat, 6 Jul 2024 20:37:09 +0200 Subject: [PATCH 10/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- .../internal/handler/LivisiBridgeHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java index 6cbd6b657f558..1f363d171a23d 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java @@ -19,7 +19,11 @@ import java.net.URI; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; -import java.util.*; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ScheduledExecutorService; From d5f40d81ed48da9ac3dc2283ae6efb6acca00bfd Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sun, 7 Jul 2024 20:42:34 +0200 Subject: [PATCH 11/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- bundles/org.openhab.binding.livisismarthome/README.md | 2 +- .../livisismarthome/internal/handler/LivisiBridgeHandler.java | 3 --- .../src/main/resources/OH-INF/thing/channels.xml | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.livisismarthome/README.md b/bundles/org.openhab.binding.livisismarthome/README.md index e0fa1736415cb..b8071a4661bf3 100644 --- a/bundles/org.openhab.binding.livisismarthome/README.md +++ b/bundles/org.openhab.binding.livisismarthome/README.md @@ -93,7 +93,7 @@ However, only devices will appear that are added in the LIVISI SmartHome app bef | moldWarning | Switch | Active, if the measured humidity is too low (ON/OFF) | RST, RST2, WRT | | motionCount | Number | Number of detected motions, increases with each detected motion | WMD, WMDO | | operationMode | String | The mode of a thermostat (auto/manual) | RST, RST2, WRT | -| restart | Switch | Restarts the device | SHC (bridge) | +| restart | Switch | Restarts the device (stateless switch / auto-update-policy veto) | SHC (bridge) | | rollershutter | Rollershutter | Controls a roller shutter | ISR2 | | targetTemperature | Number | Sets the target temperature in °C (min 6 °C, max 30 °C) | RST, RST2, WRT | | siren | Switch | Switches the siren (ON/OFF) | SIR | diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java index 1f363d171a23d..3c08eaf4f10fd 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java +++ b/bundles/org.openhab.binding.livisismarthome/src/main/java/org/openhab/binding/livisismarthome/internal/handler/LivisiBridgeHandler.java @@ -203,9 +203,6 @@ private void startClient() { scheduleBridgeRefreshJob(bridgeDevice); startWebSocket(bridgeDevice); - - // Update the restart channel to OFF to enable a (new) restart command. - updateState(CHANNEL_RESTART, OnOffType.OFF); } else { logger.debug("Failed to get bridge device, re-scheduling startClient."); scheduleRestartClient(true); diff --git a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml index 6bd5f458c93b7..c3ab274c947a3 100644 --- a/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.livisismarthome/src/main/resources/OH-INF/thing/channels.xml @@ -395,6 +395,7 @@ Restarts the device Switch + veto From 0b07a2f5774b21973a3835bf43e4ffbec028b8c9 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sun, 7 Jul 2024 20:52:30 +0200 Subject: [PATCH 12/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- bundles/org.openhab.binding.livisismarthome/pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.livisismarthome/pom.xml b/bundles/org.openhab.binding.livisismarthome/pom.xml index 28625f44947a3..ccaccaf398fac 100644 --- a/bundles/org.openhab.binding.livisismarthome/pom.xml +++ b/bundles/org.openhab.binding.livisismarthome/pom.xml @@ -1,4 +1,6 @@ - + + 4.0.0 From 9ed326c51b928d66d0e4897629724d45a13ad18f Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Sun, 7 Jul 2024 21:00:20 +0200 Subject: [PATCH 13/14] [livisismarthome] Support for restart added (#16968) Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- bundles/org.openhab.binding.livisismarthome/pom.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.livisismarthome/pom.xml b/bundles/org.openhab.binding.livisismarthome/pom.xml index ccaccaf398fac..28625f44947a3 100644 --- a/bundles/org.openhab.binding.livisismarthome/pom.xml +++ b/bundles/org.openhab.binding.livisismarthome/pom.xml @@ -1,6 +1,4 @@ - - + 4.0.0 From 38539a0fc846f68a514bd5af4d965a02d6141895 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Fri, 27 Dec 2024 21:14:27 +0100 Subject: [PATCH 14/14] [livisismarthome] Support for restart added (#16968) - Readme updated to remove the auto-update veto hint Signed-off-by: Sven Strohschein Signed-off-by: Sven Strohschein --- bundles/org.openhab.binding.livisismarthome/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.livisismarthome/README.md b/bundles/org.openhab.binding.livisismarthome/README.md index b8071a4661bf3..dff62dea5fd11 100644 --- a/bundles/org.openhab.binding.livisismarthome/README.md +++ b/bundles/org.openhab.binding.livisismarthome/README.md @@ -93,7 +93,7 @@ However, only devices will appear that are added in the LIVISI SmartHome app bef | moldWarning | Switch | Active, if the measured humidity is too low (ON/OFF) | RST, RST2, WRT | | motionCount | Number | Number of detected motions, increases with each detected motion | WMD, WMDO | | operationMode | String | The mode of a thermostat (auto/manual) | RST, RST2, WRT | -| restart | Switch | Restarts the device (stateless switch / auto-update-policy veto) | SHC (bridge) | +| restart | Switch | Restarts the device (stateless switch) | SHC (bridge) | | rollershutter | Rollershutter | Controls a roller shutter | ISR2 | | targetTemperature | Number | Sets the target temperature in °C (min 6 °C, max 30 °C) | RST, RST2, WRT | | siren | Switch | Switches the siren (ON/OFF) | SIR |