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.gce.internal.action;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.gce.internal.handler.Ipx800v3Handler;
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;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * Defines rule actions for the GCE binding.
29 * @author Gaƫl L'hopital - Initial contribution
31 @ThingActionsScope(name = "gce")
33 public class Ipx800Actions implements ThingActions {
34 private final Logger logger = LoggerFactory.getLogger(Ipx800Actions.class);
36 protected @Nullable Ipx800v3Handler handler;
38 public Ipx800Actions() {
39 logger.debug("IPX800 actions service instanciated");
43 public void setThingHandler(@Nullable ThingHandler handler) {
44 if (handler instanceof Ipx800v3Handler ipx800v3Handler) {
45 this.handler = ipx800v3Handler;
50 public @Nullable ThingHandler getThingHandler() {
54 @RuleAction(label = "reset a counter", description = "Resets to 0 value of a given counter.")
55 public void resetCounter(
56 @ActionInput(name = "counter", label = "Counter", required = true, description = "Id of the counter", type = "java.lang.Integer") Integer counter) {
57 logger.debug("IPX800 action 'resetCounter' called");
58 Ipx800v3Handler theHandler = this.handler;
59 if (theHandler != null) {
60 theHandler.resetCounter(counter);
62 logger.warn("Method call resetCounter failed because IPX800 action service ThingHandler is null!");
66 @RuleAction(label = "reset the PLC", description = "Restarts the IPX800.")
68 @ActionInput(name = "placeholder", label = "Placeholder", required = false, description = "This parameter is not used", type = "java.lang.Integer") @Nullable Integer placeholder) {
69 logger.debug("IPX800 action 'reset' called");
70 Ipx800v3Handler theHandler = this.handler;
71 if (theHandler != null) {
74 logger.warn("Method call reset failed because IPX800 action service ThingHandler is null!");
78 public static void resetCounter(ThingActions actions, Integer counter) {
79 ((Ipx800Actions) actions).resetCounter(counter);
82 public static void reset(ThingActions actions, @Nullable Integer placeholder) {
83 ((Ipx800Actions) actions).reset(placeholder);