]> git.basschouten.com Git - openhab-addons.git/blob
1023aff99856b98a3314926887a22066e7b52d7c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.openhab.binding.freeboxos.internal.handler.ActivePlayerHandler;
17 import org.openhab.binding.freeboxos.internal.handler.PlayerHandler;
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.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * The {ActivePlayerActions} class is responsible to call corresponding actions on Freebox Player with API
26  *
27  * @author GaĆ«l L'hopital - Initial contribution
28  */
29 @ThingActionsScope(name = "freeboxos")
30 @NonNullByDefault
31 public class ActivePlayerActions extends PlayerActions {
32     private final Logger logger = LoggerFactory.getLogger(ActivePlayerActions.class);
33
34     @RuleAction(label = "reboot freebox player", description = "Reboots the Freebox Player")
35     public void reboot() {
36         logger.debug("Player reboot called");
37         PlayerHandler localHandler = this.handler;
38         if (localHandler instanceof ActivePlayerHandler apHandler) {
39             apHandler.reboot();
40         } else {
41             logger.warn("Freebox Player Action service ThingHandler is null");
42         }
43     }
44
45     public static void reboot(ThingActions actions) {
46         ((ActivePlayerActions) actions).reboot();
47     }
48 }