]> git.basschouten.com Git - openhab-addons.git/blob
1921a1a17059216652a9763d3c9b6c91d0d4013b
[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.freeboxos.internal.action;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.freeboxos.internal.handler.RepeaterHandler;
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.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * The {RepeaterActions} class is responsible to call corresponding actions on Freebox Repeater
27  *
28  * @author GaĆ«l L'hopital - Initial contribution
29  */
30 @ThingActionsScope(name = "freeboxos")
31 @NonNullByDefault
32 public class RepeaterActions implements ThingActions {
33     private final Logger logger = LoggerFactory.getLogger(RepeaterActions.class);
34     private @Nullable RepeaterHandler handler;
35
36     @Override
37     public void setThingHandler(@Nullable ThingHandler handler) {
38         if (handler instanceof RepeaterHandler repeaterHandler) {
39             this.handler = repeaterHandler;
40         }
41     }
42
43     @Override
44     public @Nullable ThingHandler getThingHandler() {
45         return handler;
46     }
47
48     @RuleAction(label = "reboot free repeater", description = "Reboots the Free Repeater")
49     public void reboot() {
50         logger.debug("Repeater reboot called");
51         RepeaterHandler localHandler = this.handler;
52         if (localHandler != null) {
53             localHandler.reboot();
54         } else {
55             logger.warn("Repeater Action service ThingHandler is null");
56         }
57     }
58 }