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 conversion for HSB to RGBW and back #3849

Merged
merged 9 commits into from
Nov 12, 2023
Merged

Add conversion for HSB to RGBW and back #3849

merged 9 commits into from
Nov 12, 2023

Conversation

genesis81
Copy link
Contributor

For KNX DPT251.600 to use all 4 colors.

With the new feature, the HSBType can converted into RGBW, and also back to HSB.

Due to the conversion, some accuracy is lost, but the result is approximately correct.

@genesis81 genesis81 requested a review from a team as a code owner October 17, 2023 21:22
@genesis81 genesis81 changed the title Add conversion for HSB to RGBW and back [core] Add conversion for HSB to RGBW and back Oct 17, 2023
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. Looks like a useful addition. I have left some comments.

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.

Hi @genesis81, it is good to introduce RGBW as well.

I have added my thoughts regarding style, but also regarding the interfaces an how this fits to the existing methods for RGB.

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.

thanks, just a few last comments....

@genesis81
Copy link
Contributor Author

thanks, just a few last comments....

No problem, i add the points. Thanks for review.

@genesis81 genesis81 requested a review from J-N-K November 9, 2023 20:45
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, thanks.

Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

I only left some comments regarding the variable naming. Please also adjust that in the other direction. Once that is done, we are good to go. Please make sure that all names start with a lower case letter.

for KNX DPT251.600 to use all 4 colors.

With the new feature, the HSBType can converted into RGBW, and also back
to HSB.

Due to the conversion, some accuracy is lost, but the result is
approximately correct.

Signed-off-by: Marco Müller <[email protected]>
Signed-off-by: Marco Müller <[email protected]>
Signed-off-by: Marco Müller <[email protected]>
Signed-off-by: Marco Müller <[email protected]>
Signed-off-by: Marco Müller <[email protected]>
Signed-off-by: Marco Müller <[email protected]>
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

hsbToRgbwPercent looks good now. As I said in my last review: please also apply that to rgbwToHsb.

Signed-off-by: Marco Müller <[email protected]>
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

Thanks!

@J-N-K J-N-K added the enhancement An enhancement or new feature of the Core label Nov 12, 2023
@J-N-K J-N-K added this to the 4.1 milestone Nov 12, 2023
@J-N-K J-N-K merged commit 237f2eb into openhab:main Nov 12, 2023
3 checks passed
@J-N-K J-N-K changed the title [core] Add conversion for HSB to RGBW and back Add conversion for HSB to RGBW and back Nov 12, 2023
holgerfriedrich added a commit to holgerfriedrich/openhab-core that referenced this pull request Nov 21, 2023
New functions for RGBW introduced in openhab#3849.

Signed-off-by: Holger Friedrich <[email protected]>
kaikreuzer pushed a commit that referenced this pull request Nov 22, 2023
New functions for RGBW introduced in #3849.

Signed-off-by: Holger Friedrich <[email protected]>
}

/**
* Transform <a href="https://en.wikipedia.org/wiki/HSL_and_HSV">HSV</a> based {@link HSBType} to RGBW.
Copy link
Contributor

Choose a reason for hiding this comment

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

I just found this PR and was interested because I think this method could be used instead of doing two passes here:
https://github.com/openhab/openhab-addons/blob/a13fd80bfe5cf0b6c55e13756f42abc27b55796b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewRepeaterHandler.java#L264-L265

Anyway, commenting because this description seems to be copied from the method for the other direction. This one is RGBW to HSBType.

Copy link
Member

Choose a reason for hiding this comment

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

thanks, included in #3882

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/hue-bulb-changing-color-wrongly-when-brightness-is-0/154005/8

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.

5 participants