Skip to content

Bugfix/154 colorstate comparison fails when comparing with null values#155

Open
DivineThreepwood wants to merge 3 commits intodevfrom
bugfix/154-colorstate-comparison-fails-when-comparing-with-null-values
Open

Bugfix/154 colorstate comparison fails when comparing with null values#155
DivineThreepwood wants to merge 3 commits intodevfrom
bugfix/154-colorstate-comparison-fails-when-comparing-with-null-values

Conversation

@DivineThreepwood
Copy link
Member

📜 Description

Changes proposed in this pull request:

  • fix color state equals check
    • fix home assistant initial color lamp sync issue between hass and bco with it..
  • handle hue values 0 and 360 as equals
  • implement tests to prove implementation

✅ Checklist:

  • Created tests which fail without the change

@DivineThreepwood DivineThreepwood linked an issue Feb 18, 2026 that may be closed by this pull request
@netlify
Copy link

netlify bot commented Feb 18, 2026

Deploy Preview for basecubeone canceled.

Name Link
🔨 Latest commit 3ad5f9f
🔍 Latest deploy log https://app.netlify.com/projects/basecubeone/deploys/6996383313e4fb000788a09e

@DivineThreepwood DivineThreepwood added the preview Auto build a docker image and deploy it as a preview version. label Feb 18, 2026
boolean saturationEquals = true;
boolean brightnessEquals = true;
// normalize angle to [0,360)
java.util.function.DoubleUnaryOperator normalize = (v) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we import DoubleUnaryOperator?


if(hsbColorA.hasHue() && hsbColorB.hasHue()) {
hueEquals = OperationService.equals(hsbColorA.getHue(), hsbColorB.getHue(), 1.0);
java.util.function.BiPredicate<Double, Double> hueEqualsWithWrap = (ha, hb) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

here as well

@Test
@Timeout(10)
@Throws(VerificationFailedException::class, JPServiceException::class)
fun verifyColorState() {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this test not named with fun ``?


class ColorStateProviderServiceTest {
@Test
@Timeout(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the timeout necessary? Is this test time sensitive?

class ColorStateProviderServiceTest {
@Test
@Timeout(10)
@Throws(VerificationFailedException::class, JPServiceException::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using assertThrows where needed

val verifiedColorState = ColorStateProviderService.verifyColorState(builder.build())
ExceptionPrinter.setBeQuit(false)

Assertions.assertEquals(
Copy link
Contributor

Choose a reason for hiding this comment

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

In other Test we prefer shouldBeEqual. I think we should also switch this here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Auto build a docker image and deploy it as a preview version. ready to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ColorState comparison fails when comparing with null values

2 participants

Comments