2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.caddx.internal.action;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.caddx.internal.handler.CaddxBridgeHandler;
18 import org.openhab.core.automation.annotation.RuleAction;
19 import org.openhab.core.thing.binding.ThingActions;
20 import org.openhab.core.thing.binding.ThingActionsScope;
21 import org.openhab.core.thing.binding.ThingHandler;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * This is the automation engine action handler service for the
27 * caddx bridge actions.
29 * @author Georgios Moutsos - Initial contribution
31 @ThingActionsScope(name = "caddx")
33 public class CaddxBridgeActions implements ThingActions {
34 private final Logger logger = LoggerFactory.getLogger(CaddxBridgeActions.class);
36 private static final String HANDLER_IS_NULL = "CaddxBridgeHandler is null!";
37 private @Nullable CaddxBridgeHandler handler;
40 public void setThingHandler(@Nullable ThingHandler handler) {
41 if (handler instanceof CaddxBridgeHandler) {
42 this.handler = (CaddxBridgeHandler) handler;
47 public @Nullable ThingHandler getThingHandler() {
51 @RuleAction(label = "restart", description = "Restart the binding")
52 public void restart() {
53 // Check of parameters
54 CaddxBridgeHandler handler = this.handler;
55 if (handler == null) {
56 logger.debug(HANDLER_IS_NULL);
63 public static void restart(ThingActions actions) {
64 ((CaddxBridgeActions) actions).restart();