Also rename actions to avoid name conflicts.
Fix #17225
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
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 |
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) {
}
}
- 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.");
+ }
}
}
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) {
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.");
+ }
+ }
}
}
@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) {
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.");
+ }
+ }
}
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;
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.");
+ }
+ }
}
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.");
+ }
+ }
}
}
@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) {
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.");
+ }
+ }
}
}
@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.");
}
}
}