Repository navigation
Map color temperature onto 6500–2000 K instead of 1–300 mireds - #31
Open
stefan-schweiger wants to merge 1 commit into
Open
stefan-schweiger wants to merge 1 commit into
stefan-schweiger wants to merge 1 commit into
Conversation
Homey's light_temperature (0 coldest, 1 warmest) was mapped onto 1–300 mireds, which controllers show as roughly 3,333 K to 1,000,000 K. Map it onto 153–500 mireds (6,500 K to 2,000 K) instead, in both directions, with 4,000 K for lights without a temperature yet. Matter.js restores a stored color temperature over the Endpoint's properties, so a value stored with the old range (e.g. 1 mired) would fail validation and leave the light unusable. Keep a stored value within the new range when the light starts. Fixes athombv#30 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SzwF97RnBPp9K8AduC4A9q
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #30
Problem
Homey's
light_temperature(0 coldest … 1 warmest, without Kelvin values) is exposed as 1–300 mireds, which controllers show as ~3,333 K to 1,000,000 K. In Home Assistant almost the whole color temperature slider is "cold", and warm whites fall outside the range.Change
moveToColorTemperature.coupleColorTempToLevelMinMiredsuses the new minimum.?? 150fallback never applied:scaleNumber(null, …)returns the minimum, andundefinedgivesNaN.Existing installations
Lights from existing installations keep working after the update; this PR includes the migration for them.
The bridge saves each light's color temperature, and Matter.js restores the saved value when the light starts. Values saved with the old range can be below the new minimum (e.g. 1 mired), so
HomeyColorControlServer.initialize()moves a saved value into the new range before Matter.js validates it. Without this step, such a light would fail to initialize after updating. The second test covers this with a light that saved 1 mired.Tests
New
tests/color-temperature.test.mjs:Both tests fail on
master; all 30 tests pass.The Kelvin values remain approximate, as Homey doesn't report a light's real range.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SzwF97RnBPp9K8AduC4A9q