2 * Copyright (c) 2010-2024 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.max.internal.actions;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.max.internal.handler.MaxDevicesHandler;
18 import org.openhab.core.automation.annotation.ActionOutput;
19 import org.openhab.core.automation.annotation.RuleAction;
20 import org.openhab.core.thing.binding.ThingActions;
21 import org.openhab.core.thing.binding.ThingActionsScope;
22 import org.openhab.core.thing.binding.ThingHandler;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * The {@link MaxDevicesActions} class defines rule actions for MAX! devices
29 * @author Christoph Weitkamp - Initial contribution
31 @ThingActionsScope(name = "max-devices")
33 public class MaxDevicesActions implements ThingActions {
35 private final Logger logger = LoggerFactory.getLogger(MaxDevicesActions.class);
37 private @Nullable MaxDevicesHandler handler;
40 public void setThingHandler(@Nullable ThingHandler handler) {
41 if (handler instanceof MaxDevicesHandler devicesHandler) {
42 this.handler = devicesHandler;
47 public @Nullable ThingHandler getThingHandler() {
51 @RuleAction(label = "delete the device from the Cube", description = "Deletes the device from the MAX! Cube. Device will need to be included again!")
52 public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean deleteFromCube() {
53 MaxDevicesHandler actionsHandler = handler;
54 if (actionsHandler == null) {
55 logger.info("MaxDevicesActions: Action service ThingHandler is null!");
58 actionsHandler.deviceDelete();
62 public static boolean deleteFromCube(ThingActions actions) {
63 return ((MaxDevicesActions) actions).deleteFromCube();