Skip to content

Migrate zwave_js light tests to use Kelvin#133034

Merged
frenck merged 1 commit into
devfrom
epenet-20241212-1302
Dec 12, 2024
Merged

Migrate zwave_js light tests to use Kelvin#133034
frenck merged 1 commit into
devfrom
epenet-20241212-1302

Conversation

@epenet
Copy link
Copy Markdown
Contributor

@epenet epenet commented Dec 12, 2024

Proposed change

Based on #79591, needed for #132680

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @home-assistant/z-wave, mind taking a look at this pull request as it has been labeled with an integration (zwave_js) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zwave_js can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign zwave_js Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@epenet epenet added the smash Indicator this PR is close to finish for merging or closing label Dec 12, 2024
Copy link
Copy Markdown
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @epenet 👍

../Frenck

@frenck frenck merged commit e276f8e into dev Dec 12, 2024
@frenck frenck deleted the epenet-20241212-1302 branch December 12, 2024 19:32
assert state.attributes[ATTR_COLOR_MODE] == "color_temp"
assert state.attributes[ATTR_BRIGHTNESS] == 255
assert state.attributes[ATTR_COLOR_TEMP] == 370
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 2702
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is it 2702 instead of 2700 as above?

Copy link
Copy Markdown
Contributor Author

@epenet epenet Dec 13, 2024

Choose a reason for hiding this comment

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

2700 above is the "min kelvin" which gets set once

_attr_min_color_temp_kelvin = 2700 # 370 mireds as a safe default
_attr_max_color_temp_kelvin = 6500 # 153 mireds as a safe default

2702 is the current value from the integration (looks like a % ratio converted to mireds)

self._color_temp = color_util.color_temperature_mired_to_kelvin(
MAX_MIREDS - ((cold_white / 255) * (MAX_MIREDS - MIN_MIREDS))
)

I see three options:

  • the current code is kept with slight rounding discrepencies
  • we can change the min/max from 2700/6500 to 2702/6535 to more closely match the previous defaults
  • the formula is changed so the % ratio is based on Kelvin and not Mireds

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd use numbers in the tests that make sense when using Kelvin. It looks weird at the moment.

@github-actions github-actions Bot locked and limited conversation to collaborators Dec 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed code-quality has-tests integration: zwave_js Quality Scale: No score small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants