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

Add support for more types as output of thing actions #4435

Merged

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Oct 30, 2024

Byte
Short
Long
BigDecimal
QuantityType
LocalDate
LocalTime
LocalDateTime
ZonedDateTime
Instant
Duration

@lolodomo lolodomo requested a review from a team as a code owner October 30, 2024 23:08
@lolodomo lolodomo marked this pull request as draft October 31, 2024 06:55
@lolodomo lolodomo marked this pull request as ready for review October 31, 2024 07:45
@lolodomo
Copy link
Contributor Author

lolodomo commented Nov 2, 2024

@florian-h05 : why not simply using this for all other types ?

output.put(MODULE_RESULT, result.toString());

This would avoid the warning "Non compatible return type" and would provide descent result for date or time types for example ?

@lolodomo lolodomo marked this pull request as draft November 2, 2024 09:15
@florian-h05
Copy link
Contributor

why not simply using this for all other types ?

A. Not all data types implement proper toString().
B. Keep in mind this is also what is used when adding Thing actions to UI-based rules, where one needs to be able to do something useful with the output string.

I would rather only convert selected data types to string, those would be QuantityType, LocalTime, LocalDate, LocalDateTime, ZonedDateTime (we can add more, just to mention a few).

@lolodomo lolodomo force-pushed the thingaction_BigDecimal_output branch from 612eabb to df9fdbd Compare November 2, 2024 17:17
Byte
Short
Long
BigDecimal
QuantityType
LocalDate
LocalTime
LocalDateTime
ZonedDateTime
Instant
Duration

Signed-off-by: Laurent Garnier <[email protected]>
@lolodomo lolodomo force-pushed the thingaction_BigDecimal_output branch from df9fdbd to 8cdb914 Compare November 2, 2024 17:18
@lolodomo lolodomo changed the title Accept BigDecimal as output type of a Thing action Add support for more types as output of thing actions Nov 2, 2024
@lolodomo
Copy link
Contributor Author

lolodomo commented Nov 2, 2024

@florian-h05 : I added few more types. Tested for each of them.

@lolodomo lolodomo marked this pull request as ready for review November 2, 2024 17:20
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

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

One comment, otherwise LGTM.

@lolodomo lolodomo force-pushed the thingaction_BigDecimal_output branch from e584ac8 to 84e973e Compare November 2, 2024 20:35
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks!

@lolodomo lolodomo force-pushed the thingaction_BigDecimal_output branch from 84e973e to 774af21 Compare November 2, 2024 20:45
Signed-off-by: Laurent Garnier <[email protected]>
@lolodomo lolodomo force-pushed the thingaction_BigDecimal_output branch from 774af21 to 9d03fc6 Compare November 2, 2024 20:48
Copy link
Member

@holgerfriedrich holgerfriedrich left a comment

Choose a reason for hiding this comment

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

LGTM

@holgerfriedrich holgerfriedrich merged commit bc67311 into openhab:main Nov 4, 2024
5 checks passed
@holgerfriedrich holgerfriedrich added the enhancement An enhancement or new feature of the Core label Nov 4, 2024
@holgerfriedrich holgerfriedrich added this to the 4.3 milestone Nov 4, 2024
@lolodomo lolodomo deleted the thingaction_BigDecimal_output branch November 4, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants