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

[DSL] Expose ColorUtil methods to DSL rules #3749

Merged
merged 1 commit into from
Sep 2, 2023

Conversation

lolodomo
Copy link
Contributor

Fix #3743

Signed-off-by: Laurent Garnier [email protected]

@lolodomo lolodomo requested a review from a team as a code owner August 11, 2023 19:27
@lolodomo lolodomo marked this pull request as draft August 11, 2023 19:27
@lolodomo
Copy link
Contributor Author

With the following rule:

rule "ColorItem Changes"
when
	Item TestColor changed
then
	val hsbValue = TestColor.state as HSBType
	val rgb = hsbToRgb(hsbValue)
	logInfo("TestColor", "RGB: {},{},{}", rgb.get(0), rgb.get(1), rgb.get(2))
end

here is the result when I select color with the color picker:

21:31:25.729 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'TestColor' received command 137,57,100
21:31:25.736 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'TestColor' changed from 0,0,100 to 137,57,100
21:31:25.794 [INFO ] [g.openhab.core.model.script.TestColor] - RGB: 110,255,151
21:31:28.775 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'TestColor' received command 244,70,100
21:31:28.791 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'TestColor' changed from 137,57,100 to 244,70,100
21:31:28.791 [INFO ] [g.openhab.core.model.script.TestColor] - RGB: 88,77,255
21:31:31.354 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'TestColor' received command 346,31,100
21:31:31.367 [INFO ] [g.openhab.core.model.script.TestColor] - RGB: 255,176,194
21:31:31.366 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'TestColor' changed from 244,70,100 to 346,31,100

@lolodomo lolodomo marked this pull request as ready for review August 12, 2023 08:55
@lolodomo
Copy link
Contributor Author

Once merged, I will create a PR to enhance the openHAB documentation.

@jsetton
Copy link

jsetton commented Sep 1, 2023

Any chance this PR gets merged?

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@kaikreuzer kaikreuzer merged commit 1c8096b into openhab:main Sep 2, 2023
2 checks passed
@kaikreuzer kaikreuzer added the enhancement An enhancement or new feature of the Core label Sep 2, 2023
@kaikreuzer kaikreuzer added this to the 4.1 milestone Sep 2, 2023
@lolodomo lolodomo deleted the ColorUtil_DSL branch September 3, 2023 18:32
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Nov 12, 2023
Related to openhab/openhab-core#3749

Signed-off-by: Laurent Garnier <[email protected]>
stefan-hoehn pushed a commit to openhab/openhab-docs that referenced this pull request Nov 19, 2023
* Add color utils actions

Related to openhab/openhab-core#3749

Signed-off-by: Laurent Garnier <[email protected]>

* Review comment: remove a blank line

Signed-off-by: Laurent Garnier <[email protected]>

---------

Signed-off-by: Laurent Garnier <[email protected]>
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.

[DSL] Cannot import org.openhab.core.util namespace
3 participants