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.freeboxos.internal.action;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.freeboxos.internal.handler.CallHandler;
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.osgi.service.component.annotations.Component;
23 import org.osgi.service.component.annotations.ServiceScope;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * The {FreeplugActions} class is responsible to call corresponding actions on Freeplugs
30 * @author Gaƫl L'hopital - Initial contribution
32 @Component(scope = ServiceScope.PROTOTYPE, service = CallActions.class)
33 @ThingActionsScope(name = "freeboxos")
35 public class CallActions implements ThingActions {
36 private final Logger logger = LoggerFactory.getLogger(CallActions.class);
37 private @Nullable CallHandler handler;
40 public void setThingHandler(@Nullable ThingHandler handler) {
41 if (handler instanceof CallHandler callHandler) {
42 this.handler = callHandler;
47 public @Nullable ThingHandler getThingHandler() {
51 @RuleAction(label = "clear call queue", description = "Delete all call logged in the queue")
53 logger.debug("Call log clear called");
54 CallHandler localHandler = handler;
55 if (localHandler != null) {
56 localHandler.emptyQueue();
58 logger.warn("Call Action service ThingHandler is null");