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.avmfritz.internal.actions;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.avmfritz.internal.handler.AVMFritzHeatingActionsHandler;
18 import org.openhab.core.automation.annotation.ActionInput;
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;
25 * The {@link AVMFritzHeatingActions} defines thing actions for heating devices / groups of the avmfritz binding.
27 * @author Christoph Weitkamp - Initial contribution
29 @ThingActionsScope(name = "avmfritz")
31 public class AVMFritzHeatingActions implements ThingActions {
33 private @Nullable AVMFritzHeatingActionsHandler handler;
36 public void setThingHandler(@Nullable ThingHandler handler) {
37 this.handler = (AVMFritzHeatingActionsHandler) handler;
41 public @Nullable ThingHandler getThingHandler() {
45 @RuleAction(label = "@text/setBoostModeModeActionLabel", description = "@text/setBoostModeActionDescription")
46 public void setBoostMode(
47 @ActionInput(name = "Duration", label = "@text/setBoostModeDurationInputLabel", description = "@text/setBoostModeDurationInputDescription", type = "java.lang.Long", required = true) @Nullable Long duration) {
48 AVMFritzHeatingActionsHandler actionsHandler = handler;
49 if (actionsHandler == null) {
50 throw new IllegalArgumentException("AVMFritzHeatingActions ThingHandler is null!");
52 if (duration == null) {
53 throw new IllegalArgumentException("Cannot set Boost mode as 'duration' is null!");
55 actionsHandler.setBoostMode(duration.longValue());
58 public static void setBoostMode(ThingActions actions, @Nullable Long duration) {
59 ((AVMFritzHeatingActions) actions).setBoostMode(duration);
62 @RuleAction(label = "@text/setWindowOpenModeActionLabel", description = "@text/setWindowOpenModeActionDescription")
63 public void setWindowOpenMode(
64 @ActionInput(name = "Duration", label = "@text/setWindowOpenModeDurationInputLabel", description = "@text/setWindowOpenModeDurationInputDescription", type = "java.lang.Long", required = true) @Nullable Long duration) {
65 AVMFritzHeatingActionsHandler actionsHandler = handler;
66 if (actionsHandler == null) {
67 throw new IllegalArgumentException("AVMFritzHeatingActions ThingHandler is null!");
69 if (duration == null) {
70 throw new IllegalArgumentException("Cannot set Window Open mode as 'duration' is null!");
72 actionsHandler.setWindowOpenMode(duration.longValue());
75 public static void setWindowOpenMode(ThingActions actions, @Nullable Long duration) {
76 ((AVMFritzHeatingActions) actions).setWindowOpenMode(duration);