]> git.basschouten.com Git - openhab-addons.git/blob
355f5c8e53c39da1d64c3fa9069de37c155cecc8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.yioremote.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.automation.annotation.ActionInput;
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
23 /**
24  * The {@link YIOremoteDockActions} is responsible for handling the action commands
25  *
26  *
27  * @author Michael Loercher - Initial contribution
28  */
29 @ThingActionsScope(name = "yioremote")
30 @NonNullByDefault
31 public class YIOremoteDockActions implements ThingActions {
32     private @Nullable YIOremoteDockHandler dockHandler;
33
34     @Override
35     public void setThingHandler(@Nullable ThingHandler yiremotedockhandler) {
36         dockHandler = (YIOremoteDockHandler) yiremotedockhandler;
37     }
38
39     @Override
40     public @Nullable ThingHandler getThingHandler() {
41         return dockHandler;
42     }
43
44     @RuleAction(label = "@text/actionLabel", description = "@text/actionDesc")
45     public void sendIRCode(
46             @ActionInput(name = "IRCode", label = "@text/actionInputTopicLabel", description = "@text/actionInputTopicDesc") @Nullable String irCode) {
47         YIOremoteDockHandler dockHandlerLocal = dockHandler;
48         if (dockHandlerLocal != null) {
49             dockHandlerLocal.sendIRCode(irCode);
50         }
51     }
52
53     public static void sendIRCode(ThingActions actions, @Nullable String irCode) {
54         ((YIOremoteDockActions) actions).sendIRCode(irCode);
55     }
56 }