mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[freeboxos] Fix actions to make them available in DSL rules (#17226)
Also rename actions to avoid name conflicts. Fix #17225 Signed-off-by: Laurent Garnier <lg.hc@free.fr> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
c33c6362ac
commit
338be49c77
@ -211,15 +211,15 @@ The following channels are supported:
|
||||
|
||||
The following actions are available in rules/scripting:
|
||||
|
||||
| Thing Type | Action Name | Parameters | Description |
|
||||
|-------------|------------------|-------------------------|------------------------------------------------------|
|
||||
| host | wol | None | Sends a wake on lan packet to the lan connected host |
|
||||
| player | reboot | None | Reboots the player device |
|
||||
| player | sendKey | key: String | Send a key (remote emulation) to the player |
|
||||
| player | sendLongKey | key: String | Sends the key emulating a longpress on the button |
|
||||
| player | sendMultipleKeys | keys: String | Sends multiple keys to the player, comma separated |
|
||||
| player | sendKeyRepeat | key: String, count: int | Sends the key multiple times |
|
||||
| server | reboot | None | Reboots the Freebox Server |
|
||||
| freeplug | reset | None | Resets the Freeplug |
|
||||
| call | reset | None | Clears the call log queue |
|
||||
| repeater | reboot | None | Reboots the Repeater |
|
||||
| Thing Type | Action Name | Parameters | Description |
|
||||
|-----------------------|------------------|-------------------------|------------------------------------------------------|
|
||||
| host, wifihost | wol | None | Sends a wake on lan packet to the lan connected host |
|
||||
| active-player | rebootPlayer | None | Reboots the Freebox Player |
|
||||
| active-player, player | sendKey | key: String | Sends a key (remote emulation) to the player |
|
||||
| active-player, player | sendLongKey | key: String | Sends a key emulating a longpress on the button |
|
||||
| active-player, player | sendMultipleKeys | keys: String | Sends multiple keys to the player, comma separated |
|
||||
| active-player, player | sendKeyRepeat | key: String, count: int | Sends a key multiple times |
|
||||
| delta, revolution | rebootServer | None | Reboots the Freebox Server |
|
||||
| freeplug | resetPlug | None | Resets the Freeplug |
|
||||
| call | resetCalls | None | Deletes all calls logged in the queue |
|
||||
| repeater | rebootRepeater | None | Reboots the Free Repeater |
|
||||
|
@ -35,7 +35,7 @@ public class ActivePlayerActions extends PlayerActions {
|
||||
private final Logger logger = LoggerFactory.getLogger(ActivePlayerActions.class);
|
||||
|
||||
@RuleAction(label = "reboot freebox player", description = "Reboots the Freebox Player")
|
||||
public void reboot() {
|
||||
public void rebootPlayer() {
|
||||
logger.debug("Player reboot called");
|
||||
PlayerHandler localHandler = this.handler;
|
||||
if (localHandler instanceof ActivePlayerHandler apHandler) {
|
||||
@ -45,7 +45,11 @@ public class ActivePlayerActions extends PlayerActions {
|
||||
}
|
||||
}
|
||||
|
||||
public static void reboot(ThingActions actions) {
|
||||
((ActivePlayerActions) actions).reboot();
|
||||
public static void rebootPlayer(ThingActions actions) {
|
||||
if (actions instanceof ActivePlayerActions activePlayerActions) {
|
||||
activePlayerActions.rebootPlayer();
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not an ActivePlayerActions class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public class CallActions implements ThingActions {
|
||||
return handler;
|
||||
}
|
||||
|
||||
@RuleAction(label = "clear call queue", description = "Delete all call logged in the queue")
|
||||
public void reset() {
|
||||
@RuleAction(label = "clear call queue", description = "Deletes all calls logged in the queue")
|
||||
public void resetCalls() {
|
||||
logger.debug("Call log clear called");
|
||||
CallHandler localHandler = handler;
|
||||
if (localHandler != null) {
|
||||
@ -58,4 +58,12 @@ public class CallActions implements ThingActions {
|
||||
logger.warn("Call Action service ThingHandler is null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetCalls(ThingActions actions) {
|
||||
if (actions instanceof CallActions callActions) {
|
||||
callActions.resetCalls();
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a CallActions class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class FreeplugActions implements ThingActions {
|
||||
}
|
||||
|
||||
@RuleAction(label = "reset freeplug", description = "Resets the Freeplug")
|
||||
public void reset() {
|
||||
public void resetPlug() {
|
||||
logger.debug("Freeplug reset requested");
|
||||
FreeplugHandler plugHandler = this.handler;
|
||||
if (plugHandler != null) {
|
||||
@ -58,4 +58,12 @@ public class FreeplugActions implements ThingActions {
|
||||
logger.warn("Freeplug Action service ThingHandler is null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetPlug(ThingActions actions) {
|
||||
if (actions instanceof FreeplugActions freeplugActions) {
|
||||
freeplugActions.resetPlug();
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a FreeplugActions class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class HostActions implements ThingActions {
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
@RuleAction(label = "wol host", description = "Awakes a lan host")
|
||||
@RuleAction(label = "wol host", description = "Sends a wake on lan packet to the lan connected host")
|
||||
public void wol() {
|
||||
logger.debug("Host WOL called");
|
||||
HostHandler hostHandler = this.handler;
|
||||
@ -58,4 +58,12 @@ public class HostActions implements ThingActions {
|
||||
logger.warn("LanHost Action service ThingHandler is null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void wol(ThingActions actions) {
|
||||
if (actions instanceof HostActions hostActions) {
|
||||
hostActions.wol();
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a HostHandler class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,4 +92,36 @@ public class PlayerActions implements ThingActions {
|
||||
logger.warn("Freebox Player Action service ThingHandler is null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendKey(ThingActions actions, String key) {
|
||||
if (actions instanceof PlayerActions playerActions) {
|
||||
playerActions.sendKey(key);
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a PlayerActions class.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendLongKey(ThingActions actions, String key) {
|
||||
if (actions instanceof PlayerActions playerActions) {
|
||||
playerActions.sendLongKey(key);
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a PlayerActions class.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMultipleKeys(ThingActions actions, String keys) {
|
||||
if (actions instanceof PlayerActions playerActions) {
|
||||
playerActions.sendMultipleKeys(keys);
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a PlayerActions class.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendKeyRepeat(ThingActions actions, String key, int count) {
|
||||
if (actions instanceof PlayerActions playerActions) {
|
||||
playerActions.sendKeyRepeat(key, count);
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a PlayerActions class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class RepeaterActions implements ThingActions {
|
||||
}
|
||||
|
||||
@RuleAction(label = "reboot free repeater", description = "Reboots the Free Repeater")
|
||||
public void reboot() {
|
||||
public void rebootRepeater() {
|
||||
logger.debug("Repeater reboot called");
|
||||
RepeaterHandler localHandler = this.handler;
|
||||
if (localHandler != null) {
|
||||
@ -58,4 +58,12 @@ public class RepeaterActions implements ThingActions {
|
||||
logger.warn("Repeater Action service ThingHandler is null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void rebootRepeater(ThingActions actions) {
|
||||
if (actions instanceof RepeaterActions repeaterActions) {
|
||||
repeaterActions.rebootRepeater();
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a RepeaterActions class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,13 +49,21 @@ public class ServerActions implements ThingActions {
|
||||
}
|
||||
|
||||
@RuleAction(label = "reboot freebox server", description = "Reboots the Freebox Server")
|
||||
public void reboot() {
|
||||
public void rebootServer() {
|
||||
logger.debug("Server reboot called");
|
||||
ServerHandler serverHandler = this.handler;
|
||||
if (serverHandler != null) {
|
||||
serverHandler.reboot();
|
||||
} else {
|
||||
logger.warn("Freebox Action service ThingHandler is null");
|
||||
logger.warn("Freebox Server Action service ThingHandler is null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void rebootServer(ThingActions actions) {
|
||||
if (actions instanceof ServerActions serverActions) {
|
||||
serverActions.rebootServer();
|
||||
} else {
|
||||
throw new IllegalArgumentException("actions parameter is not a ServerActions class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user