Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[a-d] Fix @ActionOutput annotations #17644

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "get the azimuth", description = "Get the azimuth for a given time.")
public @Nullable @ActionOutput(name = "getAzimuth", label = "Azimuth", type = "org.openhab.core.library.types.QuantityType<javax.measure.quantity.Angle>") QuantityType<Angle> getAzimuth(
public @Nullable @ActionOutput(name = "result", label = "Azimuth", type = "org.openhab.core.library.types.QuantityType<javax.measure.quantity.Angle>") QuantityType<Angle> getAzimuth(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lolodomo Just FYI, it should be possible to leave out the name as it now defaults to result inside the core code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsiepel @florian-h05 : your suggestion is to set name parameters or not ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to not set names for actions with a single output.

Copy link
Contributor

@lsiepel lsiepel Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a little redundant, but also less error prone to have them explicitly set. I'm fine with either one, as long as we are consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's choose to not include name.

@ActionInput(name = "date", label = "Date", required = false, description = "Considered date") @Nullable ZonedDateTime date) {
logger.debug("Astro action 'getAzimuth' called");
AstroThingHandler theHandler = this.handler;
Expand All @@ -79,7 +79,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "get the elevation", description = "Get the elevation for a given time.")
public @Nullable @ActionOutput(name = "getElevation", label = "Elevation", type = "org.openhab.core.library.types.QuantityType<javax.measure.quantity.Angle>") QuantityType<Angle> getElevation(
public @Nullable @ActionOutput(name = "result", label = "Elevation", type = "org.openhab.core.library.types.QuantityType<javax.measure.quantity.Angle>") QuantityType<Angle> getElevation(
@ActionInput(name = "date", label = "Date", required = false, description = "Considered date") @Nullable ZonedDateTime date) {
logger.debug("Astro action 'getElevation' called");
AstroThingHandler theHandler = this.handler;
Expand All @@ -92,7 +92,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "get the total sun radiation", description = "Get the total sun radiation for a given time.")
public @Nullable @ActionOutput(name = "getTotalRadiation", label = "Total Radiation", type = "org.openhab.core.library.types.QuantityType<org.openhab.core.library.dimension.Intensity>") QuantityType<Intensity> getTotalRadiation(
public @Nullable @ActionOutput(name = "result", label = "Total Radiation", type = "org.openhab.core.library.types.QuantityType<org.openhab.core.library.dimension.Intensity>") QuantityType<Intensity> getTotalRadiation(
@ActionInput(name = "date", label = "Date", required = false, description = "Considered date") @Nullable ZonedDateTime date) {
logger.debug("Astro action 'getTotalRadiation' called");
AstroThingHandler theHandler = this.handler;
Expand All @@ -110,7 +110,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "get the date time of a sun event", description = "Get the date time of a sun event.")
public @Nullable @ActionOutput(name = "getEventTime", type = "java.time.ZonedDateTime") ZonedDateTime getEventTime(
public @Nullable @ActionOutput(name = "result", label = "Event Time", type = "java.time.ZonedDateTime") ZonedDateTime getEventTime(
@ActionInput(name = "phaseName", label = "Phase", required = true, description = "Requested phase") String phaseName,
@ActionInput(name = "date", label = "Date", required = false, description = "Considered date") @Nullable ZonedDateTime date,
@ActionInput(name = "moment", label = "Moment", required = false, defaultValue = "START", description = "Either START or END") @Nullable String moment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ChromecastActions implements ThingActions {
private @Nullable ChromecastHandler handler;

@RuleAction(label = "@text/playURLActionLabel", description = "@text/playURLActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean playURL(
public @ActionOutput(name = "result", label = "Success", type = "java.lang.Boolean") Boolean playURL(
@ActionInput(name = "url") @Nullable String url) {
if (url == null) {
logger.warn("Cannot Play as URL is missing.");
Expand All @@ -58,7 +58,7 @@ public class ChromecastActions implements ThingActions {
}

@RuleAction(label = "@text/playURLTypeActionLabel", description = "@text/playURLTypeActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean playURL(
public @ActionOutput(name = "result", label = "Success", type = "java.lang.Boolean") Boolean playURL(
@ActionInput(name = "url") @Nullable String url,
@ActionInput(name = "mediaType") @Nullable String mediaType) {
if (url == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.openhab.binding.deconz.internal.handler.GroupThingHandler;
import org.openhab.core.automation.annotation.ActionInput;
import org.openhab.core.automation.annotation.ActionOutput;
import org.openhab.core.automation.annotation.ActionOutputs;
import org.openhab.core.automation.annotation.RuleAction;
import org.openhab.core.thing.binding.ThingActions;
import org.openhab.core.thing.binding.ThingActionsScope;
Expand Down Expand Up @@ -59,8 +60,9 @@ public class GroupActions implements ThingActions {
private @Nullable GroupThingHandler handler;

@RuleAction(label = "@text/action.create-scene.label", description = "@text/action.create-scene.description")
public @ActionOutput(name = NEW_SCENE_ID_OUTPUT, type = "java.lang.Integer") Map<String, Object> createScene(
@ActionInput(name = "name", label = "@text/action.create-scene.name.label", description = "@text/action.create-scene.name.description") @Nullable String name) {
public @ActionOutputs({
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
@ActionOutput(name = NEW_SCENE_ID_OUTPUT, label = "Scene Id", type = "java.lang.Integer") }) Map<String, Object> createScene(
@ActionInput(name = "name", label = "@text/action.create-scene.name.label", description = "@text/action.create-scene.name.description") @Nullable String name) {
GroupThingHandler handler = this.handler;

if (handler == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static void sipHangup(ThingActions actions) {
}

@RuleAction(label = "get the ring time limit", description = "Get the value of RING_TIME_LIMIT.")
public @ActionOutput(name = "getRingTimeLimit", type = "java.lang.String") String getRingTimeLimit() {
public @ActionOutput(name = "result", label = "Ring Time Limit", type = "java.lang.String") String getRingTimeLimit() {
logger.debug("Doorbird action 'getRingTimeLimit' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
Expand All @@ -101,7 +101,7 @@ public static String getRingTimeLimit(ThingActions actions) {
}

@RuleAction(label = "get the call time limit", description = "Get the value of CALL_TIME_LIMIT.")
public @ActionOutput(name = "getCallTimeLimit", type = "java.lang.String") String getCallTimeLimit() {
public @ActionOutput(name = "result", label = "Call Time Limit", type = "java.lang.String") String getCallTimeLimit() {
logger.debug("Doorbird action 'getCallTimeLimit' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
Expand All @@ -117,7 +117,7 @@ public static String getCallTimeLimit(ThingActions actions) {
}

@RuleAction(label = "get the last error code", description = "Get the value of LASTERRORCODE.")
public @ActionOutput(name = "getLastErrorCode", type = "java.lang.String") String getLastErrorCode() {
public @ActionOutput(name = "result", label = "Last Error Code", type = "java.lang.String") String getLastErrorCode() {
logger.debug("Doorbird action 'getLastErrorCode' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
Expand All @@ -133,7 +133,7 @@ public static String getLastErrorCode(ThingActions actions) {
}

@RuleAction(label = "get the last error text", description = "Get the value of LASTERRORTEXT.")
public @ActionOutput(name = "getLastErrorText", type = "java.lang.String") String getLastErrorText() {
public @ActionOutput(name = "result", label = "Last Error Text", type = "java.lang.String") String getLastErrorText() {
logger.debug("Doorbird action 'getLastErrorText' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
Expand Down